@kitware/vtk.js 23.4.3 → 24.0.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 (144) 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/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  21. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  22. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  23. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  24. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  25. package/Interaction/Style/InteractorStyleImage.js +3 -3
  26. package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
  27. package/Interaction/Style/InteractorStyleManipulator.js +42 -28
  28. package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
  29. package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
  30. package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
  31. package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
  32. package/Interaction/Widgets.js +1 -35
  33. package/Proxy/Core/View2DProxy.js +1 -1
  34. package/Rendering/Core/ColorTransferFunction.js +1 -1
  35. package/Rendering/Core/Coordinate.js +1 -1
  36. package/Rendering/Core/CubeAxesActor.js +1 -1
  37. package/Rendering/Core/Glyph3DMapper.js +1 -1
  38. package/Rendering/Core/ImageMapper.js +1 -1
  39. package/Rendering/Core/InteractorObserver.js +11 -10
  40. package/Rendering/Core/InteractorStyle.js +9 -4
  41. package/Rendering/Core/Mapper.js +1 -1
  42. package/Rendering/Core/Prop.js +6 -4
  43. package/Rendering/Core/Prop3D.js +1 -1
  44. package/Rendering/Core/RenderWindowInteractor.js +24 -17
  45. package/Rendering/Core/Renderer.js +24 -19
  46. package/Rendering/Core/ScalarBarActor.js +1 -1
  47. package/Rendering/Core/Viewport.js +1 -1
  48. package/Rendering/Core/VolumeMapper.js +1 -1
  49. package/Rendering/OpenGL/Actor.js +2 -2
  50. package/Rendering/OpenGL/Actor2D.js +2 -2
  51. package/Rendering/OpenGL/BufferObject.js +6 -5
  52. package/Rendering/OpenGL/Camera.js +3 -3
  53. package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
  54. package/Rendering/OpenGL/Framebuffer.js +13 -12
  55. package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
  56. package/Rendering/OpenGL/HardwareSelector.js +35 -25
  57. package/Rendering/OpenGL/ImageMapper.js +51 -45
  58. package/Rendering/OpenGL/ImageSlice.js +2 -2
  59. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
  60. package/Rendering/OpenGL/PolyDataMapper.js +14 -11
  61. package/Rendering/OpenGL/PolyDataMapper2D.js +7 -6
  62. package/Rendering/OpenGL/Renderer.js +11 -7
  63. package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
  64. package/Rendering/OpenGL/ScalarBarActor.js +2 -2
  65. package/Rendering/OpenGL/ShaderCache.js +7 -5
  66. package/Rendering/OpenGL/Skybox.js +11 -9
  67. package/Rendering/OpenGL/SphereMapper.js +2 -2
  68. package/Rendering/OpenGL/StickMapper.js +2 -2
  69. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
  70. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
  71. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
  72. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
  73. package/Rendering/OpenGL/Texture.js +44 -31
  74. package/Rendering/OpenGL/VertexArrayObject.js +7 -7
  75. package/Rendering/OpenGL/Volume.js +3 -2
  76. package/Rendering/OpenGL/VolumeMapper.js +30 -26
  77. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  78. package/Rendering/SceneGraph/ViewNode.js +8 -7
  79. package/Rendering/WebGPU/Renderer.js +18 -10
  80. package/Widgets/Core/AbstractWidget.js +5 -4
  81. package/Widgets/Core/AbstractWidgetFactory.js +2 -1
  82. package/Widgets/Core/WidgetManager.js +66 -49
  83. package/Widgets/Manipulators/LineManipulator.js +1 -1
  84. package/Widgets/Representations/CircleContextRepresentation.js +1 -1
  85. package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
  86. package/Widgets/Representations/PolyLineRepresentation.js +1 -1
  87. package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
  88. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
  89. package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
  90. package/Widgets/SVG/SVGRepresentation.js +1 -1
  91. package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
  92. package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
  93. package/Widgets/Widgets3D/EllipseWidget.js +0 -1
  94. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
  95. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
  96. package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
  97. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  98. package/Widgets/Widgets3D/LabelWidget.js +79 -0
  99. package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
  100. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  101. package/Widgets/Widgets3D/LineWidget.js +0 -1
  102. package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
  103. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
  104. package/Widgets/Widgets3D/RectangleWidget.js +0 -1
  105. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  106. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  107. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  108. package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
  109. package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
  110. package/interfaces.d.ts +11 -0
  111. package/macros.d.ts +26 -1
  112. package/macros.js +51 -19
  113. package/package.json +1 -1
  114. package/types.d.ts +1 -0
  115. package/Interaction/Widgets/AbstractWidget.js +0 -104
  116. package/Interaction/Widgets/DistanceRepresentation.js +0 -116
  117. package/Interaction/Widgets/DistanceWidget.js +0 -77
  118. package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
  119. package/Interaction/Widgets/HandleRepresentation.js +0 -100
  120. package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
  121. package/Interaction/Widgets/HandleWidget.js +0 -194
  122. package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
  123. package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
  124. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
  125. package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
  126. package/Interaction/Widgets/LabelRepresentation.js +0 -325
  127. package/Interaction/Widgets/LabelWidget.js +0 -65
  128. package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
  129. package/Interaction/Widgets/LineRepresentation.js +0 -498
  130. package/Interaction/Widgets/LineWidget/Constants.js +0 -11
  131. package/Interaction/Widgets/LineWidget.js +0 -296
  132. package/Interaction/Widgets/PointPlacer.js +0 -51
  133. package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
  134. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
  135. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
  136. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
  137. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
  138. package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
  139. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
  140. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
  141. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
  142. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
  143. package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
  144. package/Interaction/Widgets/WidgetRepresentation.js +0 -121
@@ -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 };