@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,7 +1,7 @@
1
1
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
2
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
3
  import macro from '../../../macros.js';
4
- import { q as vtkMath } from '../../../Common/Core/Math/index.js';
4
+ import { w as vtkMath } from '../../../Common/Core/Math/index.js';
5
5
  import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
6
6
  import vtkPlane from '../../../Common/DataModel/Plane.js';
7
7
  import { ShapeBehavior, BehaviorCategory, TextPosition } from './Constants.js';
@@ -29,16 +29,16 @@ function widgetBehavior(publicAPI, model) {
29
29
  publicAPI.setText = function (text) {
30
30
  model.widgetState.getText().setText(text); // Recompute position
31
31
 
32
- model.interactor.render();
32
+ model._interactor.render();
33
33
  }; // --------------------------------------------------------------------------
34
34
  // Public methods
35
35
  // --------------------------------------------------------------------------
36
36
 
37
37
 
38
- publicAPI.setResetAfterPointPlacement = model.factory.setResetAfterPointPlacement;
39
- publicAPI.getResetAfterPointPlacement = model.factory.getResetAfterPointPlacement;
40
- publicAPI.setModifierBehavior = model.factory.setModifierBehavior;
41
- publicAPI.getModifierBehavior = model.factory.getModifierBehavior;
38
+ publicAPI.setResetAfterPointPlacement = model._factory.setResetAfterPointPlacement;
39
+ publicAPI.getResetAfterPointPlacement = model._factory.getResetAfterPointPlacement;
40
+ publicAPI.setModifierBehavior = model._factory.setModifierBehavior;
41
+ publicAPI.getModifierBehavior = model._factory.getModifierBehavior;
42
42
 
43
43
  publicAPI.isBehaviorActive = function (category, flag) {
44
44
  return Object.keys(model.keysDown).some(function (key) {
@@ -421,7 +421,9 @@ function widgetBehavior(publicAPI, model) {
421
421
  if (model.point1 && (model.activeState === model.point1Handle || model.activeState === model.point2Handle)) {
422
422
  model.isDragging = true;
423
423
  model.apiSpecificRenderWindow.setCursor('grabbing');
424
- model.interactor.requestAnimation(publicAPI);
424
+
425
+ model._interactor.requestAnimation(publicAPI);
426
+
425
427
  publicAPI.invokeStartInteractionEvent();
426
428
  return macro.EVENT_ABORT;
427
429
  }
@@ -437,7 +439,9 @@ function widgetBehavior(publicAPI, model) {
437
439
  model.isDragging = false;
438
440
  model.apiSpecificRenderWindow.setCursor('pointer');
439
441
  model.widgetState.deactivate();
440
- model.interactor.cancelAnimation(publicAPI);
442
+
443
+ model._interactor.cancelAnimation(publicAPI);
444
+
441
445
  publicAPI.invokeEndInteractionEvent();
442
446
  return macro.EVENT_ABORT;
443
447
  }
@@ -521,7 +525,8 @@ function widgetBehavior(publicAPI, model) {
521
525
  model.activeState = model.point1Handle;
522
526
  model.point1Handle.setVisible(true);
523
527
  model.shapeHandle.setVisible(false);
524
- model.interactor.requestAnimation(publicAPI);
528
+
529
+ model._interactor.requestAnimation(publicAPI);
525
530
  }
526
531
 
527
532
  superClass.grabFocus();
@@ -530,7 +535,7 @@ function widgetBehavior(publicAPI, model) {
530
535
 
531
536
  publicAPI.loseFocus = function () {
532
537
  if (model.hasFocus) {
533
- model.interactor.cancelAnimation(publicAPI);
538
+ model._interactor.cancelAnimation(publicAPI);
534
539
  }
535
540
 
536
541
  if (!model.point1) {
@@ -542,7 +547,9 @@ function widgetBehavior(publicAPI, model) {
542
547
  model.point1Handle.deactivate();
543
548
  model.point2Handle.deactivate();
544
549
  model.activeState = null;
545
- model.interactor.render();
550
+
551
+ model._interactor.render();
552
+
546
553
  model.widgetManager.enablePicking();
547
554
  superClass.loseFocus();
548
555
  };
@@ -80,34 +80,36 @@ function widgetBehavior(publicAPI, model) {
80
80
  // --------------------------------------------------------------------------
81
81
 
82
82
 
83
- publicAPI.setResetAfterPointPlacement = model.factory.setResetAfterPointPlacement;
84
- publicAPI.getResetAfterPointPlacement = model.factory.getResetAfterPointPlacement;
83
+ publicAPI.setResetAfterPointPlacement = model._factory.setResetAfterPointPlacement;
84
+ publicAPI.getResetAfterPointPlacement = model._factory.getResetAfterPointPlacement;
85
85
  publicAPI.setResetAfterPointPlacement(publicAPI.getResetAfterPointPlacement());
86
- publicAPI.setFreehandMinDistance = model.factory.setFreehandMinDistance;
87
- publicAPI.getFreehandMinDistance = model.factory.getFreehandMinDistance;
86
+ publicAPI.setFreehandMinDistance = model._factory.setFreehandMinDistance;
87
+ publicAPI.getFreehandMinDistance = model._factory.getFreehandMinDistance;
88
88
  publicAPI.setFreehandMinDistance(publicAPI.getFreehandMinDistance());
89
- publicAPI.setAllowFreehand = model.factory.setAllowFreehand;
90
- publicAPI.getAllowFreehand = model.factory.getAllowFreehand;
89
+ publicAPI.setAllowFreehand = model._factory.setAllowFreehand;
90
+ publicAPI.getAllowFreehand = model._factory.getAllowFreehand;
91
91
  publicAPI.setAllowFreehand(publicAPI.getAllowFreehand());
92
- publicAPI.setDefaultCursor = model.factory.setDefaultCursor;
93
- publicAPI.getDefaultCursor = model.factory.getDefaultCursor;
92
+ publicAPI.setDefaultCursor = model._factory.setDefaultCursor;
93
+ publicAPI.getDefaultCursor = model._factory.getDefaultCursor;
94
94
  publicAPI.setDefaultCursor(publicAPI.getDefaultCursor()); // --------------------------------------------------------------------------
95
95
 
96
96
  publicAPI.setHandleSizeInPixels = function (size) {
97
- model.factory.setHandleSizeInPixels(size);
97
+ model._factory.setHandleSizeInPixels(size);
98
+
98
99
  updateHandlesSize();
99
100
  };
100
101
 
101
- publicAPI.getHandleSizeInPixels = model.factory.getHandleSizeInPixels;
102
- publicAPI.setHandleSizeInPixels(model.factory.getHandleSizeInPixels()); // set initial value
102
+ publicAPI.getHandleSizeInPixels = model._factory.getHandleSizeInPixels;
103
+ publicAPI.setHandleSizeInPixels(model._factory.getHandleSizeInPixels()); // set initial value
103
104
  // --------------------------------------------------------------------------
104
105
 
105
106
  publicAPI.setResolution = function (resolution) {
106
- model.factory.setResolution(resolution);
107
+ model._factory.setResolution(resolution);
108
+
107
109
  model.representations[1].setResolution(resolution);
108
110
  };
109
111
 
110
- publicAPI.setResolution(model.factory.getResolution()); // set initial value
112
+ publicAPI.setResolution(model._factory.getResolution()); // set initial value
111
113
  // --------------------------------------------------------------------------
112
114
 
113
115
  publicAPI.getPoints = function () {
@@ -130,11 +132,13 @@ function widgetBehavior(publicAPI, model) {
130
132
  }
131
133
 
132
134
  if (model.activeState !== model.moveHandle) {
133
- model.interactor.requestAnimation(publicAPI);
135
+ model._interactor.requestAnimation(publicAPI);
136
+
134
137
  model.activeState.deactivate();
135
138
  model.widgetState.removeHandle(model.activeState);
136
139
  model.activeState = null;
137
- model.interactor.cancelAnimation(publicAPI);
140
+
141
+ model._interactor.cancelAnimation(publicAPI);
138
142
  } else {
139
143
  var handle = getHoveredHandle();
140
144
 
@@ -182,7 +186,9 @@ function widgetBehavior(publicAPI, model) {
182
186
  } else {
183
187
  model.isDragging = true;
184
188
  model.apiSpecificRenderWindow.setCursor('grabbing');
185
- model.interactor.requestAnimation(publicAPI);
189
+
190
+ model._interactor.requestAnimation(publicAPI);
191
+
186
192
  publicAPI.invokeStartInteractionEvent();
187
193
  }
188
194
 
@@ -197,7 +203,9 @@ function widgetBehavior(publicAPI, model) {
197
203
  if (!model.hasFocus) {
198
204
  model.apiSpecificRenderWindow.setCursor(model.defaultCursor);
199
205
  model.widgetState.deactivate();
200
- model.interactor.cancelAnimation(publicAPI);
206
+
207
+ model._interactor.cancelAnimation(publicAPI);
208
+
201
209
  publicAPI.invokeEndInteractionEvent();
202
210
  } else {
203
211
  var _model$moveHandle;
@@ -221,7 +229,7 @@ function widgetBehavior(publicAPI, model) {
221
229
  }
222
230
  }
223
231
 
224
- model.interactor.render();
232
+ model._interactor.render();
225
233
  }
226
234
  } else if (model.activeState !== model.moveHandle) {
227
235
  model.widgetState.deactivate();
@@ -323,7 +331,9 @@ function widgetBehavior(publicAPI, model) {
323
331
  model.activeState = model.moveHandle;
324
332
  model.activeState.activate();
325
333
  model.activeState.setVisible(true);
326
- model.interactor.requestAnimation(publicAPI);
334
+
335
+ model._interactor.requestAnimation(publicAPI);
336
+
327
337
  updateHandlesSize();
328
338
  }
329
339
 
@@ -333,14 +343,16 @@ function widgetBehavior(publicAPI, model) {
333
343
 
334
344
  publicAPI.loseFocus = function () {
335
345
  if (model.hasFocus) {
336
- model.interactor.cancelAnimation(publicAPI);
346
+ model._interactor.cancelAnimation(publicAPI);
337
347
  }
338
348
 
339
349
  model.widgetState.deactivate();
340
350
  model.moveHandle.deactivate();
341
351
  model.moveHandle.setVisible(false);
342
352
  model.activeState = null;
343
- model.interactor.render();
353
+
354
+ model._interactor.render();
355
+
344
356
  model.hasFocus = false;
345
357
  };
346
358
  }
package/interfaces.d.ts CHANGED
@@ -252,6 +252,17 @@ export interface vtkObject {
252
252
  */
253
253
  getState(): object;
254
254
 
255
+ /**
256
+ * Used internally by JSON.stringify to get the content to serialize.
257
+ * Allow to call directly JSON.stringify on the vtkObject instead of using getState before doing so.
258
+ *
259
+ * ```
260
+ * const actorStr = JSON.stringify(actor);
261
+ * const newActor = vtk(JSON.parse(actorStr));
262
+ * ```
263
+ */
264
+ toJSON(): object;
265
+
255
266
  /**
256
267
  * Try to copy the state of the other to ourselves by just using references.
257
268
  *
package/macros.d.ts CHANGED
@@ -65,11 +65,23 @@ export enum TYPED_ARRAYS {
65
65
  * ```
66
66
  * const set = `set${capitalize(fieldName)}`;
67
67
  * ```
68
+ * @param str String to capitalize
68
69
  */
69
70
  export function capitalize(str: string): string;
70
71
 
71
72
  /**
72
- * Lowercase the first letter of the provided string
73
+ * Capitalize provided string.
74
+ * This is typically used to convert the name of a field into its method name.
75
+ * Ignore the first letter if it starts with underscore (i.e. _).
76
+ *
77
+ * ```
78
+ * const set = `set${capitalize(fieldName)}`;
79
+ * ```
80
+ */
81
+ export function _capitalize(str: string): string;
82
+
83
+ /**
84
+ * Lowercase the first letter of the provided string.
73
85
  */
74
86
  export function uncapitalize(str: string): string;
75
87
 
@@ -208,6 +220,19 @@ export function setArray(publicAPI: object, model: object, fieldNames: Array<str
208
220
  */
209
221
  export function setGetArray(publicAPI: object, model: object, fieldNames: Array<string>, size: Number, defaultVal?: any): void;
210
222
 
223
+ /**
224
+ * Convert model and publicAPI references to _fieldName into fieldName.
225
+ * It renames:
226
+ * - model.fieldName into model._fieldName
227
+ * - publicAPI.set_fieldName and publicAPI.set_fieldNameFrom into publicAPI.setFieldName and publicAPI.setFieldNameFrom
228
+ * - publicAPI.get_fieldName and publicAPI.get_fieldNameByReference into publicAPI.getFieldName and publicAPI.getFieldNameByReference
229
+ * @param publicAPI
230
+ * @param model
231
+ * @param fieldNames List of field names to move to protected, e.g. ['interactor', 'renderWindow']
232
+ * @see get
233
+ * @see set
234
+ */
235
+ export function moveToProtected(publicAPI: object, model: object, fieldNames: Array<string>): void;
211
236
 
212
237
  /**
213
238
  * Add algorithm methods onto the provided publicAPI
package/macros.js CHANGED
@@ -96,12 +96,15 @@ function newTypedArrayFrom(type) {
96
96
 
97
97
  return (_ref = TYPED_ARRAYS[type] || Float64Array).from.apply(_ref, args);
98
98
  } // ----------------------------------------------------------------------------
99
- // capitilze provided string
99
+ // capitilize provided string
100
100
  // ----------------------------------------------------------------------------
101
101
 
102
102
  function capitalize(str) {
103
103
  return str.charAt(0).toUpperCase() + str.slice(1);
104
104
  }
105
+ function _capitalize(str) {
106
+ return capitalize(str[0] === '_' ? str.slice(1) : str);
107
+ }
105
108
  function uncapitalize(str) {
106
109
  return str.charAt(0).toLowerCase() + str.slice(1);
107
110
  } // ----------------------------------------------------------------------------
@@ -186,7 +189,7 @@ function enumToString(e, value) {
186
189
  }
187
190
 
188
191
  function getStateArrayMapFunc(item) {
189
- if (item.isA) {
192
+ if (item && item.isA) {
190
193
  return item.getState();
191
194
  }
192
195
 
@@ -344,6 +347,10 @@ function obj() {
344
347
 
345
348
 
346
349
  publicAPI.getState = function () {
350
+ if (model.deleted) {
351
+ return null;
352
+ }
353
+
347
354
  var jsonArchive = _objectSpread(_objectSpread({}, model), {}, {
348
355
  vtkClass: publicAPI.getClassName()
349
356
  }); // Convert every vtkObject to its serializable form
@@ -402,6 +409,12 @@ function obj() {
402
409
  }
403
410
 
404
411
  publicAPI.modified();
412
+ }; // This function will get called when one invoke JSON.stringify(vtkObject)
413
+ // JSON.stringify will only stringify the return value of this function
414
+
415
+
416
+ publicAPI.toJSON = function vtkObjToJSON() {
417
+ return publicAPI.getState();
405
418
  }; // Allow usage as decorator
406
419
 
407
420
 
@@ -413,11 +426,11 @@ function obj() {
413
426
  function get(publicAPI, model, fieldNames) {
414
427
  fieldNames.forEach(function (field) {
415
428
  if (_typeof(field) === 'object') {
416
- publicAPI["get".concat(capitalize(field.name))] = function () {
429
+ publicAPI["get".concat(_capitalize(field.name))] = function () {
417
430
  return model[field.name];
418
431
  };
419
432
  } else {
420
- publicAPI["get".concat(capitalize(field))] = function () {
433
+ publicAPI["get".concat(_capitalize(field))] = function () {
421
434
  return model[field];
422
435
  };
423
436
  }
@@ -502,9 +515,9 @@ function findSetter(field) {
502
515
  function set(publicAPI, model, fields) {
503
516
  fields.forEach(function (field) {
504
517
  if (_typeof(field) === 'object') {
505
- publicAPI["set".concat(capitalize(field.name))] = findSetter(field)(publicAPI, model);
518
+ publicAPI["set".concat(_capitalize(field.name))] = findSetter(field)(publicAPI, model);
506
519
  } else {
507
- publicAPI["set".concat(capitalize(field))] = findSetter(field)(publicAPI, model);
520
+ publicAPI["set".concat(_capitalize(field))] = findSetter(field)(publicAPI, model);
508
521
  }
509
522
  });
510
523
  } // ----------------------------------------------------------------------------
@@ -521,11 +534,11 @@ function setGet(publicAPI, model, fieldNames) {
521
534
 
522
535
  function getArray(publicAPI, model, fieldNames) {
523
536
  fieldNames.forEach(function (field) {
524
- publicAPI["get".concat(capitalize(field))] = function () {
537
+ publicAPI["get".concat(_capitalize(field))] = function () {
525
538
  return model[field] ? [].concat(model[field]) : model[field];
526
539
  };
527
540
 
528
- publicAPI["get".concat(capitalize(field), "ByReference")] = function () {
541
+ publicAPI["get".concat(_capitalize(field), "ByReference")] = function () {
529
542
  return model[field];
530
543
  };
531
544
  });
@@ -542,7 +555,7 @@ function setArray(publicAPI, model, fieldNames, size) {
542
555
  throw new RangeError("Invalid initial number of values for array (".concat(field, ")"));
543
556
  }
544
557
 
545
- publicAPI["set".concat(capitalize(field))] = function () {
558
+ publicAPI["set".concat(_capitalize(field))] = function () {
546
559
  if (model.deleted) {
547
560
  vtkErrorMacro('instance deleted - cannot call any method');
548
561
  return false;
@@ -597,7 +610,7 @@ function setArray(publicAPI, model, fieldNames, size) {
597
610
  return changeDetected;
598
611
  };
599
612
 
600
- publicAPI["set".concat(capitalize(field), "From")] = function (otherArray) {
613
+ publicAPI["set".concat(_capitalize(field), "From")] = function (otherArray) {
601
614
  var target = model[field];
602
615
  otherArray.forEach(function (v, i) {
603
616
  target[i] = v;
@@ -612,6 +625,16 @@ function setGetArray(publicAPI, model, fieldNames, size) {
612
625
  var defaultVal = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
613
626
  getArray(publicAPI, model, fieldNames);
614
627
  setArray(publicAPI, model, fieldNames, size, defaultVal);
628
+ }
629
+ function moveToProtected(publicAPI, model, fieldNames) {
630
+ for (var i = 0; i < fieldNames.length; i++) {
631
+ var fieldName = fieldNames[i];
632
+
633
+ if (model[fieldName] !== undefined) {
634
+ model["_".concat(fieldName)] = model[fieldName];
635
+ delete model[fieldName];
636
+ }
637
+ }
615
638
  } // ----------------------------------------------------------------------------
616
639
  // vtkAlgorithm: setInputData(), setInputConnection(), getOutputData(), getOutputPort()
617
640
  // ----------------------------------------------------------------------------
@@ -947,9 +970,9 @@ function event(publicAPI, model, eventName) {
947
970
 
948
971
  }
949
972
 
950
- publicAPI["invoke".concat(capitalize(eventName))] = invoke;
973
+ publicAPI["invoke".concat(_capitalize(eventName))] = invoke;
951
974
 
952
- publicAPI["on".concat(capitalize(eventName))] = function (callback) {
975
+ publicAPI["on".concat(_capitalize(eventName))] = function (callback) {
953
976
  var priority = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.0;
954
977
 
955
978
  if (!callback.apply) {
@@ -1249,7 +1272,7 @@ function proxy(publicAPI, model) {
1249
1272
 
1250
1273
  publicAPI.activate = function () {
1251
1274
  if (model.proxyManager) {
1252
- var setActiveMethod = "setActive".concat(capitalize(publicAPI.getProxyGroup().slice(0, -1)));
1275
+ var setActiveMethod = "setActive".concat(_capitalize(publicAPI.getProxyGroup().slice(0, -1)));
1253
1276
 
1254
1277
  if (model.proxyManager[setActiveMethod]) {
1255
1278
  model.proxyManager[setActiveMethod](publicAPI);
@@ -1315,7 +1338,7 @@ function proxy(publicAPI, model) {
1315
1338
  return null;
1316
1339
  }
1317
1340
 
1318
- var newValue = sourceLink.instance["get".concat(capitalize(sourceLink.propertyName))]();
1341
+ var newValue = sourceLink.instance["get".concat(_capitalize(sourceLink.propertyName))]();
1319
1342
 
1320
1343
  if (!shallowEquals(newValue, value) || force) {
1321
1344
  value = newValue;
@@ -1404,7 +1427,7 @@ function proxy(publicAPI, model) {
1404
1427
 
1405
1428
  for (var i = 0; i < propertyNames.length; i++) {
1406
1429
  var name = propertyNames[i];
1407
- var method = publicAPI["get".concat(capitalize(name))];
1430
+ var method = publicAPI["get".concat(_capitalize(name))];
1408
1431
  var value = method ? method() : undefined;
1409
1432
  var prop = {
1410
1433
  id: id,
@@ -1460,6 +1483,11 @@ function proxy(publicAPI, model) {
1460
1483
 
1461
1484
  Object.keys(model.propertyLinkSubscribers).forEach(publicAPI.gcPropertyLinks);
1462
1485
  parentDelete();
1486
+ }; // @todo fix infinite recursion due to active source
1487
+
1488
+
1489
+ publicAPI.getState = function () {
1490
+ return null;
1463
1491
  };
1464
1492
 
1465
1493
  function registerLinks() {
@@ -1507,8 +1535,11 @@ function proxyPropertyMapping(publicAPI, model, map) {
1507
1535
  property = _map$propertyName.property,
1508
1536
  _map$propertyName$mod = _map$propertyName.modified,
1509
1537
  modified = _map$propertyName$mod === void 0 ? true : _map$propertyName$mod;
1510
- var methodSrc = capitalize(property);
1511
- var methodDst = capitalize(propertyName);
1538
+
1539
+ var methodSrc = _capitalize(property);
1540
+
1541
+ var methodDst = _capitalize(propertyName);
1542
+
1512
1543
  publicAPI["get".concat(methodDst)] = model[modelKey]["get".concat(methodSrc)];
1513
1544
  publicAPI["set".concat(methodDst)] = model[modelKey]["set".concat(methodSrc)];
1514
1545
 
@@ -1569,7 +1600,7 @@ function proxyPropertyState(publicAPI, model) {
1569
1600
 
1570
1601
  var mapping = state[key];
1571
1602
 
1572
- publicAPI["set".concat(capitalize(key))] = function (value) {
1603
+ publicAPI["set".concat(_capitalize(key))] = function (value) {
1573
1604
  if (value !== model[key]) {
1574
1605
  model[key] = value;
1575
1606
  var propValues = mapping[value];
@@ -1793,6 +1824,7 @@ var macro = {
1793
1824
  getStateArrayMapFunc: getStateArrayMapFunc,
1794
1825
  isVtkObject: isVtkObject,
1795
1826
  keystore: keystore,
1827
+ moveToProtected: moveToProtected,
1796
1828
  newInstance: newInstance,
1797
1829
  newTypedArray: newTypedArray,
1798
1830
  newTypedArrayFrom: newTypedArrayFrom,
@@ -1822,4 +1854,4 @@ var macro = {
1822
1854
  vtkWarningMacro: vtkWarningMacro
1823
1855
  };
1824
1856
 
1825
- export { EVENT_ABORT, TYPED_ARRAYS, VOID, algo, capitalize, chain, debounce, macro as default, event, formatBytesToProperUnit, formatNumbersWithThousandSeparator, get, getArray, isVtkObject, keystore, newInstance, newTypedArray, newTypedArrayFrom, normalizeWheel, obj, proxy, proxyPropertyMapping, proxyPropertyState, set, setArray, setGet, setGetArray, setImmediateVTK, setLoggerFunction, throttle, traverseInstanceTree, uncapitalize, vtkDebugMacro, vtkErrorMacro, vtkInfoMacro, vtkLogMacro, vtkOnceErrorMacro, vtkWarningMacro };
1857
+ export { EVENT_ABORT, TYPED_ARRAYS, VOID, _capitalize, algo, capitalize, chain, debounce, macro as default, event, formatBytesToProperUnit, formatNumbersWithThousandSeparator, get, getArray, isVtkObject, keystore, moveToProtected, newInstance, newTypedArray, newTypedArrayFrom, normalizeWheel, obj, proxy, proxyPropertyMapping, proxyPropertyState, set, setArray, setGet, setGetArray, setImmediateVTK, setLoggerFunction, throttle, traverseInstanceTree, uncapitalize, vtkDebugMacro, vtkErrorMacro, vtkInfoMacro, vtkLogMacro, vtkOnceErrorMacro, vtkWarningMacro };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "23.4.3",
3
+ "version": "24.0.0",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",
package/types.d.ts CHANGED
@@ -34,6 +34,7 @@ declare type TypedArray =
34
34
  | Float32Array;
35
35
 
36
36
  declare type Bounds = [number, number, number, number, number, number];
37
+ declare type CellType = number;
37
38
  declare type Extent = [number, number, number, number, number, number];
38
39
  declare type Placement = 'top' | 'left' | 'right' | 'bottom';
39
40
  declare type Size = [number, number];
@@ -1,104 +0,0 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import macro from '../../macros.js';
3
- import vtkInteractorObserver from '../../Rendering/Core/InteractorObserver.js';
4
-
5
- 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; }
6
-
7
- 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; }
8
- // vtkAbstractWidget methods
9
- // ----------------------------------------------------------------------------
10
-
11
- function vtkAbstractWidget(publicAPI, model) {
12
- // Set our className
13
- model.classHierarchy.push('vtkAbstractWidget');
14
-
15
- var superClass = _objectSpread({}, publicAPI); //----------------------------------------------------------------------------
16
- // Public API methods
17
- //----------------------------------------------------------------------------
18
- // Virtual method
19
-
20
-
21
- publicAPI.createDefaultRepresentation = function () {}; //----------------------------------------------------------------------------
22
-
23
-
24
- publicAPI.setEnabled = function (enable) {
25
- if (enable === model.enabled) {
26
- return;
27
- }
28
-
29
- if (model.interactor) {
30
- var renderer = model.interactor.getCurrentRenderer();
31
-
32
- if (renderer && model.widgetRep) {
33
- renderer.removeViewProp(model.widgetRep);
34
- }
35
- } // Enable/disable in superclass
36
-
37
-
38
- superClass.setEnabled(enable);
39
-
40
- if (enable) {
41
- // Add representation to new interactor's renderer
42
- if (!model.interactor) {
43
- return;
44
- }
45
-
46
- var _renderer = model.interactor.getCurrentRenderer();
47
-
48
- if (!_renderer) {
49
- return;
50
- }
51
-
52
- publicAPI.createDefaultRepresentation();
53
- model.widgetRep.setRenderer(_renderer);
54
- model.widgetRep.buildRepresentation();
55
-
56
- _renderer.addViewProp(model.widgetRep);
57
- }
58
- }; //----------------------------------------------------------------------------
59
-
60
-
61
- publicAPI.render = function () {
62
- if (!model.parent && model.interactor) {
63
- model.interactor.render();
64
- }
65
- };
66
-
67
- publicAPI.isDragable = function () {
68
- return model.dragable && (model.parent ? model.parent.isDragable() : true);
69
- };
70
- } // ----------------------------------------------------------------------------
71
- // Object factory
72
- // ----------------------------------------------------------------------------
73
-
74
-
75
- var DEFAULT_VALUES = {
76
- enabled: false,
77
- // Make widgets disabled by default
78
- priority: 0.5,
79
- // Use a priority of 0.5, since default priority from vtkInteractorObserver is 0.0.
80
- widgetRep: null,
81
- parent: null,
82
- dragable: true
83
- }; // ----------------------------------------------------------------------------
84
-
85
- function extend(publicAPI, model) {
86
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
87
-
88
- var newDefault = _objectSpread(_objectSpread({}, DEFAULT_VALUES), initialValues); // Inheritance
89
-
90
-
91
- vtkInteractorObserver.extend(publicAPI, model, newDefault);
92
- macro.setGet(publicAPI, model, ['widgetRep', 'parent', 'dragable']); // Object methods
93
-
94
- vtkAbstractWidget(publicAPI, model);
95
- } // ----------------------------------------------------------------------------
96
-
97
- var newInstance = macro.newInstance(extend, 'vtkAbstractWidget'); // ----------------------------------------------------------------------------
98
-
99
- var vtkAbstractWidget$1 = {
100
- newInstance: newInstance,
101
- extend: extend
102
- };
103
-
104
- export { vtkAbstractWidget$1 as default, extend, newInstance };