Skip to content

Commit

Permalink
fix(splinewidget): fix spline widget behavior that no longer inherits…
Browse files Browse the repository at this point in the history
… factory model

Following Kitware#1913, widget model no longer inherits factory model
  • Loading branch information
finetjul committed Jul 8, 2021
1 parent 6b4bdd4 commit b076eab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
17 changes: 9 additions & 8 deletions Sources/Widgets/Widgets3D/SplineWidget/behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import { vec3 } from 'gl-matrix';
export default function widgetBehavior(publicAPI, model) {
model.classHierarchy.push('vtkSplineWidgetProp');

model.keysDown = {};
model.moveHandle = model.widgetState.getMoveHandle();

// --------------------------------------------------------------------------
// Private methods
// --------------------------------------------------------------------------

const updateHandlesSize = () => {
if (model.handleSizeInPixels !== null) {
if (model.handleSizeInPixels != null) {
const scale =
model.handleSizeInPixels *
vec3.distance(
Expand Down Expand Up @@ -104,21 +107,19 @@ export default function widgetBehavior(publicAPI, model) {

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

const superSetHandleSizeInPixels = publicAPI.setHandleSizeInPixels;
publicAPI.setHandleSizeInPixels = (size) => {
superSetHandleSizeInPixels(size);
model.factory.setHandleSizeInPixels(size);
updateHandlesSize();
};
publicAPI.setHandleSizeInPixels(model.handleSizeInPixels); // set initial value
publicAPI.setHandleSizeInPixels(model.factory.getHandleSizeInPixels()); // set initial value

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

const superSetResolution = publicAPI.setResolution;
publicAPI.setResolution = (resolution) => {
superSetResolution(resolution);
model.representations[1].setResolution(model.resolution);
model.factory.setResolution(resolution);
model.representations[1].setResolution(resolution);
};
publicAPI.setResolution(model.resolution); // set initial value
publicAPI.setResolution(model.factory.getResolution()); // set initial value

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

Expand Down
6 changes: 2 additions & 4 deletions Sources/Widgets/Widgets3D/SplineWidget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,18 @@ function vtkSplineWidget(publicAPI, model) {
// initialization
// --------------------------------------------------------------------------

model.moveHandle = model.widgetState.getMoveHandle();
// Default manipulator
model.manipulator = vtkPlanePointManipulator.newInstance();
}

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

const DEFAULT_VALUES = {
keysDown: {},
freehandMinDistance: 0.1,
allowFreehand: true,
resolution: 32,
resolution: 32, // propagates to SplineContextRepresentation
defaultCursor: 'pointer',
handleSizeInPixels: 10,
handleSizeInPixels: 10, // propagates to SplineContextRepresentation
};

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit b076eab

Please sign in to comment.