Skip to content

Commit

Permalink
Merge pull request Kitware#1987 from finetjul/spline-widget-pickability
Browse files Browse the repository at this point in the history
fix(splinewidget): do not make spline context pickable by default
  • Loading branch information
finetjul authored Jul 8, 2021
2 parents ee751f0 + b076eab commit 4449d16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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',
Expand Down
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 4449d16

Please sign in to comment.