@kitware/vtk.js 27.5.0 → 28.0.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/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/OpenGL/ImageCPRMapper.js +919 -0
- package/Rendering/OpenGL/Profiles/All.js +1 -0
- package/Rendering/OpenGL/Profiles/Volume.js +1 -0
- 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
|
@@ -11,6 +11,7 @@ import '../OpenGL/Texture.js';
|
|
|
11
11
|
import '../OpenGL/Glyph3DMapper.js';
|
|
12
12
|
import '../OpenGL/ImageResliceMapper.js';
|
|
13
13
|
import '../OpenGL/ImageMapper.js';
|
|
14
|
+
import '../OpenGL/ImageCPRMapper.js';
|
|
14
15
|
import '../OpenGL/ImageSlice.js';
|
|
15
16
|
import '../OpenGL/Volume.js';
|
|
16
17
|
import '../OpenGL/VolumeMapper.js';
|
|
@@ -2,6 +2,7 @@ import '../OpenGL/Camera.js';
|
|
|
2
2
|
import '../OpenGL/Renderer.js';
|
|
3
3
|
import '../OpenGL/ImageResliceMapper.js';
|
|
4
4
|
import '../OpenGL/ImageMapper.js';
|
|
5
|
+
import '../OpenGL/ImageCPRMapper.js';
|
|
5
6
|
import '../OpenGL/ImageSlice.js';
|
|
6
7
|
import '../OpenGL/Volume.js';
|
|
7
8
|
import '../OpenGL/VolumeMapper.js';
|
|
@@ -237,7 +237,7 @@ function vtkWidgetManager(publicAPI, model) {
|
|
|
237
237
|
case 0:
|
|
238
238
|
fromTouchEvent = _args.length > 1 && _args[1] !== undefined ? _args[1] : false;
|
|
239
239
|
|
|
240
|
-
if (!(!model.isAnimating && model.pickingEnabled)) {
|
|
240
|
+
if (!(!model.isAnimating && model.pickingEnabled && callData.pokedRenderer === model._renderer)) {
|
|
241
241
|
_context.next = 6;
|
|
242
242
|
break;
|
|
243
243
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vtkObject } from './../../interfaces';
|
|
2
2
|
import { vtkOpenGLRenderWindow } from './../../Rendering/OpenGL/RenderWindow'
|
|
3
|
-
import { Vector3 } from './../../types';
|
|
3
|
+
import { Matrix3x3, Nullable, Vector3 } from './../../types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -53,7 +53,7 @@ export interface vtkAbstractManipulator extends vtkObject {
|
|
|
53
53
|
* @param callData
|
|
54
54
|
* @param glRenderWindow
|
|
55
55
|
*/
|
|
56
|
-
handleEvent(callData: any, glRenderWindow: vtkOpenGLRenderWindow): Vector3;
|
|
56
|
+
handleEvent(callData: any, glRenderWindow: vtkOpenGLRenderWindow): { worldCoords: Nullable<Vector3>, worldDirection?: Matrix3x3 };
|
|
57
57
|
|
|
58
58
|
/* ------------------------------------------------------------------- */
|
|
59
59
|
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
+
import macro from '../../macros.js';
|
|
4
|
+
import vtkPlane from '../../Common/DataModel/Plane.js';
|
|
5
|
+
import vtkAbstractManipulator from './AbstractManipulator.js';
|
|
6
|
+
import { mat4, vec3, mat3 } from 'gl-matrix';
|
|
7
|
+
|
|
8
|
+
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; }
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
function intersectDisplayWithPlane(x, y, planeOrigin, planeNormal, renderer, glRenderWindow) {
|
|
12
|
+
var near = glRenderWindow.displayToWorld(x, y, 0, renderer);
|
|
13
|
+
var far = glRenderWindow.displayToWorld(x, y, 1, renderer);
|
|
14
|
+
return vtkPlane.intersectWithLine(near, far, planeOrigin, planeNormal).x;
|
|
15
|
+
} // ----------------------------------------------------------------------------
|
|
16
|
+
// vtkCPRManipulator methods
|
|
17
|
+
// ----------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
function vtkCPRManipulator(publicAPI, model) {
|
|
20
|
+
// Set our className
|
|
21
|
+
model.classHierarchy.push('vtkCPRManipulator');
|
|
22
|
+
|
|
23
|
+
publicAPI.handleEvent = function (callData, glRenderWindow) {
|
|
24
|
+
var _model$cprActor;
|
|
25
|
+
|
|
26
|
+
var mapper = (_model$cprActor = model.cprActor) === null || _model$cprActor === void 0 ? void 0 : _model$cprActor.getMapper();
|
|
27
|
+
|
|
28
|
+
if (!mapper) {
|
|
29
|
+
return {
|
|
30
|
+
worldCoords: null
|
|
31
|
+
};
|
|
32
|
+
} // Get normal and origin of the picking plane from the actor matrix
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var cprActorMatrix = [];
|
|
36
|
+
mat4.transpose(cprActorMatrix, model.cprActor.getMatrix());
|
|
37
|
+
var worldPlaneNormal = cprActorMatrix.slice(8, 11); // 3rd column
|
|
38
|
+
|
|
39
|
+
var worldPlaneOrigin = cprActorMatrix.slice(12, 15); // 4th column
|
|
40
|
+
// Convert world plane position to 2D position in the plane
|
|
41
|
+
|
|
42
|
+
var inversecprActorMatrix = [];
|
|
43
|
+
mat4.invert(inversecprActorMatrix, cprActorMatrix);
|
|
44
|
+
var worldPlanePicking = intersectDisplayWithPlane(callData.position.x, callData.position.y, worldPlaneOrigin, worldPlaneNormal, callData.pokedRenderer, glRenderWindow);
|
|
45
|
+
var modelPlanePicking = []; // (x, height - distance, 0)
|
|
46
|
+
|
|
47
|
+
vec3.transformMat4(modelPlanePicking, worldPlanePicking, inversecprActorMatrix);
|
|
48
|
+
var height = mapper.getHeight();
|
|
49
|
+
var distance = height - modelPlanePicking[1];
|
|
50
|
+
return publicAPI.distanceEvent(distance);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
publicAPI.distanceEvent = function (distance) {
|
|
54
|
+
var _model$cprActor2;
|
|
55
|
+
|
|
56
|
+
var mapper = (_model$cprActor2 = model.cprActor) === null || _model$cprActor2 === void 0 ? void 0 : _model$cprActor2.getMapper();
|
|
57
|
+
|
|
58
|
+
if (!mapper) {
|
|
59
|
+
return {
|
|
60
|
+
worldCoords: null
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var height = mapper.getHeight();
|
|
65
|
+
var clampedDistance = Math.max(0, Math.min(height, distance));
|
|
66
|
+
|
|
67
|
+
var _mapper$getCenterline = mapper.getCenterlinePositionAndOrientation(clampedDistance),
|
|
68
|
+
position = _mapper$getCenterline.position,
|
|
69
|
+
orientation = _mapper$getCenterline.orientation;
|
|
70
|
+
|
|
71
|
+
var worldDirection;
|
|
72
|
+
|
|
73
|
+
if (orientation) {
|
|
74
|
+
var modelDirections = mat3.fromQuat([], orientation);
|
|
75
|
+
var baseDirections = mapper.getDirectionMatrix();
|
|
76
|
+
worldDirection = mat3.mul([], modelDirections, baseDirections);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
model.currentDistance = clampedDistance;
|
|
80
|
+
return {
|
|
81
|
+
worldCoords: position,
|
|
82
|
+
worldDirection: worldDirection
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
publicAPI.handleScroll = function (nbSteps) {
|
|
87
|
+
var distance = model.currentDistance + publicAPI.getDistanceStep() * nbSteps;
|
|
88
|
+
return publicAPI.distanceEvent(distance);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
publicAPI.getDistanceStep = function () {
|
|
92
|
+
// Find default distanceStep from image spacing
|
|
93
|
+
// This only works if the mapper in the actor already has an ImageData
|
|
94
|
+
if (!model.distanceStep) {
|
|
95
|
+
var _model$cprActor3, _model$cprActor3$getM, _model$cprActor3$getM2, _model$cprActor3$getM3;
|
|
96
|
+
|
|
97
|
+
var imageSpacing = (_model$cprActor3 = model.cprActor) === null || _model$cprActor3 === void 0 ? void 0 : (_model$cprActor3$getM = _model$cprActor3.getMapper()) === null || _model$cprActor3$getM === void 0 ? void 0 : (_model$cprActor3$getM2 = _model$cprActor3$getM.getInputData(0)) === null || _model$cprActor3$getM2 === void 0 ? void 0 : (_model$cprActor3$getM3 = _model$cprActor3$getM2.getSpacing) === null || _model$cprActor3$getM3 === void 0 ? void 0 : _model$cprActor3$getM3.call(_model$cprActor3$getM2);
|
|
98
|
+
|
|
99
|
+
if (imageSpacing) {
|
|
100
|
+
return Math.min.apply(Math, _toConsumableArray(imageSpacing));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return model.distanceStep;
|
|
105
|
+
};
|
|
106
|
+
} // ----------------------------------------------------------------------------
|
|
107
|
+
// Object factory
|
|
108
|
+
// ----------------------------------------------------------------------------
|
|
109
|
+
// currentDistance is the distance from the first point of the centerline
|
|
110
|
+
// cprActor.getMapper() should be a vtkImageCPRMapper
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
function defaultValues(initialValues) {
|
|
114
|
+
return _objectSpread({
|
|
115
|
+
distanceStep: 0,
|
|
116
|
+
currentDistance: 0,
|
|
117
|
+
cprActor: null
|
|
118
|
+
}, initialValues);
|
|
119
|
+
} // ----------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
function extend(publicAPI, model) {
|
|
123
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
124
|
+
vtkAbstractManipulator.extend(publicAPI, model, defaultValues(initialValues));
|
|
125
|
+
macro.setGet(publicAPI, model, ['distance', 'currentDistance', 'cprActor']);
|
|
126
|
+
macro.set(publicAPI, model, ['distanceStep']);
|
|
127
|
+
vtkCPRManipulator(publicAPI, model);
|
|
128
|
+
} // ----------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
var newInstance = macro.newInstance(extend, 'vtkCPRManipulator'); // ----------------------------------------------------------------------------
|
|
131
|
+
|
|
132
|
+
var index = {
|
|
133
|
+
intersectDisplayWithPlane: intersectDisplayWithPlane,
|
|
134
|
+
extend: extend,
|
|
135
|
+
newInstance: newInstance
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export { index as default, extend, intersectDisplayWithPlane, newInstance };
|
|
@@ -29,7 +29,9 @@ function vtkLineManipulator(publicAPI, model) {
|
|
|
29
29
|
model.classHierarchy.push('vtkLineManipulator');
|
|
30
30
|
|
|
31
31
|
publicAPI.handleEvent = function (callData, glRenderWindow) {
|
|
32
|
-
return
|
|
32
|
+
return {
|
|
33
|
+
worldCoords: projectDisplayToLine(callData.position.x, callData.position.y, publicAPI.getOrigin(callData), publicAPI.getNormal(callData), callData.pokedRenderer, glRenderWindow)
|
|
34
|
+
};
|
|
33
35
|
};
|
|
34
36
|
} // ----------------------------------------------------------------------------
|
|
35
37
|
// Object factory
|
|
@@ -19,7 +19,9 @@ function vtkPlaneManipulator(publicAPI, model) {
|
|
|
19
19
|
model.classHierarchy.push('vtkPlaneManipulator');
|
|
20
20
|
|
|
21
21
|
publicAPI.handleEvent = function (callData, glRenderWindow) {
|
|
22
|
-
return
|
|
22
|
+
return {
|
|
23
|
+
worldCoords: intersectDisplayWithPlane(callData.position.x, callData.position.y, publicAPI.getOrigin(callData), publicAPI.getNormal(callData), callData.pokedRenderer, glRenderWindow)
|
|
24
|
+
};
|
|
23
25
|
};
|
|
24
26
|
} // ----------------------------------------------------------------------------
|
|
25
27
|
// Object factory
|
|
@@ -39,7 +39,9 @@ function vtkTrackballManipulator(publicAPI, model) {
|
|
|
39
39
|
var newDirection = trackballRotate(prevX, prevY, callData.position.x, callData.position.y, publicAPI.getOrigin(callData), publicAPI.getNormal(callData), callData.pokedRenderer);
|
|
40
40
|
prevX = callData.position.x;
|
|
41
41
|
prevY = callData.position.y;
|
|
42
|
-
return
|
|
42
|
+
return {
|
|
43
|
+
worldCoords: newDirection
|
|
44
|
+
};
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
publicAPI.reset = function (callData) {
|
|
@@ -37,7 +37,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
37
37
|
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;
|
|
38
38
|
|
|
39
39
|
if (model.activeState === model.widgetState.getMoveHandle() && model.widgetState.getHandleList().length < MAX_POINTS && manipulator) {
|
|
40
|
-
var
|
|
40
|
+
var _manipulator$handleEv = manipulator.handleEvent(e, model._apiSpecificRenderWindow),
|
|
41
|
+
worldCoords = _manipulator$handleEv.worldCoords; // Commit handle to location
|
|
42
|
+
|
|
41
43
|
|
|
42
44
|
var moveHandle = model.widgetState.getMoveHandle();
|
|
43
45
|
moveHandle.setOrigin.apply(moveHandle, _toConsumableArray(worldCoords));
|
|
@@ -67,7 +69,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
67
69
|
var manipulator = (_model$activeState$ge3 = (_model$activeState2 = model.activeState) === null || _model$activeState2 === void 0 ? void 0 : (_model$activeState2$g = _model$activeState2.getManipulator) === null || _model$activeState2$g === void 0 ? void 0 : _model$activeState2$g.call(_model$activeState2)) !== null && _model$activeState$ge3 !== void 0 ? _model$activeState$ge3 : model.manipulator;
|
|
68
70
|
|
|
69
71
|
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
70
|
-
var
|
|
72
|
+
var _manipulator$handleEv2 = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
73
|
+
worldCoords = _manipulator$handleEv2.worldCoords;
|
|
71
74
|
|
|
72
75
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging) && model.activeState.setOrigin // e.g. the line is pickable but not draggable
|
|
73
76
|
) {
|
|
@@ -32,7 +32,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
32
32
|
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;
|
|
33
33
|
|
|
34
34
|
if (model.activeState === model.widgetState.getMoveHandle() && model.widgetState.getHandleList().length < MAX_POINTS && manipulator) {
|
|
35
|
-
var
|
|
35
|
+
var _manipulator$handleEv = manipulator.handleEvent(e, model._apiSpecificRenderWindow),
|
|
36
|
+
worldCoords = _manipulator$handleEv.worldCoords; // Commit handle to location
|
|
37
|
+
|
|
36
38
|
|
|
37
39
|
var moveHandle = model.widgetState.getMoveHandle();
|
|
38
40
|
moveHandle.setOrigin.apply(moveHandle, _toConsumableArray(worldCoords));
|
|
@@ -62,7 +64,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
62
64
|
var manipulator = (_model$activeState$ge3 = (_model$activeState2 = model.activeState) === null || _model$activeState2 === void 0 ? void 0 : (_model$activeState2$g = _model$activeState2.getManipulator) === null || _model$activeState2$g === void 0 ? void 0 : _model$activeState2$g.call(_model$activeState2)) !== null && _model$activeState$ge3 !== void 0 ? _model$activeState$ge3 : model.manipulator;
|
|
63
65
|
|
|
64
66
|
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
65
|
-
var
|
|
67
|
+
var _manipulator$handleEv2 = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
68
|
+
worldCoords = _manipulator$handleEv2.worldCoords;
|
|
66
69
|
|
|
67
70
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging) && model.activeState.setOrigin // e.g. the line is pickable but not draggable
|
|
68
71
|
) {
|
|
@@ -65,7 +65,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
65
65
|
|
|
66
66
|
if (type === 'corners') {
|
|
67
67
|
// manipulator should be a plane manipulator
|
|
68
|
-
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
68
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (type === 'faces') {
|
|
@@ -78,7 +78,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
78
78
|
|
|
79
79
|
manipulator.setHandleOrigin(transformVec3(center, indexToWorldT));
|
|
80
80
|
manipulator.setHandleNormal(rotateVec3(constraintAxis, indexToWorldT));
|
|
81
|
-
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
81
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (type === 'edges') {
|
|
@@ -87,7 +87,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
87
87
|
return a === 1 ? a : 0;
|
|
88
88
|
});
|
|
89
89
|
manipulator.setHandleNormal(rotateVec3(edgeAxis, indexToWorldT));
|
|
90
|
-
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
90
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
if (worldCoords.length) {
|
|
@@ -106,7 +106,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
106
106
|
|
|
107
107
|
publicAPI.updateFromOrigin = function (callData) {
|
|
108
108
|
model.planeManipulator.setWidgetNormal(model.widgetState.getNormal());
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
var _model$planeManipulat = model.planeManipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
111
|
+
worldCoords = _model$planeManipulat.worldCoords;
|
|
110
112
|
|
|
111
113
|
if (model.widgetState.containsPoint(worldCoords)) {
|
|
112
114
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -43,7 +43,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
43
43
|
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;
|
|
44
44
|
|
|
45
45
|
if (model.activeState === model.widgetState.getMoveHandle() && manipulator) {
|
|
46
|
-
var
|
|
46
|
+
var _manipulator$handleEv = manipulator.handleEvent(e, model._apiSpecificRenderWindow),
|
|
47
|
+
worldCoords = _manipulator$handleEv.worldCoords; // Commit handle to location
|
|
48
|
+
|
|
47
49
|
|
|
48
50
|
var moveHandle = model.widgetState.getMoveHandle();
|
|
49
51
|
moveHandle.setOrigin(worldCoords);
|
|
@@ -100,7 +102,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
100
102
|
var manipulator = (_model$activeState$ge3 = (_model$activeState2 = model.activeState) === null || _model$activeState2 === void 0 ? void 0 : (_model$activeState2$g = _model$activeState2.getManipulator) === null || _model$activeState2$g === void 0 ? void 0 : _model$activeState2$g.call(_model$activeState2)) !== null && _model$activeState$ge3 !== void 0 ? _model$activeState$ge3 : model.manipulator;
|
|
101
103
|
|
|
102
104
|
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
103
|
-
var
|
|
105
|
+
var _manipulator$handleEv2 = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
106
|
+
worldCoords = _manipulator$handleEv2.worldCoords;
|
|
104
107
|
|
|
105
108
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging)) {
|
|
106
109
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -57,7 +57,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
57
57
|
|
|
58
58
|
model._isDragging = true;
|
|
59
59
|
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;
|
|
60
|
-
model.previousPosition =
|
|
60
|
+
model.previousPosition = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
|
|
61
61
|
|
|
62
62
|
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
63
63
|
|
|
@@ -203,7 +203,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
203
203
|
var manipulator = (_model$activeState$ge3 = (_model$activeState2 = model.activeState) === null || _model$activeState2 === void 0 ? void 0 : (_model$activeState2$g = _model$activeState2.getManipulator) === null || _model$activeState2$g === void 0 ? void 0 : _model$activeState2$g.call(_model$activeState2)) !== null && _model$activeState$ge3 !== void 0 ? _model$activeState$ge3 : model.manipulator;
|
|
204
204
|
|
|
205
205
|
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
206
|
-
var
|
|
206
|
+
var _manipulator$handleEv = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
207
|
+
worldCoords = _manipulator$handleEv.worldCoords;
|
|
208
|
+
|
|
207
209
|
var translation = model.previousPosition ? subtract(worldCoords, model.previousPosition, []) : [0, 0, 0];
|
|
208
210
|
model.previousPosition = worldCoords;
|
|
209
211
|
|
|
@@ -52,7 +52,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
52
52
|
|
|
53
53
|
(_model$activeState4 = model.activeState).setDirection.apply(_model$activeState4, _toConsumableArray(normal));
|
|
54
54
|
|
|
55
|
-
var
|
|
55
|
+
var _manipulator$handleEv = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
56
|
+
worldCoords = _manipulator$handleEv.worldCoords;
|
|
56
57
|
|
|
57
58
|
if (worldCoords.length) {
|
|
58
59
|
var _model$widgetState, _model$activeState5;
|
|
@@ -26,7 +26,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
26
26
|
return macro.VOID;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _manipulator$handleEv = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
30
|
+
worldCoords = _manipulator$handleEv.worldCoords;
|
|
30
31
|
|
|
31
32
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging) && model.activeState.setOrigin // e.g. the line is pickable but not draggable
|
|
32
33
|
) {
|
|
@@ -12,7 +12,8 @@ var ScrollingMethods = {
|
|
|
12
12
|
var InteractionMethodsName = {
|
|
13
13
|
TranslateAxis: 'translateAxis',
|
|
14
14
|
RotateLine: 'rotateLine',
|
|
15
|
-
TranslateCenter: 'translateCenter'
|
|
15
|
+
TranslateCenter: 'translateCenter',
|
|
16
|
+
TranslateCenterAndUpdatePlanes: 'translateCenterAndUpdatePlanes'
|
|
16
17
|
};
|
|
17
18
|
var defaultViewUpFromViewType = (_defaultViewUpFromVie = {}, _defineProperty(_defaultViewUpFromVie, ViewTypes.YZ_PLANE, [0, 0, 1]), _defineProperty(_defaultViewUpFromVie, ViewTypes.XZ_PLANE, [0, 0, 1]), _defineProperty(_defaultViewUpFromVie, ViewTypes.XY_PLANE, [0, -1, 0]), _defaultViewUpFromVie);
|
|
18
19
|
var xyzToViewType = [ViewTypes.YZ_PLANE, ViewTypes.XZ_PLANE, ViewTypes.XY_PLANE];
|
|
@@ -2,10 +2,9 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
|
2
2
|
import macro from '../../../macros.js';
|
|
3
3
|
import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
|
|
4
4
|
import vtkLine from '../../../Common/DataModel/Line.js';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { InteractionMethodsName, lineNames, ScrollingMethods, planeNameToViewType } from './Constants.js';
|
|
5
|
+
import { k as add, l as normalize, s as subtract, d as dot, j as cross, m as multiplyAccumulate, w as multiplyScalar, S as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
|
|
6
|
+
import { getLineNames, getOtherLineName, updateState, boundPointOnPlane, getLinePlaneName, getLineInPlaneName, rotateVector } from './helpers.js';
|
|
7
|
+
import { InteractionMethodsName, ScrollingMethods, planeNameToViewType } from './Constants.js';
|
|
9
8
|
|
|
10
9
|
function widgetBehavior(publicAPI, model) {
|
|
11
10
|
model._isDragging = false;
|
|
@@ -46,7 +45,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
publicAPI.getActiveLineName = function () {
|
|
49
|
-
return
|
|
48
|
+
return getLineNames(model.widgetState).find(function (lineName) {
|
|
50
49
|
return model.widgetState.getStatesWithLabel(lineName).includes(model.activeState);
|
|
51
50
|
});
|
|
52
51
|
}; // FIXME: label information should be accessible from activeState instead of parent state.
|
|
@@ -67,19 +66,27 @@ function widgetBehavior(publicAPI, model) {
|
|
|
67
66
|
publicAPI.getOtherLineHandle = function (lineName) {
|
|
68
67
|
var _model$widgetState$2, _model$widgetState2;
|
|
69
68
|
|
|
70
|
-
return (_model$widgetState$2 = (_model$widgetState2 = model.widgetState)["getAxis".concat(getOtherLineName(lineName))]) === null || _model$widgetState$2 === void 0 ? void 0 : _model$widgetState$2.call(_model$widgetState2);
|
|
69
|
+
return (_model$widgetState$2 = (_model$widgetState2 = model.widgetState)["getAxis".concat(getOtherLineName(model.widgetState, lineName))]) === null || _model$widgetState$2 === void 0 ? void 0 : _model$widgetState$2.call(_model$widgetState2);
|
|
71
70
|
}; // FIXME: label information should be accessible from activeState instead of parent state.
|
|
72
71
|
|
|
73
72
|
/**
|
|
74
73
|
* There are 2 rotation handles per axis: 'point0' and 'point1'.
|
|
75
74
|
* This function returns which rotation handle (point0 or point1) is currently active.
|
|
76
75
|
* ActiveState must be a RotationHandle.
|
|
77
|
-
* @returns 'point0'
|
|
76
|
+
* @returns 'point0', 'point1' or null if no point is active (e.g. line is being rotated)
|
|
78
77
|
*/
|
|
79
78
|
|
|
80
79
|
|
|
81
80
|
publicAPI.getActiveRotationPointName = function () {
|
|
82
|
-
|
|
81
|
+
if (model.widgetState.getStatesWithLabel('point0').includes(model.activeState)) {
|
|
82
|
+
return 'point0';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (model.widgetState.getStatesWithLabel('point1').includes(model.activeState)) {
|
|
86
|
+
return 'point1';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return null;
|
|
83
90
|
};
|
|
84
91
|
|
|
85
92
|
publicAPI.startScrolling = function (newPosition) {
|
|
@@ -122,12 +129,18 @@ function widgetBehavior(publicAPI, model) {
|
|
|
122
129
|
|
|
123
130
|
publicAPI.handleLeftButtonPress = function (callData) {
|
|
124
131
|
if (model.activeState && model.activeState.getActive()) {
|
|
132
|
+
var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
|
|
133
|
+
|
|
125
134
|
model._isDragging = true;
|
|
126
135
|
var viewType = model.viewType;
|
|
127
136
|
var currentPlaneNormal = model.widgetState.getPlanes()[viewType].normal;
|
|
128
|
-
model.
|
|
129
|
-
model.
|
|
130
|
-
|
|
137
|
+
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;
|
|
138
|
+
manipulator.setWidgetOrigin(model.widgetState.getCenter());
|
|
139
|
+
manipulator.setWidgetNormal(currentPlaneNormal);
|
|
140
|
+
|
|
141
|
+
var _manipulator$handleEv = manipulator.handleEvent(callData, model._apiSpecificRenderWindow),
|
|
142
|
+
worldCoords = _manipulator$handleEv.worldCoords;
|
|
143
|
+
|
|
131
144
|
previousPosition = worldCoords;
|
|
132
145
|
publicAPI.startInteraction();
|
|
133
146
|
} else if (model.widgetState.getScrollingMethod() === ScrollingMethods.LEFT_MOUSE_BUTTON) {
|
|
@@ -261,6 +274,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
261
274
|
};
|
|
262
275
|
|
|
263
276
|
publicAPI[InteractionMethodsName.TranslateAxis] = function (calldata) {
|
|
277
|
+
var _model$activeState$ge3, _model$activeState2, _model$activeState2$g, _model$activeState3, _model$activeState3$g;
|
|
278
|
+
|
|
264
279
|
var lineHandle = publicAPI.getActiveLineHandle();
|
|
265
280
|
var lineName = publicAPI.getActiveLineName();
|
|
266
281
|
var pointOnLine = add(lineHandle.getOrigin(), lineHandle.getDirection(), []);
|
|
@@ -268,25 +283,37 @@ function widgetBehavior(publicAPI, model) {
|
|
|
268
283
|
normalize(currentLineVector); // Translate the current line along the other line
|
|
269
284
|
|
|
270
285
|
var otherLineHandle = publicAPI.getOtherLineHandle(lineName);
|
|
271
|
-
var
|
|
272
|
-
|
|
273
|
-
var
|
|
274
|
-
var
|
|
286
|
+
var center = model.widgetState.getCenter();
|
|
287
|
+
var manipulator = (_model$activeState$ge3 = (_model$activeState2 = model.activeState) === null || _model$activeState2 === void 0 ? void 0 : (_model$activeState2$g = _model$activeState2.getManipulator) === null || _model$activeState2$g === void 0 ? void 0 : _model$activeState2$g.call(_model$activeState2)) !== null && _model$activeState$ge3 !== void 0 ? _model$activeState$ge3 : model.manipulator;
|
|
288
|
+
var worldCoords = null;
|
|
289
|
+
var newOrigin = [];
|
|
290
|
+
|
|
291
|
+
if ((_model$activeState3 = model.activeState) !== null && _model$activeState3 !== void 0 && (_model$activeState3$g = _model$activeState3.getManipulator) !== null && _model$activeState3$g !== void 0 && _model$activeState3$g.call(_model$activeState3)) {
|
|
292
|
+
worldCoords = manipulator.handleEvent(calldata, model._apiSpecificRenderWindow).worldCoords;
|
|
293
|
+
var translation = subtract(worldCoords, previousPosition, []);
|
|
294
|
+
add(center, translation, newOrigin);
|
|
295
|
+
} else if (otherLineHandle) {
|
|
296
|
+
var otherLineVector = otherLineHandle.getDirection();
|
|
297
|
+
normalize(otherLineVector);
|
|
298
|
+
var axisTranslation = otherLineVector;
|
|
299
|
+
var dot$1 = dot(currentLineVector, otherLineVector); // lines are colinear, translate along perpendicular axis from current line
|
|
300
|
+
|
|
301
|
+
if (dot$1 === 1 || dot$1 === -1) {
|
|
302
|
+
cross(currentLineVector, manipulator.getWidgetNormal(), axisTranslation);
|
|
303
|
+
}
|
|
275
304
|
|
|
276
|
-
|
|
277
|
-
|
|
305
|
+
var closestPoint = [];
|
|
306
|
+
worldCoords = manipulator.handleEvent(calldata, model._apiSpecificRenderWindow).worldCoords;
|
|
307
|
+
vtkLine.distanceToLine(worldCoords, lineHandle.getOrigin(), pointOnLine, closestPoint);
|
|
308
|
+
var translationVector = subtract(worldCoords, closestPoint, []);
|
|
309
|
+
var translationDistance = dot(translationVector, axisTranslation);
|
|
310
|
+
newOrigin = multiplyAccumulate(center, axisTranslation, translationDistance, newOrigin);
|
|
278
311
|
}
|
|
279
312
|
|
|
280
|
-
var closestPoint = [];
|
|
281
|
-
var worldCoords = model.planeManipulator.handleEvent(calldata, model._apiSpecificRenderWindow);
|
|
282
|
-
vtkLine.distanceToLine(worldCoords, lineHandle.getOrigin(), pointOnLine, closestPoint);
|
|
283
|
-
var translationVector = subtract(worldCoords, closestPoint, []);
|
|
284
|
-
var translationDistance = dot(translationVector, axisTranslation);
|
|
285
|
-
var center = model.widgetState.getCenter();
|
|
286
|
-
var newOrigin = multiplyAccumulate(center, axisTranslation, translationDistance, [0, 0, 0]);
|
|
287
313
|
newOrigin = publicAPI.getBoundedCenter(newOrigin);
|
|
288
314
|
model.widgetState.setCenter(newOrigin);
|
|
289
315
|
updateState(model.widgetState, model._factory.getScaleInPixels(), model._factory.getRotationHandlePosition());
|
|
316
|
+
previousPosition = worldCoords;
|
|
290
317
|
};
|
|
291
318
|
|
|
292
319
|
publicAPI.getBoundedCenter = function (newCenter) {
|
|
@@ -301,7 +328,13 @@ function widgetBehavior(publicAPI, model) {
|
|
|
301
328
|
};
|
|
302
329
|
|
|
303
330
|
publicAPI[InteractionMethodsName.TranslateCenter] = function (calldata) {
|
|
304
|
-
var
|
|
331
|
+
var _model$activeState$ge4, _model$activeState4, _model$activeState4$g;
|
|
332
|
+
|
|
333
|
+
var manipulator = (_model$activeState$ge4 = (_model$activeState4 = model.activeState) === null || _model$activeState4 === void 0 ? void 0 : (_model$activeState4$g = _model$activeState4.getManipulator) === null || _model$activeState4$g === void 0 ? void 0 : _model$activeState4$g.call(_model$activeState4)) !== null && _model$activeState$ge4 !== void 0 ? _model$activeState$ge4 : model.manipulator;
|
|
334
|
+
|
|
335
|
+
var _manipulator$handleEv2 = manipulator.handleEvent(calldata, model._apiSpecificRenderWindow),
|
|
336
|
+
worldCoords = _manipulator$handleEv2.worldCoords;
|
|
337
|
+
|
|
305
338
|
var translation = subtract(worldCoords, previousPosition, []);
|
|
306
339
|
previousPosition = worldCoords;
|
|
307
340
|
var newCenter = add(model.widgetState.getCenter(), translation, []);
|
|
@@ -311,20 +344,27 @@ function widgetBehavior(publicAPI, model) {
|
|
|
311
344
|
};
|
|
312
345
|
|
|
313
346
|
publicAPI[InteractionMethodsName.RotateLine] = function (calldata) {
|
|
347
|
+
var _model$activeState$ge5, _model$activeState5, _model$activeState5$g;
|
|
348
|
+
|
|
314
349
|
var activeLineHandle = publicAPI.getActiveLineHandle();
|
|
315
|
-
var
|
|
316
|
-
var
|
|
350
|
+
var manipulator = (_model$activeState$ge5 = (_model$activeState5 = model.activeState) === null || _model$activeState5 === void 0 ? void 0 : (_model$activeState5$g = _model$activeState5.getManipulator) === null || _model$activeState5$g === void 0 ? void 0 : _model$activeState5$g.call(_model$activeState5)) !== null && _model$activeState$ge5 !== void 0 ? _model$activeState$ge5 : model.manipulator;
|
|
351
|
+
var planeNormal = manipulator.getWidgetNormal();
|
|
352
|
+
|
|
353
|
+
var _manipulator$handleEv3 = manipulator.handleEvent(calldata, model._apiSpecificRenderWindow),
|
|
354
|
+
worldCoords = _manipulator$handleEv3.worldCoords;
|
|
355
|
+
|
|
317
356
|
var center = model.widgetState.getCenter();
|
|
357
|
+
var currentVectorToOrigin = [0, 0, 0];
|
|
358
|
+
subtract(worldCoords, center, currentVectorToOrigin);
|
|
359
|
+
normalize(currentVectorToOrigin);
|
|
318
360
|
var previousLineDirection = activeLineHandle.getDirection();
|
|
319
361
|
normalize(previousLineDirection);
|
|
362
|
+
var activePointName = publicAPI.getActiveRotationPointName();
|
|
320
363
|
|
|
321
|
-
if (
|
|
364
|
+
if (activePointName === 'point1' || !activePointName && dot(currentVectorToOrigin, previousLineDirection) < 0) {
|
|
322
365
|
multiplyScalar(previousLineDirection, -1);
|
|
323
366
|
}
|
|
324
367
|
|
|
325
|
-
var currentVectorToOrigin = [0, 0, 0];
|
|
326
|
-
subtract(worldCoords, center, currentVectorToOrigin);
|
|
327
|
-
normalize(currentVectorToOrigin);
|
|
328
368
|
var radianAngle = signedAngleBetweenVectors(previousLineDirection, currentVectorToOrigin, planeNormal);
|
|
329
369
|
publicAPI.rotateLineInView(publicAPI.getActiveLineName(), radianAngle);
|
|
330
370
|
};
|
|
@@ -342,7 +382,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
342
382
|
publicAPI.rotatePlane(viewType, radianAngle, planeNormal);
|
|
343
383
|
|
|
344
384
|
if (publicAPI.getKeepOrthogonality()) {
|
|
345
|
-
var otherLineName = getOtherLineName(lineName);
|
|
385
|
+
var otherLineName = getOtherLineName(model.widgetState, lineName);
|
|
346
386
|
var otherPlaneName = getLinePlaneName(otherLineName);
|
|
347
387
|
publicAPI.rotatePlane(planeNameToViewType[otherPlaneName], radianAngle, planeNormal);
|
|
348
388
|
}
|
|
@@ -371,8 +411,6 @@ function widgetBehavior(publicAPI, model) {
|
|
|
371
411
|
// initialization
|
|
372
412
|
// --------------------------------------------------------------------------
|
|
373
413
|
|
|
374
|
-
|
|
375
|
-
model.planeManipulator = vtkPlanePointManipulator.newInstance();
|
|
376
414
|
}
|
|
377
415
|
|
|
378
416
|
export { widgetBehavior as default };
|