From b076eabc322c7e0790a7e4b9e0c7c2b7e16d7c05 Mon Sep 17 00:00:00 2001 From: Julien Finet Date: Thu, 8 Jul 2021 13:06:41 +0200 Subject: [PATCH] fix(splinewidget): fix spline widget behavior that no longer inherits factory model Following #1913, widget model no longer inherits factory model --- .../Widgets/Widgets3D/SplineWidget/behavior.js | 17 +++++++++-------- Sources/Widgets/Widgets3D/SplineWidget/index.js | 6 ++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Sources/Widgets/Widgets3D/SplineWidget/behavior.js b/Sources/Widgets/Widgets3D/SplineWidget/behavior.js index f90fbc8c3bb..055be6af384 100644 --- a/Sources/Widgets/Widgets3D/SplineWidget/behavior.js +++ b/Sources/Widgets/Widgets3D/SplineWidget/behavior.js @@ -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( @@ -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 // -------------------------------------------------------------------------- diff --git a/Sources/Widgets/Widgets3D/SplineWidget/index.js b/Sources/Widgets/Widgets3D/SplineWidget/index.js index e5a8f5214f7..290bd581a87 100644 --- a/Sources/Widgets/Widgets3D/SplineWidget/index.js +++ b/Sources/Widgets/Widgets3D/SplineWidget/index.js @@ -51,7 +51,6 @@ function vtkSplineWidget(publicAPI, model) { // initialization // -------------------------------------------------------------------------- - model.moveHandle = model.widgetState.getMoveHandle(); // Default manipulator model.manipulator = vtkPlanePointManipulator.newInstance(); } @@ -59,12 +58,11 @@ function vtkSplineWidget(publicAPI, model) { // ---------------------------------------------------------------------------- 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 }; // ----------------------------------------------------------------------------