@kitware/vtk.js 24.7.1 → 24.8.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 (41) hide show
  1. package/Widgets/Core/StateBuilder/manipulatorMixin.js +15 -15
  2. package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
  3. package/Widgets/Manipulators/AbstractManipulator.js +57 -0
  4. package/Widgets/Manipulators/LineManipulator.d.ts +8 -74
  5. package/Widgets/Manipulators/LineManipulator.js +13 -10
  6. package/Widgets/Manipulators/PlaneManipulator.d.ts +8 -74
  7. package/Widgets/Manipulators/PlaneManipulator.js +12 -9
  8. package/Widgets/Manipulators/TrackballManipulator.d.ts +8 -44
  9. package/Widgets/Manipulators/TrackballManipulator.js +13 -10
  10. package/Widgets/Widgets3D/AngleWidget/behavior.js +7 -4
  11. package/Widgets/Widgets3D/AngleWidget/state.js +2 -2
  12. package/Widgets/Widgets3D/AngleWidget.js +19 -2
  13. package/Widgets/Widgets3D/DistanceWidget/behavior.js +7 -2
  14. package/Widgets/Widgets3D/DistanceWidget/state.js +2 -2
  15. package/Widgets/Widgets3D/DistanceWidget.js +19 -2
  16. package/Widgets/Widgets3D/EllipseWidget.js +4 -3
  17. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +3 -4
  18. package/Widgets/Widgets3D/ImageCroppingWidget.js +42 -13
  19. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +5 -5
  20. package/Widgets/Widgets3D/LabelWidget/behavior.js +6 -2
  21. package/Widgets/Widgets3D/LabelWidget/state.js +2 -2
  22. package/Widgets/Widgets3D/LabelWidget.js +18 -3
  23. package/Widgets/Widgets3D/LineWidget/behavior.js +10 -3
  24. package/Widgets/Widgets3D/LineWidget/state.js +1 -1
  25. package/Widgets/Widgets3D/LineWidget.js +18 -1
  26. package/Widgets/Widgets3D/PaintWidget/behavior.js +12 -9
  27. package/Widgets/Widgets3D/PaintWidget.js +24 -8
  28. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +11 -4
  29. package/Widgets/Widgets3D/PolyLineWidget/state.js +2 -2
  30. package/Widgets/Widgets3D/PolyLineWidget.js +21 -2
  31. package/Widgets/Widgets3D/RectangleWidget.js +6 -5
  32. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +4 -4
  33. package/Widgets/Widgets3D/ShapeWidget/behavior.js +9 -5
  34. package/Widgets/Widgets3D/ShapeWidget.js +12 -2
  35. package/Widgets/Widgets3D/SphereWidget/behavior.js +4 -3
  36. package/Widgets/Widgets3D/SphereWidget.js +23 -2
  37. package/Widgets/Widgets3D/SplineWidget/behavior.js +7 -3
  38. package/Widgets/Widgets3D/SplineWidget/state.js +2 -2
  39. package/Widgets/Widgets3D/SplineWidget.js +21 -2
  40. package/index.d.ts +2 -1
  41. package/package.json +1 -1
@@ -7,23 +7,23 @@ function vtkManipulatorMixin(publicAPI, model) {
7
7
  normal = model.normal,
8
8
  direction = model.direction;
9
9
  var _model$manipulator = model.manipulator,
10
- setOrigin = _model$manipulator.setOrigin,
11
- setCenter = _model$manipulator.setCenter,
12
- setNormal = _model$manipulator.setNormal,
13
- setDirection = _model$manipulator.setDirection;
14
-
15
- if (origin && setOrigin) {
16
- setOrigin(origin);
17
- } else if (origin && setCenter) {
18
- setCenter(origin);
10
+ setHandleOrigin = _model$manipulator.setHandleOrigin,
11
+ setHandleCenter = _model$manipulator.setHandleCenter,
12
+ setHandleNormal = _model$manipulator.setHandleNormal,
13
+ setHandleDirection = _model$manipulator.setHandleDirection;
14
+
15
+ if (origin && setHandleOrigin) {
16
+ setHandleOrigin(origin);
17
+ } else if (origin && setHandleCenter) {
18
+ setHandleCenter(origin);
19
19
  }
20
20
 
21
- if (direction && setDirection) {
22
- setDirection(direction);
23
- } else if (direction && !normal && setNormal) {
24
- setNormal(direction);
25
- } else if (normal && setDirection) {
26
- setDirection(normal);
21
+ if (direction && setHandleDirection) {
22
+ setHandleDirection(direction);
23
+ } else if (direction && !normal && setHandleNormal) {
24
+ setHandleNormal(direction);
25
+ } else if (normal && setHandleDirection) {
26
+ setHandleDirection(normal);
27
27
  }
28
28
  }
29
29
  };
@@ -0,0 +1,221 @@
1
+ import { vtkObject } from './../../interfaces';
2
+ import { vtkOpenGLRenderWindow } from './../../Rendering/OpenGL/RenderWindow'
3
+ import { Vector3 } from './../../types';
4
+
5
+ /**
6
+ *
7
+ */
8
+ export interface IAbstractManipulatorInitialValues {
9
+ userOrigin?: Vector3;
10
+ handleOrigin?: Vector3;
11
+ widgetOrigin?: Vector3;
12
+ userNormal?: Vector3;
13
+ handleNormal?: Vector3;
14
+ widgetNormal?: Vector3;
15
+ }
16
+
17
+ export interface vtkAbstractManipulator extends vtkObject {
18
+
19
+ /**
20
+ * Get the normal of the line
21
+ */
22
+ getNormal(callData: any): Vector3;
23
+
24
+ /**
25
+ * Get the origin of the line
26
+ */
27
+ getOrigin(callData: any): Vector3;
28
+
29
+ /**
30
+ * Get the value of useCameraFocalPoint
31
+ */
32
+ getUseCameraFocalPoint(): boolean;
33
+
34
+ /**
35
+ * Set the value of useCameraFocalPoint
36
+ * @param useCameraFocalPoint if true, the focal point of the camera will be used if userOrigin is not set.
37
+ */
38
+ setUseCameraFocalPoint(useCameraFocalPoint: boolean): boolean;
39
+
40
+ /**
41
+ * Get the value of useCameraNormal
42
+ */
43
+ getUseCameraNormal(): boolean;
44
+
45
+ /**
46
+ * Set the value of useCameraNormal
47
+ * @param useCameraNormal if true, the normal of the camera will be used if userNormal is not set.
48
+ */
49
+ setUseCameraNormal(useCameraNormal: boolean): boolean;
50
+
51
+ /**
52
+ *
53
+ * @param callData
54
+ * @param glRenderWindow
55
+ */
56
+ handleEvent(callData: any, glRenderWindow: vtkOpenGLRenderWindow): Vector3;
57
+
58
+ /* ------------------------------------------------------------------- */
59
+
60
+ /**
61
+ * Set the user normal.
62
+ * This normal take precedence on the handleNormal and the widgetNormal.
63
+ * This normal should not be set within the widget internal code.
64
+ * @param {Vector3} normal The normal coordinate.
65
+ */
66
+ setUserNormal(normal: Vector3): boolean;
67
+
68
+ /**
69
+ * Set the user normal (see setUserNormal).
70
+ * @param {Number} x The x coordinate.
71
+ * @param {Number} y The y coordinate.
72
+ * @param {Number} z The z coordinate.
73
+ */
74
+ setUserNormal(x: number, y: number, z: number): boolean;
75
+
76
+ /**
77
+ * Set the user normal (see setUserNormal).
78
+ * @param {Vector3} normal The normal coordinate.
79
+ */
80
+ setUserNormalFrom(normal: Vector3): boolean;
81
+
82
+ /**
83
+ * Set the user origin.
84
+ * This origin take precedence on the handleOrigin and the widgetOrigin.
85
+ * This origin should not be set within the widget internal code.
86
+ * @param {Vector3} origin The coordinate of the origin point.
87
+ */
88
+ setUserOrigin(origin: Vector3): boolean;
89
+
90
+ /**
91
+ * Set the user origin (see setUserOrigin).
92
+ * @param {Number} x The x coordinate of the origin point.
93
+ * @param {Number} y The y coordinate of the origin point.
94
+ * @param {Number} z The z coordinate of the origin point.
95
+ */
96
+ setUserOrigin(x: number, y: number, z: number): boolean;
97
+
98
+ /**
99
+ * Set the user origin (see setUserOrigin).
100
+ * @param {Vector3} origin The coordinate of the origin point.
101
+ */
102
+ setUserOriginFrom(origin: Vector3): boolean;
103
+
104
+ /* ------------------------------------------------------------------- */
105
+
106
+ /**
107
+ * Set the handle normal.
108
+ * This normal is used after the userNormal and before the widgetNormal.
109
+ * This normal is automatically set by any state having a manipulatorMixin,
110
+ * and can be overridden in the widget code.
111
+ * @param {Vector3} normal The normal coordinate.
112
+ */
113
+ setHandleNormal(normal: Vector3): boolean;
114
+
115
+ /**
116
+ * Set the handle normal (see setHandleNormal).
117
+ * @param {Number} x The x coordinate.
118
+ * @param {Number} y The y coordinate.
119
+ * @param {Number} z The z coordinate.
120
+ */
121
+ setHandleNormal(x: number, y: number, z: number): boolean;
122
+
123
+ /**
124
+ * Set the handle normal (see setHandleNormal).
125
+ * @param {Vector3} normal The normal coordinate.
126
+ */
127
+ setHandleNormalFrom(normal: Vector3): boolean;
128
+
129
+ /**
130
+ * Set the handle origin.
131
+ * This origin is used after the userOrigin and before the widgetOrigin.
132
+ * This origin is automatically set by any state having a manipulatorMixin,
133
+ * and can be overridden in the widget code.
134
+ * @param {Vector3} origin The coordinate of the origin point.
135
+ */
136
+ setHandleOrigin(origin: Vector3): boolean;
137
+
138
+ /**
139
+ * Set the handle origin (see setHandleOrigin).
140
+ * @param {Number} x The x coordinate of the origin point.
141
+ * @param {Number} y The y coordinate of the origin point.
142
+ * @param {Number} z The z coordinate of the origin point.
143
+ */
144
+ setHandleOrigin(x: number, y: number, z: number): boolean;
145
+
146
+ /**
147
+ * Set the handle origin (see setHandleOrigin).
148
+ * @param {Vector3} origin The coordinate of the origin point.
149
+ */
150
+ setHandleOriginFrom(origin: Vector3): boolean;
151
+
152
+ /* ------------------------------------------------------------------- */
153
+
154
+ /**
155
+ * Set the widget normal.
156
+ * This normal is used if no other normals are set.
157
+ * It can be used to define a normal global to the whole widget.
158
+ * @param {Vector3} normal The normal coordinate.
159
+ */
160
+ setWidgetNormal(normal: Vector3): boolean;
161
+
162
+ /**
163
+ * Set the widget normal (see setWidgetNormal).
164
+ * @param {Number} x The x coordinate.
165
+ * @param {Number} y The y coordinate.
166
+ * @param {Number} z The z coordinate.
167
+ */
168
+ setWidgetNormal(x: number, y: number, z: number): boolean;
169
+
170
+ /**
171
+ * Set the widget normal (see setWidgetNormal).
172
+ * @param {Vector3} normal The normal coordinate.
173
+ */
174
+ setWidgetNormalFrom(normal: Vector3): boolean;
175
+
176
+ /**
177
+ * Set the widget origin.
178
+ * This origin is used if no other origins are set.
179
+ * It can be used to define an origin global to the whole widget.
180
+ * @param {Vector3} origin The coordinate of the origin point.
181
+ */
182
+ setWidgetOrigin(origin: Vector3): boolean;
183
+
184
+ /**
185
+ * Set the widget origin (see setWidgetOrigin).
186
+ * @param {Number} x The x coordinate of the origin point.
187
+ * @param {Number} y The y coordinate of the origin point.
188
+ * @param {Number} z The z coordinate of the origin point.
189
+ */
190
+ setWidgetOrigin(x: number, y: number, z: number): boolean;
191
+
192
+ /**
193
+ * Set the widget origin (see setWidgetOrigin).
194
+ * @param {Vector3} origin The coordinate of the origin point.
195
+ */
196
+ setWidgetOriginFrom(origin: Vector3): boolean;
197
+ }
198
+
199
+
200
+ /**
201
+ * Method use to decorate a given object (publicAPI+model) with vtkAbstractManipulator characteristics.
202
+ *
203
+ * @param publicAPI object on which methods will be bounds (public)
204
+ * @param model object on which data structure will be bounds (protected)
205
+ * @param {IAbstractManipulatorInitialValues} [initialValues] (default: {})
206
+ */
207
+ export function extend(publicAPI: object, model: object, initialValues?: IAbstractManipulatorInitialValues): void;
208
+
209
+ /**
210
+ * Method use to create a new instance of vtkAbstractManipulator
211
+ */
212
+ export function newInstance(initialValues?: IAbstractManipulatorInitialValues): vtkAbstractManipulator;
213
+
214
+ /**
215
+ * vtkAbstractManipulator.
216
+ */
217
+ export declare const vtkAbstractManipulator: {
218
+ newInstance: typeof newInstance,
219
+ extend: typeof extend,
220
+ };
221
+ export default vtkAbstractManipulator;
@@ -0,0 +1,57 @@
1
+ import macro from '../../macros.js';
2
+
3
+ // vtkAbstractManipulator methods
4
+ // ----------------------------------------------------------------------------
5
+
6
+ function vtkAbstractManipulator(publicAPI, model) {
7
+ // Set our className
8
+ model.classHierarchy.push('vtkAbstractManipulator');
9
+
10
+ publicAPI.getOrigin = function (callData) {
11
+ if (model.userOrigin) return model.userOrigin;
12
+ if (model.useCameraFocalPoint) return callData.pokedRenderer.getActiveCamera().getFocalPoint();
13
+ if (model.handleOrigin) return model.handleOrigin;
14
+ if (model.widgetOrigin) return model.widgetOrigin;
15
+ return [0, 0, 0];
16
+ };
17
+
18
+ publicAPI.getNormal = function (callData) {
19
+ if (model.userNormal) return model.userNormal;
20
+ if (model.useCameraNormal) return callData.pokedRenderer.getActiveCamera().getDirectionOfProjection();
21
+ if (model.handleNormal) return model.handleNormal;
22
+ if (model.widgetNormal) return model.widgetNormal;
23
+ return [0, 0, 1];
24
+ };
25
+ } // ----------------------------------------------------------------------------
26
+ // Object factory
27
+ // ----------------------------------------------------------------------------
28
+
29
+
30
+ var DEFAULT_VALUES = {
31
+ // userOrigin: null,
32
+ // handleOrigin: null,
33
+ // widgetOrigin: null,
34
+ // userNormal: null,
35
+ // handleNormal: null,
36
+ // widgetNormal: null
37
+ useCameraFocalPoint: false,
38
+ useCameraNormal: false
39
+ }; // ----------------------------------------------------------------------------
40
+
41
+ function extend(publicAPI, model) {
42
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
43
+ Object.assign(model, DEFAULT_VALUES, initialValues);
44
+ macro.obj(publicAPI, model);
45
+ macro.setGet(publicAPI, model, ['useCameraFocalPoint', 'useCameraNormal']);
46
+ macro.setGetArray(publicAPI, model, ['userOrigin', 'handleOrigin', 'widgetOrigin', 'userNormal', 'handleNormal', 'widgetNormal'], 3);
47
+ vtkAbstractManipulator(publicAPI, model);
48
+ } // ----------------------------------------------------------------------------
49
+
50
+ var newInstance = macro.newInstance(extend, 'vtkAbstractManipulator'); // ----------------------------------------------------------------------------
51
+
52
+ var vtkAbstractManipulator$1 = {
53
+ extend: extend,
54
+ newInstance: newInstance
55
+ };
56
+
57
+ export { vtkAbstractManipulator$1 as default, extend, newInstance };
@@ -1,81 +1,15 @@
1
- import { vtkObject } from './../../interfaces';
1
+ import { IAbstractManipulatorInitialValues, vtkAbstractManipulator } from './AbstractManipulator';
2
+ import { Vector3 } from './../../types';
2
3
 
3
4
  /**
4
5
  *
5
6
  */
6
- export interface ILineManipulatorInitialValues {
7
- origin?: number[];
8
- normal?: number[];
9
- }
10
-
11
- export interface vtkLineManipulator extends vtkObject {
12
-
13
- /**
14
- * Set the normal of the line
15
- */
16
- getNormal(): number[];
17
-
18
- /**
19
- * Set the normal of the line
20
- */
21
- getNormalByReference(): number[];
22
-
23
- /**
24
- * Set the origin of the line
25
- */
26
- getOrigin(): number[];
27
-
28
- /**
29
- * Set the origin of the line
30
- */
31
- getOriginByReference(): number[];
7
+ export interface ILineManipulatorInitialValues extends IAbstractManipulatorInitialValues {
32
8
 
33
- /**
34
- *
35
- * @param callData
36
- * @param glRenderWindow
37
- */
38
- handleEvent(callData: any, glRenderWindow: any): number[];
39
-
40
- /**
41
- * Set the normal of the line
42
- * @param {Number[]} normal The normal coordinate.
43
- */
44
- setNormal(normal: number[]): boolean;
45
-
46
- /**
47
- * Set the normal of the line
48
- * @param {Number} x The x coordinate.
49
- * @param {Number} y The y coordinate.
50
- * @param {Number} z The z coordinate.
51
- */
52
- setNormal(x: number, y: number, z: number): boolean;
53
-
54
- /**
55
- * Set the normal of the line
56
- * @param {Number[]} normal The normal coordinate.
57
- */
58
- setNormalFrom(normal: number[]): boolean;
59
-
60
- /**
61
- * Set the origin of the line.
62
- * @param {Number[]} origin The coordinate of the origin point.
63
- */
64
- setOrigin(origin: number[]): boolean;
9
+ }
65
10
 
66
- /**
67
- * Set the origin of the line
68
- * @param {Number} x The x coordinate of the origin point.
69
- * @param {Number} y The y coordinate of the origin point.
70
- * @param {Number} z The z coordinate of the origin point.
71
- */
72
- setOrigin(x: number, y: number, z: number): boolean;
11
+ export interface vtkLineManipulator extends vtkAbstractManipulator {
73
12
 
74
- /**
75
- * Set the origin of the line
76
- * @param {Number[]} origin The coordinate of the origin point.
77
- */
78
- setOriginFrom(origin: number[]): boolean;
79
13
  }
80
14
 
81
15
 
@@ -97,12 +31,12 @@ export function newInstance(initialValues?: ILineManipulatorInitialValues): vtkL
97
31
  *
98
32
  * @param {Number} x
99
33
  * @param {Number} y
100
- * @param {Number[]} lineOrigin
101
- * @param {Number[]} lineDirection
34
+ * @param {Vector3} lineOrigin
35
+ * @param {Vector3} lineDirection
102
36
  * @param renderer
103
37
  * @param glRenderWindow
104
38
  */
105
- export function projectDisplayToLine(x: number, y: number, lineOrigin: number[], lineDirection: number[], renderer: any, glRenderWindow: any): number[];
39
+ export function projectDisplayToLine(x: number, y: number, lineOrigin: Vector3, lineDirection: Vector3, renderer: any, glRenderWindow: any): Vector3;
106
40
 
107
41
  /**
108
42
  * vtkLineManipulator.
@@ -1,6 +1,11 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
1
2
  import macro from '../../macros.js';
2
3
  import { g as subtract, j as cross, d as dot, x as multiplyScalar, k as add } from '../../Common/Core/Math/index.js';
4
+ import vtkAbstractManipulator from './AbstractManipulator.js';
3
5
 
6
+ 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; }
7
+
8
+ 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; }
4
9
  function projectDisplayToLine(x, y, lineOrigin, lineDirection, renderer, glRenderWindow) {
5
10
  var near = glRenderWindow.displayToWorld(x, y, 0, renderer);
6
11
  var far = glRenderWindow.displayToWorld(x, y, 1, renderer);
@@ -20,27 +25,25 @@ function projectDisplayToLine(x, y, lineOrigin, lineDirection, renderer, glRende
20
25
  // ----------------------------------------------------------------------------
21
26
 
22
27
  function vtkLineManipulator(publicAPI, model) {
23
- // Set our classNae
24
- model.classHierarchy.push('vtkLineManipulator'); // --------------------------------------------------------------------------
28
+ // Set our className
29
+ model.classHierarchy.push('vtkLineManipulator');
25
30
 
26
31
  publicAPI.handleEvent = function (callData, glRenderWindow) {
27
- return projectDisplayToLine(callData.position.x, callData.position.y, model.origin, model.normal, callData.pokedRenderer, glRenderWindow);
32
+ return projectDisplayToLine(callData.position.x, callData.position.y, publicAPI.getOrigin(callData), publicAPI.getNormal(callData), callData.pokedRenderer, glRenderWindow);
28
33
  };
29
34
  } // ----------------------------------------------------------------------------
30
35
  // Object factory
31
36
  // ----------------------------------------------------------------------------
32
37
 
33
38
 
34
- var DEFAULT_VALUES = {
35
- origin: [0, 0, 0],
36
- normal: [0, 0, 1]
37
- }; // ----------------------------------------------------------------------------
39
+ function defaultValues(initialValues) {
40
+ return _objectSpread({}, initialValues);
41
+ } // ----------------------------------------------------------------------------
42
+
38
43
 
39
44
  function extend(publicAPI, model) {
40
45
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
41
- Object.assign(model, DEFAULT_VALUES, initialValues);
42
- macro.obj(publicAPI, model);
43
- macro.setGetArray(publicAPI, model, ['origin', 'normal'], 3);
46
+ vtkAbstractManipulator.extend(publicAPI, model, defaultValues(initialValues));
44
47
  vtkLineManipulator(publicAPI, model);
45
48
  } // ----------------------------------------------------------------------------
46
49
 
@@ -1,81 +1,15 @@
1
- import { vtkObject } from './../../interfaces';
1
+ import { IAbstractManipulatorInitialValues, vtkAbstractManipulator } from './AbstractManipulator';
2
+ import { Vector3 } from './../../types';
2
3
 
3
4
  /**
4
5
  *
5
6
  */
6
- export interface IPlaneManipulatorInitialValues {
7
- origin?: number[];
8
- normal?: number[];
9
- }
10
-
11
- export interface vtkPlaneManipulator extends vtkObject {
12
-
13
- /**
14
- * Get the normal of the plane
15
- */
16
- getNormal(): number[];
17
-
18
- /**
19
- * Get the normal of the plane
20
- */
21
- getNormalByReference(): number[];
22
-
23
- /**
24
- * Get the origin of the plane
25
- */
26
- getOrigin(): number[];
27
-
28
- /**
29
- * Get the origin of the plane
30
- */
31
- getOriginByReference(): number[];
7
+ export interface IPlaneManipulatorInitialValues extends IAbstractManipulatorInitialValues {
32
8
 
33
- /**
34
- *
35
- * @param callData
36
- * @param glRenderWindow
37
- */
38
- handleEvent(callData: any, glRenderWindow: any): number[];
39
-
40
- /**
41
- * Set the normal of the plane
42
- * @param {Number[]} normal The normal coordinate.
43
- */
44
- setNormal(normal: number[]): boolean;
45
-
46
- /**
47
- * Set the normal of the plane
48
- * @param {Number} x The x coordinate.
49
- * @param {Number} y The y coordinate.
50
- * @param {Number} z The z coordinate.
51
- */
52
- setNormal(x: number, y: number, z: number): boolean;
53
-
54
- /**
55
- * Set the normal of the plane
56
- * @param {Number[]} normal The normal coordinate.
57
- */
58
- setNormalFrom(normal: number[]): boolean;
59
-
60
- /**
61
- * Set the origin of the plane.
62
- * @param {Number[]} origin The coordinate of the origin point.
63
- */
64
- setOrigin(origin: number[]): boolean;
9
+ }
65
10
 
66
- /**
67
- * Set the origin of the plane.
68
- * @param {Number} x The x coordinate of the origin point.
69
- * @param {Number} y The y coordinate of the origin point.
70
- * @param {Number} z The z coordinate of the origin point.
71
- */
72
- setOrigin(x: number, y: number, z: number): boolean;
11
+ export interface vtkPlaneManipulator extends vtkAbstractManipulator {
73
12
 
74
- /**
75
- * Set the origin of the plane.
76
- * @param {Number[]} origin The coordinate of the origin point.
77
- */
78
- setOriginFrom(origin: number[]): boolean;
79
13
  }
80
14
 
81
15
 
@@ -97,12 +31,12 @@ export function newInstance(initialValues?: IPlaneManipulatorInitialValues): vtk
97
31
  *
98
32
  * @param {Number} x
99
33
  * @param {Number} y
100
- * @param {Number[]} planeOrigin
101
- * @param {Number[]} planeNormal
34
+ * @param {Vector3} planeOrigin
35
+ * @param {Vector3} planeNormal
102
36
  * @param renderer
103
37
  * @param glRenderWindow
104
38
  */
105
- export function intersectDisplayWithPlane(x: number, y: number, planeOrigin: number[], planeNormal: number[], renderer: any, glRenderWindow: any): number[];
39
+ export function intersectDisplayWithPlane(x: number, y: number, planeOrigin: Vector3, planeNormal: Vector3, renderer: any, glRenderWindow: any): Vector3;
106
40
 
107
41
 
108
42
  /**
@@ -1,6 +1,11 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
1
2
  import macro from '../../macros.js';
2
3
  import vtkPlane from '../../Common/DataModel/Plane.js';
4
+ import vtkAbstractManipulator from './AbstractManipulator.js';
3
5
 
6
+ 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; }
7
+
8
+ 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; }
4
9
  function intersectDisplayWithPlane(x, y, planeOrigin, planeNormal, renderer, glRenderWindow) {
5
10
  var near = glRenderWindow.displayToWorld(x, y, 0, renderer);
6
11
  var far = glRenderWindow.displayToWorld(x, y, 1, renderer);
@@ -11,26 +16,24 @@ function intersectDisplayWithPlane(x, y, planeOrigin, planeNormal, renderer, glR
11
16
 
12
17
  function vtkPlaneManipulator(publicAPI, model) {
13
18
  // Set our className
14
- model.classHierarchy.push('vtkPlaneManipulator'); // --------------------------------------------------------------------------
19
+ model.classHierarchy.push('vtkPlaneManipulator');
15
20
 
16
21
  publicAPI.handleEvent = function (callData, glRenderWindow) {
17
- return intersectDisplayWithPlane(callData.position.x, callData.position.y, model.origin, model.normal, callData.pokedRenderer, glRenderWindow);
22
+ return intersectDisplayWithPlane(callData.position.x, callData.position.y, publicAPI.getOrigin(callData), publicAPI.getNormal(callData), callData.pokedRenderer, glRenderWindow);
18
23
  };
19
24
  } // ----------------------------------------------------------------------------
20
25
  // Object factory
21
26
  // ----------------------------------------------------------------------------
22
27
 
23
28
 
24
- var DEFAULT_VALUES = {
25
- normal: [0, 0, 1],
26
- origin: [0, 0, 0]
27
- }; // ----------------------------------------------------------------------------
29
+ function defaultValues(initialValues) {
30
+ return _objectSpread({}, initialValues);
31
+ } // ----------------------------------------------------------------------------
32
+
28
33
 
29
34
  function extend(publicAPI, model) {
30
35
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
31
- Object.assign(model, DEFAULT_VALUES, initialValues);
32
- macro.obj(publicAPI, model);
33
- macro.setGetArray(publicAPI, model, ['normal', 'origin'], 3);
36
+ vtkAbstractManipulator.extend(publicAPI, model, defaultValues(initialValues));
34
37
  vtkPlaneManipulator(publicAPI, model);
35
38
  } // ----------------------------------------------------------------------------
36
39