@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
1
2
|
import macro from '../../macros.js';
|
|
2
3
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
4
|
import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
|
|
@@ -8,11 +9,17 @@ import widgetBehavior from './AngleWidget/behavior.js';
|
|
|
8
9
|
import generateState from './AngleWidget/state.js';
|
|
9
10
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
10
11
|
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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
15
|
// Factory
|
|
12
16
|
// ----------------------------------------------------------------------------
|
|
13
17
|
|
|
14
18
|
function vtkAngleWidget(publicAPI, model) {
|
|
15
|
-
model.classHierarchy.push('vtkAngleWidget');
|
|
19
|
+
model.classHierarchy.push('vtkAngleWidget');
|
|
20
|
+
|
|
21
|
+
var superClass = _objectSpread({}, publicAPI); // --- Widget Requirement ---------------------------------------------------
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
model.methodsToLink = ['activeScaleFactor', 'activeColor', 'useActiveColor', 'glyphResolution', 'defaultScale'];
|
|
18
25
|
model.behavior = widgetBehavior;
|
|
@@ -56,6 +63,14 @@ function vtkAngleWidget(publicAPI, model) {
|
|
|
56
63
|
subtract(handles[0].getOrigin(), handles[1].getOrigin(), vec1);
|
|
57
64
|
subtract(handles[2].getOrigin(), handles[1].getOrigin(), vec2);
|
|
58
65
|
return angleBetweenVectors(vec1, vec2);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
publicAPI.setManipulator = function (manipulator) {
|
|
69
|
+
superClass.setManipulator(manipulator);
|
|
70
|
+
model.widgetState.getMoveHandle().setManipulator(manipulator);
|
|
71
|
+
model.widgetState.getHandleList().forEach(function (handle) {
|
|
72
|
+
handle.setManipulator(manipulator);
|
|
73
|
+
});
|
|
59
74
|
}; // --------------------------------------------------------------------------
|
|
60
75
|
// initialization
|
|
61
76
|
// --------------------------------------------------------------------------
|
|
@@ -66,7 +81,9 @@ function vtkAngleWidget(publicAPI, model) {
|
|
|
66
81
|
model.widgetState.getMoveHandle().setOrigin(center);
|
|
67
82
|
}); // Default manipulator
|
|
68
83
|
|
|
69
|
-
model.manipulator
|
|
84
|
+
publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
|
|
85
|
+
useCameraNormal: true
|
|
86
|
+
}));
|
|
70
87
|
} // ----------------------------------------------------------------------------
|
|
71
88
|
|
|
72
89
|
|
|
@@ -34,6 +34,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
34
34
|
newHandle.setOrigin.apply(newHandle, _toConsumableArray(moveHandle.getOrigin()));
|
|
35
35
|
newHandle.setColor(moveHandle.getColor());
|
|
36
36
|
newHandle.setScale1(moveHandle.getScale1());
|
|
37
|
+
newHandle.setManipulator(model.manipulator);
|
|
37
38
|
} else {
|
|
38
39
|
isDragging = true;
|
|
39
40
|
|
|
@@ -50,13 +51,17 @@ function widgetBehavior(publicAPI, model) {
|
|
|
50
51
|
|
|
51
52
|
|
|
52
53
|
publicAPI.handleMouseMove = function (callData) {
|
|
54
|
+
var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
|
|
55
|
+
|
|
53
56
|
if (model.hasFocus && model.widgetState.getHandleList().length === MAX_POINTS) {
|
|
54
57
|
publicAPI.loseFocus();
|
|
55
58
|
return macro.VOID;
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
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;
|
|
62
|
+
|
|
63
|
+
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
64
|
+
var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
60
65
|
|
|
61
66
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
|
|
62
67
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -3,7 +3,7 @@ import vtkStateBuilder from '../../Core/StateBuilder.js';
|
|
|
3
3
|
function generateState() {
|
|
4
4
|
return vtkStateBuilder.createBuilder().addStateFromMixin({
|
|
5
5
|
labels: ['moveHandle'],
|
|
6
|
-
mixins: ['origin', 'color', 'scale1', 'visible'],
|
|
6
|
+
mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
|
|
7
7
|
name: 'moveHandle',
|
|
8
8
|
initialValues: {
|
|
9
9
|
scale1: 0.1,
|
|
@@ -11,7 +11,7 @@ function generateState() {
|
|
|
11
11
|
}
|
|
12
12
|
}).addDynamicMixinState({
|
|
13
13
|
labels: ['handles'],
|
|
14
|
-
mixins: ['origin', 'color', 'scale1', 'visible'],
|
|
14
|
+
mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
|
|
15
15
|
name: 'handle',
|
|
16
16
|
initialValues: {
|
|
17
17
|
scale1: 0.1
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
1
2
|
import macro from '../../macros.js';
|
|
2
3
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
4
|
import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
|
|
@@ -8,11 +9,17 @@ import widgetBehavior from './DistanceWidget/behavior.js';
|
|
|
8
9
|
import generateState from './DistanceWidget/state.js';
|
|
9
10
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
10
11
|
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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
15
|
// Factory
|
|
12
16
|
// ----------------------------------------------------------------------------
|
|
13
17
|
|
|
14
18
|
function vtkDistanceWidget(publicAPI, model) {
|
|
15
|
-
model.classHierarchy.push('vtkDistanceWidget');
|
|
19
|
+
model.classHierarchy.push('vtkDistanceWidget');
|
|
20
|
+
|
|
21
|
+
var superClass = _objectSpread({}, publicAPI); // --- Widget Requirement ---------------------------------------------------
|
|
22
|
+
|
|
16
23
|
|
|
17
24
|
model.methodsToLink = ['activeScaleFactor', 'activeColor', 'useActiveColor', 'glyphResolution', 'defaultScale'];
|
|
18
25
|
model.behavior = widgetBehavior;
|
|
@@ -51,6 +58,14 @@ function vtkDistanceWidget(publicAPI, model) {
|
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
return Math.sqrt(distance2BetweenPoints(handles[0].getOrigin(), handles[1].getOrigin()));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
publicAPI.setManipulator = function (manipulator) {
|
|
64
|
+
superClass.setManipulator(manipulator);
|
|
65
|
+
model.widgetState.getMoveHandle().setManipulator(manipulator);
|
|
66
|
+
model.widgetState.getHandleList().forEach(function (handle) {
|
|
67
|
+
handle.setManipulator(manipulator);
|
|
68
|
+
});
|
|
54
69
|
}; // --------------------------------------------------------------------------
|
|
55
70
|
// initialization
|
|
56
71
|
// --------------------------------------------------------------------------
|
|
@@ -61,7 +76,9 @@ function vtkDistanceWidget(publicAPI, model) {
|
|
|
61
76
|
model.widgetState.getMoveHandle().setOrigin(center);
|
|
62
77
|
}); // Default manipulator
|
|
63
78
|
|
|
64
|
-
model.manipulator
|
|
79
|
+
publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
|
|
80
|
+
useCameraNormal: true
|
|
81
|
+
}));
|
|
65
82
|
} // ----------------------------------------------------------------------------
|
|
66
83
|
|
|
67
84
|
|
|
@@ -50,11 +50,12 @@ function vtkEllipseWidget(publicAPI, model) {
|
|
|
50
50
|
}; // --------------------------------------------------------------------------
|
|
51
51
|
// initialization
|
|
52
52
|
// --------------------------------------------------------------------------
|
|
53
|
-
// Default manipulator
|
|
54
53
|
|
|
55
54
|
|
|
56
|
-
model.manipulator = vtkPlanePointManipulator.newInstance();
|
|
57
55
|
model.widgetState = generateState();
|
|
56
|
+
publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
|
|
57
|
+
useCameraNormal: true
|
|
58
|
+
}));
|
|
58
59
|
} // ----------------------------------------------------------------------------
|
|
59
60
|
|
|
60
61
|
|
|
@@ -74,7 +75,7 @@ function defaultValues(initialValues) {
|
|
|
74
75
|
function extend(publicAPI, model) {
|
|
75
76
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
76
77
|
vtkShapeWidget.extend(publicAPI, model, defaultValues(initialValues));
|
|
77
|
-
macro.setGet(publicAPI, model, ['
|
|
78
|
+
macro.setGet(publicAPI, model, ['widgetState']);
|
|
78
79
|
vtkEllipseWidget(publicAPI, model);
|
|
79
80
|
} // ----------------------------------------------------------------------------
|
|
80
81
|
|
|
@@ -55,7 +55,6 @@ function widgetBehavior(publicAPI, model) {
|
|
|
55
55
|
|
|
56
56
|
if (type === 'corners') {
|
|
57
57
|
// manipulator should be a plane manipulator
|
|
58
|
-
manipulator.setNormal(model._camera.getDirectionOfProjection());
|
|
59
58
|
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
60
59
|
}
|
|
61
60
|
|
|
@@ -67,8 +66,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
67
66
|
|
|
68
67
|
var center = [(planes[0] + planes[1]) / 2, (planes[2] + planes[3]) / 2, (planes[4] + planes[5]) / 2]; // manipulator should be a line manipulator
|
|
69
68
|
|
|
70
|
-
manipulator.
|
|
71
|
-
manipulator.
|
|
69
|
+
manipulator.setHandleOrigin(transformVec3(center, indexToWorldT));
|
|
70
|
+
manipulator.setHandleNormal(rotateVec3(constraintAxis, indexToWorldT));
|
|
72
71
|
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
73
72
|
}
|
|
74
73
|
|
|
@@ -77,7 +76,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
77
76
|
var edgeAxis = index.map(function (a) {
|
|
78
77
|
return a === 1 ? a : 0;
|
|
79
78
|
});
|
|
80
|
-
manipulator.
|
|
79
|
+
manipulator.setHandleNormal(rotateVec3(edgeAxis, indexToWorldT));
|
|
81
80
|
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
4
|
import macro from '../../macros.js';
|
|
4
5
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
5
6
|
import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
|
|
@@ -11,12 +12,18 @@ import state from './ImageCroppingWidget/state.js';
|
|
|
11
12
|
import { transformVec3, AXES } from './ImageCroppingWidget/helpers.js';
|
|
12
13
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
13
14
|
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
14
18
|
// ----------------------------------------------------------------------------
|
|
15
19
|
// Factory
|
|
16
20
|
// ----------------------------------------------------------------------------
|
|
17
21
|
|
|
18
22
|
function vtkImageCroppingWidget(publicAPI, model) {
|
|
19
23
|
model.classHierarchy.push('vtkImageCroppingWidget');
|
|
24
|
+
|
|
25
|
+
var superClass = _objectSpread({}, publicAPI);
|
|
26
|
+
|
|
20
27
|
var stateSub = null; // --------------------------------------------------------------------------
|
|
21
28
|
|
|
22
29
|
function setHandlesEnabled(label, flag) {
|
|
@@ -120,28 +127,50 @@ function vtkImageCroppingWidget(publicAPI, model) {
|
|
|
120
127
|
}; // Update handle positions when cropping planes update
|
|
121
128
|
|
|
122
129
|
|
|
123
|
-
stateSub = model.widgetState.getCroppingPlanes().onModified(publicAPI.updateHandles);
|
|
130
|
+
stateSub = model.widgetState.getCroppingPlanes().onModified(publicAPI.updateHandles);
|
|
131
|
+
|
|
132
|
+
publicAPI.setCornerManipulator = function (manipulator) {
|
|
133
|
+
superClass.setCornerManipulator(manipulator);
|
|
134
|
+
model.widgetState.getStatesWithLabel('corners').forEach(function (handle) {
|
|
135
|
+
return handle.setManipulator(manipulator);
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
publicAPI.setEdgeManipulator = function (manipulator) {
|
|
140
|
+
superClass.setEdgeManipulator(manipulator);
|
|
141
|
+
model.widgetState.getStatesWithLabel('edges').forEach(function (handle) {
|
|
142
|
+
return handle.setManipulator(manipulator);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
publicAPI.setFaceManipulator = function (manipulator) {
|
|
147
|
+
superClass.setFaceManipulator(manipulator);
|
|
148
|
+
model.widgetState.getStatesWithLabel('faces').forEach(function (handle) {
|
|
149
|
+
return handle.setManipulator(manipulator);
|
|
150
|
+
});
|
|
151
|
+
}; // --------------------------------------------------------------------------
|
|
152
|
+
// initialization
|
|
153
|
+
// --------------------------------------------------------------------------
|
|
154
|
+
|
|
124
155
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
model.widgetState.getStatesWithLabel('edges').forEach(function (handle) {
|
|
131
|
-
return handle.setManipulator(planeManipulator);
|
|
132
|
-
});
|
|
133
|
-
model.widgetState.getStatesWithLabel('faces').forEach(function (handle) {
|
|
134
|
-
return handle.setManipulator(lineManipulator);
|
|
135
|
-
});
|
|
156
|
+
publicAPI.setCornerManipulator(vtkPlanePointManipulator.newInstance({
|
|
157
|
+
useCameraNormal: true
|
|
158
|
+
}));
|
|
159
|
+
publicAPI.setEdgeManipulator(vtkPlanePointManipulator.newInstance());
|
|
160
|
+
publicAPI.setFaceManipulator(vtkLineManipulator.newInstance());
|
|
136
161
|
} // ----------------------------------------------------------------------------
|
|
137
162
|
|
|
138
163
|
|
|
139
|
-
var DEFAULT_VALUES = {
|
|
164
|
+
var DEFAULT_VALUES = {// cornerManipulator: null,
|
|
165
|
+
// edgeManipulator: null,
|
|
166
|
+
// faceManipulator: null
|
|
167
|
+
}; // ----------------------------------------------------------------------------
|
|
140
168
|
|
|
141
169
|
function extend(publicAPI, model) {
|
|
142
170
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
143
171
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
144
172
|
vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
|
|
173
|
+
macro.setGet(publicAPI, model, ['cornerManipulator', 'edgeManipulator', 'faceManipulator']);
|
|
145
174
|
vtkImageCroppingWidget(publicAPI, model);
|
|
146
175
|
} // ----------------------------------------------------------------------------
|
|
147
176
|
|
|
@@ -48,8 +48,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
isDragging = true;
|
|
51
|
-
model.lineManipulator.
|
|
52
|
-
model.planeManipulator.
|
|
51
|
+
model.lineManipulator.setWidgetOrigin(model.widgetState.getOrigin());
|
|
52
|
+
model.planeManipulator.setWidgetOrigin(model.widgetState.getOrigin());
|
|
53
53
|
model.trackballManipulator.reset(callData); // setup trackball delta
|
|
54
54
|
|
|
55
55
|
model._interactor.requestAnimation(publicAPI);
|
|
@@ -91,7 +91,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
publicAPI.updateFromOrigin = function (callData) {
|
|
94
|
-
model.planeManipulator.
|
|
94
|
+
model.planeManipulator.setWidgetNormal(model.widgetState.getNormal());
|
|
95
95
|
var worldCoords = model.planeManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
96
96
|
|
|
97
97
|
if (model.widgetState.containsPoint(worldCoords)) {
|
|
@@ -104,7 +104,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
104
104
|
var _model$widgetState;
|
|
105
105
|
|
|
106
106
|
// Move origin along normal axis
|
|
107
|
-
model.lineManipulator.
|
|
107
|
+
model.lineManipulator.setWidgetNormal(model.activeState.getNormal());
|
|
108
108
|
var worldCoords = model.lineManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
109
109
|
|
|
110
110
|
if ((_model$widgetState = model.widgetState).containsPoint.apply(_model$widgetState, _toConsumableArray(worldCoords))) {
|
|
@@ -114,7 +114,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
114
114
|
|
|
115
115
|
|
|
116
116
|
publicAPI.updateFromNormal = function (callData) {
|
|
117
|
-
model.trackballManipulator.
|
|
117
|
+
model.trackballManipulator.setWidgetNormal(model.activeState.getNormal());
|
|
118
118
|
var newNormal = model.trackballManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
119
119
|
model.activeState.setNormal(newNormal);
|
|
120
120
|
}; // --------------------------------------------------------------------------
|
|
@@ -93,8 +93,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
publicAPI.handleMouseMove = function (callData) {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
|
|
97
|
+
|
|
98
|
+
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;
|
|
99
|
+
|
|
100
|
+
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
101
|
+
var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
98
102
|
|
|
99
103
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model.isDragging)) {
|
|
100
104
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -3,7 +3,7 @@ import vtkStateBuilder from '../../Core/StateBuilder.js';
|
|
|
3
3
|
function generateState() {
|
|
4
4
|
return vtkStateBuilder.createBuilder().addStateFromMixin({
|
|
5
5
|
labels: ['moveHandle'],
|
|
6
|
-
mixins: ['origin', 'color', 'scale1', 'visible'],
|
|
6
|
+
mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
|
|
7
7
|
name: 'moveHandle',
|
|
8
8
|
initialValues: {
|
|
9
9
|
scale1: 0.1,
|
|
@@ -11,7 +11,7 @@ function generateState() {
|
|
|
11
11
|
}
|
|
12
12
|
}).addStateFromMixin({
|
|
13
13
|
labels: ['SVGtext'],
|
|
14
|
-
mixins: ['origin', 'color', 'text', 'visible'],
|
|
14
|
+
mixins: ['origin', 'color', 'text', 'visible', 'manipulator'],
|
|
15
15
|
name: 'text',
|
|
16
16
|
initialValues: {
|
|
17
17
|
visible: true
|
|
@@ -16,7 +16,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
// ----------------------------------------------------------------------------
|
|
17
17
|
|
|
18
18
|
function vtkLabelWidget(publicAPI, model) {
|
|
19
|
-
model.classHierarchy.push('vtkLabelWidget');
|
|
19
|
+
model.classHierarchy.push('vtkLabelWidget');
|
|
20
|
+
|
|
21
|
+
var superClass = _objectSpread({}, publicAPI); // --- Widget Requirement ---------------------------------------------------
|
|
22
|
+
|
|
20
23
|
|
|
21
24
|
model.methodsToLink = ['textProps', 'fontProperties', 'strokeFontProperties'];
|
|
22
25
|
model.behavior = widgetBehavior;
|
|
@@ -49,10 +52,22 @@ function vtkLabelWidget(publicAPI, model) {
|
|
|
49
52
|
labels: ['SVGtext']
|
|
50
53
|
}];
|
|
51
54
|
}
|
|
52
|
-
}; //
|
|
55
|
+
}; // --- Public methods -------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
publicAPI.setManipulator = function (manipulator) {
|
|
59
|
+
superClass.setManipulator(manipulator);
|
|
60
|
+
model.widgetState.getMoveHandle().setManipulator(manipulator);
|
|
61
|
+
model.widgetState.getText().setManipulator(manipulator);
|
|
62
|
+
}; // --------------------------------------------------------------------------
|
|
63
|
+
// initialization
|
|
64
|
+
// --------------------------------------------------------------------------
|
|
65
|
+
// Default manipulator
|
|
53
66
|
|
|
54
67
|
|
|
55
|
-
model.manipulator
|
|
68
|
+
publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
|
|
69
|
+
useCameraNormal: true
|
|
70
|
+
}));
|
|
56
71
|
} // ----------------------------------------------------------------------------
|
|
57
72
|
|
|
58
73
|
|
|
@@ -35,8 +35,11 @@ function widgetBehavior(publicAPI, model) {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function updateCursor(callData) {
|
|
38
|
+
var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
|
|
39
|
+
|
|
38
40
|
model.isDragging = true;
|
|
39
|
-
|
|
41
|
+
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;
|
|
42
|
+
model.previousPosition = _toConsumableArray(manipulator.handleEvent(callData, model._apiSpecificRenderWindow));
|
|
40
43
|
|
|
41
44
|
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
42
45
|
|
|
@@ -222,13 +225,17 @@ function widgetBehavior(publicAPI, model) {
|
|
|
222
225
|
|
|
223
226
|
|
|
224
227
|
publicAPI.handleMouseMove = function (callData) {
|
|
228
|
+
var _model$activeState$ge3, _model$activeState2, _model$activeState2$g;
|
|
229
|
+
|
|
225
230
|
if (model.hasFocus && publicAPI.isPlaced() && !model.isDragging) {
|
|
226
231
|
publicAPI.loseFocus();
|
|
227
232
|
return macro.VOID;
|
|
228
233
|
}
|
|
229
234
|
|
|
230
|
-
|
|
231
|
-
|
|
235
|
+
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;
|
|
236
|
+
|
|
237
|
+
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
238
|
+
var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
232
239
|
var translation = model.previousPosition ? subtract(worldCoords, model.previousPosition, []) : [0, 0, 0];
|
|
233
240
|
model.previousPosition = worldCoords;
|
|
234
241
|
|
|
@@ -9,7 +9,7 @@ var linePosState = vtkStateBuilder.createBuilder().addField({
|
|
|
9
9
|
function generateState() {
|
|
10
10
|
return vtkStateBuilder.createBuilder().addStateFromMixin({
|
|
11
11
|
labels: ['moveHandle'],
|
|
12
|
-
mixins: ['origin', 'color', 'scale1', 'visible', 'shape'],
|
|
12
|
+
mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator', 'shape'],
|
|
13
13
|
name: 'moveHandle',
|
|
14
14
|
initialValues: {
|
|
15
15
|
scale1: 50,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
1
2
|
import { f as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
|
|
2
3
|
import macro from '../../macros.js';
|
|
3
4
|
import generateState from './LineWidget/state.js';
|
|
@@ -11,11 +12,17 @@ import { Behavior } from '../Representations/WidgetRepresentation/Constants.js';
|
|
|
11
12
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
12
13
|
import { getPoint, updateTextPosition } from './LineWidget/helpers.js';
|
|
13
14
|
|
|
15
|
+
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; }
|
|
16
|
+
|
|
17
|
+
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; }
|
|
14
18
|
// Factory
|
|
15
19
|
// ----------------------------------------------------------------------------
|
|
16
20
|
|
|
17
21
|
function vtkLineWidget(publicAPI, model) {
|
|
18
22
|
model.classHierarchy.push('vtkLineWidget');
|
|
23
|
+
|
|
24
|
+
var superClass = _objectSpread({}, publicAPI);
|
|
25
|
+
|
|
19
26
|
model.widgetState = generateState();
|
|
20
27
|
model.behavior = widgetBehavior; // --- Widget Requirement ---------------------------------------------------
|
|
21
28
|
|
|
@@ -135,6 +142,13 @@ function vtkLineWidget(publicAPI, model) {
|
|
|
135
142
|
var p1 = getPoint(0, model.widgetState);
|
|
136
143
|
var p2 = getPoint(1, model.widgetState);
|
|
137
144
|
return p1 && p2 ? Math.sqrt(distance2BetweenPoints(p1, p2)) : 0;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
publicAPI.setManipulator = function (manipulator) {
|
|
148
|
+
superClass.setManipulator(manipulator);
|
|
149
|
+
model.widgetState.getMoveHandle().setManipulator(manipulator);
|
|
150
|
+
model.widgetState.getHandle1().setManipulator(manipulator);
|
|
151
|
+
model.widgetState.getHandle2().setManipulator(manipulator);
|
|
138
152
|
}; // --------------------------------------------------------------------------
|
|
139
153
|
// initialization
|
|
140
154
|
// --------------------------------------------------------------------------
|
|
@@ -152,11 +166,14 @@ function vtkLineWidget(publicAPI, model) {
|
|
|
152
166
|
updateTextPosition(model);
|
|
153
167
|
}); // Default manipulator
|
|
154
168
|
|
|
155
|
-
model.manipulator
|
|
169
|
+
publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
|
|
170
|
+
useCameraNormal: true
|
|
171
|
+
}));
|
|
156
172
|
} // ----------------------------------------------------------------------------
|
|
157
173
|
|
|
158
174
|
|
|
159
175
|
var DEFAULT_VALUES = {
|
|
176
|
+
// manipulator: null,
|
|
160
177
|
isDragging: false
|
|
161
178
|
}; // ----------------------------------------------------------------------------
|
|
162
179
|
|
|
@@ -32,8 +32,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
publicAPI.handleEvent = function (callData) {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
|
|
36
|
+
|
|
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
|
+
|
|
39
|
+
if (manipulator && model.activeState && model.activeState.getActive()) {
|
|
40
|
+
var _model$activeState2, _model$activeState3, _model$activeState4;
|
|
37
41
|
|
|
38
42
|
var normal = model._camera.getDirectionOfProjection();
|
|
39
43
|
|
|
@@ -42,21 +46,20 @@ function widgetBehavior(publicAPI, model) {
|
|
|
42
46
|
var right = [];
|
|
43
47
|
vec3.cross(right, up, normal);
|
|
44
48
|
|
|
45
|
-
(_model$
|
|
49
|
+
(_model$activeState2 = model.activeState).setUp.apply(_model$activeState2, _toConsumableArray(up));
|
|
46
50
|
|
|
47
|
-
(_model$
|
|
51
|
+
(_model$activeState3 = model.activeState).setRight.apply(_model$activeState3, right);
|
|
48
52
|
|
|
49
|
-
(_model$
|
|
53
|
+
(_model$activeState4 = model.activeState).setDirection.apply(_model$activeState4, _toConsumableArray(normal));
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
55
|
+
var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
53
56
|
|
|
54
57
|
if (worldCoords.length) {
|
|
55
|
-
var _model$widgetState, _model$
|
|
58
|
+
var _model$widgetState, _model$activeState5;
|
|
56
59
|
|
|
57
60
|
(_model$widgetState = model.widgetState).setTrueOrigin.apply(_model$widgetState, _toConsumableArray(worldCoords));
|
|
58
61
|
|
|
59
|
-
(_model$
|
|
62
|
+
(_model$activeState5 = model.activeState).setOrigin.apply(_model$activeState5, _toConsumableArray(worldCoords));
|
|
60
63
|
|
|
61
64
|
if (model.painting) {
|
|
62
65
|
var trailCircle = model.widgetState.addTrail();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
1
2
|
import macro from '../../macros.js';
|
|
2
3
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
4
|
import vtkCircleContextRepresentation from '../Representations/CircleContextRepresentation.js';
|
|
@@ -7,11 +8,17 @@ import widgetBehavior from './PaintWidget/behavior.js';
|
|
|
7
8
|
import generateState from './PaintWidget/state.js';
|
|
8
9
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
9
10
|
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
10
14
|
// Factory
|
|
11
15
|
// ----------------------------------------------------------------------------
|
|
12
16
|
|
|
13
17
|
function vtkPaintWidget(publicAPI, model) {
|
|
14
|
-
model.classHierarchy.push('vtkPaintWidget');
|
|
18
|
+
model.classHierarchy.push('vtkPaintWidget');
|
|
19
|
+
|
|
20
|
+
var superClass = _objectSpread({}, publicAPI); // --- Widget Requirement ---------------------------------------------------
|
|
21
|
+
|
|
15
22
|
|
|
16
23
|
model.behavior = widgetBehavior;
|
|
17
24
|
model.widgetState = generateState(model.radius);
|
|
@@ -33,26 +40,35 @@ function vtkPaintWidget(publicAPI, model) {
|
|
|
33
40
|
labels: ['handle']
|
|
34
41
|
}];
|
|
35
42
|
}
|
|
36
|
-
}; // ---
|
|
43
|
+
}; // --- Public methods -------------------------------------------------------
|
|
37
44
|
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
publicAPI.setManipulator = function (manipulator) {
|
|
47
|
+
superClass.setManipulator(manipulator);
|
|
48
|
+
model.widgetState.getHandle().setManipulator(manipulator);
|
|
49
|
+
}; // override
|
|
40
50
|
|
|
41
|
-
model.manipulator = vtkPlanePointManipulator.newInstance();
|
|
42
|
-
handle.setManipulator(model.manipulator); // override
|
|
43
51
|
|
|
44
52
|
var superSetRadius = publicAPI.setRadius;
|
|
45
53
|
|
|
46
54
|
publicAPI.setRadius = function (r) {
|
|
47
55
|
if (superSetRadius(r)) {
|
|
48
|
-
|
|
56
|
+
model.widgetState.getHandle().setScale1(r);
|
|
49
57
|
}
|
|
50
|
-
};
|
|
58
|
+
}; // --------------------------------------------------------------------------
|
|
59
|
+
// initialization
|
|
60
|
+
// --------------------------------------------------------------------------
|
|
61
|
+
// Default manipulator
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
|
|
65
|
+
useCameraNormal: true
|
|
66
|
+
}));
|
|
51
67
|
} // ----------------------------------------------------------------------------
|
|
52
68
|
|
|
53
69
|
|
|
54
70
|
var DEFAULT_VALUES = {
|
|
55
|
-
manipulator: null,
|
|
71
|
+
// manipulator: null,
|
|
56
72
|
radius: 1,
|
|
57
73
|
painting: false,
|
|
58
74
|
color: [1]
|