@kitware/vtk.js 25.9.2 → 26.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/Common/Core/CellArray.d.ts +0 -6
  2. package/Common/Core/CellArray.js +21 -12
  3. package/Common/Core/ClassHierarchy.js +11 -6
  4. package/Common/Core/DataArray.d.ts +20 -0
  5. package/Common/Core/DataArray.js +21 -4
  6. package/Proxy/Core/ViewProxy.js +17 -9
  7. package/Rendering/Core/Prop3D.js +1 -6
  8. package/Rendering/Core/RenderWindow.js +9 -6
  9. package/Rendering/Core/VolumeProperty.js +2 -3
  10. package/Rendering/Misc/CanvasView.js +6 -5
  11. package/Rendering/Misc/GenericRenderWindow.js +12 -7
  12. package/Rendering/OpenGL/Actor.js +4 -4
  13. package/Rendering/OpenGL/Actor2D.js +4 -4
  14. package/Rendering/OpenGL/Camera.js +7 -4
  15. package/Rendering/OpenGL/CubeAxesActor.js +7 -5
  16. package/Rendering/OpenGL/ForwardPass.js +1 -1
  17. package/Rendering/OpenGL/Glyph3DMapper.js +4 -4
  18. package/Rendering/OpenGL/ImageMapper.js +9 -5
  19. package/Rendering/OpenGL/ImageSlice.js +3 -3
  20. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +9 -5
  21. package/Rendering/OpenGL/PolyDataMapper.js +27 -21
  22. package/Rendering/OpenGL/PolyDataMapper2D.js +17 -10
  23. package/Rendering/OpenGL/ScalarBarActor.js +6 -4
  24. package/Rendering/OpenGL/Skybox.js +10 -6
  25. package/Rendering/OpenGL/Texture.js +6 -5
  26. package/Rendering/OpenGL/Volume.js +2 -2
  27. package/Rendering/OpenGL/VolumeMapper.js +11 -11
  28. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  29. package/Rendering/SceneGraph/RenderPass.js +3 -2
  30. package/Rendering/WebGPU/ForwardPass.js +1 -1
  31. package/Rendering/WebGPU/HardwareSelectionPass.js +1 -1
  32. package/Rendering/WebGPU/HardwareSelector.js +14 -13
  33. package/Rendering/WebGPU/OpaquePass.js +1 -1
  34. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
  35. package/Rendering/WebGPU/VolumePass.js +1 -1
  36. package/Utilities/config/rules-tests.js +28 -0
  37. package/Widgets/Core/AbstractWidgetFactory.js +1 -0
  38. package/Widgets/Core/StateBuilder/color3Mixin.js +22 -0
  39. package/Widgets/Core/StateBuilder/colorMixin.js +7 -0
  40. package/Widgets/Core/StateBuilder.js +2 -0
  41. package/Widgets/Representations/ArrowHandleRepresentation.js +28 -110
  42. package/Widgets/Representations/CircleContextRepresentation.js +43 -165
  43. package/Widgets/Representations/ContextRepresentation.js +0 -3
  44. package/Widgets/Representations/ConvexFaceContextRepresentation.js +11 -11
  45. package/Widgets/Representations/CroppingOutlineRepresentation.js +5 -12
  46. package/Widgets/Representations/CubeHandleRepresentation.js +15 -104
  47. package/Widgets/Representations/GlyphRepresentation.js +320 -0
  48. package/Widgets/Representations/HandleRepresentation.js +0 -5
  49. package/Widgets/Representations/ImplicitPlaneRepresentation.js +68 -49
  50. package/Widgets/Representations/LineHandleRepresentation.js +116 -0
  51. package/Widgets/Representations/PolyLineRepresentation.js +52 -49
  52. package/Widgets/Representations/RectangleContextRepresentation.js +16 -21
  53. package/Widgets/Representations/SphereContextRepresentation.js +30 -109
  54. package/Widgets/Representations/SphereHandleRepresentation.js +13 -110
  55. package/Widgets/Representations/SplineContextRepresentation.js +53 -36
  56. package/Widgets/Representations/WidgetRepresentation.d.ts +52 -1
  57. package/Widgets/Representations/WidgetRepresentation.js +140 -78
  58. package/Widgets/Representations.js +6 -0
  59. package/Widgets/SVG/SVGLandmarkRepresentation.js +1 -13
  60. package/Widgets/Widgets3D/AngleWidget.js +1 -4
  61. package/Widgets/Widgets3D/EllipseWidget/state.js +1 -1
  62. package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +15 -3
  63. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +93 -36
  64. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +75 -82
  65. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +49 -170
  66. package/Widgets/Widgets3D/ResliceCursorWidget.js +61 -23
  67. package/index.d.ts +0 -1
  68. package/macros.d.ts +3 -5
  69. package/macros.js +4 -35
  70. package/package.json +2 -2
  71. package/Widgets/Representations/ResliceCursorContextRepresentation/Constants.js +0 -12
  72. package/Widgets/Representations/ResliceCursorContextRepresentation.d.ts +0 -54
  73. package/Widgets/Representations/ResliceCursorContextRepresentation.js +0 -357
  74. package/_vendor/available-typed-arrays/index.js_commonjs-proxy.js +0 -1
  75. package/_vendor/call-bind/callBound.js_commonjs-proxy.js +0 -1
  76. package/_vendor/call-bind/index.js_commonjs-module.js +0 -3
  77. package/_vendor/call-bind/index.js_commonjs-proxy.js +0 -1
  78. package/_vendor/deep-equal/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
  79. package/_vendor/define-properties/index.js_commonjs-proxy.js +0 -1
  80. package/_vendor/es-abstract/helpers/getOwnPropertyDescriptor.js_commonjs-proxy.js +0 -1
  81. package/_vendor/es-get-iterator/index.js_commonjs-module.js +0 -3
  82. package/_vendor/es-get-iterator/index.js_commonjs-proxy.js +0 -1
  83. package/_vendor/es-get-iterator/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
  84. package/_vendor/foreach/index.js_commonjs-proxy.js +0 -1
  85. package/_vendor/function-bind/implementation.js_commonjs-proxy.js +0 -1
  86. package/_vendor/function-bind/index.js_commonjs-proxy.js +0 -1
  87. package/_vendor/get-intrinsic/index.js_commonjs-proxy.js +0 -1
  88. package/_vendor/has/src/index.js_commonjs-proxy.js +0 -1
  89. package/_vendor/has-bigints/index.js_commonjs-proxy.js +0 -1
  90. package/_vendor/has-symbols/index.js_commonjs-proxy.js +0 -1
  91. package/_vendor/has-symbols/shams.js_commonjs-proxy.js +0 -1
  92. package/_vendor/has-tostringtag/shams.js_commonjs-proxy.js +0 -1
  93. package/_vendor/is-arguments/index.js_commonjs-proxy.js +0 -1
  94. package/_vendor/is-bigint/index.js_commonjs-module.js +0 -3
  95. package/_vendor/is-bigint/index.js_commonjs-proxy.js +0 -1
  96. package/_vendor/is-boolean-object/index.js_commonjs-proxy.js +0 -1
  97. package/_vendor/is-date-object/index.js_commonjs-proxy.js +0 -1
  98. package/_vendor/is-map/index.js_commonjs-proxy.js +0 -1
  99. package/_vendor/is-number-object/index.js_commonjs-proxy.js +0 -1
  100. package/_vendor/is-regex/index.js_commonjs-proxy.js +0 -1
  101. package/_vendor/is-set/index.js_commonjs-proxy.js +0 -1
  102. package/_vendor/is-string/index.js_commonjs-proxy.js +0 -1
  103. package/_vendor/is-symbol/index.js_commonjs-module.js +0 -3
  104. package/_vendor/is-symbol/index.js_commonjs-proxy.js +0 -1
  105. package/_vendor/is-typed-array/index.js_commonjs-proxy.js +0 -1
  106. package/_vendor/is-weakmap/index.js_commonjs-proxy.js +0 -1
  107. package/_vendor/is-weakset/index.js_commonjs-proxy.js +0 -1
  108. package/_vendor/object-inspect/index.js_commonjs-proxy.js +0 -1
  109. package/_vendor/object-is/implementation.js_commonjs-proxy.js +0 -1
  110. package/_vendor/object-is/index.js_commonjs-proxy.js +0 -1
  111. package/_vendor/object-is/polyfill.js_commonjs-proxy.js +0 -1
  112. package/_vendor/object-is/shim.js_commonjs-proxy.js +0 -1
  113. package/_vendor/object-keys/implementation.js_commonjs-proxy.js +0 -1
  114. package/_vendor/object-keys/index.js_commonjs-proxy.js +0 -1
  115. package/_vendor/object-keys/isArguments.js_commonjs-proxy.js +0 -1
  116. package/_vendor/object.assign/implementation.js_commonjs-proxy.js +0 -1
  117. package/_vendor/object.assign/index.js_commonjs-proxy.js +0 -1
  118. package/_vendor/object.assign/polyfill.js_commonjs-proxy.js +0 -1
  119. package/_vendor/object.assign/shim.js_commonjs-proxy.js +0 -2
  120. package/_vendor/regexp.prototype.flags/implementation.js_commonjs-proxy.js +0 -1
  121. package/_vendor/regexp.prototype.flags/index.js_commonjs-proxy.js +0 -1
  122. package/_vendor/regexp.prototype.flags/polyfill.js_commonjs-proxy.js +0 -1
  123. package/_vendor/regexp.prototype.flags/shim.js_commonjs-proxy.js +0 -1
  124. package/_vendor/side-channel/index.js_commonjs-proxy.js +0 -1
  125. package/_vendor/which-boxed-primitive/index.js_commonjs-proxy.js +0 -5
  126. package/_vendor/which-collection/index.js_commonjs-proxy.js +0 -4
  127. package/_vendor/which-typed-array/index.js_commonjs-proxy.js +0 -1
  128. package/_virtual/_node-resolve_empty.js_commonjs-proxy.js +0 -6
  129. package/_virtual/commonjsHelpers.js +0 -18
  130. package/_virtual/node-resolve_empty.js +0 -8
  131. package/_virtual/polyfill-node.global.js +0 -5
  132. package/_virtual/polyfill-node.process.js +0 -225
  133. package/vendor/available-typed-arrays/index.js +0 -29
  134. package/vendor/call-bind/callBound.js +0 -19
  135. package/vendor/call-bind/index.js +0 -52
  136. package/vendor/deep-equal/index.js +0 -379
  137. package/vendor/deep-equal/node_modules/isarray/index.js +0 -7
  138. package/vendor/define-properties/index.js +0 -60
  139. package/vendor/es-abstract/helpers/getOwnPropertyDescriptor.js +0 -17
  140. package/vendor/es-get-iterator/index.js +0 -217
  141. package/vendor/es-get-iterator/node_modules/isarray/index.js +0 -7
  142. package/vendor/foreach/index.js +0 -22
  143. package/vendor/function-bind/implementation.js +0 -52
  144. package/vendor/function-bind/index.js +0 -7
  145. package/vendor/get-intrinsic/index.js +0 -334
  146. package/vendor/has/src/index.js +0 -7
  147. package/vendor/has-bigints/index.js +0 -12
  148. package/vendor/has-symbols/index.js +0 -15
  149. package/vendor/has-symbols/shams.js +0 -42
  150. package/vendor/has-tostringtag/shams.js +0 -9
  151. package/vendor/is-arguments/index.js +0 -36
  152. package/vendor/is-bigint/index.js +0 -39
  153. package/vendor/is-boolean-object/index.js +0 -29
  154. package/vendor/is-date-object/index.js +0 -22
  155. package/vendor/is-map/index.js +0 -42
  156. package/vendor/is-number-object/index.js +0 -26
  157. package/vendor/is-regex/index.js +0 -61
  158. package/vendor/is-set/index.js +0 -42
  159. package/vendor/is-string/index.js +0 -26
  160. package/vendor/is-symbol/index.js +0 -36
  161. package/vendor/is-typed-array/index.js +0 -67
  162. package/vendor/is-weakmap/index.js +0 -42
  163. package/vendor/is-weakset/index.js +0 -42
  164. package/vendor/object-inspect/index.js +0 -515
  165. package/vendor/object-is/implementation.js +0 -18
  166. package/vendor/object-is/index.js +0 -25
  167. package/vendor/object-is/polyfill.js +0 -9
  168. package/vendor/object-is/shim.js +0 -17
  169. package/vendor/object-keys/implementation.js +0 -124
  170. package/vendor/object-keys/index.js +0 -35
  171. package/vendor/object-keys/isArguments.js +0 -17
  172. package/vendor/object.assign/implementation.js +0 -46
  173. package/vendor/object.assign/index.js +0 -29
  174. package/vendor/object.assign/polyfill.js +0 -57
  175. package/vendor/object.assign/shim.js +0 -17
  176. package/vendor/regexp.prototype.flags/implementation.js +0 -30
  177. package/vendor/regexp.prototype.flags/index.js +0 -25
  178. package/vendor/regexp.prototype.flags/polyfill.js +0 -23
  179. package/vendor/regexp.prototype.flags/shim.js +0 -29
  180. package/vendor/side-channel/index.js +0 -128
  181. package/vendor/which-boxed-primitive/index.js +0 -38
  182. package/vendor/which-collection/index.js +0 -29
  183. package/vendor/which-typed-array/index.js +0 -63
@@ -6,6 +6,8 @@ import vtkPlane from '../../../Common/DataModel/Plane.js';
6
6
  import { s as subtract, m as normalize, k as cross, x as multiplyScalar, o as multiplyAccumulate, T 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
+ import { planeNames, lineNames, planeNameToViewType } from './Constants.js';
9
11
 
10
12
  var EPSILON = 10e-7;
11
13
  /**
@@ -126,35 +128,91 @@ function rotateVector(vectorToBeRotated, axis, angle) {
126
128
 
127
129
  vtkMatrixBuilder.buildFromRadian().rotate(angle, axis).apply(rotatedVector);
128
130
  return rotatedVector;
131
+ }
132
+ /**
133
+ * Return X if lineName == XinY|XinZ, Y if lineName == YinX|YinZ and Z otherwise
134
+ * @param {string} lineName name of the line (YinX, ZinX, XinY, ZinY, XinZ, YinZ)
135
+ */
136
+
137
+ function getLinePlaneName(lineName) {
138
+ return lineName[0];
139
+ }
140
+ /**
141
+ * Return X if lineName == YinX|ZinX, Y if lineName == XinY|ZinY and Z otherwise
142
+ * @param {string} lineName name of the line (YinX, ZinX, XinY, ZinY, XinZ, YinZ)
143
+ */
144
+
145
+ function getLineInPlaneName(lineName) {
146
+ return lineName[3];
147
+ }
148
+ /**
149
+ * Return ZinX if lineName == YinX, YinX if lineName == ZinX, ZinY if lineName == XinY...
150
+ * @param {string} lineName name of the line (YinX, ZinX, XinY, ZinY, XinZ, YinZ)
151
+ */
152
+
153
+ function getOtherLineName(lineName) {
154
+ var linePlaneName = getLinePlaneName(lineName);
155
+ var lineInPlaneName = getLineInPlaneName(lineName);
156
+ var otherLineName = planeNames.find(function (planeName) {
157
+ return planeName !== linePlaneName && planeName !== lineInPlaneName;
158
+ });
159
+ return "".concat(otherLineName, "in").concat(lineInPlaneName);
129
160
  } // Update the extremities and the rotation point coordinate of the line
130
161
 
131
- function updateLine(lineState, center, axis, lineLength) {
132
- var p1 = [center[0] - lineLength * axis[0], center[1] - lineLength * axis[1], center[2] - lineLength * axis[2]];
133
- var p2 = [center[0] + lineLength * axis[0], center[1] + lineLength * axis[1], center[2] + lineLength * axis[2]]; // FIXME: p1 and p2 should be placed on the boundaries of the volume.
162
+ function computeRotationHandleOrigin(center, axis, rotationHandlePosition, volumeDiagonalLength, displayScaleParams) {
163
+ // 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
+ }
134
172
 
135
- lineState.setPoint1(p1);
136
- lineState.setPoint2(p2);
173
+ distanceToCenter *= rotationHandlePosition;
174
+ return multiplyAccumulate(center, axis, distanceToCenter, []);
137
175
  } // Update the reslice cursor state according to the three planes normals and the origin
138
176
 
139
177
 
140
- function updateState(widgetState) {
178
+ function updateState(widgetState, displayScaleParams, rotationHandlePosition) {
141
179
  // Compute line axis
142
180
  var xNormal = widgetState.getPlanes()[ViewTypes.YZ_PLANE].normal;
143
181
  var yNormal = widgetState.getPlanes()[ViewTypes.XZ_PLANE].normal;
144
182
  var zNormal = widgetState.getPlanes()[ViewTypes.XY_PLANE].normal;
145
- var yzIntersectionLineAxis = cross(yNormal, zNormal, []);
146
- var xzIntersectionLineAxis = cross(zNormal, xNormal, []);
147
- var xyIntersectionLineAxis = cross(xNormal, yNormal, []);
183
+ var axes = {
184
+ XY: cross(xNormal, yNormal, []),
185
+ YZ: cross(yNormal, zNormal, []),
186
+ XZ: cross(zNormal, xNormal, [])
187
+ };
188
+ axes.YX = axes.XY;
189
+ axes.ZY = axes.YZ;
190
+ axes.ZX = axes.XZ;
148
191
  var bounds = widgetState.getImage().getBounds();
149
192
  var center = widgetState.getCenter(); // Length of the principal diagonal.
150
193
 
151
- var pdLength = 0.5 * vtkBoundingBox.getDiagonalLength(bounds);
152
- updateLine(widgetState.getAxisXinY(), center, xyIntersectionLineAxis, pdLength);
153
- updateLine(widgetState.getAxisYinX(), center, xyIntersectionLineAxis, pdLength);
154
- updateLine(widgetState.getAxisYinZ(), center, yzIntersectionLineAxis, pdLength);
155
- updateLine(widgetState.getAxisZinY(), center, yzIntersectionLineAxis, pdLength);
156
- updateLine(widgetState.getAxisXinZ(), center, xzIntersectionLineAxis, pdLength);
157
- updateLine(widgetState.getAxisZinX(), center, xzIntersectionLineAxis, pdLength);
194
+ var pdLength = vtkBoundingBox.getDiagonalLength(bounds);
195
+ widgetState.getCenterHandle().setOrigin(center);
196
+ lineNames.forEach(function (lineName) {
197
+ var planeName = getLinePlaneName(lineName);
198
+ 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);
203
+ var lineHandle = widgetState["getAxis".concat(lineName)]();
204
+ lineHandle.setOrigin(center);
205
+ var direction = subtract(rotationPoint0, center, []);
206
+ var scale = normalize(direction);
207
+ var scale3 = lineHandle.getScale3();
208
+ scale3[2] = 2 * scale;
209
+ lineHandle.setScale3(scale3);
210
+ var right = widgetState.getPlanes()[planeNameToViewType[inPlaneName]].normal;
211
+ var up = cross(direction, right, []);
212
+ lineHandle.setRight(right);
213
+ lineHandle.setUp(up);
214
+ lineHandle.setDirection(direction);
215
+ });
158
216
  }
159
217
  /**
160
218
  * First rotate planeToTransform to match targetPlane normal.
@@ -173,71 +231,6 @@ function transformPlane(planeToTransform, targetCenter, targetNormal, targetView
173
231
  var angle = signedAngleBetweenVectors(viewUp, targetViewUp, targetNormal);
174
232
  planeToTransform.rotate(angle, targetNormal);
175
233
  planeToTransform.setCenter(targetCenter);
176
- } // Get name of the line in the same plane as the input
177
-
178
- function getAssociatedLinesName(lineName) {
179
- switch (lineName) {
180
- case 'AxisXinY':
181
- return 'AxisZinY';
182
-
183
- case 'AxisXinZ':
184
- return 'AxisYinZ';
185
-
186
- case 'AxisYinX':
187
- return 'AxisZinX';
188
-
189
- case 'AxisYinZ':
190
- return 'AxisXinZ';
191
-
192
- case 'AxisZinX':
193
- return 'AxisYinX';
194
-
195
- case 'AxisZinY':
196
- return 'AxisXinY';
197
-
198
- default:
199
- return '';
200
- }
201
- }
202
- /**
203
- * Get the line name, constructs from the plane name and where the plane is displayed
204
- * Example: planeName='X' rotatedPlaneName='Y', then the return values will be 'AxisXinY'
205
- * @param {String} planeName Value between 'X', 'Y' and 'Z'
206
- * @param {String} rotatedPlaneName Value between 'X', 'Y' and 'Z'
207
- * @returns {String}
208
- */
209
-
210
- function getLineNameFromPlaneAndRotatedPlaneName(planeName, rotatedPlaneName) {
211
- return "Axis".concat(planeName, "in").concat(rotatedPlaneName);
212
- }
213
- /**
214
- * Extract the plane name from the line name
215
- * Example: 'AxisXinY' will return 'X'
216
- * @param {String} lineName Should be following this template : 'Axis_in_' with _ a character
217
- * @returns {String} Value between 'X', 'Y' and 'Z' or null if an error occured
218
- */
219
-
220
- function getPlaneNameFromLineName(lineName) {
221
- var match = lineName.match('([XYZ])in[XYZ]');
222
-
223
- if (match) {
224
- return match[1];
225
- }
226
-
227
- return null;
228
- }
229
- /**
230
- * Get the orthogonal plane name of 'planeName' in a specific 'rotatedPlaneName'
231
- * Example: planeName='X' on rotatedPlaneName='Z', then the associated plane name
232
- * of 'X' plane is 'Y'
233
- * @param {String} planeName
234
- * @param {String} rotatedPlaneName
235
- */
236
-
237
- function getAssociatedPlaneName(planeName, rotatedPlaneName) {
238
- var lineName = getLineNameFromPlaneAndRotatedPlaneName(planeName, rotatedPlaneName);
239
- var associatedLine = getAssociatedLinesName(lineName);
240
- return getPlaneNameFromLineName(associatedLine);
241
234
  }
242
235
 
243
- export { boundPlane, boundPoint, boundPointOnPlane, getAssociatedLinesName, getAssociatedPlaneName, getLineNameFromPlaneAndRotatedPlaneName, getPlaneNameFromLineName, rotateVector, transformPlane, updateState };
236
+ export { boundPlane, boundPoint, boundPointOnPlane, getLineInPlaneName, getLinePlaneName, getOtherLineName, rotateVector, transformPlane, updateState };
@@ -1,184 +1,25 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import vtkStateBuilder from '../../Core/StateBuilder.js';
3
- import { ScrollingMethods } from './Constants.js';
3
+ import { ScrollingMethods, planeNames } from './Constants.js';
4
4
  import { ViewTypes } from '../../Core/WidgetManager/Constants.js';
5
5
 
6
- var factor = 1;
7
- var axisXColor = [1, 0, 0];
8
- var axisYColor = [0, 1, 0];
9
- var axisZColor = [0, 0, 1];
6
+ var viewsColor3 = {
7
+ X: [255, 0, 0],
8
+ // red
9
+ Y: [0, 255, 0],
10
+ // green
11
+ Z: [0, 0, 255] // blue
10
12
 
11
- var generateAxisXinY = function generateAxisXinY() {
12
- return vtkStateBuilder.createBuilder().addField({
13
- name: 'point1',
14
- initialValue: [0, 0, -factor]
15
- }).addField({
16
- name: 'point2',
17
- initialValue: [0, 0, factor]
18
- }).addField({
19
- name: 'color',
20
- initialValue: axisXColor
21
- }).addField({
22
- name: 'name',
23
- initialValue: 'AxisXinY'
24
- }).addField({
25
- name: 'viewType',
26
- initialValue: ViewTypes.YZ_PLANE
27
- }).addField({
28
- name: 'inViewType',
29
- initialValue: ViewTypes.XZ_PLANE
30
- }).build();
31
- };
32
-
33
- var generateAxisXinZ = function generateAxisXinZ() {
34
- return vtkStateBuilder.createBuilder().addField({
35
- name: 'point1',
36
- initialValue: [0, -factor, 0]
37
- }).addField({
38
- name: 'point2',
39
- initialValue: [0, factor, 0]
40
- }).addField({
41
- name: 'color',
42
- initialValue: axisXColor
43
- }).addField({
44
- name: 'name',
45
- initialValue: 'AxisXinZ'
46
- }).addField({
47
- name: 'viewType',
48
- initialValue: ViewTypes.YZ_PLANE
49
- }).addField({
50
- name: 'inViewType',
51
- initialValue: ViewTypes.XY_PLANE
52
- }).build();
53
- };
54
-
55
- var generateAxisYinX = function generateAxisYinX() {
56
- return vtkStateBuilder.createBuilder().addField({
57
- name: 'point1',
58
- initialValue: [0, 0, -factor]
59
- }).addField({
60
- name: 'point2',
61
- initialValue: [0, 0, factor]
62
- }).addField({
63
- name: 'color',
64
- initialValue: axisYColor
65
- }).addField({
66
- name: 'name',
67
- initialValue: 'AxisYinX'
68
- }).addField({
69
- name: 'viewType',
70
- initialValue: ViewTypes.XZ_PLANE
71
- }).addField({
72
- name: 'inViewType',
73
- initialValue: ViewTypes.YZ_PLANE
74
- }).build();
75
- };
76
-
77
- var generateAxisYinZ = function generateAxisYinZ() {
78
- return vtkStateBuilder.createBuilder().addField({
79
- name: 'point1',
80
- initialValue: [-factor, 0, 0]
81
- }).addField({
82
- name: 'point2',
83
- initialValue: [factor, 0, 0]
84
- }).addField({
85
- name: 'color',
86
- initialValue: axisYColor
87
- }).addField({
88
- name: 'name',
89
- initialValue: 'AxisYinZ'
90
- }).addField({
91
- name: 'viewType',
92
- initialValue: ViewTypes.XZ_PLANE
93
- }).addField({
94
- name: 'inViewType',
95
- initialValue: ViewTypes.XY_PLANE
96
- }).build();
97
- };
98
-
99
- var generateAxisZinX = function generateAxisZinX() {
100
- return vtkStateBuilder.createBuilder().addField({
101
- name: 'point1',
102
- initialValue: [0, -factor, 0]
103
- }).addField({
104
- name: 'point2',
105
- initialValue: [0, factor, 0]
106
- }).addField({
107
- name: 'color',
108
- initialValue: axisZColor
109
- }).addField({
110
- name: 'name',
111
- initialValue: 'AxisZinX'
112
- }).addField({
113
- name: 'viewType',
114
- initialValue: ViewTypes.XY_PLANE
115
- }).addField({
116
- name: 'inViewType',
117
- initialValue: ViewTypes.YZ_PLANE
118
- }).build();
119
- };
120
-
121
- var generateAxisZinY = function generateAxisZinY() {
122
- return vtkStateBuilder.createBuilder().addField({
123
- name: 'point1',
124
- initialValue: [-factor, 0, 0]
125
- }).addField({
126
- name: 'point2',
127
- initialValue: [factor, 0, 0]
128
- }).addField({
129
- name: 'color',
130
- initialValue: axisZColor
131
- }).addField({
132
- name: 'name',
133
- initialValue: 'AxisZinY'
134
- }).addField({
135
- name: 'viewType',
136
- initialValue: ViewTypes.XY_PLANE
137
- }).addField({
138
- name: 'inViewType',
139
- initialValue: ViewTypes.XZ_PLANE
140
- }).build();
141
13
  };
142
-
143
14
  function generateState() {
144
15
  var _initialValue;
145
16
 
146
- return vtkStateBuilder.createBuilder().addStateFromInstance({
147
- labels: ['AxisXinY'],
148
- name: 'AxisXinY',
149
- instance: generateAxisXinY()
150
- }).addStateFromInstance({
151
- labels: ['AxisXinZ'],
152
- name: 'AxisXinZ',
153
- instance: generateAxisXinZ()
154
- }).addStateFromInstance({
155
- labels: ['AxisYinX'],
156
- name: 'AxisYinX',
157
- instance: generateAxisYinX()
158
- }).addStateFromInstance({
159
- labels: ['AxisYinZ'],
160
- name: 'AxisYinZ',
161
- instance: generateAxisYinZ()
162
- }).addStateFromInstance({
163
- labels: ['AxisZinX'],
164
- name: 'AxisZinX',
165
- instance: generateAxisZinX()
166
- }).addStateFromInstance({
167
- labels: ['AxisZinY'],
168
- name: 'AxisZinY',
169
- instance: generateAxisZinY()
170
- }).addField({
17
+ var state = vtkStateBuilder.createBuilder().addField({
171
18
  name: 'center',
172
19
  initialValue: [0, 0, 0]
173
20
  }).addField({
174
21
  name: 'opacity',
175
22
  initialValue: 1
176
- }).addField({
177
- name: 'activeLineState',
178
- initialValue: null
179
- }).addField({
180
- name: 'activeRotationPointName',
181
- initialValue: ''
182
23
  }).addField({
183
24
  name: 'image',
184
25
  initialValue: null
@@ -194,8 +35,6 @@ function generateState() {
194
35
  }).addField({
195
36
  name: 'showCenter',
196
37
  initialValue: true
197
- }).addField({
198
- name: 'updateMethodName'
199
38
  }).addField({
200
39
  name: 'planes',
201
40
  initialValue: (_initialValue = {}, _defineProperty(_initialValue, ViewTypes.YZ_PLANE, {
@@ -226,7 +65,47 @@ function generateState() {
226
65
  }).addField({
227
66
  name: 'viewUpFromViewType',
228
67
  initialValue: {}
229
- }).build();
68
+ }).addStateFromMixin({
69
+ labels: ['handles', 'center'],
70
+ mixins: ['origin', 'color3', 'scale1', 'visible', 'manipulator'],
71
+ name: 'centerHandle',
72
+ initialValues: {
73
+ scale1: 30,
74
+ color3: [255, 255, 255]
75
+ }
76
+ });
77
+ planeNames.reduce(function (viewState, view) {
78
+ return planeNames.filter(function (v) {
79
+ return v !== view;
80
+ }).reduce(function (axisState, axis) {
81
+ // Line handle
82
+ axisState.addStateFromMixin({
83
+ labels: ['handles', 'line', "lineIn".concat(view), "".concat(axis, "in").concat(view)],
84
+ mixins: ['origin', 'color3', 'scale3', // scale3[2] will be automatically overwritten
85
+ 'orientation', 'visible', 'manipulator'],
86
+ name: "axis".concat(axis, "in").concat(view),
87
+ initialValues: {
88
+ scale3: [4, 4, 4],
89
+ color3: viewsColor3[axis]
90
+ }
91
+ }); // Rotation handle
92
+
93
+ for (var rotationHandle = 0; rotationHandle < 2; ++rotationHandle) {
94
+ axisState.addStateFromMixin({
95
+ labels: ['handles', 'rotation', "rotationIn".concat(view), "".concat(axis, "in").concat(view), "point".concat(rotationHandle)],
96
+ mixins: ['origin', 'color3', 'scale1', 'visible', 'manipulator'],
97
+ name: "rotationHandle".concat(axis, "in").concat(view).concat(rotationHandle),
98
+ initialValues: {
99
+ scale1: 30,
100
+ color3: viewsColor3[axis]
101
+ }
102
+ });
103
+ }
104
+
105
+ return axisState;
106
+ }, viewState);
107
+ }, state);
108
+ return state.build();
230
109
  }
231
110
 
232
111
  export { generateState as default };
@@ -4,7 +4,8 @@ import macro from '../../macros.js';
4
4
  import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
5
5
  import vtkPlane from '../../Common/DataModel/Plane.js';
6
6
  import vtkPlaneSource from '../../Filters/Sources/PlaneSource.js';
7
- import vtkResliceCursorContextRepresentation from '../Representations/ResliceCursorContextRepresentation.js';
7
+ import vtkLineHandleRepresentation from '../Representations/LineHandleRepresentation.js';
8
+ import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
8
9
  import { f as distance2BetweenPoints, o as multiplyAccumulate, s as subtract, m as normalize, x as multiplyScalar, l as add } from '../../Common/Core/Math/index.js';
9
10
  import widgetBehavior from './ResliceCursorWidget/behavior.js';
10
11
  import generateState from './ResliceCursorWidget/state.js';
@@ -23,7 +24,7 @@ var vtkErrorMacro = macro.vtkErrorMacro; // ------------------------------------
23
24
 
24
25
  function vtkResliceCursorWidget(publicAPI, model) {
25
26
  model.classHierarchy.push('vtkResliceCursorWidget');
26
- model.methodsToLink = ['scaleInPixels', 'rotationHandlePosition']; // --------------------------------------------------------------------------
27
+ model.methodsToLink = ['scaleInPixels']; // --------------------------------------------------------------------------
27
28
  // Private methods
28
29
  // --------------------------------------------------------------------------
29
30
 
@@ -135,6 +136,23 @@ function vtkResliceCursorWidget(publicAPI, model) {
135
136
  }
136
137
 
137
138
  renderer.resetCameraClippingRange(bounds);
139
+ }
140
+ /**
141
+ * Convenient function to return the ResliceCursorRepresentation for a given viewType
142
+ * @param {string} viewType
143
+ * @returns
144
+ */
145
+
146
+
147
+ function findRepresentationsForViewType(viewType) {
148
+ var widgetForViewType = publicAPI.getViewIds().map(function (viewId) {
149
+ return publicAPI.getWidgetForView({
150
+ viewId: viewId
151
+ });
152
+ }).find(function (widget) {
153
+ return widget.getViewType() === viewType;
154
+ });
155
+ return widgetForViewType.getRepresentations();
138
156
  } // --------------------------------------------------------------------------
139
157
  // initialization
140
158
  // --------------------------------------------------------------------------
@@ -144,37 +162,46 @@ function vtkResliceCursorWidget(publicAPI, model) {
144
162
  switch (viewType) {
145
163
  case ViewTypes.XY_PLANE:
146
164
  return [{
147
- builder: vtkResliceCursorContextRepresentation,
148
- labels: ['AxisXinZ', 'AxisYinZ'],
165
+ builder: vtkLineHandleRepresentation,
166
+ labels: ['lineInZ'],
167
+ initialValues: {
168
+ useActiveColor: false
169
+ }
170
+ }, {
171
+ builder: vtkSphereHandleRepresentation,
172
+ labels: ['rotationInZ', 'center'],
149
173
  initialValues: {
150
- axis1Name: 'AxisXinZ',
151
- axis2Name: 'AxisYinZ',
152
- viewType: ViewTypes.XY_PLANE,
153
- rotationEnabled: model.widgetState.getEnableRotation()
174
+ useActiveColor: false
154
175
  }
155
176
  }];
156
177
 
157
178
  case ViewTypes.XZ_PLANE:
158
179
  return [{
159
- builder: vtkResliceCursorContextRepresentation,
160
- labels: ['AxisXinY', 'AxisZinY'],
180
+ builder: vtkLineHandleRepresentation,
181
+ labels: ['lineInY'],
161
182
  initialValues: {
162
- axis1Name: 'AxisXinY',
163
- axis2Name: 'AxisZinY',
164
- viewType: ViewTypes.XZ_PLANE,
165
- rotationEnabled: model.widgetState.getEnableRotation()
183
+ useActiveColor: false
184
+ }
185
+ }, {
186
+ builder: vtkSphereHandleRepresentation,
187
+ labels: ['rotationInY', 'center'],
188
+ initialValues: {
189
+ useActiveColor: false
166
190
  }
167
191
  }];
168
192
 
169
193
  case ViewTypes.YZ_PLANE:
170
194
  return [{
171
- builder: vtkResliceCursorContextRepresentation,
172
- labels: ['AxisYinX', 'AxisZinX'],
195
+ builder: vtkLineHandleRepresentation,
196
+ labels: ['lineInX'],
197
+ initialValues: {
198
+ useActiveColor: false
199
+ }
200
+ }, {
201
+ builder: vtkSphereHandleRepresentation,
202
+ labels: ['rotationInX', 'center'],
173
203
  initialValues: {
174
- axis1Name: 'AxisYinX',
175
- axis2Name: 'AxisZinX',
176
- viewType: ViewTypes.YZ_PLANE,
177
- rotationEnabled: model.widgetState.getEnableRotation()
204
+ useActiveColor: false
178
205
  }
179
206
  }];
180
207
 
@@ -191,12 +218,12 @@ function vtkResliceCursorWidget(publicAPI, model) {
191
218
  model.widgetState.setImage(image);
192
219
  var center = image.getCenter();
193
220
  model.widgetState.setCenter(center);
194
- updateState(model.widgetState);
221
+ updateState(model.widgetState, publicAPI.getDisplayScaleParams(), model.rotationHandlePosition);
195
222
  };
196
223
 
197
224
  publicAPI.setCenter = function (center) {
198
225
  model.widgetState.setCenter(center);
199
- updateState(model.widgetState);
226
+ updateState(model.widgetState, publicAPI.getDisplayScaleParams(), model.rotationHandlePosition);
200
227
  publicAPI.modified();
201
228
  }; // --------------------------------------------------------------------------
202
229
  // Methods
@@ -398,13 +425,23 @@ function vtkResliceCursorWidget(publicAPI, model) {
398
425
 
399
426
  return m;
400
427
  };
428
+
429
+ publicAPI.getDisplayScaleParams = function () {
430
+ return [ViewTypes.YZ_PLANE, ViewTypes.XZ_PLANE, ViewTypes.XY_PLANE].reduce(function (res, viewType) {
431
+ var _findRepresentationsF, _findRepresentationsF2;
432
+
433
+ res[viewType] = (_findRepresentationsF = (_findRepresentationsF2 = findRepresentationsForViewType(viewType)[0]).getDisplayScaleParams) === null || _findRepresentationsF === void 0 ? void 0 : _findRepresentationsF.call(_findRepresentationsF2);
434
+ return res;
435
+ }, {});
436
+ };
401
437
  } // ----------------------------------------------------------------------------
402
438
 
403
439
 
404
440
  var defaultValues = function defaultValues(initialValues) {
405
441
  return _objectSpread({
406
442
  behavior: widgetBehavior,
407
- widgetState: generateState()
443
+ widgetState: generateState(),
444
+ rotationHandlePosition: 0.25
408
445
  }, initialValues);
409
446
  }; // ----------------------------------------------------------------------------
410
447
 
@@ -413,6 +450,7 @@ function extend(publicAPI, model) {
413
450
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
414
451
  Object.assign(model, defaultValues(initialValues));
415
452
  vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
453
+ macro.setGet(publicAPI, model, ['rotationHandlePosition']);
416
454
  vtkResliceCursorWidget(publicAPI, model);
417
455
  } // ----------------------------------------------------------------------------
418
456
 
package/index.d.ts CHANGED
@@ -174,7 +174,6 @@
174
174
  /// <reference path="./Widgets/Manipulators/LineManipulator.d.ts" />
175
175
  /// <reference path="./Widgets/Manipulators/PlaneManipulator.d.ts" />
176
176
  /// <reference path="./Widgets/Manipulators/TrackballManipulator.d.ts" />
177
- /// <reference path="./Widgets/Representations/ResliceCursorContextRepresentation.d.ts" />
178
177
  /// <reference path="./Widgets/Representations/WidgetRepresentation.d.ts" />
179
178
  /// <reference path="./Widgets/Widgets3D/InteractiveOrientationWidget.d.ts" />
180
179
  /// <reference path="./Widgets/Widgets3D/SphereWidget.d.ts" />
package/macros.d.ts CHANGED
@@ -172,19 +172,17 @@ export function get(publicAPI: object, model: object, fieldNames: Array<string>)
172
172
  * @param publicAPI object on which public methods get attached to
173
173
  * @param model object on which protected fields are stored
174
174
  * @param fieldNames list of fields available in model that we want to expose as set{FieldName} methods on the publicAPI
175
- * * Can be a string (the name of the field to expose) or an object (e.g. {type:enum, name: {FieldName}, enum: FieldEnum}).
176
175
  */
177
- export function set(publicAPI: object, model: object, fields: Array<string|object>): void;
176
+ export function set(publicAPI: object, model: object, fields: Array<string>): void;
178
177
 
179
178
  /**
180
179
  * Add setter+getter methods to the provided publicAPI
181
180
  *
182
181
  * @param publicAPI object on which public methods get attached to
183
182
  * @param model object on which protected fields are stored
184
- * @param fieldNames list of fields available in model that we want to expose as set{FieldName}+get{FieldName} methods on the publicAPI.
185
- * Can be a string (the name of the field to expose) or an object (e.g. {type:enum, name: {FieldName}, enum: FieldEnum}).
183
+ * @param fieldNames list of fields available in model that we want to expose as set{FieldName}+get{FieldName} methods on the publicAPI
186
184
  */
187
- export function setGet(publicAPI: object, model: object, fields: Array<string|object>): void;
185
+ export function setGet(publicAPI: object, model: object, fields: Array<string>): void;
188
186
 
189
187
  /**
190
188
  * Add getter methods to the provided publicAPI for arrays.