@kitware/vtk.js 24.7.0 → 24.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.
- package/Common/DataModel/ITKHelper.d.ts +54 -0
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +5 -2
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +3 -1
- package/Interaction/Manipulators/MouseRangeManipulator.js +23 -6
- package/Interaction/Style/InteractorStyleManipulator.js +1 -1
- package/Rendering/Core/RenderWindowInteractor.js +1 -2
- package/Widgets/Core/StateBuilder/manipulatorMixin.js +15 -15
- package/Widgets/Core/WidgetManager.js +11 -2
- package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
- package/Widgets/Manipulators/AbstractManipulator.js +57 -0
- package/Widgets/Manipulators/LineManipulator.d.ts +8 -74
- package/Widgets/Manipulators/LineManipulator.js +13 -10
- package/Widgets/Manipulators/PlaneManipulator.d.ts +8 -74
- package/Widgets/Manipulators/PlaneManipulator.js +12 -9
- package/Widgets/Manipulators/TrackballManipulator.d.ts +8 -44
- package/Widgets/Manipulators/TrackballManipulator.js +14 -11
- package/Widgets/Representations/ArrowHandleRepresentation.js +12 -3
- package/Widgets/Representations/CircleContextRepresentation.js +12 -3
- package/Widgets/Representations/CubeHandleRepresentation.js +13 -4
- package/Widgets/Representations/SphereContextRepresentation.js +12 -3
- package/Widgets/Representations/SphereHandleRepresentation.js +12 -3
- package/Widgets/Widgets3D/AngleWidget/behavior.js +7 -4
- package/Widgets/Widgets3D/AngleWidget/state.js +2 -2
- package/Widgets/Widgets3D/AngleWidget.js +19 -2
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +7 -2
- package/Widgets/Widgets3D/DistanceWidget/state.js +2 -2
- package/Widgets/Widgets3D/DistanceWidget.js +19 -2
- package/Widgets/Widgets3D/EllipseWidget.js +4 -3
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +3 -4
- package/Widgets/Widgets3D/ImageCroppingWidget.js +42 -13
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +5 -5
- package/Widgets/Widgets3D/LabelWidget/behavior.js +6 -2
- package/Widgets/Widgets3D/LabelWidget/state.js +2 -2
- package/Widgets/Widgets3D/LabelWidget.js +18 -3
- package/Widgets/Widgets3D/LineWidget/behavior.js +10 -3
- package/Widgets/Widgets3D/LineWidget/state.js +1 -1
- package/Widgets/Widgets3D/LineWidget.js +18 -1
- package/Widgets/Widgets3D/PaintWidget/behavior.js +12 -9
- package/Widgets/Widgets3D/PaintWidget.js +24 -8
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +11 -4
- package/Widgets/Widgets3D/PolyLineWidget/state.js +2 -2
- package/Widgets/Widgets3D/PolyLineWidget.js +21 -2
- package/Widgets/Widgets3D/RectangleWidget.js +6 -5
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +4 -4
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +9 -5
- package/Widgets/Widgets3D/ShapeWidget.js +12 -2
- package/Widgets/Widgets3D/SphereWidget/behavior.js +4 -3
- package/Widgets/Widgets3D/SphereWidget.js +23 -2
- package/Widgets/Widgets3D/SplineWidget/behavior.js +7 -3
- package/Widgets/Widgets3D/SplineWidget/state.js +2 -2
- package/Widgets/Widgets3D/SplineWidget.js +21 -2
- package/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import vtkPolyData from './PolyData';
|
|
2
|
+
import vtkImageData from './ImageData';
|
|
3
|
+
|
|
4
|
+
export interface IOptions {
|
|
5
|
+
pointDataName: string;
|
|
6
|
+
scalarArrayName: string;
|
|
7
|
+
cellDataName: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Converts an itk-wasm Image to a vtk.js vtkImageData.
|
|
12
|
+
* Requires an itk-wasm Image as input.
|
|
13
|
+
* @param itkImage
|
|
14
|
+
* @param {IOptions} [options]
|
|
15
|
+
*/
|
|
16
|
+
export function convertItkToVtkImage(itkImage: any, options?: IOptions): vtkImageData;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Converts a vtk.js vtkImageData to an itk-wasm Image.
|
|
20
|
+
* Requires a vtk.js vtkImageData as input.
|
|
21
|
+
* @param {vtkImageData} vtkImage
|
|
22
|
+
* @param {IOptions} [options]
|
|
23
|
+
*/
|
|
24
|
+
export function convertVtkToItkImage(vtkImage: vtkImageData, options?: IOptions): any;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Converts an itk-wasm PolyData to a vtk.js vtkPolyData.
|
|
28
|
+
* Requires an itk-wasm PolyData as input.
|
|
29
|
+
* @param itkPolyData
|
|
30
|
+
* @param {IOptions} [options]
|
|
31
|
+
*/
|
|
32
|
+
export function convertItkToVtkPolyData(itkPolyData: any, options?: IOptions): vtkPolyData;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Converts a vtk.js vtkPolyData to an itk-wasm PolyData.
|
|
36
|
+
* Requires a vtk.js vtkPolyData as input.
|
|
37
|
+
*
|
|
38
|
+
* @param {vtkPolyData} polyData
|
|
39
|
+
* @param {IOptions} [options]
|
|
40
|
+
*/
|
|
41
|
+
export function convertVtkToItkPolyData(polyData: vtkPolyData, options?: IOptions): any;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* vtkITKHelper is a helper which provides a set of functions to work with
|
|
46
|
+
* itk-wasm module.
|
|
47
|
+
*/
|
|
48
|
+
export declare const vtkITKHelper: {
|
|
49
|
+
convertItkToVtkImage: typeof convertItkToVtkImage,
|
|
50
|
+
convertVtkToItkImage: typeof convertVtkToItkImage,
|
|
51
|
+
convertItkToVtkPolyData: typeof convertItkToVtkPolyData,
|
|
52
|
+
convertVtkToItkPolyData: typeof convertVtkToItkPolyData,
|
|
53
|
+
};
|
|
54
|
+
export default vtkITKHelper;
|
|
@@ -43,7 +43,7 @@ function vtkMouseCameraAxisRotateManipulator(publicAPI, model) {
|
|
|
43
43
|
mat4.translate(trans, trans, center);
|
|
44
44
|
var dx = model.previousPosition.x - position.x;
|
|
45
45
|
var dy = model.previousPosition.y - position.y;
|
|
46
|
-
var size = interactor.getView().
|
|
46
|
+
var size = interactor.getView().getViewportSize(renderer); // Azimuth
|
|
47
47
|
|
|
48
48
|
mat4.rotate(trans, trans, radiansFromDegrees(360.0 * dx / size[0] * rotationFactor), rotationAxis); // Elevation
|
|
49
49
|
|
|
@@ -23,7 +23,7 @@ function vtkMouseCameraTrackballMultiRotateManipulator(publicAPI, model) {
|
|
|
23
23
|
var currentManipulator = null;
|
|
24
24
|
|
|
25
25
|
publicAPI.onButtonDown = function (interactor, renderer, position) {
|
|
26
|
-
var viewSize = interactor.getView().
|
|
26
|
+
var viewSize = interactor.getView().getViewportSize(renderer);
|
|
27
27
|
var viewCenter = [0.5 * viewSize[0], 0.5 * viewSize[1]];
|
|
28
28
|
var rotateRadius = 0.9 * max(viewCenter[0], viewCenter[1]);
|
|
29
29
|
var dist2 = sqr(viewCenter[0] - position.x) + sqr(viewCenter[1] - position.y);
|
|
@@ -33,7 +33,7 @@ function vtkMouseCameraTrackballPanManipulator(publicAPI, model) {
|
|
|
33
33
|
var right = [0, 0, 0];
|
|
34
34
|
cross(vpn, up, right); // These are different because y is flipped.
|
|
35
35
|
|
|
36
|
-
var height = interactor.getView().
|
|
36
|
+
var height = interactor.getView().getViewportSize(renderer)[1];
|
|
37
37
|
var dx = (pos.x - lastPos.x) / height;
|
|
38
38
|
var dy = (lastPos.y - pos.y) / height;
|
|
39
39
|
var scale = camera.getParallelScale();
|
|
@@ -42,7 +42,7 @@ function vtkMouseCameraTrackballRotateManipulator(publicAPI, model) {
|
|
|
42
42
|
|
|
43
43
|
var dx = model.previousPosition.x - position.x;
|
|
44
44
|
var dy = model.previousPosition.y - position.y;
|
|
45
|
-
var size = interactor.getView().
|
|
45
|
+
var size = interactor.getView().getViewportSize(renderer); // Azimuth
|
|
46
46
|
|
|
47
47
|
var viewUp = camera.getViewUp();
|
|
48
48
|
|
|
@@ -11,7 +11,7 @@ function vtkMouseCameraTrackballZoomManipulator(publicAPI, model) {
|
|
|
11
11
|
|
|
12
12
|
publicAPI.onButtonDown = function (interactor, renderer, position) {
|
|
13
13
|
model.previousPosition = position;
|
|
14
|
-
var size = interactor.getView().
|
|
14
|
+
var size = interactor.getView().getViewportSize(renderer);
|
|
15
15
|
var camera = renderer.getActiveCamera();
|
|
16
16
|
var direction = model.flipDirection ? -1 : 1;
|
|
17
17
|
|
|
@@ -26,7 +26,9 @@ function vtkMouseCameraUnicamManipulator(publicAPI, model) {
|
|
|
26
26
|
}); //----------------------------------------------------------------------------
|
|
27
27
|
|
|
28
28
|
var normalize$1 = function normalize(position, interactor) {
|
|
29
|
-
var
|
|
29
|
+
var renderer = interactor.findPokedRenderer();
|
|
30
|
+
|
|
31
|
+
var _interactor$getView$g = interactor.getView().getViewportSize(renderer),
|
|
30
32
|
_interactor$getView$g2 = _slicedToArray(_interactor$getView$g, 2),
|
|
31
33
|
width = _interactor$getView$g2[0],
|
|
32
34
|
height = _interactor$getView$g2[1];
|
|
@@ -63,8 +65,9 @@ function vtkMouseCameraUnicamManipulator(publicAPI, model) {
|
|
|
63
65
|
normalize(atV);
|
|
64
66
|
var l = dot(cameraToPointVec, atV);
|
|
65
67
|
var viewAngle = radiansFromDegrees(camera.getViewAngle());
|
|
68
|
+
var renderer = interactor.findPokedRenderer();
|
|
66
69
|
|
|
67
|
-
var _interactor$getView$g3 = interactor.getView().
|
|
70
|
+
var _interactor$getView$g3 = interactor.getView().getViewportSize(renderer),
|
|
68
71
|
_interactor$getView$g4 = _slicedToArray(_interactor$getView$g3, 2),
|
|
69
72
|
width = _interactor$getView$g4[0],
|
|
70
73
|
height = _interactor$getView$g4[1];
|
|
@@ -55,7 +55,9 @@ function vtkMouseCameraUnicamRotateManipulator(publicAPI, model) {
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
var normalize$1 = function normalize(position, interactor) {
|
|
58
|
-
var
|
|
58
|
+
var renderer = interactor.findPokedRenderer();
|
|
59
|
+
|
|
60
|
+
var _interactor$getView$g = interactor.getView().getViewportSize(renderer),
|
|
59
61
|
_interactor$getView$g2 = _slicedToArray(_interactor$getView$g, 2),
|
|
60
62
|
width = _interactor$getView$g2[0],
|
|
61
63
|
height = _interactor$getView$g2[1];
|
|
@@ -18,9 +18,13 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
function processDelta(listener, delta) {
|
|
21
|
-
var oldValue = listener.getValue(); //
|
|
21
|
+
var oldValue = listener.getValue(); // if exponential scroll is enabled, we raise our scale to the
|
|
22
|
+
// exponent of the net delta of the interaction. The further away
|
|
23
|
+
// the user's cursor is from the start of the interaction, the more
|
|
24
|
+
// their movements will effect the value.
|
|
22
25
|
|
|
23
|
-
var
|
|
26
|
+
var scalingFactor = listener.exponentialScroll ? Math.pow(listener.scale, Math.log2(Math.abs(model.interactionNetDelta) + 2)) : listener.scale;
|
|
27
|
+
var newDelta = delta * scalingFactor + incrementalDelta.get(listener);
|
|
24
28
|
var value = oldValue + newDelta; // Compute new value based on step
|
|
25
29
|
|
|
26
30
|
var difference = value - listener.min;
|
|
@@ -52,6 +56,7 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
52
56
|
|
|
53
57
|
publicAPI.setHorizontalListener = function (min, max, step, getValue, setValue) {
|
|
54
58
|
var scale = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
|
|
59
|
+
var exponentialScroll = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
55
60
|
var getFn = Number.isFinite(getValue) ? function () {
|
|
56
61
|
return getValue;
|
|
57
62
|
} : getValue;
|
|
@@ -61,7 +66,8 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
61
66
|
step: step,
|
|
62
67
|
getValue: getFn,
|
|
63
68
|
setValue: setValue,
|
|
64
|
-
scale: scale
|
|
69
|
+
scale: scale,
|
|
70
|
+
exponentialScroll: exponentialScroll
|
|
65
71
|
};
|
|
66
72
|
incrementalDelta.set(model.horizontalListener, 0);
|
|
67
73
|
publicAPI.modified();
|
|
@@ -70,6 +76,7 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
70
76
|
|
|
71
77
|
publicAPI.setVerticalListener = function (min, max, step, getValue, setValue) {
|
|
72
78
|
var scale = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
|
|
79
|
+
var exponentialScroll = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
73
80
|
var getFn = Number.isFinite(getValue) ? function () {
|
|
74
81
|
return getValue;
|
|
75
82
|
} : getValue;
|
|
@@ -79,7 +86,8 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
79
86
|
step: step,
|
|
80
87
|
getValue: getFn,
|
|
81
88
|
setValue: setValue,
|
|
82
|
-
scale: scale
|
|
89
|
+
scale: scale,
|
|
90
|
+
exponentialScroll: exponentialScroll
|
|
83
91
|
};
|
|
84
92
|
incrementalDelta.set(model.verticalListener, 0);
|
|
85
93
|
publicAPI.modified();
|
|
@@ -88,6 +96,7 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
88
96
|
|
|
89
97
|
publicAPI.setScrollListener = function (min, max, step, getValue, setValue) {
|
|
90
98
|
var scale = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
|
|
99
|
+
var exponentialScroll = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
91
100
|
var getFn = Number.isFinite(getValue) ? function () {
|
|
92
101
|
return getValue;
|
|
93
102
|
} : getValue;
|
|
@@ -97,7 +106,8 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
97
106
|
step: step,
|
|
98
107
|
getValue: getFn,
|
|
99
108
|
setValue: setValue,
|
|
100
|
-
scale: scale
|
|
109
|
+
scale: scale,
|
|
110
|
+
exponentialScroll: exponentialScroll
|
|
101
111
|
};
|
|
102
112
|
incrementalDelta.set(model.scrollListener, 0);
|
|
103
113
|
publicAPI.modified();
|
|
@@ -140,6 +150,7 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
140
150
|
|
|
141
151
|
publicAPI.onButtonDown = function (interactor, renderer, position) {
|
|
142
152
|
model.previousPosition = position;
|
|
153
|
+
model.interactionNetDelta = 0;
|
|
143
154
|
var glRenderWindow = interactor.getView(); // Ratio is the dom size vs renderwindow size
|
|
144
155
|
|
|
145
156
|
var ratio = glRenderWindow.getContainerSize()[0] / glRenderWindow.getSize()[0]; // Get proper pixel range used by viewport in rw size space
|
|
@@ -216,12 +227,14 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
216
227
|
if (model.horizontalListener) {
|
|
217
228
|
var dxNorm = (position.x - model.previousPosition.x) / model.containerSize[0];
|
|
218
229
|
var dx = scaleDeltaToRange(model.horizontalListener, dxNorm);
|
|
230
|
+
model.interactionNetDelta += dx;
|
|
219
231
|
processDelta(model.horizontalListener, dx);
|
|
220
232
|
}
|
|
221
233
|
|
|
222
234
|
if (model.verticalListener) {
|
|
223
235
|
var dyNorm = (position.y - model.previousPosition.y) / model.containerSize[1];
|
|
224
236
|
var dy = scaleDeltaToRange(model.verticalListener, dyNorm);
|
|
237
|
+
model.interactionNetDelta += dy;
|
|
225
238
|
processDelta(model.verticalListener, dy);
|
|
226
239
|
}
|
|
227
240
|
|
|
@@ -234,10 +247,14 @@ function vtkMouseRangeManipulator(publicAPI, model) {
|
|
|
234
247
|
return;
|
|
235
248
|
}
|
|
236
249
|
|
|
250
|
+
model.interactionNetDelta += delta * model.scrollListener.step;
|
|
237
251
|
processDelta(model.scrollListener, delta * model.scrollListener.step);
|
|
238
252
|
};
|
|
239
253
|
|
|
240
|
-
publicAPI.onStartScroll =
|
|
254
|
+
publicAPI.onStartScroll = function (payload) {
|
|
255
|
+
model.interactionNetDelta = 0;
|
|
256
|
+
publicAPI.onScroll(payload);
|
|
257
|
+
};
|
|
241
258
|
} // ----------------------------------------------------------------------------
|
|
242
259
|
// Object factory
|
|
243
260
|
// ----------------------------------------------------------------------------
|
|
@@ -42,7 +42,7 @@ function dollyToPosition(fact, position, renderer, rwi) {
|
|
|
42
42
|
|
|
43
43
|
if (cam.getParallelProjection()) {
|
|
44
44
|
// Zoom relatively to the cursor
|
|
45
|
-
var aSize = rwi.getView().
|
|
45
|
+
var aSize = rwi.getView().getViewportSize(renderer);
|
|
46
46
|
var w = aSize[0];
|
|
47
47
|
var h = aSize[1];
|
|
48
48
|
var x0 = w / 2;
|
|
@@ -118,10 +118,9 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
function getScreenEventPositionFor(source) {
|
|
121
|
-
var bounds = model.container.getBoundingClientRect();
|
|
122
|
-
|
|
123
121
|
var canvas = model._view.getCanvas();
|
|
124
122
|
|
|
123
|
+
var bounds = canvas.getBoundingClientRect();
|
|
125
124
|
var scaleX = canvas.width / bounds.width;
|
|
126
125
|
var scaleY = canvas.height / bounds.height;
|
|
127
126
|
var position = {
|
|
@@ -7,23 +7,23 @@ function vtkManipulatorMixin(publicAPI, model) {
|
|
|
7
7
|
normal = model.normal,
|
|
8
8
|
direction = model.direction;
|
|
9
9
|
var _model$manipulator = model.manipulator,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (origin &&
|
|
16
|
-
|
|
17
|
-
} else if (origin &&
|
|
18
|
-
|
|
10
|
+
setHandleOrigin = _model$manipulator.setHandleOrigin,
|
|
11
|
+
setHandleCenter = _model$manipulator.setHandleCenter,
|
|
12
|
+
setHandleNormal = _model$manipulator.setHandleNormal,
|
|
13
|
+
setHandleDirection = _model$manipulator.setHandleDirection;
|
|
14
|
+
|
|
15
|
+
if (origin && setHandleOrigin) {
|
|
16
|
+
setHandleOrigin(origin);
|
|
17
|
+
} else if (origin && setHandleCenter) {
|
|
18
|
+
setHandleCenter(origin);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
if (direction &&
|
|
22
|
-
|
|
23
|
-
} else if (direction && !normal &&
|
|
24
|
-
|
|
25
|
-
} else if (normal &&
|
|
26
|
-
|
|
21
|
+
if (direction && setHandleDirection) {
|
|
22
|
+
setHandleDirection(direction);
|
|
23
|
+
} else if (direction && !normal && setHandleNormal) {
|
|
24
|
+
setHandleNormal(direction);
|
|
25
|
+
} else if (normal && setHandleDirection) {
|
|
26
|
+
setHandleDirection(normal);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
};
|
|
@@ -37,7 +37,6 @@ function extractRenderingComponents(renderer) {
|
|
|
37
37
|
|
|
38
38
|
function createSvgRoot(id) {
|
|
39
39
|
var svgRoot = createSvgDomElement('svg');
|
|
40
|
-
svgRoot.setAttribute('style', 'position: absolute; top: 0; left: 0; width: 100%; height: 100%;');
|
|
41
40
|
svgRoot.setAttribute('version', '1.1');
|
|
42
41
|
svgRoot.setAttribute('baseProfile', 'full');
|
|
43
42
|
return svgRoot;
|
|
@@ -122,7 +121,7 @@ function vtkWidgetManager(publicAPI, model) {
|
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
function setSvgSize() {
|
|
125
|
-
var _model$_apiSpecificRe = model._apiSpecificRenderWindow.
|
|
124
|
+
var _model$_apiSpecificRe = model._apiSpecificRenderWindow.getViewportSize(model._renderer),
|
|
126
125
|
_model$_apiSpecificRe2 = _slicedToArray(_model$_apiSpecificRe, 2),
|
|
127
126
|
cwidth = _model$_apiSpecificRe2[0],
|
|
128
127
|
cheight = _model$_apiSpecificRe2[1];
|
|
@@ -148,6 +147,14 @@ function vtkWidgetManager(publicAPI, model) {
|
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
149
|
|
|
150
|
+
function setSvgRootStyle() {
|
|
151
|
+
var viewport = model._renderer.getViewport().map(function (v) {
|
|
152
|
+
return v * 100;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
model.svgRoot.setAttribute('style', "position: absolute; left: ".concat(viewport[0], "%; top: ").concat(100 - viewport[3], "%; width: ").concat(viewport[2] - viewport[0], "%; height: ").concat(viewport[3] - viewport[1], "%;"));
|
|
156
|
+
}
|
|
157
|
+
|
|
151
158
|
function updateSvg() {
|
|
152
159
|
if (model.useSvgLayer) {
|
|
153
160
|
var _loop = function _loop(i) {
|
|
@@ -459,6 +466,8 @@ function vtkWidgetManager(publicAPI, model) {
|
|
|
459
466
|
model._selector.setFieldAssociation(FieldAssociations.FIELD_ASSOCIATION_POINTS);
|
|
460
467
|
|
|
461
468
|
subscriptions.push(model._interactor.onRenderEvent(updateSvg));
|
|
469
|
+
subscriptions.push(renderer.onModified(setSvgRootStyle));
|
|
470
|
+
setSvgRootStyle();
|
|
462
471
|
subscriptions.push(model._apiSpecificRenderWindow.onModified(setSvgSize));
|
|
463
472
|
setSvgSize();
|
|
464
473
|
subscriptions.push(model._apiSpecificRenderWindow.onModified(updateDisplayScaleParams));
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { vtkObject } from './../../interfaces';
|
|
2
|
+
import { vtkOpenGLRenderWindow } from './../../Rendering/OpenGL/RenderWindow'
|
|
3
|
+
import { Vector3 } from './../../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export interface IAbstractManipulatorInitialValues {
|
|
9
|
+
userOrigin?: Vector3;
|
|
10
|
+
handleOrigin?: Vector3;
|
|
11
|
+
widgetOrigin?: Vector3;
|
|
12
|
+
userNormal?: Vector3;
|
|
13
|
+
handleNormal?: Vector3;
|
|
14
|
+
widgetNormal?: Vector3;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface vtkAbstractManipulator extends vtkObject {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the normal of the line
|
|
21
|
+
*/
|
|
22
|
+
getNormal(callData: any): Vector3;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the origin of the line
|
|
26
|
+
*/
|
|
27
|
+
getOrigin(callData: any): Vector3;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the value of useCameraFocalPoint
|
|
31
|
+
*/
|
|
32
|
+
getUseCameraFocalPoint(): boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Set the value of useCameraFocalPoint
|
|
36
|
+
* @param useCameraFocalPoint if true, the focal point of the camera will be used if userOrigin is not set.
|
|
37
|
+
*/
|
|
38
|
+
setUseCameraFocalPoint(useCameraFocalPoint: boolean): boolean;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get the value of useCameraNormal
|
|
42
|
+
*/
|
|
43
|
+
getUseCameraNormal(): boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Set the value of useCameraNormal
|
|
47
|
+
* @param useCameraNormal if true, the normal of the camera will be used if userNormal is not set.
|
|
48
|
+
*/
|
|
49
|
+
setUseCameraNormal(useCameraNormal: boolean): boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param callData
|
|
54
|
+
* @param glRenderWindow
|
|
55
|
+
*/
|
|
56
|
+
handleEvent(callData: any, glRenderWindow: vtkOpenGLRenderWindow): Vector3;
|
|
57
|
+
|
|
58
|
+
/* ------------------------------------------------------------------- */
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Set the user normal.
|
|
62
|
+
* This normal take precedence on the handleNormal and the widgetNormal.
|
|
63
|
+
* This normal should not be set within the widget internal code.
|
|
64
|
+
* @param {Vector3} normal The normal coordinate.
|
|
65
|
+
*/
|
|
66
|
+
setUserNormal(normal: Vector3): boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Set the user normal (see setUserNormal).
|
|
70
|
+
* @param {Number} x The x coordinate.
|
|
71
|
+
* @param {Number} y The y coordinate.
|
|
72
|
+
* @param {Number} z The z coordinate.
|
|
73
|
+
*/
|
|
74
|
+
setUserNormal(x: number, y: number, z: number): boolean;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Set the user normal (see setUserNormal).
|
|
78
|
+
* @param {Vector3} normal The normal coordinate.
|
|
79
|
+
*/
|
|
80
|
+
setUserNormalFrom(normal: Vector3): boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Set the user origin.
|
|
84
|
+
* This origin take precedence on the handleOrigin and the widgetOrigin.
|
|
85
|
+
* This origin should not be set within the widget internal code.
|
|
86
|
+
* @param {Vector3} origin The coordinate of the origin point.
|
|
87
|
+
*/
|
|
88
|
+
setUserOrigin(origin: Vector3): boolean;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Set the user origin (see setUserOrigin).
|
|
92
|
+
* @param {Number} x The x coordinate of the origin point.
|
|
93
|
+
* @param {Number} y The y coordinate of the origin point.
|
|
94
|
+
* @param {Number} z The z coordinate of the origin point.
|
|
95
|
+
*/
|
|
96
|
+
setUserOrigin(x: number, y: number, z: number): boolean;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Set the user origin (see setUserOrigin).
|
|
100
|
+
* @param {Vector3} origin The coordinate of the origin point.
|
|
101
|
+
*/
|
|
102
|
+
setUserOriginFrom(origin: Vector3): boolean;
|
|
103
|
+
|
|
104
|
+
/* ------------------------------------------------------------------- */
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Set the handle normal.
|
|
108
|
+
* This normal is used after the userNormal and before the widgetNormal.
|
|
109
|
+
* This normal is automatically set by any state having a manipulatorMixin,
|
|
110
|
+
* and can be overridden in the widget code.
|
|
111
|
+
* @param {Vector3} normal The normal coordinate.
|
|
112
|
+
*/
|
|
113
|
+
setHandleNormal(normal: Vector3): boolean;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Set the handle normal (see setHandleNormal).
|
|
117
|
+
* @param {Number} x The x coordinate.
|
|
118
|
+
* @param {Number} y The y coordinate.
|
|
119
|
+
* @param {Number} z The z coordinate.
|
|
120
|
+
*/
|
|
121
|
+
setHandleNormal(x: number, y: number, z: number): boolean;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Set the handle normal (see setHandleNormal).
|
|
125
|
+
* @param {Vector3} normal The normal coordinate.
|
|
126
|
+
*/
|
|
127
|
+
setHandleNormalFrom(normal: Vector3): boolean;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Set the handle origin.
|
|
131
|
+
* This origin is used after the userOrigin and before the widgetOrigin.
|
|
132
|
+
* This origin is automatically set by any state having a manipulatorMixin,
|
|
133
|
+
* and can be overridden in the widget code.
|
|
134
|
+
* @param {Vector3} origin The coordinate of the origin point.
|
|
135
|
+
*/
|
|
136
|
+
setHandleOrigin(origin: Vector3): boolean;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Set the handle origin (see setHandleOrigin).
|
|
140
|
+
* @param {Number} x The x coordinate of the origin point.
|
|
141
|
+
* @param {Number} y The y coordinate of the origin point.
|
|
142
|
+
* @param {Number} z The z coordinate of the origin point.
|
|
143
|
+
*/
|
|
144
|
+
setHandleOrigin(x: number, y: number, z: number): boolean;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Set the handle origin (see setHandleOrigin).
|
|
148
|
+
* @param {Vector3} origin The coordinate of the origin point.
|
|
149
|
+
*/
|
|
150
|
+
setHandleOriginFrom(origin: Vector3): boolean;
|
|
151
|
+
|
|
152
|
+
/* ------------------------------------------------------------------- */
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Set the widget normal.
|
|
156
|
+
* This normal is used if no other normals are set.
|
|
157
|
+
* It can be used to define a normal global to the whole widget.
|
|
158
|
+
* @param {Vector3} normal The normal coordinate.
|
|
159
|
+
*/
|
|
160
|
+
setWidgetNormal(normal: Vector3): boolean;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Set the widget normal (see setWidgetNormal).
|
|
164
|
+
* @param {Number} x The x coordinate.
|
|
165
|
+
* @param {Number} y The y coordinate.
|
|
166
|
+
* @param {Number} z The z coordinate.
|
|
167
|
+
*/
|
|
168
|
+
setWidgetNormal(x: number, y: number, z: number): boolean;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Set the widget normal (see setWidgetNormal).
|
|
172
|
+
* @param {Vector3} normal The normal coordinate.
|
|
173
|
+
*/
|
|
174
|
+
setWidgetNormalFrom(normal: Vector3): boolean;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Set the widget origin.
|
|
178
|
+
* This origin is used if no other origins are set.
|
|
179
|
+
* It can be used to define an origin global to the whole widget.
|
|
180
|
+
* @param {Vector3} origin The coordinate of the origin point.
|
|
181
|
+
*/
|
|
182
|
+
setWidgetOrigin(origin: Vector3): boolean;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Set the widget origin (see setWidgetOrigin).
|
|
186
|
+
* @param {Number} x The x coordinate of the origin point.
|
|
187
|
+
* @param {Number} y The y coordinate of the origin point.
|
|
188
|
+
* @param {Number} z The z coordinate of the origin point.
|
|
189
|
+
*/
|
|
190
|
+
setWidgetOrigin(x: number, y: number, z: number): boolean;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Set the widget origin (see setWidgetOrigin).
|
|
194
|
+
* @param {Vector3} origin The coordinate of the origin point.
|
|
195
|
+
*/
|
|
196
|
+
setWidgetOriginFrom(origin: Vector3): boolean;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Method use to decorate a given object (publicAPI+model) with vtkAbstractManipulator characteristics.
|
|
202
|
+
*
|
|
203
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
204
|
+
* @param model object on which data structure will be bounds (protected)
|
|
205
|
+
* @param {IAbstractManipulatorInitialValues} [initialValues] (default: {})
|
|
206
|
+
*/
|
|
207
|
+
export function extend(publicAPI: object, model: object, initialValues?: IAbstractManipulatorInitialValues): void;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Method use to create a new instance of vtkAbstractManipulator
|
|
211
|
+
*/
|
|
212
|
+
export function newInstance(initialValues?: IAbstractManipulatorInitialValues): vtkAbstractManipulator;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* vtkAbstractManipulator.
|
|
216
|
+
*/
|
|
217
|
+
export declare const vtkAbstractManipulator: {
|
|
218
|
+
newInstance: typeof newInstance,
|
|
219
|
+
extend: typeof extend,
|
|
220
|
+
};
|
|
221
|
+
export default vtkAbstractManipulator;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import macro from '../../macros.js';
|
|
2
|
+
|
|
3
|
+
// vtkAbstractManipulator methods
|
|
4
|
+
// ----------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
function vtkAbstractManipulator(publicAPI, model) {
|
|
7
|
+
// Set our className
|
|
8
|
+
model.classHierarchy.push('vtkAbstractManipulator');
|
|
9
|
+
|
|
10
|
+
publicAPI.getOrigin = function (callData) {
|
|
11
|
+
if (model.userOrigin) return model.userOrigin;
|
|
12
|
+
if (model.useCameraFocalPoint) return callData.pokedRenderer.getActiveCamera().getFocalPoint();
|
|
13
|
+
if (model.handleOrigin) return model.handleOrigin;
|
|
14
|
+
if (model.widgetOrigin) return model.widgetOrigin;
|
|
15
|
+
return [0, 0, 0];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
publicAPI.getNormal = function (callData) {
|
|
19
|
+
if (model.userNormal) return model.userNormal;
|
|
20
|
+
if (model.useCameraNormal) return callData.pokedRenderer.getActiveCamera().getDirectionOfProjection();
|
|
21
|
+
if (model.handleNormal) return model.handleNormal;
|
|
22
|
+
if (model.widgetNormal) return model.widgetNormal;
|
|
23
|
+
return [0, 0, 1];
|
|
24
|
+
};
|
|
25
|
+
} // ----------------------------------------------------------------------------
|
|
26
|
+
// Object factory
|
|
27
|
+
// ----------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var DEFAULT_VALUES = {
|
|
31
|
+
// userOrigin: null,
|
|
32
|
+
// handleOrigin: null,
|
|
33
|
+
// widgetOrigin: null,
|
|
34
|
+
// userNormal: null,
|
|
35
|
+
// handleNormal: null,
|
|
36
|
+
// widgetNormal: null
|
|
37
|
+
useCameraFocalPoint: false,
|
|
38
|
+
useCameraNormal: false
|
|
39
|
+
}; // ----------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
function extend(publicAPI, model) {
|
|
42
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
43
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
44
|
+
macro.obj(publicAPI, model);
|
|
45
|
+
macro.setGet(publicAPI, model, ['useCameraFocalPoint', 'useCameraNormal']);
|
|
46
|
+
macro.setGetArray(publicAPI, model, ['userOrigin', 'handleOrigin', 'widgetOrigin', 'userNormal', 'handleNormal', 'widgetNormal'], 3);
|
|
47
|
+
vtkAbstractManipulator(publicAPI, model);
|
|
48
|
+
} // ----------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
var newInstance = macro.newInstance(extend, 'vtkAbstractManipulator'); // ----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
var vtkAbstractManipulator$1 = {
|
|
53
|
+
extend: extend,
|
|
54
|
+
newInstance: newInstance
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { vtkAbstractManipulator$1 as default, extend, newInstance };
|