@kitware/vtk.js 26.8.1 → 26.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/BREAKING_CHANGES.md +6 -1
  2. package/Common/Core/DataArray.js +9 -10
  3. package/Common/Core/ScalarsToColors.d.ts +9 -1
  4. package/Common/Core/ScalarsToColors.js +22 -0
  5. package/Rendering/Core/AxesActor.js +85 -7
  6. package/Rendering/Core/Mapper.js +10 -1
  7. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +5 -0
  8. package/Rendering/Misc/SynchronizableRenderWindow.d.ts +32 -24
  9. package/Rendering/Misc/SynchronizableRenderWindow.js +15 -0
  10. package/Rendering/OpenGL/Actor.js +12 -2
  11. package/Rendering/OpenGL/Camera.js +1 -0
  12. package/Rendering/OpenGL/ForwardPass.js +6 -3
  13. package/Rendering/OpenGL/ImageMapper.js +5 -1
  14. package/Rendering/OpenGL/ImageSlice.js +17 -1
  15. package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +1 -0
  16. package/Rendering/OpenGL/PolyDataMapper.js +5 -1
  17. package/Rendering/OpenGL/RenderWindow.js +24 -8
  18. package/Rendering/OpenGL/Renderer.js +5 -1
  19. package/Rendering/OpenGL/VolumeMapper.js +5 -1
  20. package/Widgets/Core/AbstractWidget.js +1 -5
  21. package/Widgets/Core/AbstractWidgetFactory.d.ts +5 -0
  22. package/Widgets/Core/AbstractWidgetFactory.js +4 -0
  23. package/Widgets/Core/StateBuilder/color3Mixin.js +3 -1
  24. package/Widgets/Core/StateBuilder/originMixin.js +34 -3
  25. package/Widgets/Core/WidgetManager.d.ts +8 -0
  26. package/Widgets/Core/WidgetManager.js +27 -5
  27. package/Widgets/Representations/CroppingOutlineRepresentation.js +1 -1
  28. package/Widgets/Representations/GlyphRepresentation.js +10 -5
  29. package/Widgets/Representations/ImplicitPlaneRepresentation.js +2 -1
  30. package/Widgets/Representations/PolyLineRepresentation.js +2 -1
  31. package/Widgets/Representations/WidgetRepresentation.js +3 -26
  32. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +19 -7
  33. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +9 -20
  34. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +2 -23
  35. package/Widgets/Widgets3D/ResliceCursorWidget.js +40 -39
  36. package/package.json +1 -1
@@ -10,6 +10,7 @@ import { e as distance2BetweenPoints, m as multiplyAccumulate, s as subtract, l
10
10
  import widgetBehavior from './ResliceCursorWidget/behavior.js';
11
11
  import generateState from './ResliceCursorWidget/state.js';
12
12
  import { updateState, transformPlane, boundPlane } from './ResliceCursorWidget/helpers.js';
13
+ import { viewTypeToPlaneName } from './ResliceCursorWidget/Constants.js';
13
14
  import { ViewTypes } from '../Core/WidgetManager/Constants.js';
14
15
  import { mat4 } from 'gl-matrix';
15
16
  import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
@@ -138,21 +139,32 @@ function vtkResliceCursorWidget(publicAPI, model) {
138
139
  renderer.resetCameraClippingRange(bounds);
139
140
  }
140
141
  /**
141
- * Convenient function to return the ResliceCursorRepresentation for a given viewType
142
+ * Convenient function to return the widget for a given viewType
142
143
  * @param {string} viewType
143
- * @returns
144
+ * @returns the widget instanced in the given viewType.
144
145
  */
145
146
 
146
147
 
147
- function findRepresentationsForViewType(viewType) {
148
- var widgetForViewType = publicAPI.getViewIds().map(function (viewId) {
148
+ function findWidgetForViewType(viewType) {
149
+ return publicAPI.getViewIds().map(function (viewId) {
149
150
  return publicAPI.getWidgetForView({
150
151
  viewId: viewId
151
152
  });
152
153
  }).find(function (widget) {
153
154
  return widget.getViewType() === viewType;
154
155
  });
155
- return widgetForViewType.getRepresentations();
156
+ }
157
+ /**
158
+ * Convenient function to return the ResliceCursorRepresentation for a given viewType
159
+ * @param {string} viewType
160
+ * @returns an array of 3 representations (for line handles, rotation handles, center handle)
161
+ * or an empty array if the widget has not yet been added to the view type.
162
+ */
163
+
164
+
165
+ function findRepresentationsForViewType(viewType) {
166
+ var widgetForViewType = findWidgetForViewType(viewType);
167
+ return widgetForViewType ? widgetForViewType.getRepresentations() : [];
156
168
  } // --------------------------------------------------------------------------
157
169
  // initialization
158
170
  // --------------------------------------------------------------------------
@@ -161,47 +173,28 @@ function vtkResliceCursorWidget(publicAPI, model) {
161
173
  publicAPI.getRepresentationsForViewType = function (viewType) {
162
174
  switch (viewType) {
163
175
  case ViewTypes.XY_PLANE:
164
- return [{
165
- builder: vtkLineHandleRepresentation,
166
- labels: ['lineInZ'],
167
- initialValues: {
168
- useActiveColor: false
169
- }
170
- }, {
171
- builder: vtkSphereHandleRepresentation,
172
- labels: ['rotationInZ', 'center'],
173
- initialValues: {
174
- useActiveColor: false
175
- }
176
- }];
177
-
178
176
  case ViewTypes.XZ_PLANE:
177
+ case ViewTypes.YZ_PLANE:
179
178
  return [{
180
179
  builder: vtkLineHandleRepresentation,
181
- labels: ['lineInY'],
180
+ labels: ["lineIn".concat(viewTypeToPlaneName[viewType])],
182
181
  initialValues: {
183
- useActiveColor: false
182
+ useActiveColor: false,
183
+ scaleInPixels: model.scaleInPixels
184
184
  }
185
185
  }, {
186
186
  builder: vtkSphereHandleRepresentation,
187
- labels: ['rotationInY', 'center'],
187
+ labels: ["rotationIn".concat(viewTypeToPlaneName[viewType])],
188
188
  initialValues: {
189
- useActiveColor: false
190
- }
191
- }];
192
-
193
- case ViewTypes.YZ_PLANE:
194
- return [{
195
- builder: vtkLineHandleRepresentation,
196
- labels: ['lineInX'],
197
- initialValues: {
198
- useActiveColor: false
189
+ useActiveColor: false,
190
+ scaleInPixels: model.scaleInPixels
199
191
  }
200
192
  }, {
201
193
  builder: vtkSphereHandleRepresentation,
202
- labels: ['rotationInX', 'center'],
194
+ labels: ['center'],
203
195
  initialValues: {
204
- useActiveColor: false
196
+ useActiveColor: false,
197
+ scaleInPixels: model.scaleInPixels
205
198
  }
206
199
  }];
207
200
 
@@ -218,12 +211,12 @@ function vtkResliceCursorWidget(publicAPI, model) {
218
211
  model.widgetState.setImage(image);
219
212
  var center = image.getCenter();
220
213
  model.widgetState.setCenter(center);
221
- updateState(model.widgetState, publicAPI.getDisplayScaleParams(), model.rotationHandlePosition);
214
+ updateState(model.widgetState, model.scaleInPixels, model.rotationHandlePosition);
222
215
  };
223
216
 
224
217
  publicAPI.setCenter = function (center) {
225
218
  model.widgetState.setCenter(center);
226
- updateState(model.widgetState, publicAPI.getDisplayScaleParams(), model.rotationHandlePosition);
219
+ updateState(model.widgetState, model.scaleInPixels, model.rotationHandlePosition);
227
220
  publicAPI.modified();
228
221
  }; // --------------------------------------------------------------------------
229
222
  // Methods
@@ -423,10 +416,17 @@ function vtkResliceCursorWidget(publicAPI, model) {
423
416
  return [ViewTypes.YZ_PLANE, ViewTypes.XZ_PLANE, ViewTypes.XY_PLANE].reduce(function (res, viewType) {
424
417
  var _findRepresentationsF, _findRepresentationsF2;
425
418
 
426
- res[viewType] = (_findRepresentationsF = (_findRepresentationsF2 = findRepresentationsForViewType(viewType)[0]).getDisplayScaleParams) === null || _findRepresentationsF === void 0 ? void 0 : _findRepresentationsF.call(_findRepresentationsF2);
419
+ res[viewType] = (_findRepresentationsF = findRepresentationsForViewType(viewType)[0]) === null || _findRepresentationsF === void 0 ? void 0 : (_findRepresentationsF2 = _findRepresentationsF.getDisplayScaleParams) === null || _findRepresentationsF2 === void 0 ? void 0 : _findRepresentationsF2.call(_findRepresentationsF);
427
420
  return res;
428
421
  }, {});
429
422
  };
423
+
424
+ publicAPI.setScaleInPixels = macro.chain(publicAPI.setScaleInPixels, function (scale) {
425
+ publicAPI.getViewWidgets().forEach(function (w) {
426
+ return w.setScaleInPixels(scale);
427
+ });
428
+ updateState(model.widgetState, model.scaleInPixels, model.rotationHandlePosition);
429
+ });
430
430
  } // ----------------------------------------------------------------------------
431
431
 
432
432
 
@@ -434,7 +434,8 @@ var defaultValues = function defaultValues(initialValues) {
434
434
  return _objectSpread({
435
435
  behavior: widgetBehavior,
436
436
  widgetState: generateState(),
437
- rotationHandlePosition: 0.25
437
+ rotationHandlePosition: 0.5,
438
+ scaleInPixels: true
438
439
  }, initialValues);
439
440
  }; // ----------------------------------------------------------------------------
440
441
 
@@ -443,7 +444,7 @@ function extend(publicAPI, model) {
443
444
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
444
445
  Object.assign(model, defaultValues(initialValues));
445
446
  vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
446
- macro.setGet(publicAPI, model, ['rotationHandlePosition']);
447
+ macro.setGet(publicAPI, model, ['scaleInPixels', 'rotationHandlePosition']);
447
448
  vtkResliceCursorWidget(publicAPI, model);
448
449
  } // ----------------------------------------------------------------------------
449
450
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "26.8.1",
3
+ "version": "26.9.0",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",