@kitware/vtk.js 19.8.0 → 20.0.3
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 +10 -0
- package/Common/Core/Math/index.js +2 -0
- package/Common/Core/Math.d.ts +8 -8
- package/Common/DataModel/ImageData.js +2 -4
- package/Common/DataModel/Plane.d.ts +2 -2
- package/Filters/General/AppendPolyData.js +2 -2
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +1 -1
- package/Rendering/Core/Picker.js +3 -3
- package/Rendering/Core/RenderWindow.js +12 -0
- package/Rendering/OpenGL/HardwareSelector.js +4 -1
- package/Rendering/OpenGL/Renderer.js +0 -5
- package/Rendering/OpenGL/Texture.js +4 -76
- package/Rendering/WebGPU/HardwareSelector.js +17 -13
- package/Rendering/WebGPU/ImageMapper.js +13 -7
- package/Rendering/WebGPU/Renderer.js +0 -5
- package/Rendering/WebGPU/Texture.js +1 -1
- package/Widgets/Representations/CircleContextRepresentation.js +3 -5
- package/Widgets/Representations/ContextRepresentation.js +3 -0
- package/Widgets/Representations/RectangleContextRepresentation.js +2 -2
- package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +28 -0
- package/Widgets/SVG/SVGLandmarkRepresentation.js +39 -21
- package/Widgets/Widgets3D/EllipseWidget/behavior.js +6 -1
- package/Widgets/Widgets3D/EllipseWidget/state.js +22 -2
- package/Widgets/Widgets3D/EllipseWidget.js +29 -21
- package/Widgets/Widgets3D/LineWidget.js +5 -2
- package/Widgets/Widgets3D/PaintWidget/behavior.js +107 -0
- package/Widgets/Widgets3D/PaintWidget/state.js +29 -0
- package/Widgets/Widgets3D/PaintWidget.js +5 -134
- package/Widgets/Widgets3D/PolyLineWidget.js +6 -0
- package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -1
- package/Widgets/Widgets3D/RectangleWidget/state.js +22 -2
- package/Widgets/Widgets3D/RectangleWidget.js +28 -20
- package/Widgets/Widgets3D/ShapeWidget/Constants.js +5 -66
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +131 -117
- package/Widgets/Widgets3D/ShapeWidget.js +37 -15
- package/macros.js +22 -4
- package/package.json +1 -1
|
@@ -20,71 +20,10 @@ var ShapeBehavior = (_ShapeBehavior = {}, _defineProperty(_ShapeBehavior, Behavi
|
|
|
20
20
|
FIXED: 0,
|
|
21
21
|
FREE: 1
|
|
22
22
|
}), _ShapeBehavior);
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
INSIDE_RIGHT: 'INSIDE_RIGHT',
|
|
28
|
-
MIDDLE: 'MIDDLE'
|
|
23
|
+
var TextPosition = {
|
|
24
|
+
MIN: 'MIN',
|
|
25
|
+
CENTER: 'CENTER',
|
|
26
|
+
MAX: 'MAX'
|
|
29
27
|
};
|
|
30
|
-
var VerticalTextPosition = {
|
|
31
|
-
OUTSIDE_TOP: 'OUSIDE_TOP',
|
|
32
|
-
INSIDE_TOP: 'INSIDE_TOP',
|
|
33
|
-
OUTSIDE_BOTTOM: 'OUSIDE_BOTTOM',
|
|
34
|
-
INSIDE_BOTTOM: 'INSIDE_BOTTOM',
|
|
35
|
-
MIDDLE: 'MIDDLE'
|
|
36
|
-
};
|
|
37
|
-
function computeTextPosition(bounds, horizontalPosition, verticalPosition, textWidth, textHeight) {
|
|
38
|
-
var margin = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
39
|
-
var x = 0;
|
|
40
|
-
|
|
41
|
-
switch (horizontalPosition) {
|
|
42
|
-
case HorizontalTextPosition.OUTSIDE_LEFT:
|
|
43
|
-
x = bounds[0] - textWidth - margin;
|
|
44
|
-
break;
|
|
45
|
-
|
|
46
|
-
case HorizontalTextPosition.INSIDE_LEFT:
|
|
47
|
-
x = bounds[0] + margin;
|
|
48
|
-
break;
|
|
49
|
-
|
|
50
|
-
case HorizontalTextPosition.MIDDLE:
|
|
51
|
-
x = 0.5 * (bounds[0] + bounds[1] - textWidth);
|
|
52
|
-
break;
|
|
53
|
-
|
|
54
|
-
case HorizontalTextPosition.INSIDE_RIGHT:
|
|
55
|
-
x = bounds[1] - textWidth - margin;
|
|
56
|
-
break;
|
|
57
|
-
|
|
58
|
-
case HorizontalTextPosition.OUTSIDE_RIGHT:
|
|
59
|
-
x = bounds[1] + margin;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var y = 0;
|
|
64
|
-
|
|
65
|
-
switch (verticalPosition) {
|
|
66
|
-
case VerticalTextPosition.OUTSIDE_TOP:
|
|
67
|
-
y = bounds[3] + textHeight + margin;
|
|
68
|
-
break;
|
|
69
|
-
|
|
70
|
-
case VerticalTextPosition.INSIDE_TOP:
|
|
71
|
-
y = bounds[3] - margin;
|
|
72
|
-
break;
|
|
73
|
-
|
|
74
|
-
case VerticalTextPosition.MIDDLE:
|
|
75
|
-
y = 0.5 * (bounds[2] + bounds[3] + textWidth);
|
|
76
|
-
break;
|
|
77
|
-
|
|
78
|
-
case VerticalTextPosition.INSIDE_BOTTOM:
|
|
79
|
-
y = bounds[2] + textHeight + margin;
|
|
80
|
-
break;
|
|
81
|
-
|
|
82
|
-
case VerticalTextPosition.OUTSIDE_BOTTOM:
|
|
83
|
-
y = bounds[2] - margin;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return [x, y, 0];
|
|
88
|
-
}
|
|
89
28
|
|
|
90
|
-
export { BehaviorCategory,
|
|
29
|
+
export { BehaviorCategory, ShapeBehavior, TextPosition, ShapeBehavior as default };
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import macro from '../../../macros.js';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import { q as vtkMath } from '../../../Common/Core/Math/index.js';
|
|
5
|
+
import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
|
|
6
|
+
import vtkPlane from '../../../Common/DataModel/Plane.js';
|
|
7
|
+
import { ShapeBehavior, BehaviorCategory, TextPosition } from './Constants.js';
|
|
8
|
+
import { boundPlane } from '../ResliceCursorWidget/helpers.js';
|
|
9
|
+
import { a as subtract, d as dot, j as add, c as cross, x as squaredDistance, h as distance } from '../../../vendor/gl-matrix/esm/vec3.js';
|
|
7
10
|
|
|
8
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
9
12
|
|
|
10
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
11
14
|
var vtkErrorMacro = macro.vtkErrorMacro;
|
|
12
15
|
var EPSILON = 1e-6;
|
|
13
|
-
|
|
14
|
-
function makeBoundsFromPoints(point1, point2) {
|
|
15
|
-
return [Math.min(point1[0], point2[0]), Math.max(point1[0], point2[0]), Math.min(point1[1], point2[1]), Math.max(point1[1], point2[1]), Math.min(point1[2], point2[2]), Math.max(point1[2], point2[2])];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
16
|
function widgetBehavior(publicAPI, model) {
|
|
19
17
|
model.classHierarchy.push('vtkShapeWidgetProp');
|
|
18
|
+
model.keysDown = {};
|
|
20
19
|
|
|
21
20
|
var superClass = _objectSpread({}, publicAPI); // --------------------------------------------------------------------------
|
|
22
21
|
// Display 2D
|
|
@@ -25,18 +24,25 @@ function widgetBehavior(publicAPI, model) {
|
|
|
25
24
|
|
|
26
25
|
publicAPI.setDisplayCallback = function (callback) {
|
|
27
26
|
return model.representations[0].setDisplayCallback(callback);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
publicAPI.setText = function (text) {
|
|
30
|
+
model.widgetState.getText().setText(text); // Recompute position
|
|
31
|
+
|
|
32
|
+
model.interactor.render();
|
|
28
33
|
}; // --------------------------------------------------------------------------
|
|
29
34
|
// Public methods
|
|
30
35
|
// --------------------------------------------------------------------------
|
|
31
36
|
|
|
32
37
|
|
|
33
|
-
publicAPI.
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
publicAPI.setResetAfterPointPlacement = model.factory.setResetAfterPointPlacement;
|
|
39
|
+
publicAPI.getResetAfterPointPlacement = model.factory.getResetAfterPointPlacement;
|
|
40
|
+
publicAPI.setModifierBehavior = model.factory.setModifierBehavior;
|
|
41
|
+
publicAPI.getModifierBehavior = model.factory.getModifierBehavior;
|
|
36
42
|
|
|
37
43
|
publicAPI.isBehaviorActive = function (category, flag) {
|
|
38
44
|
return Object.keys(model.keysDown).some(function (key) {
|
|
39
|
-
return model.keysDown[key] &&
|
|
45
|
+
return model.keysDown[key] && publicAPI.getModifierBehavior()[key] && publicAPI.getModifierBehavior()[key][category] === flag;
|
|
40
46
|
});
|
|
41
47
|
};
|
|
42
48
|
|
|
@@ -48,7 +54,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
48
54
|
|
|
49
55
|
publicAPI.getActiveBehaviorFromCategory = function (category) {
|
|
50
56
|
return Object.values(ShapeBehavior[category]).find(function (flag) {
|
|
51
|
-
return publicAPI.isBehaviorActive(category, flag) || !publicAPI.isOppositeBehaviorActive(category, flag) &&
|
|
57
|
+
return publicAPI.isBehaviorActive(category, flag) || !publicAPI.isOppositeBehaviorActive(category, flag) && publicAPI.getModifierBehavior().None[category] === flag;
|
|
52
58
|
});
|
|
53
59
|
};
|
|
54
60
|
|
|
@@ -62,19 +68,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
62
68
|
};
|
|
63
69
|
|
|
64
70
|
publicAPI.isDraggingForced = function () {
|
|
65
|
-
return publicAPI.isBehaviorActive(BehaviorCategory.PLACEMENT, ShapeBehavior[BehaviorCategory.PLACEMENT].DRAG) ||
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
publicAPI.setVisibleOnFocus = function (visibleOnFocus) {
|
|
69
|
-
model.visibleOnFocus = visibleOnFocus;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
publicAPI.setLabelTextCallback = function (callback) {
|
|
73
|
-
model.labelTextCallback = callback;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
publicAPI.setResetAfterPointPlacement = function (reset) {
|
|
77
|
-
model.resetAfterPointPlacement = reset;
|
|
71
|
+
return publicAPI.isBehaviorActive(BehaviorCategory.PLACEMENT, ShapeBehavior[BehaviorCategory.PLACEMENT].DRAG) || publicAPI.getModifierBehavior().None[BehaviorCategory.PLACEMENT] === ShapeBehavior[BehaviorCategory.PLACEMENT].DRAG;
|
|
78
72
|
};
|
|
79
73
|
|
|
80
74
|
publicAPI.getPoint1 = function () {
|
|
@@ -104,16 +98,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
104
98
|
model.point1Handle.deactivate();
|
|
105
99
|
model.point2Handle.activate();
|
|
106
100
|
model.activeState = model.point2Handle;
|
|
107
|
-
|
|
108
|
-
if (model.useHandles) {
|
|
109
|
-
model.point2Handle.setVisible(true);
|
|
110
|
-
}
|
|
111
|
-
|
|
101
|
+
model.point2Handle.setVisible(true);
|
|
112
102
|
publicAPI.updateShapeBounds();
|
|
113
|
-
|
|
114
|
-
if (model.visibleOnFocus) {
|
|
115
|
-
model.shapeHandle.setVisible(true);
|
|
116
|
-
}
|
|
103
|
+
model.shapeHandle.setVisible(true);
|
|
117
104
|
}
|
|
118
105
|
};
|
|
119
106
|
|
|
@@ -123,49 +110,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
123
110
|
model.point2Handle.setOrigin(model.point2);
|
|
124
111
|
publicAPI.updateShapeBounds();
|
|
125
112
|
|
|
126
|
-
if (
|
|
113
|
+
if (publicAPI.getResetAfterPointPlacement()) {
|
|
127
114
|
publicAPI.reset();
|
|
128
115
|
} else {
|
|
129
116
|
publicAPI.loseFocus();
|
|
130
117
|
}
|
|
131
118
|
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
publicAPI.setPixelScale = function (pixelScale) {
|
|
135
|
-
model.pixelScale = pixelScale;
|
|
136
|
-
publicAPI.updateHandlesSize();
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
publicAPI.updateHandlesSize = function () {
|
|
140
|
-
if (model.pixelScale !== null) {
|
|
141
|
-
var scale = model.pixelScale * distance(model.apiSpecificRenderWindow.displayToWorld(0, 0, 0, model.renderer), model.apiSpecificRenderWindow.displayToWorld(1, 0, 0, model.renderer));
|
|
142
|
-
model.point1Handle.setScale1(scale);
|
|
143
|
-
model.point2Handle.setScale1(scale);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
publicAPI.setVisibility = function (visibility) {
|
|
148
|
-
var modified = false;
|
|
149
|
-
|
|
150
|
-
if (model.useHandles) {
|
|
151
|
-
modified = superClass.setVisibility(visibility) || modified;
|
|
152
|
-
} else {
|
|
153
|
-
modified = model.shapeHandle.setVisible(visibility) || modified;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (model.label) {
|
|
157
|
-
if (visibility) {
|
|
158
|
-
modified = model.label.setContainer(model.interactor.getContainer()) || modified;
|
|
159
|
-
} else {
|
|
160
|
-
modified = model.label.setContainer(null) || modified;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return modified;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
publicAPI.getLabel = function () {
|
|
168
|
-
return model.label;
|
|
169
119
|
}; // --------------------------------------------------------------------------
|
|
170
120
|
// Private methods
|
|
171
121
|
// --------------------------------------------------------------------------
|
|
@@ -211,21 +161,16 @@ function widgetBehavior(publicAPI, model) {
|
|
|
211
161
|
var getCornersFromDiameter = function getCornersFromDiameter(point1, point2) {
|
|
212
162
|
var center = [0.5 * (point1[0] + point2[0]), 0.5 * (point1[1] + point2[1]), 0.5 * (point1[2] + point2[2])];
|
|
213
163
|
return getCornersFromRadius(center, point1);
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
publicAPI.setCorners = function (point1, point2) {
|
|
217
|
-
if (model.label && model.labelTextCallback) {
|
|
218
|
-
var _model$apiSpecificRen, _model$apiSpecificRen2;
|
|
164
|
+
}; // TODO: move to ShapeWidget/index.js
|
|
219
165
|
|
|
220
|
-
var bounds = makeBoundsFromPoints(point1, point2);
|
|
221
166
|
|
|
222
|
-
|
|
167
|
+
publicAPI.getBounds = function () {
|
|
168
|
+
return model.point1 && model.point2 ? vtkMath.computeBoundsFromPoints(model.point1, model.point2, []) : vtkMath.uninitializeBounds([]);
|
|
169
|
+
}; // To be reimplemented by subclass
|
|
223
170
|
|
|
224
|
-
var screenPoint2 = (_model$apiSpecificRen2 = model.apiSpecificRenderWindow).worldToDisplay.apply(_model$apiSpecificRen2, _toConsumableArray(point2).concat([model.renderer]));
|
|
225
171
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
172
|
+
publicAPI.setCorners = function (point1, point2) {
|
|
173
|
+
publicAPI.updateTextPosition(point1, point2);
|
|
229
174
|
};
|
|
230
175
|
|
|
231
176
|
publicAPI.updateShapeBounds = function () {
|
|
@@ -275,6 +220,100 @@ function widgetBehavior(publicAPI, model) {
|
|
|
275
220
|
}
|
|
276
221
|
}
|
|
277
222
|
};
|
|
223
|
+
|
|
224
|
+
var computePositionVector = function computePositionVector(textPosition, minPoint, maxPoint) {
|
|
225
|
+
var positionVector = [0, 0, 0];
|
|
226
|
+
|
|
227
|
+
switch (textPosition) {
|
|
228
|
+
case TextPosition.MIN:
|
|
229
|
+
break;
|
|
230
|
+
|
|
231
|
+
case TextPosition.MAX:
|
|
232
|
+
vtkMath.subtract(maxPoint, minPoint, positionVector);
|
|
233
|
+
break;
|
|
234
|
+
|
|
235
|
+
case TextPosition.CENTER:
|
|
236
|
+
default:
|
|
237
|
+
vtkMath.subtract(maxPoint, minPoint, positionVector);
|
|
238
|
+
vtkMath.multiplyScalar(positionVector, 0.5);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return positionVector;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
var computeTextPosition = function computeTextPosition(worldBounds, textPosition) {
|
|
246
|
+
var _model$apiSpecificRen, _model$apiSpecificRen2, _model$apiSpecificRen5;
|
|
247
|
+
|
|
248
|
+
var worldMargin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
249
|
+
var viewPlaneOrigin = model.manipulator.getOrigin();
|
|
250
|
+
var viewPlaneNormal = model.manipulator.getNormal();
|
|
251
|
+
var viewUp = model.renderer.getActiveCamera().getViewUp();
|
|
252
|
+
var positionMargin = Array.isArray(worldMargin) ? _toConsumableArray(worldMargin) : [worldMargin, worldMargin, viewPlaneOrigin ? worldMargin : 0]; // Map bounds from world positions to display positions
|
|
253
|
+
|
|
254
|
+
var minPoint = (_model$apiSpecificRen = model.apiSpecificRenderWindow).worldToDisplay.apply(_model$apiSpecificRen, _toConsumableArray(vtkBoundingBox.getMinPoint(worldBounds)).concat([model.renderer]));
|
|
255
|
+
|
|
256
|
+
var maxPoint = (_model$apiSpecificRen2 = model.apiSpecificRenderWindow).worldToDisplay.apply(_model$apiSpecificRen2, _toConsumableArray(vtkBoundingBox.getMaxPoint(worldBounds)).concat([model.renderer]));
|
|
257
|
+
|
|
258
|
+
var displayBounds = vtkMath.computeBoundsFromPoints(minPoint, maxPoint, []);
|
|
259
|
+
var planeOrigin = [];
|
|
260
|
+
var p1 = [];
|
|
261
|
+
var p2 = [];
|
|
262
|
+
var p3 = []; // If we are in a 2D projection
|
|
263
|
+
|
|
264
|
+
if (viewPlaneOrigin && viewPlaneNormal && viewUp && vtkBoundingBox.intersectPlane(displayBounds, viewPlaneOrigin, viewPlaneNormal)) {
|
|
265
|
+
var _model$apiSpecificRen3, _model$apiSpecificRen4;
|
|
266
|
+
|
|
267
|
+
// Map plane origin from world positions to display positions
|
|
268
|
+
var displayPlaneOrigin = (_model$apiSpecificRen3 = model.apiSpecificRenderWindow).worldToDisplay.apply(_model$apiSpecificRen3, _toConsumableArray(viewPlaneOrigin).concat([model.renderer])); // Map plane normal from world positions to display positions
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
var planeNormalPoint = vtkMath.add(viewPlaneOrigin, viewPlaneNormal, []);
|
|
272
|
+
|
|
273
|
+
var displayPlaneNormalPoint = (_model$apiSpecificRen4 = model.apiSpecificRenderWindow).worldToDisplay.apply(_model$apiSpecificRen4, _toConsumableArray(planeNormalPoint).concat([model.renderer]));
|
|
274
|
+
|
|
275
|
+
var displayPlaneNormal = vtkMath.subtract(displayPlaneNormalPoint, displayPlaneOrigin); // Project view plane into bounding box
|
|
276
|
+
|
|
277
|
+
var largeDistance = 10 * vtkBoundingBox.getDiagonalLength(displayBounds);
|
|
278
|
+
vtkPlane.projectPoint(vtkBoundingBox.getCenter(displayBounds), displayPlaneOrigin, displayPlaneNormal, planeOrigin);
|
|
279
|
+
var planeU = vtkMath.cross(viewUp, displayPlaneNormal, []);
|
|
280
|
+
vtkMath.normalize(planeU); // u
|
|
281
|
+
|
|
282
|
+
vtkMath.normalize(viewUp); // v
|
|
283
|
+
|
|
284
|
+
vtkMath.normalize(displayPlaneNormal); // w
|
|
285
|
+
|
|
286
|
+
vtkMath.multiplyAccumulate(planeOrigin, viewUp, -largeDistance, planeOrigin);
|
|
287
|
+
vtkMath.multiplyAccumulate(planeOrigin, planeU, -largeDistance, planeOrigin);
|
|
288
|
+
p1 = vtkMath.multiplyAccumulate(planeOrigin, planeU, 2 * largeDistance, []);
|
|
289
|
+
p2 = vtkMath.multiplyAccumulate(planeOrigin, viewUp, 2 * largeDistance, []);
|
|
290
|
+
p3 = planeOrigin;
|
|
291
|
+
boundPlane(displayBounds, planeOrigin, p1, p2);
|
|
292
|
+
} else {
|
|
293
|
+
planeOrigin = [displayBounds[0], displayBounds[2], displayBounds[4]];
|
|
294
|
+
p1 = [displayBounds[1], displayBounds[2], displayBounds[4]];
|
|
295
|
+
p2 = [displayBounds[0], displayBounds[3], displayBounds[4]];
|
|
296
|
+
p3 = [displayBounds[0], displayBounds[2], displayBounds[5]];
|
|
297
|
+
} // Compute horizontal, vertical and depth position
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
var u = computePositionVector(textPosition[0], planeOrigin, p1);
|
|
301
|
+
var v = computePositionVector(textPosition[1], planeOrigin, p2);
|
|
302
|
+
var w = computePositionVector(textPosition[2], planeOrigin, p3);
|
|
303
|
+
var finalPosition = planeOrigin;
|
|
304
|
+
vtkMath.add(finalPosition, u, finalPosition);
|
|
305
|
+
vtkMath.add(finalPosition, v, finalPosition);
|
|
306
|
+
vtkMath.add(finalPosition, w, finalPosition);
|
|
307
|
+
vtkMath.add(finalPosition, positionMargin, finalPosition);
|
|
308
|
+
return (_model$apiSpecificRen5 = model.apiSpecificRenderWindow).displayToWorld.apply(_model$apiSpecificRen5, finalPosition.concat([model.renderer]));
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
publicAPI.updateTextPosition = function (point1, point2) {
|
|
312
|
+
var bounds = vtkMath.computeBoundsFromPoints(point1, point2, []);
|
|
313
|
+
var screenPosition = computeTextPosition(bounds, model.widgetState.getTextPosition(), model.widgetState.getTextWorldMargin());
|
|
314
|
+
var textHandle = model.widgetState.getText();
|
|
315
|
+
textHandle.setOrigin(screenPosition);
|
|
316
|
+
};
|
|
278
317
|
/*
|
|
279
318
|
* If the widget has the focus, this method reset the widget
|
|
280
319
|
* to it's state just after it grabbed the focus. Otherwise
|
|
@@ -290,11 +329,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
290
329
|
model.shapeHandle.setVisible(false);
|
|
291
330
|
model.point1 = null;
|
|
292
331
|
model.point2 = null;
|
|
293
|
-
|
|
294
|
-
if (model.label) {
|
|
295
|
-
model.label.setLabelText('');
|
|
296
|
-
}
|
|
297
|
-
|
|
332
|
+
model.widgetState.getText().setVisible(false);
|
|
298
333
|
model.point1Handle.setOrigin(model.point2Handle.getOrigin());
|
|
299
334
|
model.point2Handle.setVisible(false);
|
|
300
335
|
model.point2Handle.deactivate();
|
|
@@ -344,8 +379,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
344
379
|
model.point2Handle.setOrigin(worldCoords);
|
|
345
380
|
model.point2 = worldCoords;
|
|
346
381
|
publicAPI.updateShapeBounds();
|
|
382
|
+
publicAPI.invokeInteractionEvent();
|
|
347
383
|
}
|
|
348
|
-
} else if (model.
|
|
384
|
+
} else if (model.isDragging) {
|
|
349
385
|
if (model.activeState === model.point1Handle) {
|
|
350
386
|
model.point1Handle.setOrigin(worldCoords);
|
|
351
387
|
model.point1 = worldCoords;
|
|
@@ -428,7 +464,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
428
464
|
publicAPI.invokeInteractionEvent();
|
|
429
465
|
publicAPI.invokeEndInteractionEvent();
|
|
430
466
|
|
|
431
|
-
if (
|
|
467
|
+
if (publicAPI.getResetAfterPointPlacement()) {
|
|
432
468
|
publicAPI.reset();
|
|
433
469
|
} else {
|
|
434
470
|
publicAPI.loseFocus();
|
|
@@ -482,45 +518,23 @@ function widgetBehavior(publicAPI, model) {
|
|
|
482
518
|
publicAPI.grabFocus = function () {
|
|
483
519
|
if (!model.hasFocus) {
|
|
484
520
|
publicAPI.reset();
|
|
485
|
-
|
|
486
|
-
if (!model.label) {
|
|
487
|
-
model.label = vtkLabelRepresentation.newInstance();
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
model.label.setRenderer(model.renderer);
|
|
491
|
-
model.label.buildRepresentation();
|
|
492
|
-
model.renderer.addViewProp(model.label);
|
|
493
|
-
model.label.setContainer(model.interactor.getContainer());
|
|
494
521
|
model.point1Handle.activate();
|
|
495
522
|
model.activeState = model.point1Handle;
|
|
496
|
-
|
|
497
|
-
if (model.useHandles) {
|
|
498
|
-
model.point1Handle.setVisible(true);
|
|
499
|
-
}
|
|
500
|
-
|
|
523
|
+
model.point1Handle.setVisible(true);
|
|
501
524
|
model.shapeHandle.setVisible(false);
|
|
502
525
|
model.interactor.requestAnimation(publicAPI);
|
|
503
526
|
}
|
|
504
527
|
|
|
505
|
-
|
|
506
|
-
model.hasFocus = true;
|
|
528
|
+
superClass.grabFocus();
|
|
507
529
|
}; // --------------------------------------------------------------------------
|
|
508
530
|
|
|
509
531
|
|
|
510
532
|
publicAPI.loseFocus = function () {
|
|
511
533
|
if (model.hasFocus) {
|
|
512
|
-
if (model.visibleOnFocus && !model.useHandles) {
|
|
513
|
-
model.shapeHandle.setVisible(false);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
534
|
model.interactor.cancelAnimation(publicAPI);
|
|
517
535
|
}
|
|
518
536
|
|
|
519
|
-
if (
|
|
520
|
-
model.label.setContainer(null);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
if (!model.useHandles || !model.point1) {
|
|
537
|
+
if (!model.point1) {
|
|
524
538
|
model.point1Handle.setVisible(false);
|
|
525
539
|
model.point2Handle.setVisible(false);
|
|
526
540
|
}
|
|
@@ -531,7 +545,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
531
545
|
model.activeState = null;
|
|
532
546
|
model.interactor.render();
|
|
533
547
|
model.widgetManager.enablePicking();
|
|
534
|
-
|
|
548
|
+
superClass.loseFocus();
|
|
535
549
|
};
|
|
536
550
|
}
|
|
537
551
|
|
|
@@ -1,20 +1,42 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import macro from '../../macros.js';
|
|
3
|
+
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
2
4
|
import { BehaviorCategory, ShapeBehavior } from './ShapeWidget/Constants.js';
|
|
3
5
|
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
+
|
|
10
|
+
function vtkShapeWidget(publicAPI, model) {
|
|
11
|
+
model.classHierarchy.push('vtkShapeWidget');
|
|
12
|
+
model.methodsToLink = ['scaleInPixels', 'textProps', 'fontProperties'];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function defaultValues(initialValues) {
|
|
16
|
+
var _None;
|
|
17
|
+
|
|
18
|
+
return _objectSpread({
|
|
19
|
+
manipulator: null,
|
|
20
|
+
modifierBehavior: {
|
|
21
|
+
None: (_None = {}, _defineProperty(_None, BehaviorCategory.PLACEMENT, ShapeBehavior[BehaviorCategory.PLACEMENT].CLICK_AND_DRAG), _defineProperty(_None, BehaviorCategory.POINTS, ShapeBehavior[BehaviorCategory.POINTS].CORNER_TO_CORNER), _defineProperty(_None, BehaviorCategory.RATIO, ShapeBehavior[BehaviorCategory.RATIO].FREE), _None)
|
|
22
|
+
},
|
|
23
|
+
resetAfterPointPlacement: false
|
|
24
|
+
}, initialValues);
|
|
25
|
+
} // ----------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function extend(publicAPI, model) {
|
|
29
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
30
|
+
Object.assign(model, defaultValues(initialValues));
|
|
31
|
+
vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
|
|
32
|
+
macro.setGet(publicAPI, model, ['modifierBehavior', 'resetAfterPointPlacement']);
|
|
33
|
+
vtkShapeWidget(publicAPI, model);
|
|
34
|
+
} // ----------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
var newInstance = macro.newInstance(extend, 'vtkShapeWidget');
|
|
37
|
+
var vtkShapeWidget$1 = {
|
|
38
|
+
newInstance: newInstance,
|
|
39
|
+
extend: extend
|
|
18
40
|
};
|
|
19
41
|
|
|
20
|
-
export {
|
|
42
|
+
export { vtkShapeWidget$1 as default, extend, newInstance };
|
package/macros.js
CHANGED
|
@@ -692,8 +692,17 @@ function algo(publicAPI, model, numberOfInputs, numberOfOutputs) {
|
|
|
692
692
|
return;
|
|
693
693
|
}
|
|
694
694
|
|
|
695
|
-
model.numberOfInputs
|
|
696
|
-
|
|
695
|
+
var portToFill = model.numberOfInputs;
|
|
696
|
+
|
|
697
|
+
while (portToFill && !model.inputData[portToFill - 1] && !model.inputConnection[portToFill - 1]) {
|
|
698
|
+
portToFill--;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
if (portToFill === model.numberOfInputs) {
|
|
702
|
+
model.numberOfInputs++;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
setInputConnection(outputPort, portToFill);
|
|
697
706
|
}
|
|
698
707
|
|
|
699
708
|
function addInputData(dataset) {
|
|
@@ -702,8 +711,17 @@ function algo(publicAPI, model, numberOfInputs, numberOfOutputs) {
|
|
|
702
711
|
return;
|
|
703
712
|
}
|
|
704
713
|
|
|
705
|
-
model.numberOfInputs
|
|
706
|
-
|
|
714
|
+
var portToFill = model.numberOfInputs;
|
|
715
|
+
|
|
716
|
+
while (portToFill && !model.inputData[portToFill - 1] && !model.inputConnection[portToFill - 1]) {
|
|
717
|
+
portToFill--;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (portToFill === model.numberOfInputs) {
|
|
721
|
+
model.numberOfInputs++;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
setInputData(dataset, portToFill);
|
|
707
725
|
}
|
|
708
726
|
|
|
709
727
|
function getOutputData() {
|