@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
@@ -52,7 +52,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
52
52
  // intermixed volume rendering
53
53
 
54
54
 
55
- publicAPI.opaqueZBufferPass = function (prepass, renderPass) {
55
+ publicAPI.zBufferPass = function (prepass, renderPass) {
56
56
  if (prepass) {
57
57
  var zbt = renderPass.getZBufferTexture();
58
58
 
@@ -60,6 +60,10 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
60
60
  model.zBufferTexture = zbt;
61
61
  }
62
62
  }
63
+ };
64
+
65
+ publicAPI.opaqueZBufferPass = function (prepass, renderPass) {
66
+ return publicAPI.zBufferPass(prepass, renderPass);
63
67
  }; // Renders myself
64
68
 
65
69
 
@@ -87,11 +87,7 @@ function vtkAbstractWidget(publicAPI, model) {
87
87
  };
88
88
 
89
89
  publicAPI.getViewWidgets = function () {
90
- return model._factory.getViewIds().map(function (viewId) {
91
- return model._factory.getWidgetForView({
92
- viewId: viewId
93
- });
94
- });
90
+ return model._factory.getViewWidgets();
95
91
  }; // --------------------------------------------------------------------------
96
92
  // Initialization calls
97
93
  // --------------------------------------------------------------------------
@@ -27,6 +27,11 @@ export interface vtkAbstractWidgetFactory {
27
27
  */
28
28
  getViewIds(): string[];
29
29
 
30
+ /**
31
+ * Get a list of all the instances of the widget.
32
+ */
33
+ getViewWidgets(): vtkAbstractWidget[];
34
+
30
35
  /**
31
36
  * Set the visiblity on each underlying view widget.
32
37
  *
@@ -121,6 +121,10 @@ function vtkAbstractWidgetFactory(publicAPI, model) {
121
121
 
122
122
  publicAPI.getViewIds = function () {
123
123
  return Object.keys(viewToWidget);
124
+ };
125
+
126
+ publicAPI.getViewWidgets = function () {
127
+ return Object.values(viewToWidget);
124
128
  }; // --------------------------------------------------------------------------
125
129
  // Widget visibility / enable
126
130
  // --------------------------------------------------------------------------
@@ -6,13 +6,15 @@ import macro from '../../../macros.js';
6
6
  */
7
7
 
8
8
  var DEFAULT_VALUES = {
9
- color3: [255, 255, 255]
9
+ color3: [255, 255, 255],
10
+ opacity: 255
10
11
  }; // ----------------------------------------------------------------------------
11
12
 
12
13
  function extend(publicAPI, model) {
13
14
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
14
15
  Object.assign(model, DEFAULT_VALUES, initialValues);
15
16
  macro.setGetArray(publicAPI, model, ['color3'], 3, 255);
17
+ macro.setGet(publicAPI, model, ['opacity']);
16
18
  } // ----------------------------------------------------------------------------
17
19
 
18
20
  var color3 = {
@@ -1,7 +1,16 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
3
  import macro from '../../../macros.js';
4
+ import { f as vtkMath } from '../../../Common/Core/Math/index.js';
5
+ import { getPixelWorldHeightAtCoord } from '../WidgetManager.js';
6
+
7
+ 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; }
8
+
9
+ 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; }
3
10
 
4
11
  function vtkOriginMixin(publicAPI, model) {
12
+ var superClass = _objectSpread({}, publicAPI);
13
+
5
14
  publicAPI.translate = function (dx, dy, dz) {
6
15
  var _publicAPI$getOriginB = publicAPI.getOriginByReference(),
7
16
  _publicAPI$getOriginB2 = _slicedToArray(_publicAPI$getOriginB, 3),
@@ -11,18 +20,40 @@ function vtkOriginMixin(publicAPI, model) {
11
20
 
12
21
  publicAPI.setOrigin(x + dx, y + dy, z + dz);
13
22
  };
23
+
24
+ publicAPI.getOrigin = function (displayScaleParams) {
25
+ var origin = superClass.getOrigin();
26
+
27
+ if (!model.offset) {
28
+ return origin;
29
+ }
30
+
31
+ if (!displayScaleParams) {
32
+ return vtkMath.add(origin, model.offset, origin);
33
+ }
34
+
35
+ var pixelWorldHeight = getPixelWorldHeightAtCoord(origin, displayScaleParams);
36
+ var rendererPixelDims = displayScaleParams.rendererPixelDims;
37
+ var totalSize = Math.min(rendererPixelDims[0], rendererPixelDims[1]);
38
+ return vtkMath.multiplyAccumulate(origin, model.offset, totalSize * pixelWorldHeight, origin);
39
+ };
14
40
  } // ----------------------------------------------------------------------------
15
41
 
42
+ /**
43
+ * offset: optional offset that can be scaled to pixel screen space.
44
+ */
45
+
16
46
 
17
47
  var DEFAULT_VALUES = {
18
- origin: null
48
+ origin: null,
49
+ offset: null
19
50
  }; // ----------------------------------------------------------------------------
20
51
 
21
52
  function extend(publicAPI, model) {
22
53
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
23
54
  Object.assign(model, DEFAULT_VALUES, initialValues);
24
- macro.setGetArray(publicAPI, model, ['origin'], 3);
25
- vtkOriginMixin(publicAPI);
55
+ macro.setGetArray(publicAPI, model, ['origin', 'offset'], 3);
56
+ vtkOriginMixin(publicAPI, model);
26
57
  } // ----------------------------------------------------------------------------
27
58
 
28
59
  var origin = {
@@ -37,6 +37,14 @@ export interface IRenderingComponents {
37
37
  */
38
38
  export function extractRenderingComponents(renderer: vtkRenderer): IRenderingComponents;
39
39
 
40
+ /**
41
+ * This method returns the world distance that corresponds to the height of a
42
+ * single display pixel at a given coordinate. For example, to determine the
43
+ * (vertical) distance that matches a display distance of 30px for a coordinate
44
+ * `coord`, you would compute `30 * getPixelWorldHeightAtCoord(coord)`.
45
+ */
46
+ export function getPixelWorldHeightAtCoord(coord: []): Number;
47
+
40
48
  export interface vtkWidgetManager extends vtkObject {
41
49
  /**
42
50
  * The the captureOn value.
@@ -1,7 +1,8 @@
1
1
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
2
2
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
4
  import _regeneratorRuntime from '@babel/runtime/regenerator';
4
- import { r as radiansFromDegrees } from '../../Common/Core/Math/index.js';
5
+ import { f as vtkMath } from '../../Common/Core/Math/index.js';
5
6
  import { FieldAssociations } from '../../Common/DataModel/DataSet/Constants.js';
6
7
  import macro from '../../macros.js';
7
8
  import WidgetManagerConst from './WidgetManager/Constants.js';
@@ -28,6 +29,26 @@ function extractRenderingComponents(renderer) {
28
29
  apiSpecificRenderWindow: apiSpecificRenderWindow,
29
30
  camera: camera
30
31
  };
32
+ }
33
+ function getPixelWorldHeightAtCoord(worldCoord, displayScaleParams) {
34
+ var dispHeightFactor = displayScaleParams.dispHeightFactor,
35
+ cameraPosition = displayScaleParams.cameraPosition,
36
+ cameraDir = displayScaleParams.cameraDir,
37
+ isParallel = displayScaleParams.isParallel,
38
+ rendererPixelDims = displayScaleParams.rendererPixelDims;
39
+ var scale = 1;
40
+
41
+ if (isParallel) {
42
+ scale = dispHeightFactor;
43
+ } else {
44
+ var worldCoordToCamera = _toConsumableArray(worldCoord);
45
+
46
+ vtkMath.subtract(worldCoordToCamera, cameraPosition, worldCoordToCamera);
47
+ scale = vtkMath.dot(worldCoordToCamera, cameraDir) * dispHeightFactor;
48
+ }
49
+
50
+ var rHeight = rendererPixelDims[1];
51
+ return scale / rHeight;
31
52
  } // ----------------------------------------------------------------------------
32
53
  // vtkWidgetManager methods
33
54
  // ----------------------------------------------------------------------------
@@ -98,7 +119,7 @@ function vtkWidgetManager(publicAPI, model) {
98
119
 
99
120
  var isParallel = _camera.getParallelProjection();
100
121
 
101
- var dispHeightFactor = isParallel ? 2 * _camera.getParallelScale() : 2 * Math.tan(radiansFromDegrees(_camera.getViewAngle()) / 2);
122
+ var dispHeightFactor = isParallel ? 2 * _camera.getParallelScale() : 2 * Math.tan(vtkMath.radiansFromDegrees(_camera.getViewAngle()) / 2);
102
123
  model.widgets.forEach(function (w) {
103
124
  w.getNestedProps().forEach(function (r) {
104
125
  if (r.getScaleInPixels()) {
@@ -327,7 +348,7 @@ function vtkWidgetManager(publicAPI, model) {
327
348
 
328
349
  model._selector.setFieldAssociation(FieldAssociations.FIELD_ASSOCIATION_POINTS);
329
350
 
330
- subscriptions.push(model._apiSpecificRenderWindow.onModified(updateDisplayScaleParams));
351
+ subscriptions.push(model._apiSpecificRenderWindow.onWindowResizeEvent(updateDisplayScaleParams));
331
352
  subscriptions.push(model._camera.onModified(updateDisplayScaleParams));
332
353
  updateDisplayScaleParams();
333
354
  subscriptions.push(model._interactor.onStartAnimation(function () {
@@ -622,7 +643,8 @@ var newInstance = macro.newInstance(extend, 'vtkWidgetManager'); // ------------
622
643
  var vtkWidgetManager$1 = {
623
644
  newInstance: newInstance,
624
645
  extend: extend,
625
- Constants: WidgetManagerConst
646
+ Constants: WidgetManagerConst,
647
+ getPixelWorldHeightAtCoord: getPixelWorldHeightAtCoord
626
648
  };
627
649
 
628
- export { vtkWidgetManager$1 as default, extend, extractRenderingComponents, newInstance };
650
+ export { vtkWidgetManager$1 as default, extend, extractRenderingComponents, getPixelWorldHeightAtCoord, newInstance };
@@ -28,7 +28,7 @@ function vtkCroppingOutlineRepresentation(publicAPI, model) {
28
28
  mtime: 0
29
29
  });
30
30
  allocateArray(model.internalPolyData, 'lines', OUTLINE_ARRAY.length).getData().set(OUTLINE_ARRAY);
31
- var applyOrigin = origin(); // --------------------------------------------------------------------------
31
+ var applyOrigin = origin(publicAPI, model); // --------------------------------------------------------------------------
32
32
  // Generic rendering pipeline
33
33
  // --------------------------------------------------------------------------
34
34
 
@@ -7,7 +7,8 @@ import vtkContextRepresentation from './ContextRepresentation.js';
7
7
  import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
8
8
  import vtkPolyData from '../../Common/DataModel/PolyData.js';
9
9
  import { ScalarMode } from '../../Rendering/Core/Mapper/Constants.js';
10
- import vtkWidgetRepresentation, { allocateArray, getPixelWorldHeightAtCoord } from './WidgetRepresentation.js';
10
+ import { getPixelWorldHeightAtCoord } from '../Core/WidgetManager.js';
11
+ import vtkWidgetRepresentation, { allocateArray } from './WidgetRepresentation.js';
11
12
  import { Behavior } from './WidgetRepresentation/Constants.js';
12
13
  import { OrientationModes } from '../../Rendering/Core/Glyph3DMapper/Constants.js';
13
14
 
@@ -23,7 +24,7 @@ function origin(publicAPI, model) {
23
24
  var j = 0;
24
25
 
25
26
  for (var i = 0; i < states.length; ++i) {
26
- var coord = states[i].getOrigin();
27
+ var coord = states[i].getOrigin(model.scaleInPixels && model.displayScaleParams);
27
28
  points[j++] = coord[0];
28
29
  points[j++] = coord[1];
29
30
  points[j++] = coord[2];
@@ -39,8 +40,9 @@ function color3(publicAPI, model) {
39
40
  return function (polyData, states) {
40
41
  model._pipeline.mapper.setColorByArrayName('color');
41
42
 
42
- var colors = allocateArray(polyData, 'color', states.length, 'Uint8Array', // RGB
43
- 3).getData();
43
+ var colorArray = allocateArray(polyData, 'color', states.length, 'Uint8Array', // RGBA
44
+ 4);
45
+ var colors = colorArray.getData();
44
46
  var j = 0;
45
47
 
46
48
  for (var i = 0; i < states.length; ++i) {
@@ -53,7 +55,10 @@ function color3(publicAPI, model) {
53
55
  colors[j++] = c3[0];
54
56
  colors[j++] = c3[1];
55
57
  colors[j++] = c3[2];
58
+ colors[j++] = states[i].getOpacity();
56
59
  }
60
+
61
+ colorArray.dataChange();
57
62
  };
58
63
  }
59
64
  function color(publicAPI, model) {
@@ -278,7 +283,7 @@ function defaultValues(publicAPI, model, initialValues) {
278
283
  })
279
284
  }, initialValues._pipeline),
280
285
  applyMixin: _objectSpread({
281
- origin: (_initialValues$applyM = (_initialValues$applyM2 = initialValues.applyMixin) === null || _initialValues$applyM2 === void 0 ? void 0 : _initialValues$applyM2.origin) !== null && _initialValues$applyM !== void 0 ? _initialValues$applyM : origin(),
286
+ origin: (_initialValues$applyM = (_initialValues$applyM2 = initialValues.applyMixin) === null || _initialValues$applyM2 === void 0 ? void 0 : _initialValues$applyM2.origin) !== null && _initialValues$applyM !== void 0 ? _initialValues$applyM : origin(publicAPI, model),
282
287
  noPosition: (_initialValues$applyM3 = (_initialValues$applyM4 = initialValues.applyMixin) === null || _initialValues$applyM4 === void 0 ? void 0 : _initialValues$applyM4.noPosition) !== null && _initialValues$applyM3 !== void 0 ? _initialValues$applyM3 : noPosition(),
283
288
  color3: (_initialValues$applyM5 = (_initialValues$applyM6 = initialValues.applyMixin) === null || _initialValues$applyM6 === void 0 ? void 0 : _initialValues$applyM6.color3) !== null && _initialValues$applyM5 !== void 0 ? _initialValues$applyM5 : color3(publicAPI, model),
284
289
  color: (_initialValues$applyM7 = (_initialValues$applyM8 = initialValues.applyMixin) === null || _initialValues$applyM8 === void 0 ? void 0 : _initialValues$applyM8.color) !== null && _initialValues$applyM7 !== void 0 ? _initialValues$applyM7 : color(publicAPI, model),
@@ -11,7 +11,8 @@ import vtkPlane from '../../Common/DataModel/Plane.js';
11
11
  import vtkPolyData from '../../Common/DataModel/PolyData.js';
12
12
  import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
13
13
  import vtkStateBuilder from '../Core/StateBuilder.js';
14
- import vtkWidgetRepresentation, { getPixelWorldHeightAtCoord } from './WidgetRepresentation.js';
14
+ import { getPixelWorldHeightAtCoord } from '../Core/WidgetManager.js';
15
+ import vtkWidgetRepresentation from './WidgetRepresentation.js';
15
16
  import WidgetManagerConst from '../Core/WidgetManager/Constants.js';
16
17
  import PropertyConst from '../../Rendering/Core/Property/Constants.js';
17
18
 
@@ -5,7 +5,8 @@ import vtkMapper from '../../Rendering/Core/Mapper.js';
5
5
  import { B as areEquals } from '../../Common/Core/Math/index.js';
6
6
  import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
7
7
  import vtkTubeFilter from '../../Filters/General/TubeFilter.js';
8
- import vtkWidgetRepresentation, { allocateArray, getPixelWorldHeightAtCoord } from './WidgetRepresentation.js';
8
+ import { getPixelWorldHeightAtCoord } from '../Core/WidgetManager.js';
9
+ import vtkWidgetRepresentation, { allocateArray } from './WidgetRepresentation.js';
9
10
  import { RenderingTypes } from '../Core/WidgetManager/Constants.js';
10
11
  import vtkPolyData from '../../Common/DataModel/PolyData.js';
11
12
 
@@ -1,8 +1,6 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
2
  import macro from '../../macros.js';
4
3
  import vtkProp from '../../Rendering/Core/Prop.js';
5
- import { f as vtkMath } from '../../Common/Core/Math/index.js';
6
4
  import vtkCellArray from '../../Common/Core/CellArray.js';
7
5
  import vtkDataArray from '../../Common/Core/DataArray.js';
8
6
  import vtkPoints from '../../Common/Core/Points.js';
@@ -96,26 +94,6 @@ function connectPipeline(pipeline) {
96
94
  }
97
95
 
98
96
  pipeline.actor.setMapper(pipeline.mapper);
99
- }
100
- function getPixelWorldHeightAtCoord(worldCoord, displayScaleParams) {
101
- var dispHeightFactor = displayScaleParams.dispHeightFactor,
102
- cameraPosition = displayScaleParams.cameraPosition,
103
- cameraDir = displayScaleParams.cameraDir,
104
- isParallel = displayScaleParams.isParallel,
105
- rendererPixelDims = displayScaleParams.rendererPixelDims;
106
- var scale = 1;
107
-
108
- if (isParallel) {
109
- scale = dispHeightFactor;
110
- } else {
111
- var worldCoordToCamera = _toConsumableArray(worldCoord);
112
-
113
- vtkMath.subtract(worldCoordToCamera, cameraPosition, worldCoordToCamera);
114
- scale = vtkMath.dot(worldCoordToCamera, cameraDir) * dispHeightFactor;
115
- }
116
-
117
- var rHeight = rendererPixelDims[1];
118
- return scale / rHeight;
119
97
  } // Internal convenient function to create a data array:
120
98
 
121
99
  function allocateArray(polyData, name, numberOfTuples, dataType, numberOfComponents) {
@@ -362,7 +340,7 @@ function extend(publicAPI, model) {
362
340
  // Object methods
363
341
  vtkProp.extend(publicAPI, model, defaultValues(initialValues));
364
342
  macro.algo(publicAPI, model, 1, 1);
365
- macro.get(publicAPI, model, ['labels']);
343
+ macro.get(publicAPI, model, ['labels', 'displayScaleParams', 'coincidentTopologyParameters']);
366
344
  macro.set(publicAPI, model, [{
367
345
  type: 'object',
368
346
  name: 'displayScaleParams'
@@ -379,8 +357,7 @@ var vtkWidgetRepresentation$1 = {
379
357
  extend: extend,
380
358
  mergeStyles: mergeStyles,
381
359
  applyStyles: applyStyles,
382
- connectPipeline: connectPipeline,
383
- getPixelWorldHeightAtCoord: getPixelWorldHeightAtCoord
360
+ connectPipeline: connectPipeline
384
361
  };
385
362
 
386
- export { allocateArray, applyStyles, connectPipeline, vtkWidgetRepresentation$1 as default, extend, getPixelWorldHeightAtCoord, mergeStyles };
363
+ export { allocateArray, applyStyles, connectPipeline, vtkWidgetRepresentation$1 as default, extend, mergeStyles };
@@ -10,7 +10,19 @@ import { InteractionMethodsName, lineNames, ScrollingMethods, planeNameToViewTyp
10
10
  function widgetBehavior(publicAPI, model) {
11
11
  model._isDragging = false;
12
12
  var isScrolling = false;
13
- var previousPosition; // FIXME: label information should be accessible from activeState instead of parent state.
13
+ var previousPosition;
14
+ macro.setGet(publicAPI, model, ['keepOrthogonality']);
15
+
16
+ publicAPI.setEnableTranslation = function (enable) {
17
+ model.representations[0].setPickable(enable); // line handle
18
+
19
+ model.representations[2].setPickable(enable); // center handle
20
+ };
21
+
22
+ publicAPI.setEnableRotation = function (enable) {
23
+ model.representations[1].setPickable(enable); // rotation handle
24
+ }; // FIXME: label information should be accessible from activeState instead of parent state.
25
+
14
26
 
15
27
  publicAPI.getActiveInteraction = function () {
16
28
  if (model.widgetState.getStatesWithLabel('rotation').includes(model.activeState)) {
@@ -245,7 +257,7 @@ function widgetBehavior(publicAPI, model) {
245
257
  var newCenter = [oldCenter[0] + movingFactor * dirProj[0], oldCenter[1] + movingFactor * dirProj[1], oldCenter[2] + movingFactor * dirProj[2]];
246
258
  newCenter = publicAPI.getBoundedCenter(newCenter);
247
259
  model.widgetState.setCenter(newCenter);
248
- updateState(model.widgetState, model._factory.getDisplayScaleParams(), model._factory.getRotationHandlePosition());
260
+ updateState(model.widgetState, model._factory.getScaleInPixels(), model._factory.getRotationHandlePosition());
249
261
  };
250
262
 
251
263
  publicAPI[InteractionMethodsName.TranslateAxis] = function (calldata) {
@@ -274,7 +286,7 @@ function widgetBehavior(publicAPI, model) {
274
286
  var newOrigin = multiplyAccumulate(center, axisTranslation, translationDistance, [0, 0, 0]);
275
287
  newOrigin = publicAPI.getBoundedCenter(newOrigin);
276
288
  model.widgetState.setCenter(newOrigin);
277
- updateState(model.widgetState, model._factory.getDisplayScaleParams(), model._factory.getRotationHandlePosition());
289
+ updateState(model.widgetState, model._factory.getScaleInPixels(), model._factory.getRotationHandlePosition());
278
290
  };
279
291
 
280
292
  publicAPI.getBoundedCenter = function (newCenter) {
@@ -295,7 +307,7 @@ function widgetBehavior(publicAPI, model) {
295
307
  var newCenter = add(model.widgetState.getCenter(), translation, []);
296
308
  newCenter = publicAPI.getBoundedCenter(newCenter);
297
309
  model.widgetState.setCenter(newCenter);
298
- updateState(model.widgetState, model._factory.getDisplayScaleParams(), model._factory.getRotationHandlePosition());
310
+ updateState(model.widgetState, model._factory.getScaleInPixels(), model._factory.getRotationHandlePosition());
299
311
  };
300
312
 
301
313
  publicAPI[InteractionMethodsName.RotateLine] = function (calldata) {
@@ -306,7 +318,7 @@ function widgetBehavior(publicAPI, model) {
306
318
  var previousLineDirection = activeLineHandle.getDirection();
307
319
  normalize(previousLineDirection);
308
320
 
309
- if (publicAPI.getActiveRotationPointName() === 'point0') {
321
+ if (publicAPI.getActiveRotationPointName() === 'point1') {
310
322
  multiplyScalar(previousLineDirection, -1);
311
323
  }
312
324
 
@@ -329,13 +341,13 @@ function widgetBehavior(publicAPI, model) {
329
341
  var planeNormal = model.widgetState.getPlanes()[inViewType].normal;
330
342
  publicAPI.rotatePlane(viewType, radianAngle, planeNormal);
331
343
 
332
- if (model.widgetState.getKeepOrthogonality()) {
344
+ if (publicAPI.getKeepOrthogonality()) {
333
345
  var otherLineName = getOtherLineName(lineName);
334
346
  var otherPlaneName = getLinePlaneName(otherLineName);
335
347
  publicAPI.rotatePlane(planeNameToViewType[otherPlaneName], radianAngle, planeNormal);
336
348
  }
337
349
 
338
- updateState(model.widgetState, model._factory.getDisplayScaleParams(), model._factory.getRotationHandlePosition());
350
+ updateState(model.widgetState, model._factory.getScaleInPixels(), model._factory.getRotationHandlePosition());
339
351
  };
340
352
  /**
341
353
  * Rotate a specified plane around an other specified plane.
@@ -6,7 +6,6 @@ import vtkPlane from '../../../Common/DataModel/Plane.js';
6
6
  import { s as subtract, l as normalize, j as cross, w as multiplyScalar, m as multiplyAccumulate, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
7
7
  import vtkMatrixBuilder from '../../../Common/Core/MatrixBuilder.js';
8
8
  import { ViewTypes } from '../../Core/WidgetManager/Constants.js';
9
- import { getPixelWorldHeightAtCoord } from '../../Representations/WidgetRepresentation.js';
10
9
  import { planeNames, lineNames, planeNameToViewType } from './Constants.js';
11
10
 
12
11
  var EPSILON = 10e-7;
@@ -157,25 +156,15 @@ function getOtherLineName(lineName) {
157
156
  return planeName !== linePlaneName && planeName !== lineInPlaneName;
158
157
  });
159
158
  return "".concat(otherLineName, "in").concat(lineInPlaneName);
160
- } // Update the extremities and the rotation point coordinate of the line
159
+ } // Compute the offset of the rotation handle origin
161
160
 
162
- function computeRotationHandleOrigin(center, axis, rotationHandlePosition, volumeDiagonalLength, displayScaleParams) {
161
+ function computeRotationHandleOriginOffset(axis, rotationHandlePosition, volumeDiagonalLength, scaleInPixels) {
163
162
  // FIXME: p1 and p2 could be placed on the exact boundaries of the volume.
164
- var distanceToCenter = volumeDiagonalLength; // displayScaleParams is not null when representation.getScaleInPixels() is true
165
-
166
- if (displayScaleParams) {
167
- var pixelWorldHeight = getPixelWorldHeightAtCoord(center, displayScaleParams);
168
- var rendererPixelDims = displayScaleParams.rendererPixelDims;
169
- var totalSize = Math.min(rendererPixelDims[0], rendererPixelDims[1]) / 2;
170
- distanceToCenter = pixelWorldHeight * totalSize;
171
- }
172
-
173
- distanceToCenter *= rotationHandlePosition;
174
- return multiplyAccumulate(center, axis, distanceToCenter, []);
163
+ return multiplyScalar(_toConsumableArray(axis), rotationHandlePosition * (scaleInPixels ? 1 : volumeDiagonalLength) / 2);
175
164
  } // Update the reslice cursor state according to the three planes normals and the origin
176
165
 
177
166
 
178
- function updateState(widgetState, displayScaleParams, rotationHandlePosition) {
167
+ function updateState(widgetState, scaleInPixels, rotationHandlePosition) {
179
168
  // Compute line axis
180
169
  var xNormal = widgetState.getPlanes()[ViewTypes.YZ_PLANE].normal;
181
170
  var yNormal = widgetState.getPlanes()[ViewTypes.XZ_PLANE].normal;
@@ -196,13 +185,13 @@ function updateState(widgetState, displayScaleParams, rotationHandlePosition) {
196
185
  lineNames.forEach(function (lineName) {
197
186
  var planeName = getLinePlaneName(lineName);
198
187
  var inPlaneName = getLineInPlaneName(lineName);
199
- var rotationPoint0 = computeRotationHandleOrigin(center, axes["".concat(planeName).concat(inPlaneName)], rotationHandlePosition, pdLength, displayScaleParams[planeNameToViewType[inPlaneName]]);
200
- widgetState["getRotationHandle".concat(lineName, "0")]().setOrigin(rotationPoint0);
201
- var rotationPoint1 = computeRotationHandleOrigin(center, multiplyScalar(axes["".concat(planeName).concat(inPlaneName)], -1), rotationHandlePosition, pdLength, displayScaleParams[planeNameToViewType[inPlaneName]]);
202
- widgetState["getRotationHandle".concat(lineName, "1")]().setOrigin(rotationPoint1);
188
+ var direction = axes["".concat(planeName).concat(inPlaneName)];
189
+ widgetState["getRotationHandle".concat(lineName, "0")]().setOrigin(center);
190
+ widgetState["getRotationHandle".concat(lineName, "0")]().setOffset(computeRotationHandleOriginOffset(direction, rotationHandlePosition, pdLength, scaleInPixels));
191
+ widgetState["getRotationHandle".concat(lineName, "1")]().setOrigin(center);
192
+ widgetState["getRotationHandle".concat(lineName, "1")]().setOffset(computeRotationHandleOriginOffset(direction, -rotationHandlePosition, pdLength, scaleInPixels));
203
193
  var lineHandle = widgetState["getAxis".concat(lineName)]();
204
194
  lineHandle.setOrigin(center);
205
- var direction = subtract(rotationPoint0, center, []);
206
195
  var scale = normalize(direction);
207
196
  var scale3 = lineHandle.getScale3();
208
197
  scale3[2] = 2 * scale;
@@ -17,24 +17,12 @@ function generateState() {
17
17
  var state = vtkStateBuilder.createBuilder().addField({
18
18
  name: 'center',
19
19
  initialValue: [0, 0, 0]
20
- }).addField({
21
- name: 'opacity',
22
- initialValue: 1
23
20
  }).addField({
24
21
  name: 'image',
25
22
  initialValue: null
26
23
  }).addField({
27
24
  name: 'activeViewType',
28
25
  initialValue: null
29
- }).addField({
30
- name: 'lineThickness',
31
- initialValue: 2
32
- }).addField({
33
- name: 'sphereRadius',
34
- initialValue: 5
35
- }).addField({
36
- name: 'showCenter',
37
- initialValue: true
38
26
  }).addField({
39
27
  name: 'planes',
40
28
  initialValue: (_initialValue = {}, _defineProperty(_initialValue, ViewTypes.YZ_PLANE, {
@@ -47,15 +35,6 @@ function generateState() {
47
35
  normal: [0, 0, -1],
48
36
  viewUp: [0, -1, 0]
49
37
  }), _initialValue)
50
- }).addField({
51
- name: 'enableRotation',
52
- initialValue: true
53
- }).addField({
54
- name: 'enableTranslation',
55
- initialValue: true
56
- }).addField({
57
- name: 'keepOrthogonality',
58
- initialValue: false
59
38
  }).addField({
60
39
  name: 'scrollingMethod',
61
40
  initialValue: ScrollingMethods.MIDDLE_MOUSE_BUTTON
@@ -66,7 +45,7 @@ function generateState() {
66
45
  name: 'viewUpFromViewType',
67
46
  initialValue: {}
68
47
  }).addStateFromMixin({
69
- labels: ['handles', 'center'],
48
+ labels: ['handles', 'sphere', 'center'],
70
49
  mixins: ['origin', 'color3', 'scale1', 'visible', 'manipulator'],
71
50
  name: 'centerHandle',
72
51
  initialValues: {
@@ -92,7 +71,7 @@ function generateState() {
92
71
 
93
72
  for (var rotationHandle = 0; rotationHandle < 2; ++rotationHandle) {
94
73
  axisState.addStateFromMixin({
95
- labels: ['handles', 'rotation', "rotationIn".concat(view), "".concat(axis, "in").concat(view), "point".concat(rotationHandle)],
74
+ labels: ['handles', 'sphere', 'rotation', "rotationIn".concat(view), "".concat(axis, "in").concat(view), "point".concat(rotationHandle)],
96
75
  mixins: ['origin', 'color3', 'scale1', 'visible', 'manipulator'],
97
76
  name: "rotationHandle".concat(axis, "in").concat(view).concat(rotationHandle),
98
77
  initialValues: {