@kitware/vtk.js 27.5.0 → 28.0.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.
- package/BREAKING_CHANGES.md +4 -0
- package/Common/DataModel/Line.d.ts +24 -2
- package/Common/DataModel/Line.js +17 -1
- package/Common/DataModel/PolyLine.d.ts +36 -2
- package/Common/DataModel/PolyLine.js +80 -10
- package/Common/Transform/Transform.d.ts +177 -0
- package/Common/Transform/Transform.js +81 -3
- package/Proxy/Core/View2DProxy.js +22 -12
- package/Rendering/Core/AbstractMapper3D.d.ts +1 -3
- package/Rendering/Core/AbstractMapper3D.js +21 -45
- package/Rendering/Core/ImageCPRMapper.d.ts +380 -0
- package/Rendering/Core/ImageCPRMapper.js +361 -0
- package/Rendering/Core/ImageProperty/Constants.js +2 -2
- package/Rendering/Core/ImageProperty.js +2 -2
- package/Rendering/OpenGL/ImageCPRMapper.js +919 -0
- package/Rendering/OpenGL/ImageResliceMapper.js +2 -2
- package/Rendering/OpenGL/Profiles/All.js +1 -0
- package/Rendering/OpenGL/Profiles/Volume.js +1 -0
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/Profiles/All.js +1 -0
- package/Rendering/Profiles/Volume.js +1 -0
- package/Widgets/Core/WidgetManager.js +1 -1
- package/Widgets/Manipulators/AbstractManipulator.d.ts +2 -2
- package/Widgets/Manipulators/CPRManipulator.js +138 -0
- package/Widgets/Manipulators/LineManipulator.js +3 -1
- package/Widgets/Manipulators/PlaneManipulator.js +3 -1
- package/Widgets/Manipulators/TrackballManipulator.js +3 -1
- package/Widgets/Widgets3D/AngleWidget/behavior.js +5 -2
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +5 -2
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +3 -3
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +3 -1
- package/Widgets/Widgets3D/LabelWidget/behavior.js +5 -2
- package/Widgets/Widgets3D/LineWidget/behavior.js +4 -2
- package/Widgets/Widgets3D/PaintWidget/behavior.js +2 -1
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +2 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +2 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +72 -34
- package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +92 -0
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +64 -18
- package/Widgets/Widgets3D/ResliceCursorWidget/state.js +30 -16
- package/Widgets/Widgets3D/ResliceCursorWidget.js +43 -20
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +4 -2
- package/Widgets/Widgets3D/SphereWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/SplineWidget/behavior.js +3 -1
- package/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ 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 vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
|
|
7
8
|
import vtkLineHandleRepresentation from '../Representations/LineHandleRepresentation.js';
|
|
8
9
|
import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
|
|
9
10
|
import { e as distance2BetweenPoints, m as multiplyAccumulate, s as subtract, l as normalize, w as multiplyScalar, k as add } from '../../Common/Core/Math/index.js';
|
|
@@ -263,11 +264,9 @@ function vtkResliceCursorWidget(publicAPI, model) {
|
|
|
263
264
|
updateCamera(renderer, normal, viewType, resetFocalPoint, keepCenterFocalDistance);
|
|
264
265
|
};
|
|
265
266
|
|
|
266
|
-
publicAPI.
|
|
267
|
-
//
|
|
268
|
-
var spacing = model.widgetState.getImage().getSpacing(); // Compute original (i.e. before rotation) plane (i.e. origin, p1, p2)
|
|
267
|
+
publicAPI.getPlaneSource = function (viewType) {
|
|
268
|
+
// Compute original (i.e. before rotation) plane (i.e. origin, p1, p2)
|
|
269
269
|
// centered on cursor center.
|
|
270
|
-
|
|
271
270
|
var planeSource = computeReslicePlaneOrigin(viewType);
|
|
272
271
|
var _model$widgetState$ge = model.widgetState.getPlanes()[viewType],
|
|
273
272
|
normal = _model$widgetState$ge.normal,
|
|
@@ -286,18 +285,25 @@ function vtkResliceCursorWidget(publicAPI, model) {
|
|
|
286
285
|
planeSource.setOrigin.apply(planeSource, _toConsumableArray(boundedOrigin));
|
|
287
286
|
planeSource.setPoint1.apply(planeSource, _toConsumableArray(boundedP1));
|
|
288
287
|
planeSource.setPoint2.apply(planeSource, _toConsumableArray(boundedP2));
|
|
289
|
-
|
|
288
|
+
return planeSource;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
publicAPI.getResliceAxes = function (viewType) {
|
|
292
|
+
// Compute original (i.e. before rotation) plane (i.e. origin, p1, p2)
|
|
293
|
+
// centered on cursor center.
|
|
294
|
+
var planeSource = publicAPI.getPlaneSource(viewType); // TBD: use normal from planeSource ?
|
|
295
|
+
|
|
296
|
+
var normal = model.widgetState.getPlanes()[viewType].normal;
|
|
297
|
+
var planeOrigin = planeSource.getOrigin();
|
|
290
298
|
var p1 = planeSource.getPoint1();
|
|
291
299
|
var planeAxis1 = [];
|
|
292
|
-
subtract(p1,
|
|
300
|
+
subtract(p1, planeOrigin, planeAxis1);
|
|
301
|
+
normalize(planeAxis1);
|
|
293
302
|
var p2 = planeSource.getPoint2();
|
|
294
303
|
var planeAxis2 = [];
|
|
295
|
-
subtract(p2,
|
|
296
|
-
|
|
297
|
-
var planeSizeX = normalize(planeAxis1);
|
|
298
|
-
var planeSizeY = normalize(planeAxis2);
|
|
304
|
+
subtract(p2, planeOrigin, planeAxis2);
|
|
305
|
+
normalize(planeAxis2);
|
|
299
306
|
var newResliceAxes = mat4.identity(new Float64Array(16));
|
|
300
|
-
var planeOrigin = planeSource.getOrigin();
|
|
301
307
|
|
|
302
308
|
for (var i = 0; i < 3; i++) {
|
|
303
309
|
newResliceAxes[i] = planeAxis1[i];
|
|
@@ -306,6 +312,21 @@ function vtkResliceCursorWidget(publicAPI, model) {
|
|
|
306
312
|
newResliceAxes[12 + i] = planeOrigin[i];
|
|
307
313
|
}
|
|
308
314
|
|
|
315
|
+
return newResliceAxes;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
publicAPI.updateReslicePlane = function (imageReslice, viewType) {
|
|
319
|
+
// Calculate appropriate pixel spacing for the reslicing
|
|
320
|
+
var spacing = model.widgetState.getImage().getSpacing();
|
|
321
|
+
var planeSource = publicAPI.getPlaneSource(viewType);
|
|
322
|
+
var newResliceAxes = publicAPI.getResliceAxes(viewType);
|
|
323
|
+
var planeOrigin = planeSource.getOrigin();
|
|
324
|
+
var p1 = planeSource.getPoint1();
|
|
325
|
+
var planeAxis1 = subtract(p1, planeOrigin, []);
|
|
326
|
+
var planeSizeX = normalize(planeAxis1);
|
|
327
|
+
var p2 = planeSource.getPoint2();
|
|
328
|
+
var planeAxis2 = subtract(p2, planeOrigin, []);
|
|
329
|
+
var planeSizeY = normalize(planeAxis2);
|
|
309
330
|
var spacingX = Math.abs(planeAxis1[0] * spacing[0]) + Math.abs(planeAxis1[1] * spacing[1]) + Math.abs(planeAxis1[2] * spacing[2]);
|
|
310
331
|
var spacingY = Math.abs(planeAxis2[0] * spacing[0]) + Math.abs(planeAxis2[1] * spacing[1]) + Math.abs(planeAxis2[2] * spacing[2]); // Compute a new set of resliced extents
|
|
311
332
|
|
|
@@ -350,12 +371,7 @@ function vtkResliceCursorWidget(publicAPI, model) {
|
|
|
350
371
|
modified = imageReslice.setOutputSpacing([outputSpacingX, outputSpacingY, 1]) || modified;
|
|
351
372
|
modified = imageReslice.setOutputOrigin([0.5 * outputSpacingX, 0.5 * outputSpacingY, 0]) || modified;
|
|
352
373
|
modified = imageReslice.setOutputExtent([0, extentX - 1, 0, extentY - 1, 0, 0]) || modified;
|
|
353
|
-
return
|
|
354
|
-
modified: modified,
|
|
355
|
-
origin: o,
|
|
356
|
-
point1: p1,
|
|
357
|
-
point2: p2
|
|
358
|
-
};
|
|
374
|
+
return modified;
|
|
359
375
|
};
|
|
360
376
|
/**
|
|
361
377
|
* Returns a plane source with origin at cursor center and
|
|
@@ -429,13 +445,20 @@ function vtkResliceCursorWidget(publicAPI, model) {
|
|
|
429
445
|
});
|
|
430
446
|
} // ----------------------------------------------------------------------------
|
|
431
447
|
|
|
448
|
+
/**
|
|
449
|
+
* Initializes the model.
|
|
450
|
+
* @param {*} initialValues optional object of member variables. initialValues.planes is an optional list of axis names (e.g. ['X', 'Y'])
|
|
451
|
+
* @returns the initial model object
|
|
452
|
+
*/
|
|
453
|
+
|
|
432
454
|
|
|
433
455
|
var defaultValues = function defaultValues(initialValues) {
|
|
434
456
|
return _objectSpread({
|
|
435
457
|
behavior: widgetBehavior,
|
|
436
|
-
widgetState: generateState(),
|
|
458
|
+
widgetState: generateState(initialValues.planes),
|
|
437
459
|
rotationHandlePosition: 0.5,
|
|
438
|
-
scaleInPixels: true
|
|
460
|
+
scaleInPixels: true,
|
|
461
|
+
manipulator: vtkPlanePointManipulator.newInstance()
|
|
439
462
|
}, initialValues);
|
|
440
463
|
}; // ----------------------------------------------------------------------------
|
|
441
464
|
|
|
@@ -444,7 +467,7 @@ function extend(publicAPI, model) {
|
|
|
444
467
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
445
468
|
Object.assign(model, defaultValues(initialValues));
|
|
446
469
|
vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
|
|
447
|
-
macro.setGet(publicAPI, model, ['scaleInPixels', 'rotationHandlePosition']);
|
|
470
|
+
macro.setGet(publicAPI, model, ['scaleInPixels', 'rotationHandlePosition', 'manipulator']);
|
|
448
471
|
vtkResliceCursorWidget(publicAPI, model);
|
|
449
472
|
} // ----------------------------------------------------------------------------
|
|
450
473
|
|
|
@@ -369,7 +369,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
369
369
|
model.shapeHandle.setDirection(normal);
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
var
|
|
372
|
+
var _manipulator$handleEv = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
373
|
+
worldCoords = _manipulator$handleEv.worldCoords;
|
|
373
374
|
|
|
374
375
|
if (!worldCoords.length) {
|
|
375
376
|
return macro.VOID;
|
|
@@ -413,7 +414,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
413
414
|
}
|
|
414
415
|
|
|
415
416
|
if (model.hasFocus) {
|
|
416
|
-
var
|
|
417
|
+
var _manipulator$handleEv2 = manipulator.handleEvent(e, model._apiSpecificRenderWindow),
|
|
418
|
+
worldCoords = _manipulator$handleEv2.worldCoords;
|
|
417
419
|
|
|
418
420
|
if (!model.point1) {
|
|
419
421
|
model.point1Handle.setOrigin(worldCoords);
|
|
@@ -56,7 +56,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
56
56
|
var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
|
|
57
57
|
|
|
58
58
|
var manipulator = (_model$activeState$ge = (_model$activeState = model.activeState) === null || _model$activeState === void 0 ? void 0 : (_model$activeState$ge2 = _model$activeState.getManipulator) === null || _model$activeState$ge2 === void 0 ? void 0 : _model$activeState$ge2.call(_model$activeState)) !== null && _model$activeState$ge !== void 0 ? _model$activeState$ge : model.manipulator;
|
|
59
|
-
return manipulator.handleEvent(e, model._apiSpecificRenderWindow);
|
|
59
|
+
return manipulator.handleEvent(e, model._apiSpecificRenderWindow).worldCoords;
|
|
60
60
|
} // Update the sphere's center and radius. Example:
|
|
61
61
|
// handle.setCenterAndRadius([1,2,3], 10);
|
|
62
62
|
|
|
@@ -255,7 +255,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
255
255
|
return macro.VOID;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
var
|
|
258
|
+
var _manipulator$handleEv = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
259
|
+
worldCoords = _manipulator$handleEv.worldCoords;
|
|
260
|
+
|
|
259
261
|
var hoveredHandle = getHoveredHandle();
|
|
260
262
|
|
|
261
263
|
if (hoveredHandle) {
|
package/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
/// <reference path="./Common/DataModel/Spline3D.d.ts" />
|
|
53
53
|
/// <reference path="./Common/DataModel/Triangle.d.ts" />
|
|
54
54
|
/// <reference path="./Common/Transform/LandmarkTransform.d.ts" />
|
|
55
|
+
/// <reference path="./Common/Transform/Transform.d.ts" />
|
|
55
56
|
/// <reference path="./Filters/General/AppendPolyData.d.ts" />
|
|
56
57
|
/// <reference path="./Filters/General/ClipClosedSurface.d.ts" />
|
|
57
58
|
/// <reference path="./Filters/General/ContourTriangulator.d.ts" />
|
|
@@ -151,6 +152,7 @@
|
|
|
151
152
|
/// <reference path="./Rendering/Core/Glyph3DMapper.d.ts" />
|
|
152
153
|
/// <reference path="./Rendering/Core/HardwareSelector.d.ts" />
|
|
153
154
|
/// <reference path="./Rendering/Core/ImageArrayMapper.d.ts" />
|
|
155
|
+
/// <reference path="./Rendering/Core/ImageCPRMapper.d.ts" />
|
|
154
156
|
/// <reference path="./Rendering/Core/ImageMapper/Constants.d.ts" />
|
|
155
157
|
/// <reference path="./Rendering/Core/ImageMapper.d.ts" />
|
|
156
158
|
/// <reference path="./Rendering/Core/ImageProperty/Constants.d.ts" />
|