@kitware/vtk.js 23.4.0 → 24.0.0-beta.1

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 (152) 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/BoundingBox.js +3 -8
  6. package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
  7. package/Common/DataModel/ITKHelper.js +2 -346
  8. package/Common/DataModel/ImageData.d.ts +23 -6
  9. package/Common/DataModel/ImageData.js +8 -1
  10. package/Common/DataModel/PolyData.d.ts +8 -1
  11. package/Common/DataModel/PolyData.js +5 -3
  12. package/Common/DataModel/Triangle.js +217 -2
  13. package/Common/Transform/LandmarkTransform.js +1 -1
  14. package/Filters/General/OBBTree/OBBNode.js +82 -0
  15. package/Filters/General/OBBTree/helper.js +92 -0
  16. package/Filters/General/OBBTree.js +1249 -0
  17. package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
  18. package/Filters/General.js +2 -0
  19. package/Filters/Sources/CircleSource.js +1 -1
  20. package/Filters/Sources/PointSource.js +1 -1
  21. package/Filters/Texture/TextureMapToPlane.js +1 -1
  22. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  23. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  24. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  25. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  26. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  27. package/Interaction/Style/InteractorStyleImage.js +3 -3
  28. package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
  29. package/Interaction/Style/InteractorStyleManipulator.js +42 -28
  30. package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
  31. package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
  32. package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
  33. package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
  34. package/Interaction/Widgets.js +1 -35
  35. package/Proxy/Core/View2DProxy.js +1 -1
  36. package/Rendering/Core/ColorTransferFunction.js +1 -1
  37. package/Rendering/Core/Coordinate.js +1 -1
  38. package/Rendering/Core/CubeAxesActor.js +1 -1
  39. package/Rendering/Core/Glyph3DMapper.js +1 -1
  40. package/Rendering/Core/ImageMapper.js +1 -1
  41. package/Rendering/Core/InteractorObserver.js +11 -10
  42. package/Rendering/Core/InteractorStyle.js +9 -4
  43. package/Rendering/Core/Mapper.js +1 -1
  44. package/Rendering/Core/Prop.js +6 -4
  45. package/Rendering/Core/Prop3D.js +1 -1
  46. package/Rendering/Core/RenderWindowInteractor.js +24 -17
  47. package/Rendering/Core/Renderer.js +24 -19
  48. package/Rendering/Core/ScalarBarActor.js +1 -1
  49. package/Rendering/Core/Viewport.js +1 -1
  50. package/Rendering/Core/VolumeMapper.js +1 -1
  51. package/Rendering/OpenGL/Actor.js +2 -2
  52. package/Rendering/OpenGL/Actor2D.js +2 -2
  53. package/Rendering/OpenGL/BufferObject.js +6 -5
  54. package/Rendering/OpenGL/Camera.js +3 -3
  55. package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
  56. package/Rendering/OpenGL/Framebuffer.js +13 -12
  57. package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
  58. package/Rendering/OpenGL/HardwareSelector.js +35 -25
  59. package/Rendering/OpenGL/ImageMapper.js +51 -45
  60. package/Rendering/OpenGL/ImageSlice.js +2 -2
  61. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
  62. package/Rendering/OpenGL/PolyDataMapper.js +14 -11
  63. package/Rendering/OpenGL/PolyDataMapper2D.js +17 -16
  64. package/Rendering/OpenGL/Renderer.js +11 -7
  65. package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
  66. package/Rendering/OpenGL/ScalarBarActor.js +2 -2
  67. package/Rendering/OpenGL/ShaderCache.js +7 -5
  68. package/Rendering/OpenGL/Skybox.js +11 -9
  69. package/Rendering/OpenGL/SphereMapper.js +2 -2
  70. package/Rendering/OpenGL/StickMapper.js +2 -2
  71. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
  72. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
  73. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
  74. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
  75. package/Rendering/OpenGL/Texture.js +44 -31
  76. package/Rendering/OpenGL/VertexArrayObject.js +7 -7
  77. package/Rendering/OpenGL/Volume.js +3 -2
  78. package/Rendering/OpenGL/VolumeMapper.js +30 -26
  79. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  80. package/Rendering/SceneGraph/ViewNode.js +8 -7
  81. package/Rendering/WebGPU/Renderer.js +18 -10
  82. package/Widgets/Core/AbstractWidget.js +5 -4
  83. package/Widgets/Core/AbstractWidgetFactory.js +2 -1
  84. package/Widgets/Core/WidgetManager.js +66 -49
  85. package/Widgets/Manipulators/LineManipulator.js +1 -1
  86. package/Widgets/Representations/CircleContextRepresentation.js +1 -1
  87. package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
  88. package/Widgets/Representations/PolyLineRepresentation.js +1 -1
  89. package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
  90. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
  91. package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
  92. package/Widgets/SVG/SVGRepresentation.js +1 -1
  93. package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
  94. package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
  95. package/Widgets/Widgets3D/EllipseWidget.js +0 -1
  96. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
  97. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
  98. package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
  99. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  100. package/Widgets/Widgets3D/LabelWidget.js +79 -0
  101. package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
  102. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  103. package/Widgets/Widgets3D/LineWidget.js +0 -1
  104. package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
  105. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
  106. package/Widgets/Widgets3D/RectangleWidget.js +0 -1
  107. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  108. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  109. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  110. package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
  111. package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
  112. package/index.d.ts +3 -4
  113. package/interfaces.d.ts +11 -0
  114. package/macros.d.ts +26 -1
  115. package/macros.js +51 -19
  116. package/package.json +1 -1
  117. package/types.d.ts +1 -0
  118. package/Interaction/Widgets/AbstractWidget.js +0 -104
  119. package/Interaction/Widgets/DistanceRepresentation.js +0 -116
  120. package/Interaction/Widgets/DistanceWidget.js +0 -77
  121. package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
  122. package/Interaction/Widgets/HandleRepresentation.js +0 -100
  123. package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
  124. package/Interaction/Widgets/HandleWidget.js +0 -194
  125. package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
  126. package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
  127. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
  128. package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
  129. package/Interaction/Widgets/LabelRepresentation.js +0 -325
  130. package/Interaction/Widgets/LabelWidget.js +0 -65
  131. package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
  132. package/Interaction/Widgets/LineRepresentation.js +0 -498
  133. package/Interaction/Widgets/LineWidget/Constants.js +0 -11
  134. package/Interaction/Widgets/LineWidget.js +0 -296
  135. package/Interaction/Widgets/PointPlacer.js +0 -51
  136. package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
  137. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
  138. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
  139. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
  140. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
  141. package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
  142. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
  143. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
  144. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
  145. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
  146. package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
  147. package/Interaction/Widgets/WidgetRepresentation.js +0 -121
  148. package/Widgets/Representations/SphereContextRepresentation.js +0 -131
  149. package/Widgets/Widgets3D/SphereWidget/behavior.js +0 -177
  150. package/Widgets/Widgets3D/SphereWidget/state.js +0 -45
  151. package/Widgets/Widgets3D/SphereWidget.d.ts +0 -50
  152. package/Widgets/Widgets3D/SphereWidget.js +0 -62
@@ -1,370 +0,0 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import macro from '../../macros.js';
3
- import vtkActor from '../../Rendering/Core/Actor.js';
4
- import vtkCellPicker from '../../Rendering/Core/CellPicker.js';
5
- import vtkHandleRepresentation from './HandleRepresentation.js';
6
- import vtkInteractorObserver from '../../Rendering/Core/InteractorObserver.js';
7
- import vtkMapper from '../../Rendering/Core/Mapper.js';
8
- import { f as distance2BetweenPoints, n as norm } from '../../Common/Core/Math/index.js';
9
- import vtkProperty from '../../Rendering/Core/Property.js';
10
- import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
11
- import { InteractionState } from './HandleRepresentation/Constants.js';
12
-
13
- 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; }
14
-
15
- 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; }
16
- // vtkSphereHandleRepresentation methods
17
- // ----------------------------------------------------------------------------
18
-
19
- function vtkSphereHandleRepresentation(publicAPI, model) {
20
- // Set our className
21
- model.classHierarchy.push('vtkSphereHandleRepresentation');
22
-
23
- var superClass = _objectSpread({}, publicAPI);
24
-
25
- publicAPI.getActors = function () {
26
- return [model.actor];
27
- };
28
-
29
- publicAPI.getNestedProps = function () {
30
- return publicAPI.getActors();
31
- };
32
-
33
- publicAPI.placeWidget = function () {
34
- var boundsArray = [];
35
-
36
- if (Array.isArray(arguments.length <= 0 ? undefined : arguments[0])) {
37
- boundsArray = arguments.length <= 0 ? undefined : arguments[0];
38
- } else {
39
- for (var i = 0; i < arguments.length; i++) {
40
- boundsArray.push(i < 0 || arguments.length <= i ? undefined : arguments[i]);
41
- }
42
- }
43
-
44
- if (boundsArray.length !== 6) {
45
- return;
46
- }
47
-
48
- var newBounds = [];
49
- var center = [];
50
- publicAPI.adjustBounds(boundsArray, newBounds, center);
51
- publicAPI.setWorldPosition(center);
52
-
53
- for (var _i = 0; _i < 6; _i++) {
54
- model.initialBounds[_i] = newBounds[_i];
55
- }
56
-
57
- model.initialLength = Math.sqrt((newBounds[1] - newBounds[0]) * (newBounds[1] - newBounds[0]) + (newBounds[3] - newBounds[2]) * (newBounds[3] - newBounds[2]) + (newBounds[5] - newBounds[4]) * (newBounds[5] - newBounds[4]));
58
- };
59
-
60
- publicAPI.setSphereRadius = function (radius) {
61
- model.sphere.setRadius(radius);
62
- publicAPI.modified();
63
- };
64
-
65
- publicAPI.getSphereRadius = function () {
66
- return model.sphere.getRadius();
67
- };
68
-
69
- publicAPI.getBounds = function () {
70
- var radius = model.sphere.getRadius();
71
- var center = model.sphere.getCenter();
72
- var bounds = [];
73
- bounds[0] = model.placeFactor * (center[0] - radius);
74
- bounds[1] = model.placeFactor * (center[0] + radius);
75
- bounds[2] = model.placeFactor * (center[1] - radius);
76
- bounds[3] = model.placeFactor * (center[1] + radius);
77
- bounds[4] = model.placeFactor * (center[2] - radius);
78
- bounds[5] = model.placeFactor * (center[2] + radius);
79
- return bounds;
80
- };
81
-
82
- publicAPI.setWorldPosition = function (position) {
83
- model.sphere.setCenter(position);
84
- superClass.setWorldPosition(model.sphere.getCenter());
85
- };
86
-
87
- publicAPI.setDisplayPosition = function (position) {
88
- superClass.setDisplayPosition(position);
89
- publicAPI.setWorldPosition(model.worldPosition.getValue());
90
- };
91
-
92
- publicAPI.setHandleSize = function (size) {
93
- superClass.setHandleSize(size);
94
- model.currentHandleSize = model.handleSize;
95
- };
96
-
97
- publicAPI.computeInteractionState = function (pos) {
98
- model.visibility = 1;
99
- var pos3d = [pos[0], pos[1], 0.0];
100
- model.cursorPicker.pick(pos3d, model.renderer);
101
- var pickedActor = model.cursorPicker.getDataSet();
102
-
103
- if (pickedActor) {
104
- model.interactionState = InteractionState.SELECTING;
105
- } else {
106
- model.interactionState = InteractionState.OUTSIDE;
107
-
108
- if (model.activeRepresentation) {
109
- model.visibility = 0;
110
- }
111
- }
112
-
113
- return model.interactionState;
114
- };
115
-
116
- publicAPI.determineConstraintAxis = function (constraint, x) {
117
- // Look for trivial cases
118
- if (!model.constrained) {
119
- return -1;
120
- }
121
-
122
- if (constraint >= 0 && constraint < 3) {
123
- return constraint;
124
- } // Okay, figure out constraint. First see if the choice is
125
- // outside the hot spot
126
-
127
-
128
- if (!model.waitingForMotion) {
129
- var pickedPosition = model.cursorPicker.getPickPosition();
130
- var d2 = distance2BetweenPoints(pickedPosition, model.startEventPosition);
131
- var tol = model.hotSpotSize * model.initialLength;
132
-
133
- if (d2 > tol * tol) {
134
- model.waitingForMotion = 0;
135
- return model.cursorPicker.getCellId();
136
- }
137
-
138
- model.waitingForMotion = 1;
139
- model.waitCount = 0;
140
- return -1;
141
- }
142
-
143
- if (model.waitingForMotion && x) {
144
- model.waitingForMotion = 0;
145
- var v = [];
146
- v[0] = Math.abs(x[0] - model.startEventPosition[0]);
147
- v[1] = Math.abs(x[1] - model.startEventPosition[1]);
148
- v[2] = Math.abs(x[2] - model.startEventPosition[2]);
149
-
150
- if (v[0] > v[1]) {
151
- return v[0] > v[2] ? 0 : 2;
152
- }
153
-
154
- return v[1] > v[2] ? 1 : 2;
155
- }
156
-
157
- return -1;
158
- };
159
-
160
- publicAPI.startComplexWidgetInteraction = function (startEventPos) {
161
- // Record the current event position, and the rectilinear wipe position.
162
- model.startEventPosition[0] = startEventPos[0];
163
- model.startEventPosition[1] = startEventPos[1];
164
- model.startEventPosition[2] = 0.0;
165
- model.lastEventPosition[0] = startEventPos[0];
166
- model.lastEventPosition[1] = startEventPos[1];
167
- var pos = [startEventPos[0], startEventPos[1], 0];
168
- model.cursorPicker.pick(pos, model.renderer);
169
- var pickedActor = model.cursorPicker.getDataSet();
170
-
171
- if (pickedActor) {
172
- model.interactionState = InteractionState.SELECTING;
173
- model.constraintAxis = publicAPI.determineConstraintAxis(-1, null);
174
- model.lastPickPosition = model.cursorPicker.getPickPosition();
175
- } else {
176
- model.interactionState = InteractionState.OUTSIDE;
177
- model.constraintAxis = -1;
178
- }
179
- };
180
-
181
- publicAPI.displayToWorld = function (eventPos, z) {
182
- return vtkInteractorObserver.computeDisplayToWorld(model.renderer, eventPos[0], eventPos[1], z);
183
- };
184
-
185
- publicAPI.complexWidgetInteraction = function (eventPos) {
186
- var focalPoint = vtkInteractorObserver.computeWorldToDisplay(model.renderer, model.lastPickPosition[0], model.lastPickPosition[1], model.lastPickPosition[2]);
187
- var z = focalPoint[2];
188
- var prevPickPoint = publicAPI.displayToWorld(model.lastEventPosition, z);
189
- var pickPoint = publicAPI.displayToWorld(eventPos, z);
190
-
191
- if (model.interactionState === InteractionState.SELECTING || model.interactionState === InteractionState.TRANSLATING) {
192
- if (!model.waitingForMotion || model.waitCount++ > 3) {
193
- model.constraintAxis = publicAPI.determineConstraintAxis(model.constraintAxis, pickPoint);
194
-
195
- if (model.interactionState === InteractionState.SELECTING && !model.translationMode) {
196
- publicAPI.moveFocus(prevPickPoint, pickPoint);
197
- } else {
198
- publicAPI.translate(prevPickPoint, pickPoint);
199
- }
200
- }
201
- } else if (model.interactionState === InteractionState.SCALING) {
202
- publicAPI.scale(prevPickPoint, pickPoint, eventPos);
203
- }
204
-
205
- model.lastEventPosition[0] = eventPos[0];
206
- model.lastEventPosition[1] = eventPos[1];
207
- publicAPI.modified();
208
- };
209
-
210
- publicAPI.moveFocus = function (p1, p2) {
211
- // get the motion vector
212
- var v = [];
213
- v[0] = p2[0] - p1[0];
214
- v[1] = p2[1] - p1[1];
215
- v[2] = p2[2] - p1[2];
216
- var focus = model.sphere.getCenter();
217
-
218
- if (model.constraintAxis >= 0) {
219
- focus[model.constraintAxis] += v[model.constraintAxis];
220
- } else {
221
- focus[0] += v[0];
222
- focus[1] += v[1];
223
- focus[2] += v[2];
224
- }
225
-
226
- publicAPI.setWorldPosition(focus);
227
- };
228
-
229
- publicAPI.translate = function (p1, p2) {
230
- // get the motion vector
231
- var v = [];
232
- v[0] = p2[0] - p1[0];
233
- v[1] = p2[1] - p1[1];
234
- v[2] = p2[2] - p1[2];
235
- var pos = model.sphere.getCenter();
236
-
237
- if (model.constraintAxis >= 0) {
238
- // move along axis
239
- for (var i = 0; i < 3; i++) {
240
- if (i !== model.constraintAxis) {
241
- v[i] = 0.0;
242
- }
243
- }
244
- }
245
-
246
- var newFocus = [];
247
-
248
- for (var _i2 = 0; _i2 < 3; _i2++) {
249
- newFocus[_i2] = pos[_i2] + v[_i2];
250
- }
251
-
252
- publicAPI.setWorldPosition(newFocus);
253
- var radius = publicAPI.sizeHandlesInPixels(1.0, newFocus);
254
- radius *= model.currentHandleSize / model.handleSize;
255
- model.sphere.setRadius(radius);
256
- };
257
-
258
- publicAPI.sizeBounds = function () {
259
- var center = model.sphere.getCenter();
260
- var radius = publicAPI.sizeHandlesInPixels(1.0, center);
261
- radius *= model.currentHandleSize / model.handleSize;
262
- model.sphere.setRadius(radius);
263
- };
264
-
265
- publicAPI.scale = function (p1, p2, eventPos) {
266
- // get the motion vector
267
- var v = [];
268
- v[0] = p2[0] - p1[0];
269
- v[1] = p2[1] - p1[1];
270
- v[2] = p2[2] - p1[2];
271
- var bounds = publicAPI.getBounds(); // Compute the scale factor
272
-
273
- var sf = norm(v) / Math.sqrt((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) + (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) + (bounds[5] - bounds[4]) * (bounds[5] - bounds[4]));
274
-
275
- if (eventPos[1] > model.lastEventPosition[1]) {
276
- sf += 1.0;
277
- } else {
278
- sf = 1.0 - sf;
279
- }
280
-
281
- model.currentHandleSize *= sf;
282
- model.currentHandleSize = model.currentHandleSize < 0.001 ? 0.001 : model.currentHandleSize;
283
- publicAPI.sizeBounds();
284
- };
285
-
286
- publicAPI.highlight = function (highlight) {
287
- if (highlight) {
288
- publicAPI.applyProperty(model.selectProperty);
289
- } else {
290
- publicAPI.applyProperty(model.property);
291
- }
292
- };
293
-
294
- publicAPI.buildRepresentation = function () {
295
- if (model.renderer) {
296
- if (!model.placed) {
297
- model.validPick = 1;
298
- model.placed = 1;
299
- }
300
-
301
- publicAPI.sizeBounds();
302
- model.sphere.update();
303
- publicAPI.modified();
304
- }
305
- };
306
-
307
- publicAPI.applyProperty = function (property) {
308
- model.actor.setProperty(property);
309
- };
310
- } // ----------------------------------------------------------------------------
311
- // Object factory
312
- // ----------------------------------------------------------------------------
313
-
314
-
315
- var DEFAULT_VALUES = {
316
- actor: null,
317
- mapper: null,
318
- sphere: null,
319
- cursorPicker: null,
320
- lastPickPosition: [0, 0, 0],
321
- lastEventPosition: [0, 0],
322
- constraintAxis: -1,
323
- translationMode: 1,
324
- property: null,
325
- selectProperty: null,
326
- placeFactor: 1,
327
- waitingForMotion: 0,
328
- hotSpotSize: 0.05
329
- }; // ----------------------------------------------------------------------------
330
-
331
- function extend(publicAPI, model) {
332
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
333
- Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
334
-
335
- vtkHandleRepresentation.extend(publicAPI, model, initialValues);
336
- macro.setGet(publicAPI, model, ['glyphResolution', 'defaultScale']);
337
- macro.setGet(publicAPI, model, ['translationMode', 'property', 'selectProperty']);
338
- macro.get(publicAPI, model, ['actor']);
339
- model.sphere = vtkSphereSource.newInstance();
340
- model.sphere.setThetaResolution(16);
341
- model.sphere.setPhiResolution(8);
342
- model.mapper = vtkMapper.newInstance();
343
- model.mapper.setInputConnection(model.sphere.getOutputPort());
344
- model.actor = vtkActor.newInstance({
345
- parentProp: publicAPI
346
- });
347
- model.actor.setMapper(model.mapper);
348
- publicAPI.setHandleSize(15);
349
- model.currentHandleSize = model.handleSize;
350
- model.cursorPicker = vtkCellPicker.newInstance();
351
- model.cursorPicker.setPickFromList(1);
352
- model.cursorPicker.initializePickList();
353
- model.cursorPicker.addPickList(model.actor);
354
- model.property = vtkProperty.newInstance();
355
- model.property.setColor(1, 1, 1);
356
- model.selectProperty = vtkProperty.newInstance();
357
- model.selectProperty.setColor(0, 1, 0);
358
- model.actor.setProperty(model.property); // Object methods
359
-
360
- vtkSphereHandleRepresentation(publicAPI, model);
361
- } // ----------------------------------------------------------------------------
362
-
363
- var newInstance = macro.newInstance(extend, 'vtkSphereHandleRepresentation'); // ----------------------------------------------------------------------------
364
-
365
- var vtkSphereHandleRepresentation$1 = {
366
- newInstance: newInstance,
367
- extend: extend
368
- };
369
-
370
- export { vtkSphereHandleRepresentation$1 as default, extend, newInstance };
@@ -1,121 +0,0 @@
1
- import macro from '../../macros.js';
2
- import vtkInteractorObserver from '../../Rendering/Core/InteractorObserver.js';
3
- import vtkProp from '../../Rendering/Core/Prop.js';
4
-
5
- var vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
6
- // vtkWidgetRepresentation methods
7
- // ----------------------------------------------------------------------------
8
-
9
- function vtkWidgetRepresentation(publicAPI, model) {
10
- // Set our className
11
- model.classHierarchy.push('vtkWidgetRepresentation');
12
-
13
- publicAPI.getPickedActor = function (x, y, z, picker) {
14
- picker.pick(x, y, z, model.renderer);
15
- return picker.getActors[0];
16
- };
17
-
18
- publicAPI.adjustBounds = function (bounds, newBounds, center) {
19
- if (bounds.length !== 6) {
20
- vtkErrorMacro("vtkWidgetRepresentation::adjustBounds Can't process bounds, not enough values...");
21
- return;
22
- }
23
-
24
- center[0] = (bounds[0] + bounds[1]) / 2.0;
25
- center[1] = (bounds[2] + bounds[3]) / 2.0;
26
- center[2] = (bounds[4] + bounds[5]) / 2.0;
27
- newBounds[0] = center[0] + model.placeFactor * (bounds[0] - center[0]);
28
- newBounds[1] = center[0] + model.placeFactor * (bounds[1] - center[0]);
29
- newBounds[2] = center[1] + model.placeFactor * (bounds[2] - center[1]);
30
- newBounds[3] = center[1] + model.placeFactor * (bounds[3] - center[1]);
31
- newBounds[4] = center[2] + model.placeFactor * (bounds[4] - center[2]);
32
- newBounds[5] = center[2] + model.placeFactor * (bounds[5] - center[2]);
33
- };
34
-
35
- publicAPI.sizeHandlesInPixels = function (factor, pos) {
36
- var renderer = model.renderer;
37
-
38
- if (!model.validPick || !renderer || !renderer.getActiveCamera()) {
39
- return model.handleSize * factor * model.initialLength;
40
- }
41
-
42
- var focalPoint = vtkInteractorObserver.computeWorldToDisplay(renderer, pos[0], pos[1], pos[2]);
43
- var z = focalPoint[2];
44
- var x = focalPoint[0] - model.handleSize / 2.0;
45
- var y = focalPoint[1] - model.handleSize / 2.0;
46
- var lowerLeft = vtkInteractorObserver.computeDisplayToWorld(renderer, x, y, z);
47
- x = focalPoint[0] + model.handleSize / 2.0;
48
- y = focalPoint[1] + model.handleSize / 2.0;
49
- var upperRight = vtkInteractorObserver.computeDisplayToWorld(renderer, x, y, z);
50
- var radius = 0.0;
51
-
52
- for (var i = 0; i < 3; i++) {
53
- radius += (upperRight[i] - lowerLeft[i]) * (upperRight[i] - lowerLeft[i]);
54
- }
55
-
56
- return factor * (Math.sqrt(radius) / 2.0);
57
- };
58
-
59
- publicAPI.sizeHandlesRelativeToViewport = function (factor, pos) {
60
- var renderer = model.renderer;
61
-
62
- if (!model.validPick || !renderer || !renderer.getActiveCamera()) {
63
- return model.handleSize * factor * model.initialLength;
64
- }
65
-
66
- var viewport = renderer.getViewport();
67
- var view = renderer.getRenderWindow().getViews()[0];
68
- var winSize = view.getViewportSize(renderer);
69
- var focalPoint = vtkInteractorObserver.computeWorldToDisplay(renderer, pos[0], pos[1], pos[2]);
70
- var z = focalPoint[2];
71
- var x = winSize[0] * viewport[0];
72
- var y = winSize[1] * viewport[1];
73
- var windowLowerLeft = vtkInteractorObserver.computeDisplayToWorld(renderer, x, y, z);
74
- x = winSize[0] * viewport[2];
75
- y = winSize[1] * viewport[3];
76
- var windowUpperRight = vtkInteractorObserver.computeDisplayToWorld(renderer, x, y, z);
77
- var radius = 0.0;
78
-
79
- for (var i = 0; i < 3; i++) {
80
- radius += (windowUpperRight[i] - windowLowerLeft[i]) * (windowUpperRight[i] - windowLowerLeft[i]);
81
- }
82
-
83
- return factor * (Math.sqrt(radius) / 2.0);
84
- };
85
- } // ----------------------------------------------------------------------------
86
- // Object factory
87
- // ----------------------------------------------------------------------------
88
-
89
-
90
- var DEFAULT_VALUES = {
91
- renderer: null,
92
- interactionState: 0,
93
- startEventPosition: [0.0, 0.0, 0.0],
94
- lastEventPosition: [0.0, 0.0, 0.0],
95
- placeFactor: 0.5,
96
- placed: 0,
97
- handleSize: 0.05,
98
- validPick: 0,
99
- initialBounds: [0.0, 1.0, 0.0, 1.0, 0.0, 1.0],
100
- initialLength: 0.0,
101
- needToRender: 0
102
- }; // ----------------------------------------------------------------------------
103
-
104
- function extend(publicAPI, model) {
105
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
106
- Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
107
-
108
- vtkProp.extend(publicAPI, model, initialValues);
109
- macro.setGet(publicAPI, model, ['renderer', 'handleSize', 'placeFactor', 'needToRender', 'interactionState']); // Object methods
110
-
111
- vtkWidgetRepresentation(publicAPI, model);
112
- } // ----------------------------------------------------------------------------
113
-
114
- var newInstance = macro.newInstance(extend, 'vtkWidgetRepresentation'); // ----------------------------------------------------------------------------
115
-
116
- var vtkWidgetRepresentation$1 = {
117
- newInstance: newInstance,
118
- extend: extend
119
- };
120
-
121
- export { vtkWidgetRepresentation$1 as default, extend, newInstance };
@@ -1,131 +0,0 @@
1
- import vtkDataArray from '../../Common/Core/DataArray.js';
2
- import vtkPolyData from '../../Common/DataModel/PolyData.js';
3
- import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
4
- import vtkActor from '../../Rendering/Core/Actor.js';
5
- import vtkGlyph3DMapper from '../../Rendering/Core/Glyph3DMapper.js';
6
- import { ScalarMode } from '../../Rendering/Core/Mapper/Constants.js';
7
- import vtkContextRepresentation from './ContextRepresentation.js';
8
- import vtkWidgetRepresentation from './WidgetRepresentation.js';
9
- import macro from '../../macros.js';
10
-
11
- function vtkSphereContextRepresentation(publicAPI, model) {
12
- model.classHierarchy.push('vtkSphereContextRepresentation');
13
- model.internalPolyData = vtkPolyData.newInstance({
14
- mtime: 0
15
- });
16
- model.internalArrays = {
17
- points: model.internalPolyData.getPoints(),
18
- scale: vtkDataArray.newInstance({
19
- name: 'scale',
20
- numberOfComponents: 3,
21
- empty: true
22
- }),
23
- color: vtkDataArray.newInstance({
24
- name: 'color',
25
- numberOfComponents: 1,
26
- empty: true
27
- })
28
- };
29
- model.internalPolyData.getPointData().addArray(model.internalArrays.scale);
30
- model.internalPolyData.getPointData().addArray(model.internalArrays.color);
31
- model.pipelines = {
32
- circle: {
33
- source: publicAPI,
34
- glyph: vtkSphereSource.newInstance({
35
- phiResolution: model.glyphResolution,
36
- thetaResolution: model.glyphResolution
37
- }),
38
- mapper: vtkGlyph3DMapper.newInstance({
39
- scaleArray: 'scale',
40
- scaleMode: vtkGlyph3DMapper.ScaleModes.SCALE_BY_MAGNITUDE,
41
- colorByArrayName: 'color',
42
- scalarMode: ScalarMode.USE_POINT_FIELD_DATA
43
- }),
44
- actor: vtkActor.newInstance({
45
- pickable: false,
46
- parentProp: publicAPI
47
- })
48
- }
49
- };
50
- model.pipelines.circle.actor.getProperty().setOpacity(0.2);
51
- vtkWidgetRepresentation.connectPipeline(model.pipelines.circle);
52
- publicAPI.addActor(model.pipelines.circle.actor);
53
- publicAPI.setGlyphResolution = macro.chain(publicAPI.setGlyphResolution, function (r) {
54
- return model.pipelines.circle.glyph.setResolution(r);
55
- });
56
-
57
- publicAPI.setDrawBorder = function (draw) {
58
- model.pipelines.circle.glyph.setLines(draw);
59
- };
60
-
61
- publicAPI.setDrawFace = function (draw) {
62
- model.pipelines.circle.glyph.setFace(draw);
63
- };
64
-
65
- publicAPI.setOpacity = function (opacity) {
66
- model.pipelines.circle.actor.getProperty().setOpacity(opacity);
67
- };
68
-
69
- publicAPI.requestData = function (inData, outData) {
70
- var _model$internalArrays = model.internalArrays,
71
- points = _model$internalArrays.points,
72
- scale = _model$internalArrays.scale,
73
- 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
- });
77
- var totalCount = list.length;
78
-
79
- if (color.getNumberOfValues() !== totalCount) {
80
- // Need to resize dataset
81
- points.setData(new Float32Array(3 * totalCount));
82
- scale.setData(new Float32Array(3 * totalCount));
83
- color.setData(new Float32Array(totalCount));
84
- }
85
-
86
- var typedArray = {
87
- points: points.getData(),
88
- scale: scale.getData(),
89
- color: color.getData()
90
- };
91
-
92
- for (var i = 0; i < totalCount; i += 1) {
93
- var state = list[i];
94
- var isActive = state.getActive();
95
- var scaleFactor = isActive ? model.activeScaleFactor : 1;
96
- var coord = state.getOrigin();
97
- typedArray.points[i * 3 + 0] = coord[0];
98
- typedArray.points[i * 3 + 1] = coord[1];
99
- typedArray.points[i * 3 + 2] = coord[2];
100
- typedArray.scale[i] = scaleFactor * (state.getScale1 ? state.getScale1() : model.defaultScale);
101
- typedArray.color[i] = model.useActiveColor && isActive ? model.activeColor : state.getColor();
102
- }
103
-
104
- model.internalPolyData.modified();
105
- outData[0] = model.internalPolyData;
106
- };
107
- }
108
-
109
- var DEFAULT_VALUES = {
110
- glyphResolution: 32,
111
- defaultScale: 1,
112
- drawBorder: false,
113
- drawFace: true
114
- }; // ----------------------------------------------------------------------------
115
-
116
- function extend(publicAPI, model) {
117
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
118
- Object.assign(model, DEFAULT_VALUES, initialValues);
119
- vtkContextRepresentation.extend(publicAPI, model, initialValues);
120
- macro.setGet(publicAPI, model, ['glyphResolution', 'defaultScale']);
121
- macro.get(publicAPI, model, ['glyph', 'mapper', 'actor']);
122
- vtkSphereContextRepresentation(publicAPI, model);
123
- } // ----------------------------------------------------------------------------
124
-
125
- var newInstance = macro.newInstance(extend, 'vtkSphereContextRepresentation');
126
- var vtkSphereContextRepresentation$1 = {
127
- newInstance: newInstance,
128
- extend: extend
129
- };
130
-
131
- export { vtkSphereContextRepresentation$1 as default, extend, newInstance };