From 6b4bdd4035610aa88afe54fa97649b806e7b08af Mon Sep 17 00:00:00 2001 From: Julien Finet Date: Wed, 7 Jul 2021 16:12:45 +0200 Subject: [PATCH 1/2] fix(splinewidget): do not make spline context pickable by default --- .../Representations/SplineContextRepresentation/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Widgets/Representations/SplineContextRepresentation/index.js b/Sources/Widgets/Representations/SplineContextRepresentation/index.js index 364fe5c662c..8b652083c43 100644 --- a/Sources/Widgets/Representations/SplineContextRepresentation/index.js +++ b/Sources/Widgets/Representations/SplineContextRepresentation/index.js @@ -1,6 +1,6 @@ import macro from 'vtk.js/Sources/macro'; import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor'; -import vtkHandleRepresentation from 'vtk.js/Sources/Widgets/Representations/HandleRepresentation'; +import vtkContextRepresentation from 'vtk.js/Sources/Widgets/Representations/ContextRepresentation'; import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper'; import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData'; import vtkSpline3D from 'vtk.js/Sources/Common/DataModel/Spline3D'; @@ -155,7 +155,7 @@ const DEFAULT_VALUES = { export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); - vtkHandleRepresentation.extend(publicAPI, model, initialValues); + vtkContextRepresentation.extend(publicAPI, model, initialValues); macro.get(publicAPI, model, ['mapper']); macro.setGet(publicAPI, model, [ 'resolution', From b076eabc322c7e0790a7e4b9e0c7c2b7e16d7c05 Mon Sep 17 00:00:00 2001 From: Julien Finet Date: Thu, 8 Jul 2021 13:06:41 +0200 Subject: [PATCH 2/2] 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 }; // ----------------------------------------------------------------------------