Skip to content

Commit

Permalink
Merge pull request #455 from DavidBerger98/fix-text-widget
Browse files Browse the repository at this point in the history
fix(textwidget): Fix the TextWidget
  • Loading branch information
floryst authored Oct 11, 2022
2 parents 108356d + 105ec38 commit a386b3c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
'no-plusplus': 0,
'import/no-extraneous-dependencies': 0, // paraview-glance alias
'linebreak-style': 0,
'no-underscore-dangle': 0,

'vue/component-tags-order': 0,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import create2DTool, {

// ----------------------------------------------------------------------------

const RulerComponent = create2DTool('Text', {
const TextComponent = create2DTool('Text', {
watch: {
name() {
this.updateMeasurements();
Expand Down Expand Up @@ -59,4 +59,4 @@ const RulerComponent = create2DTool('Text', {
},
});

export default RulerComponent;
export default TextComponent;
23 changes: 11 additions & 12 deletions src/vtk/TextWidget/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import macro from '@kitware/vtk.js/macro';
const MAX_POINTS = 1;

export default function widgetBehavior(publicAPI, model) {
model.classHierarchy.push('vtkDistanceWidgetProp');
model.classHierarchy.push('vtkTextWidgetProp');
let isDragging = null;

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -47,8 +47,8 @@ export default function widgetBehavior(publicAPI, model) {
newHandle.setScale1(moveHandle.getScale1());
} else {
isDragging = true;
model.openGLRenderWindow.setCursor('grabbing');
model.interactor.requestAnimation(publicAPI);
model._apiSpecificRenderWindow.setCursor('grabbing');
model._interactor.requestAnimation(publicAPI);
}

publicAPI.invokeStartInteractionEvent();
Expand All @@ -64,7 +64,7 @@ export default function widgetBehavior(publicAPI, model) {
model.hasFocus &&
model.widgetState.getHandleList().length === MAX_POINTS
) {
model.widgetManager.releaseFocus();
model._widgetManager.releaseFocus();
return macro.VOID;
}

Expand All @@ -77,7 +77,7 @@ export default function widgetBehavior(publicAPI, model) {
) {
const worldCoords = model.manipulator.handleEvent(
callData,
model.openGLRenderWindow
model._apiSpecificRenderWindow
);
if (
worldCoords.length &&
Expand All @@ -98,9 +98,9 @@ export default function widgetBehavior(publicAPI, model) {

publicAPI.handleLeftButtonRelease = () => {
if (isDragging && model.pickable) {
model.openGLRenderWindow.setCursor('pointer');
model._apiSpecificRenderWindow.setCursor('pointer');
model.widgetState.deactivate();
model.interactor.cancelAnimation(publicAPI);
model._interactor.cancelAnimation(publicAPI);
publicAPI.invokeEndInteractionEvent();
} else if (model.activeState !== model.widgetState.getMoveHandle()) {
model.widgetState.deactivate();
Expand All @@ -112,7 +112,6 @@ export default function widgetBehavior(publicAPI, model) {
) {
publicAPI.invokeEndInteractionEvent();
}

isDragging = false;
};

Expand All @@ -128,7 +127,7 @@ export default function widgetBehavior(publicAPI, model) {
model.activeState = model.widgetState.getMoveHandle();
model.activeState.activate();
model.activeState.setVisible(true);
model.interactor.requestAnimation(publicAPI);
model._interactor.requestAnimation(publicAPI);
publicAPI.invokeStartInteractionEvent();
}
model.hasFocus = true;
Expand All @@ -138,15 +137,15 @@ export default function widgetBehavior(publicAPI, model) {

publicAPI.loseFocus = () => {
if (model.hasFocus) {
model.interactor.cancelAnimation(publicAPI);
model._interactor.cancelAnimation(publicAPI);
publicAPI.invokeEndInteractionEvent();
}
model.widgetState.deactivate();
model.widgetState.getMoveHandle().deactivate();
model.widgetState.getMoveHandle().setVisible(false);
model.activeState = null;
model.hasFocus = false;
model.widgetManager.enablePicking();
model.interactor.render();
model._widgetManager.enablePicking();
model._interactor.render();
};
}
2 changes: 1 addition & 1 deletion src/vtk/TextWidget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ViewTypes } from '@kitware/vtk.js/Widgets/Core/WidgetManager/Constants'
// ----------------------------------------------------------------------------

function vtkTextWidget(publicAPI, model) {
model.classHierarchy.push('vtkDistanceWidget');
model.classHierarchy.push('vtkTextWidget');

// --- Widget Requirement ---------------------------------------------------

Expand Down

0 comments on commit a386b3c

Please sign in to comment.