@kitware/vtk.js 24.18.9 → 24.18.10
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/Representations/PolyLineRepresentation.js +2 -16
- package/Widgets/Widgets3D/AngleWidget/behavior.js +1 -0
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +1 -0
- package/Widgets/Widgets3D/LineWidget/behavior.js +24 -8
- package/Widgets/Widgets3D/LineWidget/helpers.js +4 -0
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
4
4
|
import vtkMapper from '../../Rendering/Core/Mapper.js';
|
|
5
|
-
import { B as areEquals
|
|
5
|
+
import { B as areEquals } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
7
7
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
8
8
|
import vtkTubeFilter from '../../Filters/General/TubeFilter.js';
|
|
@@ -104,21 +104,7 @@ function vtkPolyLineRepresentation(publicAPI, model) {
|
|
|
104
104
|
subStates.push(subState);
|
|
105
105
|
return subStates;
|
|
106
106
|
}, []);
|
|
107
|
-
var size = list.length;
|
|
108
|
-
|
|
109
|
-
if (size > 1) {
|
|
110
|
-
var lastState = list[list.length - 1];
|
|
111
|
-
var last = lastState.getOrigin();
|
|
112
|
-
var prevLast = list[list.length - 2].getOrigin();
|
|
113
|
-
var delta = distance2BetweenPoints(last, prevLast) > model.threshold ? 0 : 1;
|
|
114
|
-
|
|
115
|
-
if (!delta && lastState.isVisible && !lastState.isVisible()) {
|
|
116
|
-
delta++;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
size -= delta;
|
|
120
|
-
}
|
|
121
|
-
|
|
107
|
+
var size = list.length;
|
|
122
108
|
var points = allocateSize(size, model.closePolyLine && size > 2);
|
|
123
109
|
|
|
124
110
|
if (points) {
|
|
@@ -147,6 +147,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
147
147
|
model.widgetState.deactivate();
|
|
148
148
|
model.widgetState.getMoveHandle().deactivate();
|
|
149
149
|
model.widgetState.getMoveHandle().setVisible(false);
|
|
150
|
+
model.widgetState.getMoveHandle().setOrigin(null);
|
|
150
151
|
model.activeState = null;
|
|
151
152
|
model.hasFocus = false;
|
|
152
153
|
|
|
@@ -138,6 +138,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
138
138
|
model.widgetState.deactivate();
|
|
139
139
|
model.widgetState.getMoveHandle().deactivate();
|
|
140
140
|
model.widgetState.getMoveHandle().setVisible(false);
|
|
141
|
+
model.widgetState.getMoveHandle().setOrigin(null);
|
|
141
142
|
model.activeState = null;
|
|
142
143
|
model.hasFocus = false;
|
|
143
144
|
|
|
@@ -23,6 +23,27 @@ function widgetBehavior(publicAPI, model) {
|
|
|
23
23
|
publicAPI.getHandle = function (handleIndex) {
|
|
24
24
|
return model.widgetState[handleGetters[handleIndex]]();
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Return the index in the of tbe handle in `representations` array,
|
|
28
|
+
* or -1 if the handle is not present in the widget state.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
publicAPI.getHandleIndex = function (handle) {
|
|
33
|
+
switch (handle) {
|
|
34
|
+
case model.widgetState.getHandle1():
|
|
35
|
+
return 0;
|
|
36
|
+
|
|
37
|
+
case model.widgetState.getHandle2():
|
|
38
|
+
return 1;
|
|
39
|
+
|
|
40
|
+
case model.widgetState.getMoveHandle():
|
|
41
|
+
return 2;
|
|
42
|
+
|
|
43
|
+
default:
|
|
44
|
+
return -1;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
26
47
|
|
|
27
48
|
publicAPI.isPlaced = function () {
|
|
28
49
|
return getNumberOfPlacedHandles(model.widgetState) === MAX_POINTS;
|
|
@@ -146,12 +167,6 @@ function widgetBehavior(publicAPI, model) {
|
|
|
146
167
|
model.representations[1].setViewMatrix(Array.from(model._camera.getViewMatrix()));
|
|
147
168
|
}; // Handles visibility ---------------------------------------------------------
|
|
148
169
|
|
|
149
|
-
|
|
150
|
-
publicAPI.setMoveHandleVisibility = function (visibility) {
|
|
151
|
-
model.representations[2].setVisibilityFlagArray([visibility, visibility]);
|
|
152
|
-
model.widgetState.getMoveHandle().setVisible(visibility);
|
|
153
|
-
model.representations[2].updateActorVisibility();
|
|
154
|
-
};
|
|
155
170
|
/**
|
|
156
171
|
* Set actor visibility to true unless it is a NONE handle
|
|
157
172
|
* and uses state visibility variable for the displayActor visibility to
|
|
@@ -197,7 +212,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
197
212
|
|
|
198
213
|
if (handleIndex === 1) {
|
|
199
214
|
publicAPI.placeText();
|
|
200
|
-
publicAPI.
|
|
215
|
+
publicAPI.loseFocus();
|
|
201
216
|
}
|
|
202
217
|
}; // --------------------------------------------------------------------------
|
|
203
218
|
// Left press: Select handle to drag
|
|
@@ -240,6 +255,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
240
255
|
model._isDragging) {
|
|
241
256
|
if (model.activeState.setOrigin) {
|
|
242
257
|
model.activeState.setOrigin(worldCoords);
|
|
258
|
+
publicAPI.updateHandleVisibility(publicAPI.getHandleIndex(model.activeState));
|
|
243
259
|
} else {
|
|
244
260
|
// Dragging line
|
|
245
261
|
publicAPI.getHandle(0).setOrigin(add(publicAPI.getHandle(0).getOrigin(), translation, []));
|
|
@@ -306,7 +322,6 @@ function widgetBehavior(publicAPI, model) {
|
|
|
306
322
|
if (!model.hasFocus && !publicAPI.isPlaced()) {
|
|
307
323
|
model.activeState = model.widgetState.getMoveHandle();
|
|
308
324
|
model.activeState.setShape(publicAPI.getHandle(0).getShape());
|
|
309
|
-
publicAPI.setMoveHandleVisibility(true);
|
|
310
325
|
model.activeState.activate();
|
|
311
326
|
|
|
312
327
|
model._interactor.requestAnimation(publicAPI);
|
|
@@ -327,6 +342,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
327
342
|
|
|
328
343
|
model.widgetState.deactivate();
|
|
329
344
|
model.widgetState.getMoveHandle().deactivate();
|
|
345
|
+
model.widgetState.getMoveHandle().setOrigin(null);
|
|
330
346
|
model.activeState = null;
|
|
331
347
|
model.hasFocus = false;
|
|
332
348
|
|
|
@@ -21,6 +21,10 @@ function updateTextPosition(model) {
|
|
|
21
21
|
SVGTextState.setOrigin(calculateTextPosition(model));
|
|
22
22
|
}
|
|
23
23
|
function isHandlePlaced(handleIndex, widgetState) {
|
|
24
|
+
if (handleIndex === 2) {
|
|
25
|
+
return widgetState.getMoveHandle().getOrigin() != null;
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
var handle1Origin = widgetState.getHandle1().getOrigin();
|
|
25
29
|
|
|
26
30
|
if (handleIndex === 0) {
|
|
@@ -180,6 +180,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
180
180
|
model.widgetState.deactivate();
|
|
181
181
|
model.widgetState.getMoveHandle().deactivate();
|
|
182
182
|
model.widgetState.getMoveHandle().setVisible(false);
|
|
183
|
+
model.widgetState.getMoveHandle().setOrigin(null);
|
|
183
184
|
model.activeState = null;
|
|
184
185
|
model.hasFocus = false;
|
|
185
186
|
|