@kitware/vtk.js 23.4.0 → 24.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 (152) 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/BoundingBox.js +3 -8
  6. package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
  7. package/Common/DataModel/ITKHelper.js +2 -346
  8. package/Common/DataModel/ImageData.d.ts +23 -6
  9. package/Common/DataModel/ImageData.js +8 -1
  10. package/Common/DataModel/PolyData.d.ts +8 -1
  11. package/Common/DataModel/PolyData.js +5 -3
  12. package/Common/DataModel/Triangle.js +217 -2
  13. package/Common/Transform/LandmarkTransform.js +1 -1
  14. package/Filters/General/OBBTree/OBBNode.js +82 -0
  15. package/Filters/General/OBBTree/helper.js +92 -0
  16. package/Filters/General/OBBTree.js +1249 -0
  17. package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
  18. package/Filters/General.js +2 -0
  19. package/Filters/Sources/CircleSource.js +1 -1
  20. package/Filters/Sources/PointSource.js +1 -1
  21. package/Filters/Texture/TextureMapToPlane.js +1 -1
  22. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  23. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  24. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  25. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  26. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  27. package/Interaction/Style/InteractorStyleImage.js +3 -3
  28. package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
  29. package/Interaction/Style/InteractorStyleManipulator.js +42 -28
  30. package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
  31. package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
  32. package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
  33. package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
  34. package/Interaction/Widgets.js +1 -35
  35. package/Proxy/Core/View2DProxy.js +1 -1
  36. package/Rendering/Core/ColorTransferFunction.js +1 -1
  37. package/Rendering/Core/Coordinate.js +1 -1
  38. package/Rendering/Core/CubeAxesActor.js +1 -1
  39. package/Rendering/Core/Glyph3DMapper.js +1 -1
  40. package/Rendering/Core/ImageMapper.js +1 -1
  41. package/Rendering/Core/InteractorObserver.js +11 -10
  42. package/Rendering/Core/InteractorStyle.js +9 -4
  43. package/Rendering/Core/Mapper.js +1 -1
  44. package/Rendering/Core/Prop.js +6 -4
  45. package/Rendering/Core/Prop3D.js +1 -1
  46. package/Rendering/Core/RenderWindowInteractor.js +24 -17
  47. package/Rendering/Core/Renderer.js +24 -19
  48. package/Rendering/Core/ScalarBarActor.js +1 -1
  49. package/Rendering/Core/Viewport.js +1 -1
  50. package/Rendering/Core/VolumeMapper.js +1 -1
  51. package/Rendering/OpenGL/Actor.js +2 -2
  52. package/Rendering/OpenGL/Actor2D.js +2 -2
  53. package/Rendering/OpenGL/BufferObject.js +6 -5
  54. package/Rendering/OpenGL/Camera.js +3 -3
  55. package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
  56. package/Rendering/OpenGL/Framebuffer.js +13 -12
  57. package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
  58. package/Rendering/OpenGL/HardwareSelector.js +35 -25
  59. package/Rendering/OpenGL/ImageMapper.js +51 -45
  60. package/Rendering/OpenGL/ImageSlice.js +2 -2
  61. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
  62. package/Rendering/OpenGL/PolyDataMapper.js +14 -11
  63. package/Rendering/OpenGL/PolyDataMapper2D.js +17 -16
  64. package/Rendering/OpenGL/Renderer.js +11 -7
  65. package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
  66. package/Rendering/OpenGL/ScalarBarActor.js +2 -2
  67. package/Rendering/OpenGL/ShaderCache.js +7 -5
  68. package/Rendering/OpenGL/Skybox.js +11 -9
  69. package/Rendering/OpenGL/SphereMapper.js +2 -2
  70. package/Rendering/OpenGL/StickMapper.js +2 -2
  71. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
  72. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
  73. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
  74. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
  75. package/Rendering/OpenGL/Texture.js +44 -31
  76. package/Rendering/OpenGL/VertexArrayObject.js +7 -7
  77. package/Rendering/OpenGL/Volume.js +3 -2
  78. package/Rendering/OpenGL/VolumeMapper.js +30 -26
  79. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  80. package/Rendering/SceneGraph/ViewNode.js +8 -7
  81. package/Rendering/WebGPU/Renderer.js +18 -10
  82. package/Widgets/Core/AbstractWidget.js +5 -4
  83. package/Widgets/Core/AbstractWidgetFactory.js +2 -1
  84. package/Widgets/Core/WidgetManager.js +66 -49
  85. package/Widgets/Manipulators/LineManipulator.js +1 -1
  86. package/Widgets/Representations/CircleContextRepresentation.js +1 -1
  87. package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
  88. package/Widgets/Representations/PolyLineRepresentation.js +1 -1
  89. package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
  90. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
  91. package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
  92. package/Widgets/SVG/SVGRepresentation.js +1 -1
  93. package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
  94. package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
  95. package/Widgets/Widgets3D/EllipseWidget.js +0 -1
  96. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
  97. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
  98. package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
  99. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  100. package/Widgets/Widgets3D/LabelWidget.js +79 -0
  101. package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
  102. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  103. package/Widgets/Widgets3D/LineWidget.js +0 -1
  104. package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
  105. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
  106. package/Widgets/Widgets3D/RectangleWidget.js +0 -1
  107. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  108. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  109. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  110. package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
  111. package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
  112. package/index.d.ts +3 -4
  113. package/interfaces.d.ts +11 -0
  114. package/macros.d.ts +26 -1
  115. package/macros.js +51 -19
  116. package/package.json +1 -1
  117. package/types.d.ts +1 -0
  118. package/Interaction/Widgets/AbstractWidget.js +0 -104
  119. package/Interaction/Widgets/DistanceRepresentation.js +0 -116
  120. package/Interaction/Widgets/DistanceWidget.js +0 -77
  121. package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
  122. package/Interaction/Widgets/HandleRepresentation.js +0 -100
  123. package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
  124. package/Interaction/Widgets/HandleWidget.js +0 -194
  125. package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
  126. package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
  127. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
  128. package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
  129. package/Interaction/Widgets/LabelRepresentation.js +0 -325
  130. package/Interaction/Widgets/LabelWidget.js +0 -65
  131. package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
  132. package/Interaction/Widgets/LineRepresentation.js +0 -498
  133. package/Interaction/Widgets/LineWidget/Constants.js +0 -11
  134. package/Interaction/Widgets/LineWidget.js +0 -296
  135. package/Interaction/Widgets/PointPlacer.js +0 -51
  136. package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
  137. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
  138. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
  139. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
  140. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
  141. package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
  142. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
  143. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
  144. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
  145. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
  146. package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
  147. package/Interaction/Widgets/WidgetRepresentation.js +0 -121
  148. package/Widgets/Representations/SphereContextRepresentation.js +0 -131
  149. package/Widgets/Widgets3D/SphereWidget/behavior.js +0 -177
  150. package/Widgets/Widgets3D/SphereWidget/state.js +0 -45
  151. package/Widgets/Widgets3D/SphereWidget.d.ts +0 -50
  152. package/Widgets/Widgets3D/SphereWidget.js +0 -62
@@ -1,371 +0,0 @@
1
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
- import macro from '../../../macros.js';
3
- import { mat4, vec4 } from 'gl-matrix';
4
- import vtkImageMapper from '../../../Rendering/Core/ImageMapper.js';
5
- import vtkImageReslice from '../../../Imaging/Core/ImageReslice.js';
6
- import vtkImageSlice from '../../../Rendering/Core/ImageSlice.js';
7
- import { k as add, g as subtract, l as normalize } from '../../../Common/Core/Math/index.js';
8
- import vtkPlaneSource from '../../../Filters/Sources/PlaneSource.js';
9
- import vtkWidgetRepresentation from '../WidgetRepresentation.js';
10
- import { transformPlane, boundPlane } from '../../../Widgets/Widgets3D/ResliceCursorWidget/helpers.js';
11
-
12
- var vtkErrorMacro = macro.vtkErrorMacro;
13
- var VTK_INT_MAX = 2147483647; // ----------------------------------------------------------------------------
14
- // vtkResliceCursorRepresentation methods
15
- // ----------------------------------------------------------------------------
16
-
17
- function vtkResliceCursorRepresentation(publicAPI, model) {
18
- // Set our className
19
- model.classHierarchy.push('vtkResliceCursorRepresentation');
20
- var buildTime = {};
21
- macro.obj(buildTime); //----------------------------------------------------------------------------
22
- // Public API methods
23
- //----------------------------------------------------------------------------
24
-
25
- publicAPI.getResliceCursor = function () {};
26
-
27
- publicAPI.getCursorAlgorithm = function () {};
28
-
29
- publicAPI.createDefaultResliceAlgorithm = function () {
30
- if (!model.reslice) {
31
- model.reslice = vtkImageReslice.newInstance();
32
- model.reslice.setTransformInputSampling(false);
33
- model.reslice.setAutoCropOutput(true);
34
- model.reslice.setOutputDimensionality(2);
35
- }
36
- };
37
-
38
- publicAPI.buildRepresentation = function () {
39
- if (publicAPI.getResliceCursor()) {
40
- var image = publicAPI.getResliceCursor().getImage();
41
-
42
- if (image) {
43
- model.reslice.setInputData(image);
44
- model.imageActor.setVisibility(model.showReslicedImage);
45
- var modifiedTime = Math.max(publicAPI.getMTime(), publicAPI.getResliceCursor().getMTime());
46
-
47
- if (buildTime.getMTime() < modifiedTime) {
48
- publicAPI.updateReslicePlane();
49
- }
50
- } else {
51
- model.imageActor.setVisibility(false);
52
- }
53
- }
54
- };
55
-
56
- publicAPI.computeReslicePlaneOrigin = function () {
57
- var resliceCursor = publicAPI.getResliceCursor();
58
- var bounds = resliceCursor.getImage().getBounds();
59
- var center = resliceCursor.getCenter();
60
- var imageCenter = resliceCursor.getImage().getCenter(); // Offset based on the center of the image and how far from it the
61
- // reslice cursor is. This allows us to capture the whole image even
62
- // if we resliced in awkward places.
63
-
64
- var offset = [];
65
-
66
- for (var i = 0; i < 3; i++) {
67
- offset[i] = -Math.abs(center[i] - imageCenter[i]);
68
- offset[i] *= 2; // give us room
69
- } // Now resize the plane based on these offsets.
70
-
71
-
72
- var planeOrientation = publicAPI.getCursorAlgorithm().getReslicePlaneNormal(); // Now set the size of the plane based on the location of the cursor so as to
73
- // at least completely cover the viewed region
74
-
75
- if (planeOrientation === 1) {
76
- model.planeSource.setOrigin(bounds[0] + offset[0], center[1], bounds[4] + offset[2]);
77
- model.planeSource.setPoint1(bounds[1] - offset[0], center[1], bounds[4] + offset[2]);
78
- model.planeSource.setPoint2(bounds[0] + offset[0], center[1], bounds[5] - offset[2]);
79
- } else if (planeOrientation === 2) {
80
- model.planeSource.setOrigin(bounds[0] + offset[0], bounds[2] + offset[1], center[2]);
81
- model.planeSource.setPoint1(bounds[1] - offset[0], bounds[2] + offset[1], center[2]);
82
- model.planeSource.setPoint2(bounds[0] + offset[0], bounds[3] - offset[1], center[2]);
83
- } else if (planeOrientation === 0) {
84
- model.planeSource.setOrigin(center[0], bounds[2] + offset[1], bounds[4] + offset[2]);
85
- model.planeSource.setPoint1(center[0], bounds[3] - offset[1], bounds[4] + offset[2]);
86
- model.planeSource.setPoint2(center[0], bounds[2] + offset[1], bounds[5] - offset[2]);
87
- }
88
- };
89
-
90
- publicAPI.resetCamera = function () {
91
- if (model.renderer) {
92
- var center = publicAPI.getResliceCursor().getCenter();
93
- model.renderer.getActiveCamera().setFocalPoint(center[0], center[1], center[2]);
94
- var normalAxis = publicAPI.getCursorAlgorithm().getReslicePlaneNormal();
95
- var normal = publicAPI.getResliceCursor().getPlane(normalAxis).getNormal();
96
- var cameraPosition = [];
97
- add(center, normal, cameraPosition);
98
- model.renderer.getActiveCamera().setPosition(cameraPosition[0], cameraPosition[1], cameraPosition[2]);
99
- model.renderer.resetCamera();
100
- model.renderer.resetCameraClippingRange();
101
- }
102
- };
103
-
104
- publicAPI.initializeReslicePlane = function () {
105
- if (!publicAPI.getResliceCursor().getImage()) {
106
- return;
107
- } // Initialize the reslice plane origins. Offset should be zero within
108
- // this function here.
109
-
110
-
111
- publicAPI.computeReslicePlaneOrigin(); // Finally reset the camera to whatever orientation they were staring in
112
-
113
- publicAPI.resetCamera();
114
- };
115
-
116
- publicAPI.updateReslicePlane = function () {
117
- if (!publicAPI.getResliceCursor().getImage() || !model.imageActor.getVisibility()) {
118
- return;
119
- } // Reinitialize the reslice plane.. We will recompute everything here.
120
-
121
-
122
- if (!model.planeInitialized) {
123
- publicAPI.initializeReslicePlane();
124
- model.planeInitialized = true;
125
- } // Calculate appropriate pixel spacing for the reslicing
126
-
127
-
128
- var spacing = publicAPI.getResliceCursor().getImage().getSpacing();
129
- var planeNormalType = publicAPI.getCursorAlgorithm().getReslicePlaneNormal();
130
- var plane = publicAPI.getResliceCursor().getPlane(planeNormalType); // Compute the origin of the reslice plane prior to transformations.
131
-
132
- publicAPI.computeReslicePlaneOrigin(); // Compute view up to configure camera later on
133
-
134
- var viewUp = publicAPI.getResliceCursor().getViewUp(planeNormalType);
135
- transformPlane(model.planeSource, publicAPI.getResliceCursor().getCenter(), plane.getNormal(), viewUp);
136
-
137
- var boundedOrigin = _toConsumableArray(model.planeSource.getOrigin());
138
-
139
- var boundedP1 = _toConsumableArray(model.planeSource.getPoint1());
140
-
141
- var boundedP2 = _toConsumableArray(model.planeSource.getPoint2());
142
-
143
- boundPlane(publicAPI.getResliceCursor().getImage().getBounds(), boundedOrigin, boundedP1, boundedP2);
144
- model.planeSource.setOrigin(boundedOrigin);
145
- model.planeSource.setPoint1(boundedP1[0], boundedP1[1], boundedP1[2]);
146
- model.planeSource.setPoint2(boundedP2[0], boundedP2[1], boundedP2[2]);
147
- var o = model.planeSource.getOrigin();
148
- var p1 = model.planeSource.getPoint1();
149
- var planeAxis1 = [];
150
- subtract(p1, o, planeAxis1);
151
- var p2 = model.planeSource.getPoint2();
152
- var planeAxis2 = [];
153
- subtract(p2, o, planeAxis2); // The x,y dimensions of the plane
154
-
155
- var planeSizeX = normalize(planeAxis1);
156
- var planeSizeY = normalize(planeAxis2);
157
- var normal = model.planeSource.getNormal();
158
- mat4.identity(model.newResliceAxes);
159
-
160
- for (var i = 0; i < 3; i++) {
161
- model.newResliceAxes[4 * i + 0] = planeAxis1[i];
162
- model.newResliceAxes[4 * i + 1] = planeAxis2[i];
163
- model.newResliceAxes[4 * i + 2] = normal[i];
164
- }
165
-
166
- var spacingX = Math.abs(planeAxis1[0] * spacing[0]) + Math.abs(planeAxis1[1] * spacing[1]) + Math.abs(planeAxis1[2] * spacing[2]);
167
- var spacingY = Math.abs(planeAxis2[0] * spacing[0]) + Math.abs(planeAxis2[1] * spacing[1]) + Math.abs(planeAxis2[2] * spacing[2]);
168
- var planeOrigin = [].concat(_toConsumableArray(model.planeSource.getOrigin()), [1.0]);
169
- var originXYZW = [];
170
- var newOriginXYZW = [];
171
- vec4.transformMat4(originXYZW, planeOrigin, model.newResliceAxes);
172
- mat4.transpose(model.newResliceAxes, model.newResliceAxes);
173
- vec4.transformMat4(newOriginXYZW, originXYZW, model.newResliceAxes);
174
- model.newResliceAxes[4 * 3 + 0] = newOriginXYZW[0];
175
- model.newResliceAxes[4 * 3 + 1] = newOriginXYZW[1];
176
- model.newResliceAxes[4 * 3 + 2] = newOriginXYZW[2]; // Compute a new set of resliced extents
177
-
178
- var extentX = 0;
179
- var extentY = 0; // Pad extent up to a power of two for efficient texture mapping
180
- // make sure we're working with valid values
181
-
182
- var realExtentX = spacingX === 0 ? Number.MAX_SAFE_INTEGER : planeSizeX / spacingX; // Sanity check the input data:
183
- // * if realExtentX is too large, extentX will wrap
184
- // * if spacingX is 0, things will blow up.
185
-
186
- var value = VTK_INT_MAX >> 1; // eslint-disable-line no-bitwise
187
-
188
- if (realExtentX > value) {
189
- vtkErrorMacro('Invalid X extent: ', realExtentX);
190
- extentX = 0;
191
- } else {
192
- extentX = 1;
193
-
194
- while (extentX < realExtentX) {
195
- extentX <<= 1; // eslint-disable-line no-bitwise
196
- }
197
- } // make sure extentY doesn't wrap during padding
198
-
199
-
200
- var realExtentY = spacingY === 0 ? Number.MAX_SAFE_INTEGER : planeSizeY / spacingY;
201
-
202
- if (realExtentY > value) {
203
- vtkErrorMacro('Invalid Y extent:', realExtentY);
204
- extentY = 0;
205
- } else {
206
- extentY = 1;
207
-
208
- while (extentY < realExtentY) {
209
- extentY <<= 1; // eslint-disable-line no-bitwise
210
- }
211
- }
212
-
213
- var outputSpacingX = extentX === 0 ? 1.0 : planeSizeX / extentX;
214
- var outputSpacingY = extentY === 0 ? 1.0 : planeSizeY / extentY;
215
- var modify = false;
216
-
217
- for (var _i = 0; _i < 4; _i++) {
218
- for (var j = 0; j < 4; j++) {
219
- var index = 4 * j + _i;
220
- var d = model.newResliceAxes[index];
221
-
222
- if (d !== model.resliceAxes[index]) {
223
- model.resliceAxes[index] = d;
224
- modify = true;
225
- }
226
- }
227
- }
228
-
229
- if (modify) {
230
- publicAPI.setResliceParameters(outputSpacingX, outputSpacingY, extentX, extentY);
231
- publicAPI.modified();
232
- }
233
-
234
- buildTime.modified();
235
- publicAPI.resetCamera();
236
- };
237
-
238
- publicAPI.setResliceParameters = function (outputSpacingX, outputSpacingY, extentX, extentY) {
239
- if (model.reslice) {
240
- model.reslice.setResliceAxes(model.resliceAxes);
241
- model.reslice.setOutputSpacing([outputSpacingX, outputSpacingY, 1]);
242
- model.reslice.setOutputOrigin([0.5 * outputSpacingX, 0.5 * outputSpacingY, 0]);
243
- model.reslice.setOutputExtent([0, extentX - 1, 0, extentY - 1, 0, 0]);
244
- model.imageActor.setUserMatrix(model.resliceAxes);
245
- model.reslice.update();
246
- }
247
- };
248
-
249
- publicAPI.computeOrigin = function (matrix) {
250
- var center = publicAPI.getResliceCursor().getCenter();
251
- var centerTransformed = [];
252
- vec4.transformMat4(centerTransformed, center, matrix);
253
-
254
- for (var i = 0; i < 3; i++) {
255
- matrix[4 * 3 + i] = matrix[4 * 3 + i] + center[i] - centerTransformed[i];
256
- }
257
- };
258
-
259
- publicAPI.getActors = function () {
260
- return model.imageActor;
261
- };
262
-
263
- publicAPI.getNestedProps = function () {
264
- return publicAPI.getActors();
265
- };
266
- /**
267
- * t1 and t2 should be orthogonal and axis aligned
268
- */
269
-
270
-
271
- publicAPI.boundPoint = function (inPoint, t1, t2, outPoint) {
272
- if (!publicAPI.getResliceCursor()) {
273
- return;
274
- }
275
-
276
- var bounds = publicAPI.getResliceCursor().getImage().getBounds();
277
- var absT1 = t1.map(function (val) {
278
- return Math.abs(val);
279
- });
280
- var absT2 = t2.map(function (val) {
281
- return Math.abs(val);
282
- });
283
- var epsilon = 0.00001;
284
- var o1 = 0.0;
285
- var o2 = 0.0;
286
-
287
- for (var i = 0; i < 3; i++) {
288
- var axisOffset = 0;
289
- var useT1 = absT1[i] > absT2[i];
290
- var t = useT1 ? t1 : t2;
291
- var absT = useT1 ? absT1 : absT2;
292
-
293
- if (inPoint[i] < bounds[i * 2]) {
294
- axisOffset = absT[i] > epsilon ? (bounds[2 * i] - inPoint[i]) / t[i] : 0;
295
- } else if (inPoint[i] > bounds[2 * i + 1]) {
296
- axisOffset = absT[i] !== epsilon ? (bounds[2 * i + 1] - inPoint[i]) / t[i] : 0;
297
- }
298
-
299
- if (useT1) {
300
- if (Math.abs(axisOffset) > Math.abs(o1)) {
301
- o1 = axisOffset;
302
- }
303
- } else if (Math.abs(axisOffset) > Math.abs(o2)) {
304
- o2 = axisOffset;
305
- }
306
- }
307
-
308
- outPoint[0] = inPoint[0];
309
- outPoint[1] = inPoint[1];
310
- outPoint[2] = inPoint[2];
311
-
312
- if (o1 !== 0.0) {
313
- var translation = [];
314
- translation[0] = t1[0] * o1;
315
- translation[1] = t1[1] * o1;
316
- translation[2] = t1[2] * o1;
317
- add(outPoint, translation, outPoint);
318
- }
319
-
320
- if (o2 !== 0) {
321
- var _translation = [];
322
- _translation[0] = t2[0] * o2;
323
- _translation[1] = t2[1] * o2;
324
- _translation[2] = t2[2] * o2;
325
- add(outPoint, _translation, outPoint);
326
- }
327
- };
328
-
329
- publicAPI.getBounds = function () {
330
- return model.imageActor.getBounds();
331
- };
332
- } // ----------------------------------------------------------------------------
333
- // Object factory
334
- // ----------------------------------------------------------------------------
335
-
336
-
337
- var DEFAULT_VALUES = {
338
- tolerance: 5,
339
- showReslicedImage: true
340
- }; // ----------------------------------------------------------------------------
341
-
342
- function extend(publicAPI, model) {
343
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
344
- Object.assign(model, DEFAULT_VALUES, initialValues);
345
- vtkWidgetRepresentation.extend(publicAPI, model, initialValues);
346
- model.reslice = null;
347
- model.planeSource = vtkPlaneSource.newInstance();
348
- model.resliceAxes = mat4.identity(new Float64Array(16));
349
- model.newResliceAxes = mat4.identity(new Float64Array(16));
350
- model.imageActor = vtkImageSlice.newInstance();
351
- model.imageMapper = vtkImageMapper.newInstance();
352
- model.imageMapper.setResolveCoincidentTopologyToPolygonOffset();
353
- model.imageMapper.setRelativeCoincidentTopologyPolygonOffsetParameters(1.0, 1.0);
354
- model.planeInitialized = false;
355
- macro.setGet(publicAPI, model, ['tolerance', 'planeSource', 'showReslicedImage']);
356
- macro.get(publicAPI, model, ['resliceAxes', 'reslice', 'imageActor']); // Object methods
357
-
358
- vtkResliceCursorRepresentation(publicAPI, model);
359
- publicAPI.createDefaultResliceAlgorithm();
360
- model.imageMapper.setInputConnection(model.reslice.getOutputPort());
361
- model.imageActor.setMapper(model.imageMapper);
362
- } // ----------------------------------------------------------------------------
363
-
364
- var newInstance = macro.newInstance(extend, 'vtkResliceCursorRepresentation'); // ----------------------------------------------------------------------------
365
-
366
- var vtkResliceCursorRepresentation$1 = {
367
- newInstance: newInstance,
368
- extend: extend
369
- };
370
-
371
- export { vtkResliceCursorRepresentation$1 as default, extend, newInstance };
@@ -1,10 +0,0 @@
1
- var WidgetState = {
2
- START: 0,
3
- ACTIVE: 1,
4
- WINDOW_LEVEL: 2
5
- };
6
- var Constants = {
7
- WidgetState: WidgetState
8
- };
9
-
10
- export { WidgetState, Constants as default };
@@ -1,157 +0,0 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import macro from '../../../macros.js';
3
- import vtkAbstractWidget from '../AbstractWidget.js';
4
- import vtkInteractorStyleImage from '../../Style/InteractorStyleImage.js';
5
- import vtkResliceCursorLineRepresentation from './ResliceCursorLineRepresentation.js';
6
- import { WidgetState } from './ResliceCursorWidget/Constants.js';
7
- import { InteractionState } from './ResliceCursorRepresentation/Constants.js';
8
-
9
- 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; }
10
-
11
- 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; }
12
- var VOID = macro.VOID,
13
- EVENT_ABORT = macro.EVENT_ABORT; // ----------------------------------------------------------------------------
14
- // vtkResliceCursorWidget methods
15
- // ----------------------------------------------------------------------------
16
-
17
- function vtkResliceCursorWidget(publicAPI, model) {
18
- // Set our className
19
- model.classHierarchy.push('vtkResliceCursorWidget');
20
-
21
- var superClass = _objectSpread({}, publicAPI); //----------------------------------------------------------------------------
22
- // Public API methods
23
- //----------------------------------------------------------------------------
24
-
25
-
26
- publicAPI.setCursor = function (state) {
27
- switch (state) {
28
- case InteractionState.ON_AXIS1:
29
- case InteractionState.ON_AXIS2:
30
- case InteractionState.ON_CENTER:
31
- {
32
- model.interactor.getView().setCursor('pointer');
33
- break;
34
- }
35
-
36
- default:
37
- {
38
- model.interactor.getView().setCursor('default');
39
- }
40
- }
41
- };
42
-
43
- publicAPI.createDefaultRepresentation = function () {
44
- if (!model.widgetRep) {
45
- publicAPI.setWidgetRep(vtkResliceCursorLineRepresentation.newInstance());
46
- }
47
- };
48
-
49
- publicAPI.handleMouseMove = function (callData) {
50
- return publicAPI.moveAction(callData);
51
- };
52
-
53
- publicAPI.handleLeftButtonPress = function (callData) {
54
- return publicAPI.selectAction(callData);
55
- };
56
-
57
- publicAPI.handleLeftButtonRelease = function (callData) {
58
- return publicAPI.endSelectAction(callData);
59
- };
60
-
61
- publicAPI.selectAction = function (callData) {
62
- var position = [callData.position.x, callData.position.y];
63
- var state = model.widgetRep.computeInteractionState(position);
64
-
65
- if (state === InteractionState.OUTSIDE) {
66
- model.widgetState = WidgetState.WINDOW_LEVEL;
67
- model.imageInteractorStyle.handleLeftButtonPress(callData);
68
- } else {
69
- model.widgetRep.startComplexWidgetInteraction(position);
70
- model.widgetState = WidgetState.ACTIVE;
71
- publicAPI.setCursor(state);
72
- }
73
-
74
- publicAPI.invokeStartInteractionEvent();
75
- publicAPI.render();
76
- return EVENT_ABORT;
77
- };
78
-
79
- publicAPI.endSelectAction = function (callData) {
80
- if (model.widgetState === WidgetState.START) {
81
- return VOID;
82
- }
83
-
84
- if (model.widgetState === WidgetState.WINDOW_LEVEL) {
85
- model.imageInteractorStyle.handleLeftButtonRelease(callData);
86
- }
87
-
88
- model.widgetState = WidgetState.START;
89
- publicAPI.invokeEndInteractionEvent();
90
- publicAPI.render();
91
- return EVENT_ABORT;
92
- };
93
-
94
- publicAPI.moveAction = function (callData) {
95
- var position = [callData.position.x, callData.position.y];
96
-
97
- if (model.widgetState === WidgetState.START) {
98
- var state = model.widgetRep.getInteractionState();
99
- model.widgetRep.computeInteractionState(position);
100
- publicAPI.setCursor(model.widgetRep.getInteractionState());
101
-
102
- if (state !== model.widgetRep.getInteractionState()) {
103
- publicAPI.render();
104
- }
105
-
106
- return VOID;
107
- }
108
-
109
- if (model.widgetState === WidgetState.WINDOW_LEVEL) {
110
- model.imageInteractorStyle.handleMouseMove(callData);
111
- } else {
112
- model.widgetRep.complexWidgetInteraction(position);
113
- }
114
-
115
- publicAPI.invokeInteractionEvent();
116
- publicAPI.render();
117
- return EVENT_ABORT;
118
- };
119
-
120
- publicAPI.setWidgetRep = function (widgetRep) {
121
- superClass.setWidgetRep(widgetRep);
122
- model.imageInteractorStyle.setCurrentImageProperty(model.widgetRep.getImageActor().getProperty());
123
- };
124
-
125
- publicAPI.setInteractor = function (i) {
126
- superClass.setInteractor(i);
127
- model.imageInteractorStyle.setInteractor(model.interactor);
128
- model.imageInteractorStyle.setEnabled(false);
129
- };
130
- } // ----------------------------------------------------------------------------
131
- // Object factory
132
- // ----------------------------------------------------------------------------
133
-
134
-
135
- var DEFAULT_VALUES = {
136
- widgetState: WidgetState.START
137
- }; // ----------------------------------------------------------------------------
138
-
139
- function extend(publicAPI, model) {
140
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
141
- Object.assign(model, DEFAULT_VALUES, initialValues);
142
- vtkAbstractWidget.extend(publicAPI, model, DEFAULT_VALUES, initialValues);
143
- model.imageInteractorStyle = vtkInteractorStyleImage.newInstance({
144
- currentImageNumber: null
145
- }); // Object methods
146
-
147
- vtkResliceCursorWidget(publicAPI, model);
148
- } // ----------------------------------------------------------------------------
149
-
150
- var newInstance = macro.newInstance(extend, 'vtkResliceCursorWidget'); // ----------------------------------------------------------------------------
151
-
152
- var vtkResliceCursorWidget$1 = {
153
- newInstance: newInstance,
154
- extend: extend
155
- };
156
-
157
- export { vtkResliceCursorWidget$1 as default, extend, newInstance };