@kitware/vtk.js 24.7.0 → 24.9.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 (58) hide show
  1. package/Common/DataModel/ITKHelper.d.ts +54 -0
  2. package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
  3. package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +1 -1
  4. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
  5. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  6. package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +1 -1
  7. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +5 -2
  8. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +3 -1
  9. package/Interaction/Manipulators/MouseRangeManipulator.js +23 -6
  10. package/Interaction/Style/InteractorStyleManipulator.js +1 -1
  11. package/Rendering/Core/RenderWindowInteractor.js +1 -2
  12. package/Widgets/Core/StateBuilder/manipulatorMixin.js +15 -15
  13. package/Widgets/Core/WidgetManager.js +11 -2
  14. package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
  15. package/Widgets/Manipulators/AbstractManipulator.js +57 -0
  16. package/Widgets/Manipulators/LineManipulator.d.ts +8 -74
  17. package/Widgets/Manipulators/LineManipulator.js +13 -10
  18. package/Widgets/Manipulators/PlaneManipulator.d.ts +8 -74
  19. package/Widgets/Manipulators/PlaneManipulator.js +12 -9
  20. package/Widgets/Manipulators/TrackballManipulator.d.ts +8 -44
  21. package/Widgets/Manipulators/TrackballManipulator.js +14 -11
  22. package/Widgets/Representations/ArrowHandleRepresentation.js +12 -3
  23. package/Widgets/Representations/CircleContextRepresentation.js +12 -3
  24. package/Widgets/Representations/CubeHandleRepresentation.js +13 -4
  25. package/Widgets/Representations/SphereContextRepresentation.js +12 -3
  26. package/Widgets/Representations/SphereHandleRepresentation.js +12 -3
  27. package/Widgets/Widgets3D/AngleWidget/behavior.js +7 -4
  28. package/Widgets/Widgets3D/AngleWidget/state.js +2 -2
  29. package/Widgets/Widgets3D/AngleWidget.js +19 -2
  30. package/Widgets/Widgets3D/DistanceWidget/behavior.js +7 -2
  31. package/Widgets/Widgets3D/DistanceWidget/state.js +2 -2
  32. package/Widgets/Widgets3D/DistanceWidget.js +19 -2
  33. package/Widgets/Widgets3D/EllipseWidget.js +4 -3
  34. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +3 -4
  35. package/Widgets/Widgets3D/ImageCroppingWidget.js +42 -13
  36. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +5 -5
  37. package/Widgets/Widgets3D/LabelWidget/behavior.js +6 -2
  38. package/Widgets/Widgets3D/LabelWidget/state.js +2 -2
  39. package/Widgets/Widgets3D/LabelWidget.js +18 -3
  40. package/Widgets/Widgets3D/LineWidget/behavior.js +10 -3
  41. package/Widgets/Widgets3D/LineWidget/state.js +1 -1
  42. package/Widgets/Widgets3D/LineWidget.js +18 -1
  43. package/Widgets/Widgets3D/PaintWidget/behavior.js +12 -9
  44. package/Widgets/Widgets3D/PaintWidget.js +24 -8
  45. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +11 -4
  46. package/Widgets/Widgets3D/PolyLineWidget/state.js +2 -2
  47. package/Widgets/Widgets3D/PolyLineWidget.js +21 -2
  48. package/Widgets/Widgets3D/RectangleWidget.js +6 -5
  49. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +4 -4
  50. package/Widgets/Widgets3D/ShapeWidget/behavior.js +9 -5
  51. package/Widgets/Widgets3D/ShapeWidget.js +12 -2
  52. package/Widgets/Widgets3D/SphereWidget/behavior.js +4 -3
  53. package/Widgets/Widgets3D/SphereWidget.js +23 -2
  54. package/Widgets/Widgets3D/SplineWidget/behavior.js +7 -3
  55. package/Widgets/Widgets3D/SplineWidget/state.js +2 -2
  56. package/Widgets/Widgets3D/SplineWidget.js +21 -2
  57. package/index.d.ts +3 -1
  58. package/package.json +1 -1
@@ -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
 
@@ -1,50 +1,14 @@
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 ITrackballManipulatorInitialValues {
7
- normal?: number[];
8
- }
9
-
10
- export interface vtkTrackballManipulator extends vtkObject {
11
-
12
- /**
13
- * Get normal
14
- */
15
- getNormal(): number[];
16
-
17
- /**
18
- * Get normal
19
- */
20
- getNormalByReference(): number[];
21
-
22
- /**
23
- *
24
- * @param callData
25
- * @param glRenderWindow
26
- */
27
- handleEvent(callData: any, glRenderWindow: any): void;
28
-
29
- /**
30
- * Set the normal of the line.
31
- * @param {Number[]} normal The normal coordinate.
32
- */
33
- setNormal(normal: number[]): boolean;
7
+ export interface ITrackballManipulatorInitialValues extends IAbstractManipulatorInitialValues {
34
8
 
35
- /**
36
- * Set the normal of the line.
37
- * @param {Number} x The x coordinate.
38
- * @param {Number} y The y coordinate.
39
- * @param {Number} z The z coordinate.
40
- */
41
- setNormal(x: number, y: number, z: number): boolean;
9
+ }
42
10
 
43
- /**
44
- * Set the normal of the line.
45
- * @param {Number[]} normal The normal coordinate.
46
- */
47
- setNormalFrom(normal: number[]): boolean;
11
+ export interface vtkTrackballManipulator extends vtkAbstractManipulator {
48
12
 
49
13
  /**
50
14
  *
@@ -73,12 +37,12 @@ export function newInstance(initialValues?: ITrackballManipulatorInitialValues):
73
37
  * @param {Number} prevY
74
38
  * @param {Number} curX
75
39
  * @param {Number} curY
76
- * @param {Number[]} origin
77
- * @param {Number[]} direction
40
+ * @param {Vector3} origin
41
+ * @param {Vector3} direction
78
42
  * @param renderer
79
43
  * @param glRenderWindow
80
44
  */
81
- export function trackballRotate(prevX: number, prevY: number, curX: number, curY: number, origin: number[], direction: number[], renderer: any, glRenderWindow: any): void;
45
+ export function trackballRotate(prevX: number, prevY: number, curX: number, curY: number, origin: Vector3, direction: Vector3, renderer: any, glRenderWindow: any): void;
82
46
 
83
47
 
84
48
  /**
@@ -1,14 +1,19 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
1
2
  import { mat4, vec3 } from 'gl-matrix';
2
3
  import macro from '../../macros.js';
3
4
  import { j as cross, r as radiansFromDegrees } from '../../Common/Core/Math/index.js';
5
+ import vtkAbstractManipulator from './AbstractManipulator.js';
4
6
 
7
+ 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; }
8
+
9
+ 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; }
5
10
  function trackballRotate(prevX, prevY, curX, curY, origin, direction, renderer, glRenderWindow) {
6
11
  var dx = curX - prevX;
7
12
  var dy = curY - prevY;
8
13
  var camera = renderer.getActiveCamera();
9
14
  var viewUp = camera.getViewUp();
10
15
  var dop = camera.getDirectionOfProjection();
11
- var size = renderer.getRenderWindow().getInteractor().getView().getSize();
16
+ var size = renderer.getRenderWindow().getInteractor().getView().getViewportSize(renderer);
12
17
  var xdeg = 360.0 * dx / size[0];
13
18
  var ydeg = 360.0 * dy / size[1];
14
19
  var newDirection = new Float64Array([direction[0], direction[1], direction[2]]);
@@ -28,15 +33,14 @@ function vtkTrackballManipulator(publicAPI, model) {
28
33
  // Set our className
29
34
  model.classHierarchy.push('vtkTrackballManipulator');
30
35
  var prevX = 0;
31
- var prevY = 0; // --------------------------------------------------------------------------
36
+ var prevY = 0;
32
37
 
33
38
  publicAPI.handleEvent = function (callData, glRenderWindow) {
34
- var newDirection = trackballRotate(prevX, prevY, callData.position.x, callData.position.y, model.origin, model.normal, callData.pokedRenderer);
39
+ var newDirection = trackballRotate(prevX, prevY, callData.position.x, callData.position.y, publicAPI.getOrigin(callData), publicAPI.getNormal(callData), callData.pokedRenderer);
35
40
  prevX = callData.position.x;
36
41
  prevY = callData.position.y;
37
42
  return newDirection;
38
- }; // --------------------------------------------------------------------------
39
-
43
+ };
40
44
 
41
45
  publicAPI.reset = function (callData) {
42
46
  prevX = callData.position.x;
@@ -47,15 +51,14 @@ function vtkTrackballManipulator(publicAPI, model) {
47
51
  // ----------------------------------------------------------------------------
48
52
 
49
53
 
50
- var DEFAULT_VALUES = {
51
- normal: [0, 0, 1]
52
- }; // ----------------------------------------------------------------------------
54
+ function defaultValues(initialValues) {
55
+ return _objectSpread({}, initialValues);
56
+ } // ----------------------------------------------------------------------------
57
+
53
58
 
54
59
  function extend(publicAPI, model) {
55
60
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
56
- Object.assign(model, DEFAULT_VALUES, initialValues);
57
- macro.obj(publicAPI, model);
58
- macro.setGetArray(publicAPI, model, ['normal'], 3);
61
+ vtkAbstractManipulator.extend(publicAPI, model, defaultValues(initialValues));
59
62
  vtkTrackballManipulator(publicAPI, model);
60
63
  } // ----------------------------------------------------------------------------
61
64
 
@@ -255,15 +255,24 @@ function vtkArrowHandleRepresentation(publicAPI, model) {
255
255
  return orientationRotation;
256
256
  }
257
257
 
258
+ var superGetRepresentationStates = publicAPI.getRepresentationStates;
259
+
260
+ publicAPI.getRepresentationStates = function () {
261
+ var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
262
+ return superGetRepresentationStates(input).filter(function (state) {
263
+ var _state$getOrigin, _state$isVisible;
264
+
265
+ return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = state.isVisible) === null || _state$isVisible === void 0 ? void 0 : _state$isVisible.call(state));
266
+ });
267
+ };
268
+
258
269
  publicAPI.requestDataInternal = function (inData, outData) {
259
270
  var _model$internalArrays = model.internalArrays,
260
271
  points = _model$internalArrays.points,
261
272
  scale = _model$internalArrays.scale,
262
273
  color = _model$internalArrays.color,
263
274
  direction = _model$internalArrays.direction;
264
- var list = publicAPI.getRepresentationStates(inData[0]).filter(function (state) {
265
- return state.getOrigin && state.getOrigin() && state.isVisible && state.isVisible();
266
- });
275
+ var list = publicAPI.getRepresentationStates(inData[0]);
267
276
  var totalCount = list.length;
268
277
 
269
278
  if (color.getNumberOfValues() !== totalCount) {
@@ -93,6 +93,17 @@ function vtkCircleContextRepresentation(publicAPI, model) {
93
93
 
94
94
  publicAPI.setOpacity = function (opacity) {
95
95
  model.pipelines.circle.actor.getProperty().setOpacity(opacity);
96
+ };
97
+
98
+ var superGetRepresentationStates = publicAPI.getRepresentationStates;
99
+
100
+ publicAPI.getRepresentationStates = function () {
101
+ var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
102
+ return superGetRepresentationStates(input).filter(function (state) {
103
+ var _state$getOrigin, _state$isVisible;
104
+
105
+ return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = state.isVisible) === null || _state$isVisible === void 0 ? void 0 : _state$isVisible.call(state));
106
+ });
96
107
  }; // --------------------------------------------------------------------------
97
108
 
98
109
 
@@ -102,9 +113,7 @@ function vtkCircleContextRepresentation(publicAPI, model) {
102
113
  scale = _model$internalArrays.scale,
103
114
  color = _model$internalArrays.color,
104
115
  direction = _model$internalArrays.direction;
105
- var list = publicAPI.getRepresentationStates(inData[0]).filter(function (state) {
106
- return state.getOrigin && state.getOrigin() && state.isVisible && state.isVisible();
107
- });
116
+ var list = publicAPI.getRepresentationStates(inData[0]);
108
117
  var totalCount = list.length;
109
118
 
110
119
  if (color.getNumberOfValues() !== totalCount) {
@@ -49,16 +49,25 @@ function vtkCubeHandleRepresentation(publicAPI, model) {
49
49
  model.mapper.setInputConnection(publicAPI.getOutputPort(), 0);
50
50
  model.mapper.setInputConnection(model.glyph.getOutputPort(), 1);
51
51
  model.actor.setMapper(model.mapper);
52
- publicAPI.addActor(model.actor); // --------------------------------------------------------------------------
52
+ publicAPI.addActor(model.actor);
53
+ var superGetRepresentationStates = publicAPI.getRepresentationStates;
54
+
55
+ publicAPI.getRepresentationStates = function () {
56
+ var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
57
+ return superGetRepresentationStates(input).filter(function (state) {
58
+ var _state$getOrigin, _state$isVisible;
59
+
60
+ return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = state.isVisible) === null || _state$isVisible === void 0 ? void 0 : _state$isVisible.call(state));
61
+ });
62
+ }; // --------------------------------------------------------------------------
63
+
53
64
 
54
65
  publicAPI.requestData = function (inData, outData) {
55
66
  var _model$internalArrays = model.internalArrays,
56
67
  points = _model$internalArrays.points,
57
68
  scale = _model$internalArrays.scale,
58
69
  color = _model$internalArrays.color;
59
- var list = publicAPI.getRepresentationStates(inData[0]).filter(function (state) {
60
- return state.getOrigin && state.getOrigin() && state.isVisible && state.isVisible();
61
- });
70
+ var list = publicAPI.getRepresentationStates(inData[0]);
62
71
  var totalCount = list.length;
63
72
 
64
73
  if (color.getNumberOfValues() !== totalCount) {
@@ -66,14 +66,23 @@ function vtkSphereContextRepresentation(publicAPI, model) {
66
66
  model.pipelines.circle.actor.getProperty().setOpacity(opacity);
67
67
  };
68
68
 
69
+ var superGetRepresentationStates = publicAPI.getRepresentationStates;
70
+
71
+ publicAPI.getRepresentationStates = function () {
72
+ var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
73
+ return superGetRepresentationStates(input).filter(function (state) {
74
+ var _state$getOrigin, _state$isVisible;
75
+
76
+ return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = state.isVisible) === null || _state$isVisible === void 0 ? void 0 : _state$isVisible.call(state));
77
+ });
78
+ };
79
+
69
80
  publicAPI.requestData = function (inData, outData) {
70
81
  var _model$internalArrays = model.internalArrays,
71
82
  points = _model$internalArrays.points,
72
83
  scale = _model$internalArrays.scale,
73
84
  color = _model$internalArrays.color;
74
- var list = publicAPI.getRepresentationStates(inData[0]).filter(function (state) {
75
- return state.getOrigin && state.getOrigin() && state.isVisible && state.isVisible();
76
- });
85
+ var list = publicAPI.getRepresentationStates(inData[0]);
77
86
  var totalCount = list.length;
78
87
 
79
88
  if (color.getNumberOfValues() !== totalCount) {
@@ -96,6 +96,17 @@ function vtkSphereHandleRepresentation(publicAPI, model) {
96
96
  publicAPI.setDisplayCallback = function (callback) {
97
97
  model.displayCallback = callback;
98
98
  model.displayMapper.setCallback(callback ? callbackProxy : null);
99
+ };
100
+
101
+ var superGetRepresentationStates = publicAPI.getRepresentationStates;
102
+
103
+ publicAPI.getRepresentationStates = function () {
104
+ var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
105
+ return superGetRepresentationStates(input).filter(function (state) {
106
+ var _state$getOrigin, _state$isVisible;
107
+
108
+ return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = state.isVisible) === null || _state$isVisible === void 0 ? void 0 : _state$isVisible.call(state));
109
+ });
99
110
  }; // --------------------------------------------------------------------------
100
111
 
101
112
 
@@ -104,9 +115,7 @@ function vtkSphereHandleRepresentation(publicAPI, model) {
104
115
  points = _model$internalArrays.points,
105
116
  scale = _model$internalArrays.scale,
106
117
  color = _model$internalArrays.color;
107
- var list = publicAPI.getRepresentationStates(inData[0]).filter(function (state) {
108
- return state.getOrigin && state.getOrigin() && state.isVisible && state.isVisible();
109
- });
118
+ var list = publicAPI.getRepresentationStates(inData[0]);
110
119
  var totalCount = list.length;
111
120
 
112
121
  if (color.getNumberOfValues() !== totalCount) {
@@ -40,6 +40,7 @@ function widgetBehavior(publicAPI, model) {
40
40
  newHandle.setOrigin.apply(newHandle, _toConsumableArray(moveHandle.getOrigin()));
41
41
  newHandle.setColor(moveHandle.getColor());
42
42
  newHandle.setScale1(moveHandle.getScale1());
43
+ newHandle.setManipulator(model.manipulator);
43
44
  } else {
44
45
  isDragging = true;
45
46
 
@@ -56,10 +57,12 @@ function widgetBehavior(publicAPI, model) {
56
57
 
57
58
 
58
59
  publicAPI.handleMouseMove = function (callData) {
59
- if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
60
- model.manipulator.setOrigin(model.activeState.getOrigin());
61
- model.manipulator.setNormal(model._camera.getDirectionOfProjection());
62
- var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
60
+ var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
61
+
62
+ 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;
63
+
64
+ if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
65
+ var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
63
66
 
64
67
  if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
65
68
  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
  }).addDynamicMixinState({
13
13
  labels: ['handles'],
14
- mixins: ['origin', 'color', 'scale1', 'visible'],
14
+ mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
15
15
  name: 'handle',
16
16
  initialValues: {
17
17
  scale1: 0.1