@kitware/vtk.js 24.7.1 → 24.8.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/Widgets/Core/StateBuilder/manipulatorMixin.js +15 -15
- 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 +13 -10
- 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 +2 -1
- package/package.json +1 -1
|
@@ -1,50 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAbstractManipulatorInitialValues, vtkAbstractManipulator } from './AbstractManipulator';
|
|
2
|
+
import { Vector3 } from './../../types';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
5
6
|
*/
|
|
6
|
-
export interface ITrackballManipulatorInitialValues {
|
|
7
|
-
normal?: number[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface vtkTrackballManipulator extends vtkObject {
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Get normal
|
|
14
|
-
*/
|
|
15
|
-
getNormal(): number[];
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Get normal
|
|
19
|
-
*/
|
|
20
|
-
getNormalByReference(): number[];
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param callData
|
|
25
|
-
* @param glRenderWindow
|
|
26
|
-
*/
|
|
27
|
-
handleEvent(callData: any, glRenderWindow: any): void;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Set the normal of the line.
|
|
31
|
-
* @param {Number[]} normal The normal coordinate.
|
|
32
|
-
*/
|
|
33
|
-
setNormal(normal: number[]): boolean;
|
|
7
|
+
export interface ITrackballManipulatorInitialValues extends IAbstractManipulatorInitialValues {
|
|
34
8
|
|
|
35
|
-
|
|
36
|
-
* Set the normal of the line.
|
|
37
|
-
* @param {Number} x The x coordinate.
|
|
38
|
-
* @param {Number} y The y coordinate.
|
|
39
|
-
* @param {Number} z The z coordinate.
|
|
40
|
-
*/
|
|
41
|
-
setNormal(x: number, y: number, z: number): boolean;
|
|
9
|
+
}
|
|
42
10
|
|
|
43
|
-
|
|
44
|
-
* Set the normal of the line.
|
|
45
|
-
* @param {Number[]} normal The normal coordinate.
|
|
46
|
-
*/
|
|
47
|
-
setNormalFrom(normal: number[]): boolean;
|
|
11
|
+
export interface vtkTrackballManipulator extends vtkAbstractManipulator {
|
|
48
12
|
|
|
49
13
|
/**
|
|
50
14
|
*
|
|
@@ -73,12 +37,12 @@ export function newInstance(initialValues?: ITrackballManipulatorInitialValues):
|
|
|
73
37
|
* @param {Number} prevY
|
|
74
38
|
* @param {Number} curX
|
|
75
39
|
* @param {Number} curY
|
|
76
|
-
* @param {
|
|
77
|
-
* @param {
|
|
40
|
+
* @param {Vector3} origin
|
|
41
|
+
* @param {Vector3} direction
|
|
78
42
|
* @param renderer
|
|
79
43
|
* @param glRenderWindow
|
|
80
44
|
*/
|
|
81
|
-
export function trackballRotate(prevX: number, prevY: number, curX: number, curY: number, origin:
|
|
45
|
+
export function trackballRotate(prevX: number, prevY: number, curX: number, curY: number, origin: Vector3, direction: Vector3, renderer: any, glRenderWindow: any): void;
|
|
82
46
|
|
|
83
47
|
|
|
84
48
|
/**
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
1
2
|
import { mat4, vec3 } from 'gl-matrix';
|
|
2
3
|
import macro from '../../macros.js';
|
|
3
4
|
import { j as cross, r as radiansFromDegrees } from '../../Common/Core/Math/index.js';
|
|
5
|
+
import vtkAbstractManipulator from './AbstractManipulator.js';
|
|
4
6
|
|
|
7
|
+
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; }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
5
10
|
function trackballRotate(prevX, prevY, curX, curY, origin, direction, renderer, glRenderWindow) {
|
|
6
11
|
var dx = curX - prevX;
|
|
7
12
|
var dy = curY - prevY;
|
|
@@ -28,15 +33,14 @@ function vtkTrackballManipulator(publicAPI, model) {
|
|
|
28
33
|
// Set our className
|
|
29
34
|
model.classHierarchy.push('vtkTrackballManipulator');
|
|
30
35
|
var prevX = 0;
|
|
31
|
-
var prevY = 0;
|
|
36
|
+
var prevY = 0;
|
|
32
37
|
|
|
33
38
|
publicAPI.handleEvent = function (callData, glRenderWindow) {
|
|
34
|
-
var newDirection = trackballRotate(prevX, prevY, callData.position.x, callData.position.y,
|
|
39
|
+
var newDirection = trackballRotate(prevX, prevY, callData.position.x, callData.position.y, publicAPI.getOrigin(callData), publicAPI.getNormal(callData), callData.pokedRenderer);
|
|
35
40
|
prevX = callData.position.x;
|
|
36
41
|
prevY = callData.position.y;
|
|
37
42
|
return newDirection;
|
|
38
|
-
};
|
|
39
|
-
|
|
43
|
+
};
|
|
40
44
|
|
|
41
45
|
publicAPI.reset = function (callData) {
|
|
42
46
|
prevX = callData.position.x;
|
|
@@ -47,15 +51,14 @@ function vtkTrackballManipulator(publicAPI, model) {
|
|
|
47
51
|
// ----------------------------------------------------------------------------
|
|
48
52
|
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
54
|
+
function defaultValues(initialValues) {
|
|
55
|
+
return _objectSpread({}, initialValues);
|
|
56
|
+
} // ----------------------------------------------------------------------------
|
|
57
|
+
|
|
53
58
|
|
|
54
59
|
function extend(publicAPI, model) {
|
|
55
60
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
56
|
-
|
|
57
|
-
macro.obj(publicAPI, model);
|
|
58
|
-
macro.setGetArray(publicAPI, model, ['normal'], 3);
|
|
61
|
+
vtkAbstractManipulator.extend(publicAPI, model, defaultValues(initialValues));
|
|
59
62
|
vtkTrackballManipulator(publicAPI, model);
|
|
60
63
|
} // ----------------------------------------------------------------------------
|
|
61
64
|
|
|
@@ -40,6 +40,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
40
40
|
newHandle.setOrigin.apply(newHandle, _toConsumableArray(moveHandle.getOrigin()));
|
|
41
41
|
newHandle.setColor(moveHandle.getColor());
|
|
42
42
|
newHandle.setScale1(moveHandle.getScale1());
|
|
43
|
+
newHandle.setManipulator(model.manipulator);
|
|
43
44
|
} else {
|
|
44
45
|
isDragging = true;
|
|
45
46
|
|
|
@@ -56,10 +57,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
publicAPI.handleMouseMove = function (callData) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
|
|
61
|
+
|
|
62
|
+
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;
|
|
63
|
+
|
|
64
|
+
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
65
|
+
var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
63
66
|
|
|
64
67
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
|
|
65
68
|
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 './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,
|