@kitware/vtk.js 24.7.1 → 24.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/Common/Core/Math/index.js +1 -1
  2. package/Common/Core/Math.js +1 -1
  3. package/Common/Core/ScalarsToColors/Constants.d.ts +18 -0
  4. package/Common/Core/ScalarsToColors.d.ts +6 -16
  5. package/Common/DataModel/Box.d.ts +4 -4
  6. package/Common/DataModel/CardinalSpline1D.d.ts +8 -4
  7. package/Common/DataModel/CardinalSpline1D.js +133 -4
  8. package/Common/DataModel/Cell.js +3 -1
  9. package/Common/DataModel/CellTypes.js +6 -1
  10. package/Common/DataModel/ITKHelper.d.ts +54 -0
  11. package/Common/DataModel/KochanekSpline1D.d.ts +8 -4
  12. package/Common/DataModel/KochanekSpline1D.js +103 -2
  13. package/Common/DataModel/Line.d.ts +8 -3
  14. package/Common/DataModel/Line.js +16 -11
  15. package/Common/DataModel/Plane.js +1 -1
  16. package/Common/DataModel/PolyData/Constants.d.ts +6 -0
  17. package/Common/DataModel/PolyLine.d.ts +63 -0
  18. package/Common/DataModel/PolyLine.js +84 -0
  19. package/Common/DataModel/Polygon.js +1 -1
  20. package/Common/DataModel/Spline1D/Constants.js +17 -0
  21. package/Common/DataModel/Spline1D.d.ts +20 -2
  22. package/Common/DataModel/Spline3D/Constants.d.ts +9 -0
  23. package/Common/DataModel/Spline3D.d.ts +4 -9
  24. package/Common/DataModel/Spline3D.js +20 -15
  25. package/Filters/General/ImageCropFilter.d.ts +9 -6
  26. package/Filters/Sources/LineSource.js +1 -1
  27. package/Filters/Sources/PlaneSource.js +1 -1
  28. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  29. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  30. package/Interaction/Manipulators/MouseRangeManipulator.js +23 -6
  31. package/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +11 -0
  32. package/Interaction/Widgets/OrientationMarkerWidget.d.ts +2 -6
  33. package/Rendering/Core/CellPicker.js +53 -32
  34. package/Rendering/Core/Mapper/Constants.d.ts +26 -0
  35. package/Rendering/Core/Mapper.d.ts +5 -21
  36. package/Rendering/Core/Property/Constants.d.ts +24 -0
  37. package/Rendering/Core/Property.d.ts +6 -20
  38. package/Rendering/Core/RenderWindowInteractor/Constants.d.ts +31 -0
  39. package/Rendering/Core/RenderWindowInteractor.d.ts +223 -121
  40. package/Rendering/Core/Viewport.d.ts +2 -4
  41. package/Rendering/Core/VolumeMapper/Constants.d.ts +19 -0
  42. package/Rendering/Core/VolumeMapper.d.ts +5 -9
  43. package/Rendering/Core/VolumeProperty.d.ts +5 -13
  44. package/Rendering/Misc/FullScreenRenderWindow.d.ts +3 -2
  45. package/Rendering/OpenGL/RenderWindow.d.ts +28 -10
  46. package/Widgets/Core/StateBuilder/manipulatorMixin.js +15 -15
  47. package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
  48. package/Widgets/Manipulators/AbstractManipulator.js +57 -0
  49. package/Widgets/Manipulators/LineManipulator.d.ts +8 -74
  50. package/Widgets/Manipulators/LineManipulator.js +14 -11
  51. package/Widgets/Manipulators/PlaneManipulator.d.ts +8 -74
  52. package/Widgets/Manipulators/PlaneManipulator.js +12 -9
  53. package/Widgets/Manipulators/TrackballManipulator.d.ts +8 -44
  54. package/Widgets/Manipulators/TrackballManipulator.js +13 -10
  55. package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
  56. package/Widgets/Representations/SplineContextRepresentation.js +28 -9
  57. package/Widgets/Representations/WidgetRepresentation.js +1 -1
  58. package/Widgets/Widgets3D/AngleWidget/behavior.js +7 -4
  59. package/Widgets/Widgets3D/AngleWidget/state.js +2 -2
  60. package/Widgets/Widgets3D/AngleWidget.js +20 -3
  61. package/Widgets/Widgets3D/DistanceWidget/behavior.js +7 -2
  62. package/Widgets/Widgets3D/DistanceWidget/state.js +2 -2
  63. package/Widgets/Widgets3D/DistanceWidget.js +19 -2
  64. package/Widgets/Widgets3D/EllipseWidget.js +4 -3
  65. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +3 -4
  66. package/Widgets/Widgets3D/ImageCroppingWidget.js +42 -13
  67. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +5 -5
  68. package/Widgets/Widgets3D/LabelWidget/behavior.js +6 -2
  69. package/Widgets/Widgets3D/LabelWidget/state.js +2 -2
  70. package/Widgets/Widgets3D/LabelWidget.js +18 -3
  71. package/Widgets/Widgets3D/LineWidget/behavior.js +11 -4
  72. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  73. package/Widgets/Widgets3D/LineWidget/state.js +1 -1
  74. package/Widgets/Widgets3D/LineWidget.js +18 -1
  75. package/Widgets/Widgets3D/PaintWidget/behavior.js +12 -9
  76. package/Widgets/Widgets3D/PaintWidget.js +24 -8
  77. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +11 -4
  78. package/Widgets/Widgets3D/PolyLineWidget/state.js +2 -2
  79. package/Widgets/Widgets3D/PolyLineWidget.js +21 -2
  80. package/Widgets/Widgets3D/RectangleWidget.js +6 -5
  81. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +5 -5
  82. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  83. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  84. package/Widgets/Widgets3D/ShapeWidget/behavior.js +9 -5
  85. package/Widgets/Widgets3D/ShapeWidget.js +12 -2
  86. package/Widgets/Widgets3D/SphereWidget/behavior.js +4 -3
  87. package/Widgets/Widgets3D/SphereWidget.js +23 -2
  88. package/Widgets/Widgets3D/SplineWidget/behavior.js +7 -3
  89. package/Widgets/Widgets3D/SplineWidget/state.js +12 -2
  90. package/Widgets/Widgets3D/SplineWidget.js +22 -3
  91. package/index.d.ts +12 -1
  92. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
2
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
4
  import macro from '../../macros.js';
4
5
  import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
5
6
  import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
@@ -11,12 +12,18 @@ import state from './ImageCroppingWidget/state.js';
11
12
  import { transformVec3, AXES } from './ImageCroppingWidget/helpers.js';
12
13
  import { ViewTypes } from '../Core/WidgetManager/Constants.js';
13
14
 
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+
17
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
18
  // ----------------------------------------------------------------------------
15
19
  // Factory
16
20
  // ----------------------------------------------------------------------------
17
21
 
18
22
  function vtkImageCroppingWidget(publicAPI, model) {
19
23
  model.classHierarchy.push('vtkImageCroppingWidget');
24
+
25
+ var superClass = _objectSpread({}, publicAPI);
26
+
20
27
  var stateSub = null; // --------------------------------------------------------------------------
21
28
 
22
29
  function setHandlesEnabled(label, flag) {
@@ -120,28 +127,50 @@ function vtkImageCroppingWidget(publicAPI, model) {
120
127
  }; // Update handle positions when cropping planes update
121
128
 
122
129
 
123
- stateSub = model.widgetState.getCroppingPlanes().onModified(publicAPI.updateHandles); // Add manipulators to our widgets.
130
+ stateSub = model.widgetState.getCroppingPlanes().onModified(publicAPI.updateHandles);
131
+
132
+ publicAPI.setCornerManipulator = function (manipulator) {
133
+ superClass.setCornerManipulator(manipulator);
134
+ model.widgetState.getStatesWithLabel('corners').forEach(function (handle) {
135
+ return handle.setManipulator(manipulator);
136
+ });
137
+ };
138
+
139
+ publicAPI.setEdgeManipulator = function (manipulator) {
140
+ superClass.setEdgeManipulator(manipulator);
141
+ model.widgetState.getStatesWithLabel('edges').forEach(function (handle) {
142
+ return handle.setManipulator(manipulator);
143
+ });
144
+ };
145
+
146
+ publicAPI.setFaceManipulator = function (manipulator) {
147
+ superClass.setFaceManipulator(manipulator);
148
+ model.widgetState.getStatesWithLabel('faces').forEach(function (handle) {
149
+ return handle.setManipulator(manipulator);
150
+ });
151
+ }; // --------------------------------------------------------------------------
152
+ // initialization
153
+ // --------------------------------------------------------------------------
154
+
124
155
 
125
- var planeManipulator = vtkPlanePointManipulator.newInstance();
126
- var lineManipulator = vtkLineManipulator.newInstance();
127
- model.widgetState.getStatesWithLabel('corners').forEach(function (handle) {
128
- return handle.setManipulator(planeManipulator);
129
- });
130
- model.widgetState.getStatesWithLabel('edges').forEach(function (handle) {
131
- return handle.setManipulator(planeManipulator);
132
- });
133
- model.widgetState.getStatesWithLabel('faces').forEach(function (handle) {
134
- return handle.setManipulator(lineManipulator);
135
- });
156
+ publicAPI.setCornerManipulator(vtkPlanePointManipulator.newInstance({
157
+ useCameraNormal: true
158
+ }));
159
+ publicAPI.setEdgeManipulator(vtkPlanePointManipulator.newInstance());
160
+ publicAPI.setFaceManipulator(vtkLineManipulator.newInstance());
136
161
  } // ----------------------------------------------------------------------------
137
162
 
138
163
 
139
- var DEFAULT_VALUES = {}; // ----------------------------------------------------------------------------
164
+ var DEFAULT_VALUES = {// cornerManipulator: null,
165
+ // edgeManipulator: null,
166
+ // faceManipulator: null
167
+ }; // ----------------------------------------------------------------------------
140
168
 
141
169
  function extend(publicAPI, model) {
142
170
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
143
171
  Object.assign(model, DEFAULT_VALUES, initialValues);
144
172
  vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
173
+ macro.setGet(publicAPI, model, ['cornerManipulator', 'edgeManipulator', 'faceManipulator']);
145
174
  vtkImageCroppingWidget(publicAPI, model);
146
175
  } // ----------------------------------------------------------------------------
147
176
 
@@ -48,8 +48,8 @@ function widgetBehavior(publicAPI, model) {
48
48
  }
49
49
 
50
50
  isDragging = true;
51
- model.lineManipulator.setOrigin(model.widgetState.getOrigin());
52
- model.planeManipulator.setOrigin(model.widgetState.getOrigin());
51
+ model.lineManipulator.setWidgetOrigin(model.widgetState.getOrigin());
52
+ model.planeManipulator.setWidgetOrigin(model.widgetState.getOrigin());
53
53
  model.trackballManipulator.reset(callData); // setup trackball delta
54
54
 
55
55
  model._interactor.requestAnimation(publicAPI);
@@ -91,7 +91,7 @@ function widgetBehavior(publicAPI, model) {
91
91
 
92
92
 
93
93
  publicAPI.updateFromOrigin = function (callData) {
94
- model.planeManipulator.setNormal(model.widgetState.getNormal());
94
+ model.planeManipulator.setWidgetNormal(model.widgetState.getNormal());
95
95
  var worldCoords = model.planeManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
96
96
 
97
97
  if (model.widgetState.containsPoint(worldCoords)) {
@@ -104,7 +104,7 @@ function widgetBehavior(publicAPI, model) {
104
104
  var _model$widgetState;
105
105
 
106
106
  // Move origin along normal axis
107
- model.lineManipulator.setNormal(model.activeState.getNormal());
107
+ model.lineManipulator.setWidgetNormal(model.activeState.getNormal());
108
108
  var worldCoords = model.lineManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
109
109
 
110
110
  if ((_model$widgetState = model.widgetState).containsPoint.apply(_model$widgetState, _toConsumableArray(worldCoords))) {
@@ -114,7 +114,7 @@ function widgetBehavior(publicAPI, model) {
114
114
 
115
115
 
116
116
  publicAPI.updateFromNormal = function (callData) {
117
- model.trackballManipulator.setNormal(model.activeState.getNormal());
117
+ model.trackballManipulator.setWidgetNormal(model.activeState.getNormal());
118
118
  var newNormal = model.trackballManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
119
119
  model.activeState.setNormal(newNormal);
120
120
  }; // --------------------------------------------------------------------------
@@ -93,8 +93,12 @@ function widgetBehavior(publicAPI, model) {
93
93
 
94
94
 
95
95
  publicAPI.handleMouseMove = function (callData) {
96
- if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
97
- var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
96
+ var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
97
+
98
+ var manipulator = (_model$activeState$ge = (_model$activeState = model.activeState) === null || _model$activeState === void 0 ? void 0 : (_model$activeState$ge2 = _model$activeState.getManipulator) === null || _model$activeState$ge2 === void 0 ? void 0 : _model$activeState$ge2.call(_model$activeState)) !== null && _model$activeState$ge !== void 0 ? _model$activeState$ge : model.manipulator;
99
+
100
+ if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
101
+ var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
98
102
 
99
103
  if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model.isDragging)) {
100
104
  model.activeState.setOrigin(worldCoords);
@@ -3,7 +3,7 @@ import vtkStateBuilder from '../../Core/StateBuilder.js';
3
3
  function generateState() {
4
4
  return vtkStateBuilder.createBuilder().addStateFromMixin({
5
5
  labels: ['moveHandle'],
6
- mixins: ['origin', 'color', 'scale1', 'visible'],
6
+ mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
7
7
  name: 'moveHandle',
8
8
  initialValues: {
9
9
  scale1: 0.1,
@@ -11,7 +11,7 @@ function generateState() {
11
11
  }
12
12
  }).addStateFromMixin({
13
13
  labels: ['SVGtext'],
14
- mixins: ['origin', 'color', 'text', 'visible'],
14
+ mixins: ['origin', 'color', 'text', 'visible', 'manipulator'],
15
15
  name: 'text',
16
16
  initialValues: {
17
17
  visible: true
@@ -16,7 +16,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
16
  // ----------------------------------------------------------------------------
17
17
 
18
18
  function vtkLabelWidget(publicAPI, model) {
19
- model.classHierarchy.push('vtkLabelWidget'); // --- Widget Requirement ---------------------------------------------------
19
+ model.classHierarchy.push('vtkLabelWidget');
20
+
21
+ var superClass = _objectSpread({}, publicAPI); // --- Widget Requirement ---------------------------------------------------
22
+
20
23
 
21
24
  model.methodsToLink = ['textProps', 'fontProperties', 'strokeFontProperties'];
22
25
  model.behavior = widgetBehavior;
@@ -49,10 +52,22 @@ function vtkLabelWidget(publicAPI, model) {
49
52
  labels: ['SVGtext']
50
53
  }];
51
54
  }
52
- }; // Default manipulator
55
+ }; // --- Public methods -------------------------------------------------------
56
+
57
+
58
+ publicAPI.setManipulator = function (manipulator) {
59
+ superClass.setManipulator(manipulator);
60
+ model.widgetState.getMoveHandle().setManipulator(manipulator);
61
+ model.widgetState.getText().setManipulator(manipulator);
62
+ }; // --------------------------------------------------------------------------
63
+ // initialization
64
+ // --------------------------------------------------------------------------
65
+ // Default manipulator
53
66
 
54
67
 
55
- model.manipulator = vtkPlanePointManipulator.newInstance();
68
+ publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
69
+ useCameraNormal: true
70
+ }));
56
71
  } // ----------------------------------------------------------------------------
57
72
 
58
73
 
@@ -2,7 +2,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
3
  import Constants from './Constants.js';
4
4
  import macro from '../../../macros.js';
5
- import { g as subtract, k as add, l as normalize } from '../../../Common/Core/Math/index.js';
5
+ import { s as subtract, k as add, l as normalize } from '../../../Common/Core/Math/index.js';
6
6
  import { getNumberOfPlacedHandles, isHandlePlaced, calculateTextPosition, updateTextPosition, getPoint } from './helpers.js';
7
7
 
8
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -35,8 +35,11 @@ function widgetBehavior(publicAPI, model) {
35
35
  }
36
36
 
37
37
  function updateCursor(callData) {
38
+ var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
39
+
38
40
  model.isDragging = true;
39
- model.previousPosition = _toConsumableArray(model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow));
41
+ var manipulator = (_model$activeState$ge = (_model$activeState = model.activeState) === null || _model$activeState === void 0 ? void 0 : (_model$activeState$ge2 = _model$activeState.getManipulator) === null || _model$activeState$ge2 === void 0 ? void 0 : _model$activeState$ge2.call(_model$activeState)) !== null && _model$activeState$ge !== void 0 ? _model$activeState$ge : model.manipulator;
42
+ model.previousPosition = _toConsumableArray(manipulator.handleEvent(callData, model._apiSpecificRenderWindow));
40
43
 
41
44
  model._apiSpecificRenderWindow.setCursor('grabbing');
42
45
 
@@ -222,13 +225,17 @@ function widgetBehavior(publicAPI, model) {
222
225
 
223
226
 
224
227
  publicAPI.handleMouseMove = function (callData) {
228
+ var _model$activeState$ge3, _model$activeState2, _model$activeState2$g;
229
+
225
230
  if (model.hasFocus && publicAPI.isPlaced() && !model.isDragging) {
226
231
  publicAPI.loseFocus();
227
232
  return macro.VOID;
228
233
  }
229
234
 
230
- if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
231
- var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
235
+ var manipulator = (_model$activeState$ge3 = (_model$activeState2 = model.activeState) === null || _model$activeState2 === void 0 ? void 0 : (_model$activeState2$g = _model$activeState2.getManipulator) === null || _model$activeState2$g === void 0 ? void 0 : _model$activeState2$g.call(_model$activeState2)) !== null && _model$activeState$ge3 !== void 0 ? _model$activeState$ge3 : model.manipulator;
236
+
237
+ if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
238
+ var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
232
239
  var translation = model.previousPosition ? subtract(worldCoords, model.previousPosition, []) : [0, 0, 0];
233
240
  model.previousPosition = worldCoords;
234
241
 
@@ -1,4 +1,4 @@
1
- import { g as subtract, x as multiplyScalar, k as add, B as areEquals } from '../../../Common/Core/Math/index.js';
1
+ import { s as subtract, x as multiplyScalar, k as add, B as areEquals } from '../../../Common/Core/Math/index.js';
2
2
 
3
3
  function calculateTextPosition(model) {
4
4
  var vector = [0, 0, 0];
@@ -9,7 +9,7 @@ var linePosState = vtkStateBuilder.createBuilder().addField({
9
9
  function generateState() {
10
10
  return vtkStateBuilder.createBuilder().addStateFromMixin({
11
11
  labels: ['moveHandle'],
12
- mixins: ['origin', 'color', 'scale1', 'visible', 'shape'],
12
+ mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator', 'shape'],
13
13
  name: 'moveHandle',
14
14
  initialValues: {
15
15
  scale1: 50,
@@ -1,3 +1,4 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
1
2
  import { f as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
2
3
  import macro from '../../macros.js';
3
4
  import generateState from './LineWidget/state.js';
@@ -11,11 +12,17 @@ import { Behavior } from '../Representations/WidgetRepresentation/Constants.js';
11
12
  import { ViewTypes } from '../Core/WidgetManager/Constants.js';
12
13
  import { getPoint, updateTextPosition } from './LineWidget/helpers.js';
13
14
 
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
+
17
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
18
  // Factory
15
19
  // ----------------------------------------------------------------------------
16
20
 
17
21
  function vtkLineWidget(publicAPI, model) {
18
22
  model.classHierarchy.push('vtkLineWidget');
23
+
24
+ var superClass = _objectSpread({}, publicAPI);
25
+
19
26
  model.widgetState = generateState();
20
27
  model.behavior = widgetBehavior; // --- Widget Requirement ---------------------------------------------------
21
28
 
@@ -135,6 +142,13 @@ function vtkLineWidget(publicAPI, model) {
135
142
  var p1 = getPoint(0, model.widgetState);
136
143
  var p2 = getPoint(1, model.widgetState);
137
144
  return p1 && p2 ? Math.sqrt(distance2BetweenPoints(p1, p2)) : 0;
145
+ };
146
+
147
+ publicAPI.setManipulator = function (manipulator) {
148
+ superClass.setManipulator(manipulator);
149
+ model.widgetState.getMoveHandle().setManipulator(manipulator);
150
+ model.widgetState.getHandle1().setManipulator(manipulator);
151
+ model.widgetState.getHandle2().setManipulator(manipulator);
138
152
  }; // --------------------------------------------------------------------------
139
153
  // initialization
140
154
  // --------------------------------------------------------------------------
@@ -152,11 +166,14 @@ function vtkLineWidget(publicAPI, model) {
152
166
  updateTextPosition(model);
153
167
  }); // Default manipulator
154
168
 
155
- model.manipulator = vtkPlanePointManipulator.newInstance();
169
+ publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
170
+ useCameraNormal: true
171
+ }));
156
172
  } // ----------------------------------------------------------------------------
157
173
 
158
174
 
159
175
  var DEFAULT_VALUES = {
176
+ // manipulator: null,
160
177
  isDragging: false
161
178
  }; // ----------------------------------------------------------------------------
162
179
 
@@ -32,8 +32,12 @@ function widgetBehavior(publicAPI, model) {
32
32
  };
33
33
 
34
34
  publicAPI.handleEvent = function (callData) {
35
- if (model.manipulator && model.activeState && model.activeState.getActive()) {
36
- var _model$activeState, _model$activeState2, _model$activeState3;
35
+ var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
36
+
37
+ var manipulator = (_model$activeState$ge = (_model$activeState = model.activeState) === null || _model$activeState === void 0 ? void 0 : (_model$activeState$ge2 = _model$activeState.getManipulator) === null || _model$activeState$ge2 === void 0 ? void 0 : _model$activeState$ge2.call(_model$activeState)) !== null && _model$activeState$ge !== void 0 ? _model$activeState$ge : model.manipulator;
38
+
39
+ if (manipulator && model.activeState && model.activeState.getActive()) {
40
+ var _model$activeState2, _model$activeState3, _model$activeState4;
37
41
 
38
42
  var normal = model._camera.getDirectionOfProjection();
39
43
 
@@ -42,21 +46,20 @@ function widgetBehavior(publicAPI, model) {
42
46
  var right = [];
43
47
  vec3.cross(right, up, normal);
44
48
 
45
- (_model$activeState = model.activeState).setUp.apply(_model$activeState, _toConsumableArray(up));
49
+ (_model$activeState2 = model.activeState).setUp.apply(_model$activeState2, _toConsumableArray(up));
46
50
 
47
- (_model$activeState2 = model.activeState).setRight.apply(_model$activeState2, right);
51
+ (_model$activeState3 = model.activeState).setRight.apply(_model$activeState3, right);
48
52
 
49
- (_model$activeState3 = model.activeState).setDirection.apply(_model$activeState3, _toConsumableArray(normal));
53
+ (_model$activeState4 = model.activeState).setDirection.apply(_model$activeState4, _toConsumableArray(normal));
50
54
 
51
- model.manipulator.setNormal(normal);
52
- var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
55
+ var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
53
56
 
54
57
  if (worldCoords.length) {
55
- var _model$widgetState, _model$activeState4;
58
+ var _model$widgetState, _model$activeState5;
56
59
 
57
60
  (_model$widgetState = model.widgetState).setTrueOrigin.apply(_model$widgetState, _toConsumableArray(worldCoords));
58
61
 
59
- (_model$activeState4 = model.activeState).setOrigin.apply(_model$activeState4, _toConsumableArray(worldCoords));
62
+ (_model$activeState5 = model.activeState).setOrigin.apply(_model$activeState5, _toConsumableArray(worldCoords));
60
63
 
61
64
  if (model.painting) {
62
65
  var trailCircle = model.widgetState.addTrail();
@@ -1,3 +1,4 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
1
2
  import macro from '../../macros.js';
2
3
  import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
3
4
  import vtkCircleContextRepresentation from '../Representations/CircleContextRepresentation.js';
@@ -7,11 +8,17 @@ import widgetBehavior from './PaintWidget/behavior.js';
7
8
  import generateState from './PaintWidget/state.js';
8
9
  import { ViewTypes } from '../Core/WidgetManager/Constants.js';
9
10
 
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+
13
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
14
  // Factory
11
15
  // ----------------------------------------------------------------------------
12
16
 
13
17
  function vtkPaintWidget(publicAPI, model) {
14
- model.classHierarchy.push('vtkPaintWidget'); // --- Widget Requirement ---------------------------------------------------
18
+ model.classHierarchy.push('vtkPaintWidget');
19
+
20
+ var superClass = _objectSpread({}, publicAPI); // --- Widget Requirement ---------------------------------------------------
21
+
15
22
 
16
23
  model.behavior = widgetBehavior;
17
24
  model.widgetState = generateState(model.radius);
@@ -33,26 +40,35 @@ function vtkPaintWidget(publicAPI, model) {
33
40
  labels: ['handle']
34
41
  }];
35
42
  }
36
- }; // --- Widget Requirement ---------------------------------------------------
43
+ }; // --- Public methods -------------------------------------------------------
37
44
 
38
45
 
39
- var handle = model.widgetState.getHandle(); // Default manipulator
46
+ publicAPI.setManipulator = function (manipulator) {
47
+ superClass.setManipulator(manipulator);
48
+ model.widgetState.getHandle().setManipulator(manipulator);
49
+ }; // override
40
50
 
41
- model.manipulator = vtkPlanePointManipulator.newInstance();
42
- handle.setManipulator(model.manipulator); // override
43
51
 
44
52
  var superSetRadius = publicAPI.setRadius;
45
53
 
46
54
  publicAPI.setRadius = function (r) {
47
55
  if (superSetRadius(r)) {
48
- handle.setScale1(r);
56
+ model.widgetState.getHandle().setScale1(r);
49
57
  }
50
- };
58
+ }; // --------------------------------------------------------------------------
59
+ // initialization
60
+ // --------------------------------------------------------------------------
61
+ // Default manipulator
62
+
63
+
64
+ publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
65
+ useCameraNormal: true
66
+ }));
51
67
  } // ----------------------------------------------------------------------------
52
68
 
53
69
 
54
70
  var DEFAULT_VALUES = {
55
- manipulator: null,
71
+ // manipulator: null,
56
72
  radius: 1,
57
73
  painting: false,
58
74
  color: [1]
@@ -19,9 +19,15 @@ function widgetBehavior(publicAPI, model) {
19
19
  }
20
20
 
21
21
  function updateMoveHandle(callData) {
22
- model.manipulator.setOrigin(model._camera.getFocalPoint());
23
- model.manipulator.setNormal(model._camera.getDirectionOfProjection());
24
- var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
22
+ var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
23
+
24
+ var manipulator = (_model$activeState$ge = (_model$activeState = model.activeState) === null || _model$activeState === void 0 ? void 0 : (_model$activeState$ge2 = _model$activeState.getManipulator) === null || _model$activeState$ge2 === void 0 ? void 0 : _model$activeState$ge2.call(_model$activeState)) !== null && _model$activeState$ge !== void 0 ? _model$activeState$ge : model.manipulator;
25
+
26
+ if (!manipulator) {
27
+ return macro.VOID;
28
+ }
29
+
30
+ var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
25
31
 
26
32
  if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
27
33
  model.activeState.setOrigin(worldCoords);
@@ -72,6 +78,7 @@ function widgetBehavior(publicAPI, model) {
72
78
  newHandle.setOrigin.apply(newHandle, _toConsumableArray(moveHandle.getOrigin()));
73
79
  newHandle.setColor(moveHandle.getColor());
74
80
  newHandle.setScale1(moveHandle.getScale1());
81
+ newHandle.setManipulator(model.manipulator);
75
82
  } else {
76
83
  isDragging = true;
77
84
 
@@ -88,7 +95,7 @@ function widgetBehavior(publicAPI, model) {
88
95
 
89
96
 
90
97
  publicAPI.handleMouseMove = function (callData) {
91
- if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
98
+ if (model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
92
99
  if (updateMoveHandle(callData) === macro.EVENT_ABORT) {
93
100
  return macro.EVENT_ABORT;
94
101
  }
@@ -3,7 +3,7 @@ import vtkStateBuilder from '../../Core/StateBuilder.js';
3
3
  function generateState() {
4
4
  return vtkStateBuilder.createBuilder().addStateFromMixin({
5
5
  labels: ['moveHandle'],
6
- mixins: ['origin', 'color', 'scale1', 'visible'],
6
+ mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
7
7
  name: 'moveHandle',
8
8
  initialValues: {
9
9
  // when scaleInPixels=true, the handles have 30px height
@@ -12,7 +12,7 @@ function generateState() {
12
12
  }
13
13
  }).addDynamicMixinState({
14
14
  labels: ['handles'],
15
- mixins: ['origin', 'color', 'scale1', 'visible'],
15
+ mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
16
16
  name: 'handle',
17
17
  initialValues: {
18
18
  scale1: 30
@@ -1,3 +1,4 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
1
2
  import macro from '../../macros.js';
2
3
  import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
3
4
  import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
@@ -8,11 +9,17 @@ import widgetBehavior from './PolyLineWidget/behavior.js';
8
9
  import generateState from './PolyLineWidget/state.js';
9
10
  import { ViewTypes } from '../Core/WidgetManager/Constants.js';
10
11
 
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
+
14
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
11
15
  // Factory
12
16
  // ----------------------------------------------------------------------------
13
17
 
14
18
  function vtkPolyLineWidget(publicAPI, model) {
15
- model.classHierarchy.push('vtkPolyLineWidget'); // --- Widget Requirement ---------------------------------------------------
19
+ model.classHierarchy.push('vtkPolyLineWidget');
20
+
21
+ var superClass = _objectSpread({}, publicAPI); // --- Widget Requirement ---------------------------------------------------
22
+
16
23
 
17
24
  model.methodsToLink = ['activeColor', 'activeScaleFactor', 'closePolyLine', 'defaultScale', 'glyphResolution', 'lineThickness', 'useActiveColor', 'scaleInPixels'];
18
25
  model.behavior = widgetBehavior;
@@ -51,6 +58,15 @@ function vtkPolyLineWidget(publicAPI, model) {
51
58
  labels: ['handles', 'moveHandle']
52
59
  }];
53
60
  }
61
+ }; // --- Public methods -------------------------------------------------------
62
+
63
+
64
+ publicAPI.setManipulator = function (manipulator) {
65
+ superClass.setManipulator(manipulator);
66
+ model.widgetState.getMoveHandle().setManipulator(manipulator);
67
+ model.widgetState.getHandleList().forEach(function (handle) {
68
+ handle.setManipulator(manipulator);
69
+ });
54
70
  }; // --------------------------------------------------------------------------
55
71
  // initialization
56
72
  // --------------------------------------------------------------------------
@@ -61,7 +77,10 @@ function vtkPolyLineWidget(publicAPI, model) {
61
77
  model.widgetState.getMoveHandle().setOrigin(center);
62
78
  }); // Default manipulator
63
79
 
64
- model.manipulator = vtkPlanePointManipulator.newInstance();
80
+ publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
81
+ useCameraFocalPoint: true,
82
+ useCameraNormal: true
83
+ }));
65
84
  } // ----------------------------------------------------------------------------
66
85
 
67
86
 
@@ -50,15 +50,16 @@ function vtkRectangleWidget(publicAPI, model) {
50
50
  }; // --------------------------------------------------------------------------
51
51
  // initialization
52
52
  // --------------------------------------------------------------------------
53
- // Default manipulator
54
53
 
55
54
 
56
- model.manipulator = vtkPlanePointManipulator.newInstance();
57
55
  model.widgetState = generateState();
56
+ model.manipulator = vtkPlanePointManipulator.newInstance({
57
+ useCameraNormal: true
58
+ });
58
59
  } // ----------------------------------------------------------------------------
59
60
 
60
61
 
61
- function defaultValues(initalValues) {
62
+ function defaultValues(initialValues) {
62
63
  var _None;
63
64
 
64
65
  return _objectSpread({
@@ -67,14 +68,14 @@ function defaultValues(initalValues) {
67
68
  Shift: _defineProperty({}, BehaviorCategory.RATIO, ShapeBehavior[BehaviorCategory.RATIO].FIXED),
68
69
  Control: _defineProperty({}, BehaviorCategory.POINTS, ShapeBehavior[BehaviorCategory.POINTS].CENTER_TO_CORNER)
69
70
  }
70
- }, initalValues);
71
+ }, initialValues);
71
72
  } // ----------------------------------------------------------------------------
72
73
 
73
74
 
74
75
  function extend(publicAPI, model) {
75
76
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
76
77
  vtkShapeWidget.extend(publicAPI, model, defaultValues(initialValues));
77
- macro.setGet(publicAPI, model, ['manipulator', 'widgetState']);
78
+ macro.setGet(publicAPI, model, ['widgetState']);
78
79
  vtkRectangleWidget(publicAPI, model);
79
80
  } // ----------------------------------------------------------------------------
80
81
 
@@ -3,7 +3,7 @@ import macro from '../../../macros.js';
3
3
  import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
4
4
  import vtkLine from '../../../Common/DataModel/Line.js';
5
5
  import vtkPlanePointManipulator from '../../Manipulators/PlaneManipulator.js';
6
- import { x as multiplyScalar, g as subtract, l as normalize, d as dot, j as cross, m as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
6
+ import { x as multiplyScalar, s as subtract, l as normalize, d as dot, j as cross, m as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
7
7
  import { updateState, getAssociatedLinesName, boundPointOnPlane, rotateVector } from './helpers.js';
8
8
  import { InteractionMethodsName, ScrollingMethods } from './Constants.js';
9
9
 
@@ -63,8 +63,8 @@ function widgetBehavior(publicAPI, model) {
63
63
  isDragging = true;
64
64
  var viewType = model.widgetState.getActiveViewType();
65
65
  var currentPlaneNormal = model.widgetState.getPlanes()[viewType].normal;
66
- model.planeManipulator.setOrigin(model.widgetState.getCenter());
67
- model.planeManipulator.setNormal(currentPlaneNormal);
66
+ model.planeManipulator.setWidgetOrigin(model.widgetState.getCenter());
67
+ model.planeManipulator.setWidgetNormal(currentPlaneNormal);
68
68
  publicAPI.startInteraction();
69
69
  } else if (model.widgetState.getScrollingMethod() === ScrollingMethods.LEFT_MOUSE_BUTTON) {
70
70
  publicAPI.startScrolling(callData.position);
@@ -215,7 +215,7 @@ function widgetBehavior(publicAPI, model) {
215
215
  var dot$1 = dot(currentLineVector, otherLineVector); // lines are colinear, translate along perpendicular axis from current line
216
216
 
217
217
  if (dot$1 === 1 || dot$1 === -1) {
218
- cross(currentLineVector, model.planeManipulator.getNormal(), axisTranslation);
218
+ cross(currentLineVector, model.planeManipulator.getWidgetNormal(), axisTranslation);
219
219
  }
220
220
 
221
221
  var closestPoint = [];
@@ -249,7 +249,7 @@ function widgetBehavior(publicAPI, model) {
249
249
 
250
250
  publicAPI[InteractionMethodsName.RotateLine] = function (calldata) {
251
251
  var activeLine = model.widgetState.getActiveLineState();
252
- var planeNormal = model.planeManipulator.getNormal();
252
+ var planeNormal = model.planeManipulator.getWidgetNormal();
253
253
  var worldCoords = model.planeManipulator.handleEvent(calldata, model._apiSpecificRenderWindow);
254
254
  var center = model.widgetState.getCenter();
255
255
  var previousLineDirection = subtract(activeLine.getPoint1(), activeLine.getPoint2(), []);
@@ -3,7 +3,7 @@ import vtkBoundingBox, { STATIC } from '../../../Common/DataModel/BoundingBox.js
3
3
  import vtkCubeSource from '../../../Filters/Sources/CubeSource.js';
4
4
  import vtkCutter from '../../../Filters/Core/Cutter.js';
5
5
  import vtkPlane from '../../../Common/DataModel/Plane.js';
6
- import { g as subtract, l as normalize, j as cross, x as multiplyScalar, m as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
6
+ import { s as subtract, l as normalize, j as cross, x as multiplyScalar, m as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
7
7
  import vtkMatrixBuilder from '../../../Common/Core/MatrixBuilder.js';
8
8
  import { ViewTypes } from '../../Core/WidgetManager/Constants.js';
9
9
 
@@ -4,7 +4,7 @@ import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
4
4
  import vtkPlane from '../../Common/DataModel/Plane.js';
5
5
  import vtkPlaneSource from '../../Filters/Sources/PlaneSource.js';
6
6
  import vtkResliceCursorContextRepresentation from '../Representations/ResliceCursorContextRepresentation.js';
7
- import { f as distance2BetweenPoints, m as multiplyAccumulate, g as subtract, l as normalize, x as multiplyScalar, k as add } from '../../Common/Core/Math/index.js';
7
+ import { f as distance2BetweenPoints, m as multiplyAccumulate, s as subtract, l as normalize, x as multiplyScalar, k as add } from '../../Common/Core/Math/index.js';
8
8
  import widgetBehavior from './ResliceCursorWidget/behavior.js';
9
9
  import generateState from './ResliceCursorWidget/state.js';
10
10
  import { updateState, transformPlane, boundPlane } from './ResliceCursorWidget/helpers.js';