@kitware/vtk.js 23.4.1 → 24.0.0-beta.2

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 (145) hide show
  1. package/BREAKING_CHANGES.md +33 -0
  2. package/Common/Core/DataArray.js +4 -0
  3. package/Common/Core/Math/index.js +2 -2
  4. package/Common/Core/Math.js +1 -1
  5. package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
  6. package/Common/DataModel/ImageData.d.ts +23 -6
  7. package/Common/DataModel/ImageData.js +8 -1
  8. package/Common/DataModel/PolyData.d.ts +8 -1
  9. package/Common/DataModel/PolyData.js +5 -3
  10. package/Common/DataModel/Triangle.js +217 -2
  11. package/Common/Transform/LandmarkTransform.js +1 -1
  12. package/Filters/General/OBBTree/OBBNode.js +82 -0
  13. package/Filters/General/OBBTree/helper.js +92 -0
  14. package/Filters/General/OBBTree.js +1249 -0
  15. package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
  16. package/Filters/General.js +2 -0
  17. package/Filters/Sources/CircleSource.js +1 -1
  18. package/Filters/Sources/PointSource.js +1 -1
  19. package/Filters/Texture/TextureMapToPlane.js +1 -1
  20. package/IO/Core/DataAccessHelper.d.ts +6 -0
  21. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  22. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  23. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  24. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  25. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  26. package/Interaction/Style/InteractorStyleImage.js +3 -3
  27. package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
  28. package/Interaction/Style/InteractorStyleManipulator.js +42 -28
  29. package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
  30. package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
  31. package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
  32. package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
  33. package/Interaction/Widgets.js +1 -35
  34. package/Proxy/Core/View2DProxy.js +1 -1
  35. package/Rendering/Core/ColorTransferFunction.js +1 -1
  36. package/Rendering/Core/Coordinate.js +1 -1
  37. package/Rendering/Core/CubeAxesActor.js +1 -1
  38. package/Rendering/Core/Glyph3DMapper.js +1 -1
  39. package/Rendering/Core/ImageMapper.js +1 -1
  40. package/Rendering/Core/InteractorObserver.js +11 -10
  41. package/Rendering/Core/InteractorStyle.js +9 -4
  42. package/Rendering/Core/Mapper.js +1 -1
  43. package/Rendering/Core/Prop.js +6 -4
  44. package/Rendering/Core/Prop3D.js +1 -1
  45. package/Rendering/Core/RenderWindowInteractor.js +24 -17
  46. package/Rendering/Core/Renderer.js +24 -19
  47. package/Rendering/Core/ScalarBarActor.js +1 -1
  48. package/Rendering/Core/Viewport.js +1 -1
  49. package/Rendering/Core/VolumeMapper.js +1 -1
  50. package/Rendering/OpenGL/Actor.js +2 -2
  51. package/Rendering/OpenGL/Actor2D.js +2 -2
  52. package/Rendering/OpenGL/BufferObject.js +6 -5
  53. package/Rendering/OpenGL/Camera.js +3 -3
  54. package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
  55. package/Rendering/OpenGL/Framebuffer.js +13 -12
  56. package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
  57. package/Rendering/OpenGL/HardwareSelector.js +35 -25
  58. package/Rendering/OpenGL/ImageMapper.js +51 -45
  59. package/Rendering/OpenGL/ImageSlice.js +2 -2
  60. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
  61. package/Rendering/OpenGL/PolyDataMapper.js +14 -11
  62. package/Rendering/OpenGL/PolyDataMapper2D.js +7 -6
  63. package/Rendering/OpenGL/Renderer.js +11 -7
  64. package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
  65. package/Rendering/OpenGL/ScalarBarActor.js +2 -2
  66. package/Rendering/OpenGL/ShaderCache.js +7 -5
  67. package/Rendering/OpenGL/Skybox.js +11 -9
  68. package/Rendering/OpenGL/SphereMapper.js +2 -2
  69. package/Rendering/OpenGL/StickMapper.js +2 -2
  70. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
  71. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
  72. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
  73. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
  74. package/Rendering/OpenGL/Texture.js +44 -31
  75. package/Rendering/OpenGL/VertexArrayObject.js +7 -7
  76. package/Rendering/OpenGL/Volume.js +3 -2
  77. package/Rendering/OpenGL/VolumeMapper.js +30 -26
  78. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  79. package/Rendering/SceneGraph/ViewNode.js +8 -7
  80. package/Rendering/WebGPU/Renderer.js +18 -10
  81. package/Widgets/Core/AbstractWidget.js +5 -4
  82. package/Widgets/Core/AbstractWidgetFactory.js +2 -1
  83. package/Widgets/Core/WidgetManager.js +66 -49
  84. package/Widgets/Manipulators/LineManipulator.js +1 -1
  85. package/Widgets/Representations/CircleContextRepresentation.js +1 -1
  86. package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
  87. package/Widgets/Representations/PolyLineRepresentation.js +1 -1
  88. package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
  89. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
  90. package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
  91. package/Widgets/SVG/SVGRepresentation.js +1 -1
  92. package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
  93. package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
  94. package/Widgets/Widgets3D/EllipseWidget.js +0 -1
  95. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
  96. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
  97. package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
  98. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  99. package/Widgets/Widgets3D/LabelWidget.js +79 -0
  100. package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
  101. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  102. package/Widgets/Widgets3D/LineWidget.js +0 -1
  103. package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
  104. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
  105. package/Widgets/Widgets3D/RectangleWidget.js +0 -1
  106. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  107. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  108. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  109. package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
  110. package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
  111. package/interfaces.d.ts +11 -0
  112. package/macros.d.ts +26 -1
  113. package/macros.js +51 -19
  114. package/package.json +1 -1
  115. package/types.d.ts +1 -0
  116. package/Interaction/Widgets/AbstractWidget.js +0 -104
  117. package/Interaction/Widgets/DistanceRepresentation.js +0 -116
  118. package/Interaction/Widgets/DistanceWidget.js +0 -77
  119. package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
  120. package/Interaction/Widgets/HandleRepresentation.js +0 -100
  121. package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
  122. package/Interaction/Widgets/HandleWidget.js +0 -194
  123. package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
  124. package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
  125. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
  126. package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
  127. package/Interaction/Widgets/LabelRepresentation.js +0 -325
  128. package/Interaction/Widgets/LabelWidget.js +0 -65
  129. package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
  130. package/Interaction/Widgets/LineRepresentation.js +0 -498
  131. package/Interaction/Widgets/LineWidget/Constants.js +0 -11
  132. package/Interaction/Widgets/LineWidget.js +0 -296
  133. package/Interaction/Widgets/PointPlacer.js +0 -51
  134. package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
  135. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
  136. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
  137. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
  138. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
  139. package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
  140. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
  141. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
  142. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
  143. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
  144. package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
  145. package/Interaction/Widgets/WidgetRepresentation.js +0 -121
@@ -60,7 +60,7 @@ function vtkSVGRepresentation(publicAPI, model) {
60
60
  var deferred = null;
61
61
  model.psActor = vtkActor.newInstance({
62
62
  pickable: false,
63
- parentProp: publicAPI
63
+ _parentProp: publicAPI
64
64
  });
65
65
  model.psMapper = vtkPixelSpaceCallbackMapper.newInstance();
66
66
  model.points = vtkPolyData.newInstance();
@@ -43,7 +43,8 @@ function widgetBehavior(publicAPI, model) {
43
43
  } else {
44
44
  isDragging = true;
45
45
  model.apiSpecificRenderWindow.setCursor('grabbing');
46
- model.interactor.requestAnimation(publicAPI);
46
+
47
+ model._interactor.requestAnimation(publicAPI);
47
48
  }
48
49
 
49
50
  publicAPI.invokeStartInteractionEvent();
@@ -80,7 +81,9 @@ function widgetBehavior(publicAPI, model) {
80
81
  if (isDragging && model.pickable) {
81
82
  model.apiSpecificRenderWindow.setCursor('pointer');
82
83
  model.widgetState.deactivate();
83
- model.interactor.cancelAnimation(publicAPI);
84
+
85
+ model._interactor.cancelAnimation(publicAPI);
86
+
84
87
  publicAPI.invokeEndInteractionEvent();
85
88
  } else if (model.activeState !== model.widgetState.getMoveHandle()) {
86
89
  model.widgetState.deactivate();
@@ -89,7 +92,8 @@ function widgetBehavior(publicAPI, model) {
89
92
  if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
90
93
  publicAPI.invokeEndInteractionEvent();
91
94
  model.widgetManager.enablePicking();
92
- model.interactor.render();
95
+
96
+ model._interactor.render();
93
97
  } // Don't make any more points
94
98
 
95
99
 
@@ -108,7 +112,9 @@ function widgetBehavior(publicAPI, model) {
108
112
  model.activeState = model.widgetState.getMoveHandle();
109
113
  model.activeState.activate();
110
114
  model.activeState.setVisible(true);
111
- model.interactor.requestAnimation(publicAPI);
115
+
116
+ model._interactor.requestAnimation(publicAPI);
117
+
112
118
  publicAPI.invokeStartInteractionEvent();
113
119
  }
114
120
 
@@ -118,7 +124,8 @@ function widgetBehavior(publicAPI, model) {
118
124
 
119
125
  publicAPI.loseFocus = function () {
120
126
  if (model.hasFocus) {
121
- model.interactor.cancelAnimation(publicAPI);
127
+ model._interactor.cancelAnimation(publicAPI);
128
+
122
129
  publicAPI.invokeEndInteractionEvent();
123
130
  }
124
131
 
@@ -128,7 +135,8 @@ function widgetBehavior(publicAPI, model) {
128
135
  model.activeState = null;
129
136
  model.hasFocus = false;
130
137
  model.widgetManager.enablePicking();
131
- model.interactor.render();
138
+
139
+ model._interactor.render();
132
140
  };
133
141
  }
134
142
 
@@ -37,7 +37,8 @@ function widgetBehavior(publicAPI, model) {
37
37
  } else {
38
38
  isDragging = true;
39
39
  model.apiSpecificRenderWindow.setCursor('grabbing');
40
- model.interactor.requestAnimation(publicAPI);
40
+
41
+ model._interactor.requestAnimation(publicAPI);
41
42
  }
42
43
 
43
44
  publicAPI.invokeStartInteractionEvent();
@@ -73,7 +74,9 @@ function widgetBehavior(publicAPI, model) {
73
74
  if (isDragging && model.pickable) {
74
75
  model.apiSpecificRenderWindow.setCursor('pointer');
75
76
  model.widgetState.deactivate();
76
- model.interactor.cancelAnimation(publicAPI);
77
+
78
+ model._interactor.cancelAnimation(publicAPI);
79
+
77
80
  publicAPI.invokeEndInteractionEvent();
78
81
  } else if (model.activeState !== model.widgetState.getMoveHandle()) {
79
82
  model.widgetState.deactivate();
@@ -82,7 +85,8 @@ function widgetBehavior(publicAPI, model) {
82
85
  if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
83
86
  publicAPI.invokeEndInteractionEvent();
84
87
  model.widgetManager.enablePicking();
85
- model.interactor.render();
88
+
89
+ model._interactor.render();
86
90
  }
87
91
 
88
92
  isDragging = false;
@@ -96,7 +100,9 @@ function widgetBehavior(publicAPI, model) {
96
100
  model.activeState = model.widgetState.getMoveHandle();
97
101
  model.activeState.activate();
98
102
  model.activeState.setVisible(true);
99
- model.interactor.requestAnimation(publicAPI);
103
+
104
+ model._interactor.requestAnimation(publicAPI);
105
+
100
106
  publicAPI.invokeStartInteractionEvent();
101
107
  }
102
108
 
@@ -106,7 +112,8 @@ function widgetBehavior(publicAPI, model) {
106
112
 
107
113
  publicAPI.loseFocus = function () {
108
114
  if (model.hasFocus) {
109
- model.interactor.cancelAnimation(publicAPI);
115
+ model._interactor.cancelAnimation(publicAPI);
116
+
110
117
  publicAPI.invokeEndInteractionEvent();
111
118
  }
112
119
 
@@ -116,7 +123,8 @@ function widgetBehavior(publicAPI, model) {
116
123
  model.activeState = null;
117
124
  model.hasFocus = false;
118
125
  model.widgetManager.enablePicking();
119
- model.interactor.render();
126
+
127
+ model._interactor.render();
120
128
  };
121
129
  }
122
130
 
@@ -42,7 +42,6 @@ function vtkEllipseWidget(publicAPI, model) {
42
42
  }, {
43
43
  builder: vtkSVGLandmarkRepresentation,
44
44
  initialValues: {
45
- showCircle: false,
46
45
  text: ''
47
46
  },
48
47
  labels: ['SVGtext']
@@ -15,7 +15,9 @@ function widgetBehavior(publicAPI, model) {
15
15
  }
16
16
 
17
17
  isDragging = true;
18
- model.interactor.requestAnimation(publicAPI);
18
+
19
+ model._interactor.requestAnimation(publicAPI);
20
+
19
21
  return macro.EVENT_ABORT;
20
22
  };
21
23
 
@@ -30,7 +32,9 @@ function widgetBehavior(publicAPI, model) {
30
32
  publicAPI.handleLeftButtonRelease = function () {
31
33
  if (isDragging && model.pickable) {
32
34
  isDragging = false;
33
- model.interactor.cancelAnimation(publicAPI);
35
+
36
+ model._interactor.cancelAnimation(publicAPI);
37
+
34
38
  model.widgetState.deactivate();
35
39
  }
36
40
  };
@@ -48,7 +48,8 @@ function widgetBehavior(publicAPI, model) {
48
48
  model.planeManipulator.setOrigin(model.widgetState.getOrigin());
49
49
  model.trackballManipulator.reset(callData); // setup trackball delta
50
50
 
51
- model.interactor.requestAnimation(publicAPI);
51
+ model._interactor.requestAnimation(publicAPI);
52
+
52
53
  publicAPI.invokeStartInteractionEvent();
53
54
  return macro.EVENT_ABORT;
54
55
  };
@@ -64,7 +65,8 @@ function widgetBehavior(publicAPI, model) {
64
65
  publicAPI.handleLeftButtonRelease = function () {
65
66
  if (isDragging && model.pickable) {
66
67
  publicAPI.invokeEndInteractionEvent();
67
- model.interactor.cancelAnimation(publicAPI);
68
+
69
+ model._interactor.cancelAnimation(publicAPI);
68
70
  }
69
71
 
70
72
  isDragging = false;
@@ -0,0 +1,138 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import macro from '../../../macros.js';
3
+
4
+ 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; }
5
+
6
+ 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; }
7
+ function widgetBehavior(publicAPI, model) {
8
+ model.classHierarchy.push('vtkLabelWidgetProp');
9
+ model.isDragging = null; // --------------------------------------------------------------------------
10
+ // Public methods
11
+ // --------------------------------------------------------------------------
12
+
13
+ publicAPI.setText = function (text) {
14
+ model.widgetState.getText().setText(text);
15
+ model.representations[1].setCircleProps(_objectSpread(_objectSpread({}, model.representations[1].getCircleProps()), {}, {
16
+ visible: !text
17
+ }));
18
+ model.interactor.render();
19
+ };
20
+
21
+ publicAPI.getText = function () {
22
+ return model.widgetState.getText().getText();
23
+ }; // --------------------------------------------------------------------------
24
+ // Display 2D
25
+ // --------------------------------------------------------------------------
26
+
27
+
28
+ publicAPI.setDisplayCallback = function (callback) {
29
+ return model.representations[0].setDisplayCallback(callback);
30
+ }; // --------------------------------------------------------------------------
31
+ // Interactor events
32
+ // --------------------------------------------------------------------------
33
+
34
+
35
+ function ignoreKey(e) {
36
+ return e.altKey || e.controlKey || e.shiftKey;
37
+ } // --------------------------------------------------------------------------
38
+ // Left press: Select handle to drag / Place text handle
39
+ // --------------------------------------------------------------------------
40
+
41
+
42
+ publicAPI.handleLeftButtonPress = function (e) {
43
+ if (!model.activeState || !model.activeState.getActive() || !model.pickable || ignoreKey(e)) {
44
+ return macro.VOID;
45
+ }
46
+
47
+ if (model.activeState === model.widgetState.getMoveHandle()) {
48
+ // Commit handle to location
49
+ var moveHandle = model.widgetState.getMoveHandle();
50
+ model.widgetState.getText().setOrigin(moveHandle.getOrigin());
51
+ publicAPI.loseFocus();
52
+ } else {
53
+ model.isDragging = true;
54
+ model.apiSpecificRenderWindow.setCursor('grabbing');
55
+ model.interactor.requestAnimation(publicAPI);
56
+ }
57
+
58
+ publicAPI.invokeStartInteractionEvent();
59
+ return macro.EVENT_ABORT;
60
+ }; // --------------------------------------------------------------------------
61
+ // Left release: Finish drag
62
+ // --------------------------------------------------------------------------
63
+
64
+
65
+ publicAPI.handleLeftButtonRelease = function () {
66
+ if (model.isDragging && model.pickable) {
67
+ model.apiSpecificRenderWindow.setCursor('pointer');
68
+ model.widgetState.deactivate();
69
+ model.interactor.cancelAnimation(publicAPI);
70
+ publicAPI.invokeEndInteractionEvent();
71
+ } else if (model.activeState !== model.widgetState.getMoveHandle()) {
72
+ model.widgetState.deactivate();
73
+ }
74
+
75
+ if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
76
+ publicAPI.invokeEndInteractionEvent();
77
+ model.widgetManager.enablePicking();
78
+ model.interactor.render();
79
+ }
80
+
81
+ model.isDragging = false;
82
+ }; // --------------------------------------------------------------------------
83
+ // Mouse move: Drag selected handle / Handle follow the mouse
84
+ // --------------------------------------------------------------------------
85
+
86
+
87
+ publicAPI.handleMouseMove = function (callData) {
88
+ if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
89
+ var worldCoords = model.manipulator.handleEvent(callData, model.apiSpecificRenderWindow);
90
+
91
+ if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model.isDragging)) {
92
+ model.activeState.setOrigin(worldCoords);
93
+ model.widgetState.getText().setOrigin(model.activeState.getOrigin());
94
+ publicAPI.invokeInteractionEvent();
95
+ return macro.EVENT_ABORT;
96
+ }
97
+ }
98
+
99
+ return macro.VOID;
100
+ }; // --------------------------------------------------------------------------
101
+ // Focus API
102
+ // --------------------------------------------------------------------------
103
+
104
+
105
+ publicAPI.reset = function () {
106
+ model.widgetState.getMoveHandle().setOrigin(null);
107
+ model.widgetState.getText().setOrigin(null);
108
+ model.widgetState.getText().setText('');
109
+ };
110
+
111
+ publicAPI.grabFocus = function () {
112
+ if (!model.hasFocus) {
113
+ publicAPI.reset();
114
+ model.activeState = model.widgetState.getMoveHandle();
115
+ model.widgetState.getMoveHandle().activate();
116
+ model.interactor.requestAnimation(publicAPI);
117
+ publicAPI.invokeStartInteractionEvent();
118
+ }
119
+
120
+ model.hasFocus = true;
121
+ };
122
+
123
+ publicAPI.loseFocus = function () {
124
+ if (model.hasFocus) {
125
+ model.interactor.cancelAnimation(publicAPI);
126
+ publicAPI.invokeEndInteractionEvent();
127
+ }
128
+
129
+ model.widgetState.deactivate();
130
+ model.widgetState.getMoveHandle().deactivate();
131
+ model.activeState = null;
132
+ model.hasFocus = false;
133
+ model.widgetManager.enablePicking();
134
+ model.interactor.render();
135
+ };
136
+ }
137
+
138
+ export { widgetBehavior as default };
@@ -0,0 +1,22 @@
1
+ import vtkStateBuilder from '../../Core/StateBuilder.js';
2
+
3
+ function generateState() {
4
+ return vtkStateBuilder.createBuilder().addStateFromMixin({
5
+ labels: ['moveHandle'],
6
+ mixins: ['origin', 'color', 'scale1', 'visible'],
7
+ name: 'moveHandle',
8
+ initialValues: {
9
+ scale1: 0.1,
10
+ visible: false
11
+ }
12
+ }).addStateFromMixin({
13
+ labels: ['SVGtext'],
14
+ mixins: ['origin', 'color', 'text', 'visible'],
15
+ name: 'text',
16
+ initialValues: {
17
+ visible: true
18
+ }
19
+ }).build();
20
+ }
21
+
22
+ export { generateState as default };
@@ -0,0 +1,79 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import macro from '../../macros.js';
3
+ import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
4
+ import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
5
+ import vtkSVGLandmarkRepresentation from '../SVG/SVGLandmarkRepresentation.js';
6
+ import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
7
+ import widgetBehavior from './LabelWidget/behavior.js';
8
+ import generateState from './LabelWidget/state.js';
9
+ import { VerticalTextAlignment } from '../SVG/SVGLandmarkRepresentation/Constants.js';
10
+ import { ViewTypes } from '../Core/WidgetManager/Constants.js';
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; }
15
+ // Factory
16
+ // ----------------------------------------------------------------------------
17
+
18
+ function vtkLabelWidget(publicAPI, model) {
19
+ model.classHierarchy.push('vtkLabelWidget'); // --- Widget Requirement ---------------------------------------------------
20
+
21
+ model.methodsToLink = ['textProps', 'fontProperties', 'strokeFontProperties'];
22
+ model.behavior = widgetBehavior;
23
+ model.widgetState = generateState();
24
+
25
+ publicAPI.getRepresentationsForViewType = function (viewType) {
26
+ switch (viewType) {
27
+ case ViewTypes.DEFAULT:
28
+ case ViewTypes.GEOMETRY:
29
+ case ViewTypes.SLICE:
30
+ case ViewTypes.VOLUME:
31
+ default:
32
+ return [{
33
+ builder: vtkSphereHandleRepresentation,
34
+ labels: ['moveHandle']
35
+ }, {
36
+ builder: vtkSVGLandmarkRepresentation,
37
+ initialValues: {
38
+ circleProps: {
39
+ visible: true
40
+ },
41
+ textProps: {
42
+ 'text-anchor': 'middle',
43
+ verticalAlign: VerticalTextAlignment.MIDDLE
44
+ },
45
+ strokeFontProperties: {
46
+ fontStyle: 'bold'
47
+ }
48
+ },
49
+ labels: ['SVGtext']
50
+ }];
51
+ }
52
+ }; // Default manipulator
53
+
54
+
55
+ model.manipulator = vtkPlanePointManipulator.newInstance();
56
+ } // ----------------------------------------------------------------------------
57
+
58
+
59
+ function defaultValues(initialValues) {
60
+ return _objectSpread({}, initialValues);
61
+ } // ----------------------------------------------------------------------------
62
+
63
+
64
+ function extend(publicAPI, model) {
65
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
66
+ Object.assign(model, defaultValues(initialValues));
67
+ vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
68
+ macro.setGet(publicAPI, model, ['manipulator']);
69
+ vtkLabelWidget(publicAPI, model);
70
+ } // ----------------------------------------------------------------------------
71
+
72
+ var newInstance = macro.newInstance(extend, 'vtkLabelWidget'); // ----------------------------------------------------------------------------
73
+
74
+ var index = {
75
+ newInstance: newInstance,
76
+ extend: extend
77
+ };
78
+
79
+ export { index as default, extend, newInstance };
@@ -38,7 +38,8 @@ function widgetBehavior(publicAPI, model) {
38
38
  model.isDragging = true;
39
39
  model.previousPosition = _toConsumableArray(model.manipulator.handleEvent(callData, model.apiSpecificRenderWindow));
40
40
  model.apiSpecificRenderWindow.setCursor('grabbing');
41
- model.interactor.requestAnimation(publicAPI);
41
+
42
+ model._interactor.requestAnimation(publicAPI);
42
43
  } // --------------------------------------------------------------------------
43
44
  // Text methods
44
45
  // --------------------------------------------------------------------------
@@ -78,12 +79,14 @@ function widgetBehavior(publicAPI, model) {
78
79
 
79
80
  textPropsCp.dy = dySign * Math.abs(textPropsCp.dy);
80
81
  model.representations[3].setTextProps(textPropsCp);
81
- model.interactor.render();
82
+
83
+ model._interactor.render();
82
84
  };
83
85
 
84
86
  publicAPI.setText = function (text) {
85
87
  model.widgetState.getText().setText(text);
86
- model.interactor.render();
88
+
89
+ model._interactor.render();
87
90
  }; // --------------------------------------------------------------------------
88
91
  // Handle positioning methods
89
92
  // --------------------------------------------------------------------------
@@ -158,7 +161,8 @@ function widgetBehavior(publicAPI, model) {
158
161
  var visibility = handle.getVisible() && isHandlePlaced(handleIndex, model.widgetState);
159
162
  model.representations[handleIndex].setVisibilityFlagArray([visibility, visibility && handle.getShape() !== ShapeType.NONE]);
160
163
  model.representations[handleIndex].updateActorVisibility();
161
- model.interactor.render();
164
+
165
+ model._interactor.render();
162
166
  };
163
167
  /**
164
168
  * Called when placing a point from the first time.
@@ -262,14 +266,15 @@ function widgetBehavior(publicAPI, model) {
262
266
  model.activeState = null;
263
267
 
264
268
  if (!wasTextActive) {
265
- model.interactor.cancelAnimation(publicAPI);
269
+ model._interactor.cancelAnimation(publicAPI);
266
270
  }
267
271
 
268
272
  model.apiSpecificRenderWindow.setCursor('pointer');
269
273
  model.hasFocus = false;
270
274
  publicAPI.invokeEndInteractionEvent();
271
275
  model.widgetManager.enablePicking();
272
- model.interactor.render();
276
+
277
+ model._interactor.render();
273
278
  }
274
279
 
275
280
  if (model.isDragging === false && (!model.activeState || !model.activeState.getActive())) {
@@ -288,7 +293,9 @@ function widgetBehavior(publicAPI, model) {
288
293
  model.activeState.setShape(publicAPI.getHandle(0).getShape());
289
294
  publicAPI.setMoveHandleVisibility(true);
290
295
  model.activeState.activate();
291
- model.interactor.requestAnimation(publicAPI);
296
+
297
+ model._interactor.requestAnimation(publicAPI);
298
+
292
299
  publicAPI.invokeStartInteractionEvent();
293
300
  }
294
301
 
@@ -298,7 +305,8 @@ function widgetBehavior(publicAPI, model) {
298
305
 
299
306
  publicAPI.loseFocus = function () {
300
307
  if (model.hasFocus) {
301
- model.interactor.cancelAnimation(publicAPI);
308
+ model._interactor.cancelAnimation(publicAPI);
309
+
302
310
  publicAPI.invokeEndInteractionEvent();
303
311
  }
304
312
 
@@ -307,7 +315,8 @@ function widgetBehavior(publicAPI, model) {
307
315
  model.activeState = null;
308
316
  model.hasFocus = false;
309
317
  model.widgetManager.enablePicking();
310
- model.interactor.render();
318
+
319
+ model._interactor.render();
311
320
  };
312
321
  }
313
322
 
@@ -1,4 +1,4 @@
1
- import { g as subtract, t as multiplyScalar, k as add, z as areEquals } from '../../../Common/Core/Math/index.js';
1
+ import { g 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];
@@ -112,7 +112,6 @@ function vtkLineWidget(publicAPI, model) {
112
112
  }, {
113
113
  builder: vtkSVGLandmarkRepresentation,
114
114
  initialValues: {
115
- showCircle: false,
116
115
  text: '',
117
116
  textProps: {
118
117
  dx: 12,
@@ -3,7 +3,7 @@ import macro from '../../../macros.js';
3
3
  import { vec3 } from 'gl-matrix';
4
4
 
5
5
  function widgetBehavior(publicAPI, model) {
6
- model.painting = model.factory.getPainting();
6
+ model.painting = model._factory.getPainting();
7
7
 
8
8
  publicAPI.handleLeftButtonPress = function (callData) {
9
9
  if (!model.activeState || !model.activeState.getActive()) {
@@ -73,7 +73,9 @@ function widgetBehavior(publicAPI, model) {
73
73
  if (!model.hasFocus) {
74
74
  model.activeState = model.widgetState.getHandle();
75
75
  model.activeState.activate();
76
- model.interactor.requestAnimation(publicAPI);
76
+
77
+ model._interactor.requestAnimation(publicAPI);
78
+
77
79
  var canvas = model.apiSpecificRenderWindow.getCanvas();
78
80
 
79
81
  canvas.onmouseenter = function () {
@@ -94,7 +96,7 @@ function widgetBehavior(publicAPI, model) {
94
96
 
95
97
  publicAPI.loseFocus = function () {
96
98
  if (model.hasFocus) {
97
- model.interactor.cancelAnimation(publicAPI);
99
+ model._interactor.cancelAnimation(publicAPI);
98
100
  }
99
101
 
100
102
  model.widgetState.deactivate();
@@ -27,11 +27,13 @@ function widgetBehavior(publicAPI, model) {
27
27
  }
28
28
 
29
29
  if (model.activeState !== model.widgetState.getMoveHandle()) {
30
- model.interactor.requestAnimation(publicAPI);
30
+ model._interactor.requestAnimation(publicAPI);
31
+
31
32
  model.activeState.deactivate();
32
33
  model.widgetState.removeHandle(model.activeState);
33
34
  model.activeState = null;
34
- model.interactor.cancelAnimation(publicAPI);
35
+
36
+ model._interactor.cancelAnimation(publicAPI);
35
37
  }
36
38
 
37
39
  publicAPI.invokeStartInteractionEvent();
@@ -58,7 +60,8 @@ function widgetBehavior(publicAPI, model) {
58
60
  } else {
59
61
  isDragging = true;
60
62
  model.apiSpecificRenderWindow.setCursor('grabbing');
61
- model.interactor.requestAnimation(publicAPI);
63
+
64
+ model._interactor.requestAnimation(publicAPI);
62
65
  }
63
66
 
64
67
  publicAPI.invokeStartInteractionEvent();
@@ -95,7 +98,9 @@ function widgetBehavior(publicAPI, model) {
95
98
  if (isDragging && model.pickable) {
96
99
  model.apiSpecificRenderWindow.setCursor('pointer');
97
100
  model.widgetState.deactivate();
98
- model.interactor.cancelAnimation(publicAPI);
101
+
102
+ model._interactor.cancelAnimation(publicAPI);
103
+
99
104
  publicAPI.invokeEndInteractionEvent();
100
105
  } else if (model.activeState !== model.widgetState.getMoveHandle()) {
101
106
  model.widgetState.deactivate();
@@ -104,7 +109,8 @@ function widgetBehavior(publicAPI, model) {
104
109
  if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
105
110
  publicAPI.invokeEndInteractionEvent();
106
111
  model.widgetManager.enablePicking();
107
- model.interactor.render();
112
+
113
+ model._interactor.render();
108
114
  }
109
115
 
110
116
  isDragging = false;
@@ -129,7 +135,9 @@ function widgetBehavior(publicAPI, model) {
129
135
  model.activeState = model.widgetState.getMoveHandle();
130
136
  model.activeState.activate();
131
137
  model.activeState.setVisible(true);
132
- model.interactor.requestAnimation(publicAPI);
138
+
139
+ model._interactor.requestAnimation(publicAPI);
140
+
133
141
  publicAPI.invokeStartInteractionEvent();
134
142
  }
135
143
 
@@ -139,7 +147,8 @@ function widgetBehavior(publicAPI, model) {
139
147
 
140
148
  publicAPI.loseFocus = function () {
141
149
  if (model.hasFocus) {
142
- model.interactor.cancelAnimation(publicAPI);
150
+ model._interactor.cancelAnimation(publicAPI);
151
+
143
152
  publicAPI.invokeEndInteractionEvent();
144
153
  }
145
154
 
@@ -149,7 +158,8 @@ function widgetBehavior(publicAPI, model) {
149
158
  model.activeState = null;
150
159
  model.hasFocus = false;
151
160
  model.widgetManager.enablePicking();
152
- model.interactor.render();
161
+
162
+ model._interactor.render();
153
163
  };
154
164
  }
155
165
 
@@ -42,7 +42,6 @@ function vtkRectangleWidget(publicAPI, model) {
42
42
  }, {
43
43
  builder: vtkSVGLandmarkRepresentation,
44
44
  initialValues: {
45
- showCircle: false,
46
45
  text: ''
47
46
  },
48
47
  labels: ['SVGtext']
@@ -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 { t as multiplyScalar, g as subtract, l as normalize, d as dot, j as cross, Q as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.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';
7
7
  import { updateState, getAssociatedLinesName, boundPointOnPlane, rotateVector } from './helpers.js';
8
8
  import { InteractionMethodsName, ScrollingMethods } from './Constants.js';
9
9
 
@@ -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, t as multiplyScalar, Q as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.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';
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, Q as multiplyAccumulate, g as subtract, l as normalize, t as multiplyScalar, k as add } from '../../Common/Core/Math/index.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';
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';