@kitware/vtk.js 23.4.3 → 24.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +33 -0
- package/Common/Core/DataArray.js +4 -0
- package/Common/Core/Math/index.js +2 -2
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
- package/Common/DataModel/ImageData.d.ts +23 -6
- package/Common/DataModel/ImageData.js +8 -1
- package/Common/DataModel/PolyData.d.ts +8 -1
- package/Common/DataModel/PolyData.js +5 -3
- package/Common/DataModel/Triangle.js +217 -2
- package/Common/Transform/LandmarkTransform.js +1 -1
- package/Filters/General/OBBTree/OBBNode.js +82 -0
- package/Filters/General/OBBTree/helper.js +92 -0
- package/Filters/General/OBBTree.js +1249 -0
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/Filters/General.js +2 -0
- package/Filters/Sources/CircleSource.js +1 -1
- package/Filters/Sources/PointSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Style/InteractorStyleImage.js +3 -3
- package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
- package/Interaction/Style/InteractorStyleManipulator.js +42 -28
- package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
- package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
- package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
- package/Interaction/Widgets.js +1 -35
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +1 -1
- package/Rendering/Core/Glyph3DMapper.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/InteractorObserver.js +11 -10
- package/Rendering/Core/InteractorStyle.js +9 -4
- package/Rendering/Core/Mapper.js +1 -1
- package/Rendering/Core/Prop.js +6 -4
- package/Rendering/Core/Prop3D.js +1 -1
- package/Rendering/Core/RenderWindowInteractor.js +24 -17
- package/Rendering/Core/Renderer.js +24 -19
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/Viewport.js +1 -1
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/OpenGL/Actor.js +2 -2
- package/Rendering/OpenGL/Actor2D.js +2 -2
- package/Rendering/OpenGL/BufferObject.js +6 -5
- package/Rendering/OpenGL/Camera.js +3 -3
- package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
- package/Rendering/OpenGL/Framebuffer.js +13 -12
- package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
- package/Rendering/OpenGL/HardwareSelector.js +35 -25
- package/Rendering/OpenGL/ImageMapper.js +51 -45
- package/Rendering/OpenGL/ImageSlice.js +2 -2
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
- package/Rendering/OpenGL/PolyDataMapper.js +14 -11
- package/Rendering/OpenGL/PolyDataMapper2D.js +7 -6
- package/Rendering/OpenGL/Renderer.js +11 -7
- package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
- package/Rendering/OpenGL/ScalarBarActor.js +2 -2
- package/Rendering/OpenGL/ShaderCache.js +7 -5
- package/Rendering/OpenGL/Skybox.js +11 -9
- package/Rendering/OpenGL/SphereMapper.js +2 -2
- package/Rendering/OpenGL/StickMapper.js +2 -2
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
- package/Rendering/OpenGL/Texture.js +44 -31
- package/Rendering/OpenGL/VertexArrayObject.js +7 -7
- package/Rendering/OpenGL/Volume.js +3 -2
- package/Rendering/OpenGL/VolumeMapper.js +30 -26
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/SceneGraph/ViewNode.js +8 -7
- package/Rendering/WebGPU/Renderer.js +18 -10
- package/Widgets/Core/AbstractWidget.js +5 -4
- package/Widgets/Core/AbstractWidgetFactory.js +2 -1
- package/Widgets/Core/WidgetManager.js +66 -49
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Representations/CircleContextRepresentation.js +1 -1
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
- package/Widgets/Representations/PolyLineRepresentation.js +1 -1
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
- package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
- package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
- package/Widgets/SVG/SVGRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
- package/Widgets/Widgets3D/EllipseWidget.js +0 -1
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
- package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
- package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
- package/Widgets/Widgets3D/LabelWidget.js +79 -0
- package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/LineWidget.js +0 -1
- package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
- package/Widgets/Widgets3D/RectangleWidget.js +0 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
- package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
- package/interfaces.d.ts +11 -0
- package/macros.d.ts +26 -1
- package/macros.js +51 -19
- package/package.json +1 -1
- package/types.d.ts +1 -0
- package/Interaction/Widgets/AbstractWidget.js +0 -104
- package/Interaction/Widgets/DistanceRepresentation.js +0 -116
- package/Interaction/Widgets/DistanceWidget.js +0 -77
- package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
- package/Interaction/Widgets/HandleRepresentation.js +0 -100
- package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
- package/Interaction/Widgets/HandleWidget.js +0 -194
- package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
- package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
- package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
- package/Interaction/Widgets/LabelRepresentation.js +0 -325
- package/Interaction/Widgets/LabelWidget.js +0 -65
- package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
- package/Interaction/Widgets/LineRepresentation.js +0 -498
- package/Interaction/Widgets/LineWidget/Constants.js +0 -11
- package/Interaction/Widgets/LineWidget.js +0 -296
- package/Interaction/Widgets/PointPlacer.js +0 -51
- package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
- package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
- package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
- package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
- package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
- package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
- package/Interaction/Widgets/WidgetRepresentation.js +0 -121
|
@@ -1,573 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import macro from '../../macros.js';
|
|
4
|
-
import { l as normalize, d as dot, g as subtract, B as projectVector, k as add } from '../../Common/Core/Math/index.js';
|
|
5
|
-
import vtkPlane from '../../Common/DataModel/Plane.js';
|
|
6
|
-
import vtkAbstractWidget from './AbstractWidget.js';
|
|
7
|
-
import vtkImageCroppingRegionsRepresentation from './ImageCroppingRegionsRepresentation.js';
|
|
8
|
-
import Constants from './ImageCroppingRegionsWidget/Constants.js';
|
|
9
|
-
import { mat4, vec3 } from 'gl-matrix';
|
|
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; }
|
|
14
|
-
var vtkErrorMacro = macro.vtkErrorMacro,
|
|
15
|
-
VOID = macro.VOID,
|
|
16
|
-
EVENT_ABORT = macro.EVENT_ABORT;
|
|
17
|
-
var TOTAL_NUM_HANDLES = Constants.TOTAL_NUM_HANDLES,
|
|
18
|
-
WidgetState = Constants.WidgetState,
|
|
19
|
-
CropWidgetEvents = Constants.CropWidgetEvents; // Determines the ordering of edge handles for some fixed axis
|
|
20
|
-
|
|
21
|
-
var EDGE_ORDER = [[0, 0], [0, 1], [1, 0], [1, 1]]; // ----------------------------------------------------------------------------
|
|
22
|
-
// vtkImageCroppingRegionsWidget methods
|
|
23
|
-
// ----------------------------------------------------------------------------
|
|
24
|
-
|
|
25
|
-
function arrayEquals(a, b) {
|
|
26
|
-
if (a.length === b.length) {
|
|
27
|
-
for (var i = 0; i < a.length; ++i) {
|
|
28
|
-
if (a[i] !== b[i]) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function vtkImageCroppingRegionsWidget(publicAPI, model) {
|
|
40
|
-
// Set our className
|
|
41
|
-
model.classHierarchy.push('vtkImageCroppingRegionsWidget'); // camera subscription
|
|
42
|
-
|
|
43
|
-
var cameraSub = null;
|
|
44
|
-
model.indexToWorld = mat4.identity(new Float64Array(16));
|
|
45
|
-
model.worldToIndex = mat4.identity(new Float64Array(16));
|
|
46
|
-
var handlesCache = null;
|
|
47
|
-
model.widgetState = {
|
|
48
|
-
activeHandleIndex: -1,
|
|
49
|
-
// index space: xmin, xmax, ymin, ymax, zmin, zmax
|
|
50
|
-
planes: Array(6).fill(0),
|
|
51
|
-
controlState: WidgetState.IDLE
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
function worldToIndex(ain) {
|
|
55
|
-
var vout = [];
|
|
56
|
-
vec3.transformMat4(vout, ain, model.worldToIndex);
|
|
57
|
-
return vout;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function indexToWorld(ain) {
|
|
61
|
-
var vout = [];
|
|
62
|
-
vec3.transformMat4(vout, ain, model.indexToWorld);
|
|
63
|
-
return vout;
|
|
64
|
-
} // Overridden method
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
publicAPI.createDefaultRepresentation = function () {
|
|
68
|
-
if (!model.widgetRep) {
|
|
69
|
-
model.widgetRep = vtkImageCroppingRegionsRepresentation.newInstance();
|
|
70
|
-
publicAPI.updateRepresentation();
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
publicAPI.getWidgetState = function () {
|
|
75
|
-
return _objectSpread({}, model.widgetState);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
publicAPI.updateWidgetState = function (state) {
|
|
79
|
-
var needsUpdate = Object.keys(state).reduce(function (flag, key) {
|
|
80
|
-
return flag || model.widgetState[key] !== state[key];
|
|
81
|
-
}, false);
|
|
82
|
-
|
|
83
|
-
if (needsUpdate) {
|
|
84
|
-
var oldState = model.widgetState;
|
|
85
|
-
model.widgetState = _objectSpread(_objectSpread({}, oldState), state);
|
|
86
|
-
|
|
87
|
-
if (!arrayEquals(oldState.planes, model.widgetState.planes)) {
|
|
88
|
-
// invalidate handles cache
|
|
89
|
-
handlesCache = null;
|
|
90
|
-
publicAPI.invokeCroppingPlanesChanged(model.widgetState.planes);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
publicAPI.updateRepresentation();
|
|
94
|
-
publicAPI.modified();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
publicAPI.setVolumeMapper = function (volumeMapper) {
|
|
99
|
-
if (volumeMapper !== model.volumeMapper) {
|
|
100
|
-
model.volumeMapper = volumeMapper;
|
|
101
|
-
publicAPI.resetWidgetState();
|
|
102
|
-
|
|
103
|
-
if (model.enabled) {
|
|
104
|
-
publicAPI.updateRepresentation();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
publicAPI.planesToHandles = function (planes) {
|
|
110
|
-
if (!model.volumeMapper || !model.volumeMapper.getInputData()) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (handlesCache) {
|
|
115
|
-
return handlesCache;
|
|
116
|
-
} // coords are in world space.
|
|
117
|
-
// a null handle means it is disabled
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var handles = Array(TOTAL_NUM_HANDLES).fill(null);
|
|
121
|
-
|
|
122
|
-
if (model.faceHandlesEnabled) {
|
|
123
|
-
var _loop = function _loop(i) {
|
|
124
|
-
var center = [0, 0, 0].map(function (c, j) {
|
|
125
|
-
if (j === Math.floor(i / 2)) {
|
|
126
|
-
return planes[i];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return (planes[j * 2] + planes[j * 2 + 1]) / 2;
|
|
130
|
-
});
|
|
131
|
-
handles[i] = [center[0], center[1], center[2]];
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// construct face handles
|
|
135
|
-
for (var i = 0; i < 6; ++i) {
|
|
136
|
-
_loop(i);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (model.edgeHandlesEnabled) {
|
|
141
|
-
// construct edge handles
|
|
142
|
-
for (var _i = 0; _i < 12; ++_i) {
|
|
143
|
-
// the axis around which edge handles will be placed
|
|
144
|
-
var fixedAxis = Math.floor(_i / 4);
|
|
145
|
-
|
|
146
|
-
var edgeSpec = EDGE_ORDER[_i % 4].slice();
|
|
147
|
-
|
|
148
|
-
var center = [];
|
|
149
|
-
|
|
150
|
-
for (var j = 0; j < 3; ++j) {
|
|
151
|
-
if (j !== fixedAxis) {
|
|
152
|
-
// edgeSpec[j] determines whether to pick a min or max cropping
|
|
153
|
-
// plane for edge selection.
|
|
154
|
-
center.push(planes[j * 2 + edgeSpec.shift()]);
|
|
155
|
-
}
|
|
156
|
-
} // set fixed axis coordinate
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
center.splice(fixedAxis, 0, (planes[fixedAxis * 2] + planes[fixedAxis * 2 + 1]) / 2);
|
|
160
|
-
handles[_i + 6] = [center[0], center[1], center[2]];
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (model.cornerHandlesEnabled) {
|
|
165
|
-
// construct corner handles
|
|
166
|
-
for (var _i2 = 0; _i2 < 8; ++_i2) {
|
|
167
|
-
/* eslint-disable no-bitwise */
|
|
168
|
-
handles[_i2 + 18] = [planes[0 + (_i2 >> 2 & 0x1)], planes[2 + (_i2 >> 1 & 0x1)], planes[4 + (_i2 >> 0 & 0x1)]];
|
|
169
|
-
/* eslint-enable no-bitwise */
|
|
170
|
-
}
|
|
171
|
-
} // transform handles from index to world space
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
for (var _i3 = 0; _i3 < handles.length; ++_i3) {
|
|
175
|
-
if (handles[_i3]) {
|
|
176
|
-
handles[_i3] = indexToWorld(handles[_i3]);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
handlesCache = handles;
|
|
181
|
-
return handles;
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
publicAPI.planesToBBoxCorners = function (planes) {
|
|
185
|
-
if (!model.volumeMapper || !model.volumeMapper.getInputData()) {
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return [[planes[0], planes[2], planes[4]], [planes[0], planes[2], planes[5]], [planes[0], planes[3], planes[4]], [planes[0], planes[3], planes[5]], [planes[1], planes[2], planes[4]], [planes[1], planes[2], planes[5]], [planes[1], planes[3], planes[4]], [planes[1], planes[3], planes[5]]].map(function (coord) {
|
|
190
|
-
return indexToWorld(coord);
|
|
191
|
-
});
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
publicAPI.resetWidgetState = function () {
|
|
195
|
-
if (!model.volumeMapper) {
|
|
196
|
-
vtkErrorMacro('Volume mapper must be set to update representation');
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (!model.volumeMapper.getInputData()) {
|
|
201
|
-
vtkErrorMacro('Volume mapper has no input data');
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
var data = model.volumeMapper.getInputData(); // cache transforms
|
|
206
|
-
|
|
207
|
-
model.indexToWorld = data.getIndexToWorld();
|
|
208
|
-
model.worldToIndex = data.getWorldToIndex();
|
|
209
|
-
var planes = data.getExtent();
|
|
210
|
-
publicAPI.setCroppingPlanes.apply(publicAPI, _toConsumableArray(planes));
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
publicAPI.setEnabled = macro.chain(publicAPI.setEnabled, function (enable) {
|
|
214
|
-
if (cameraSub) {
|
|
215
|
-
cameraSub.unsubscribe();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (enable) {
|
|
219
|
-
var camera = publicAPI.getInteractor().getCurrentRenderer().getActiveCamera();
|
|
220
|
-
cameraSub = camera.onModified(publicAPI.updateRepresentation);
|
|
221
|
-
publicAPI.updateRepresentation();
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
publicAPI.setFaceHandlesEnabled = function (enabled) {
|
|
226
|
-
if (model.faceHandlesEnabled !== enabled) {
|
|
227
|
-
model.faceHandlesEnabled = enabled;
|
|
228
|
-
publicAPI.updateRepresentation();
|
|
229
|
-
publicAPI.modified();
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
publicAPI.setEdgeHandlesEnabled = function (enabled) {
|
|
234
|
-
if (model.edgeHandlesEnabled !== enabled) {
|
|
235
|
-
model.edgeHandlesEnabled = enabled;
|
|
236
|
-
publicAPI.updateRepresentation();
|
|
237
|
-
publicAPI.modified();
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
publicAPI.setCornerHandlesEnabled = function (enabled) {
|
|
242
|
-
if (model.cornerHandlesEnabled !== enabled) {
|
|
243
|
-
model.cornerHandlesEnabled = enabled;
|
|
244
|
-
publicAPI.updateRepresentation();
|
|
245
|
-
publicAPI.modified();
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
publicAPI.setHandleSize = function (size) {
|
|
250
|
-
if (model.handleSize !== size) {
|
|
251
|
-
model.handleSize = size;
|
|
252
|
-
publicAPI.updateRepresentation();
|
|
253
|
-
publicAPI.modified();
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
publicAPI.getCroppingPlanes = function () {
|
|
258
|
-
return model.widgetState.planes.slice();
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
publicAPI.setCroppingPlanes = function () {
|
|
262
|
-
for (var _len = arguments.length, planes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
263
|
-
planes[_key] = arguments[_key];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
publicAPI.updateWidgetState({
|
|
267
|
-
planes: planes
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
publicAPI.updateRepresentation = function () {
|
|
272
|
-
if (model.widgetRep) {
|
|
273
|
-
var _model$widgetRep;
|
|
274
|
-
|
|
275
|
-
var bounds = model.volumeMapper.getBounds();
|
|
276
|
-
|
|
277
|
-
(_model$widgetRep = model.widgetRep).placeWidget.apply(_model$widgetRep, _toConsumableArray(bounds));
|
|
278
|
-
|
|
279
|
-
var _model$widgetState = model.widgetState,
|
|
280
|
-
activeHandleIndex = _model$widgetState.activeHandleIndex,
|
|
281
|
-
planes = _model$widgetState.planes;
|
|
282
|
-
var bboxCorners = publicAPI.planesToBBoxCorners(planes);
|
|
283
|
-
var handlePositions = publicAPI.planesToHandles(planes);
|
|
284
|
-
var handleSizes = handlePositions.map(function (handle) {
|
|
285
|
-
if (!handle) {
|
|
286
|
-
return model.handleSize;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return publicAPI.adjustHandleSize(handle, model.handleSize);
|
|
290
|
-
});
|
|
291
|
-
model.widgetRep.set({
|
|
292
|
-
activeHandleIndex: activeHandleIndex,
|
|
293
|
-
handlePositions: handlePositions,
|
|
294
|
-
bboxCorners: bboxCorners,
|
|
295
|
-
handleSizes: handleSizes
|
|
296
|
-
});
|
|
297
|
-
publicAPI.render();
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
publicAPI.adjustHandleSize = function (pos, size) {
|
|
302
|
-
var interactor = publicAPI.getInteractor();
|
|
303
|
-
|
|
304
|
-
if (!interactor && !interactor.getCurrentRenderer()) {
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
var renderer = interactor.getCurrentRenderer();
|
|
309
|
-
|
|
310
|
-
if (!renderer.getActiveCamera()) {
|
|
311
|
-
return null;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
var worldCoords = publicAPI.computeWorldToDisplay(renderer, pos[0], pos[1], pos[2]);
|
|
315
|
-
var lowerLeft = publicAPI.computeDisplayToWorld(renderer, worldCoords[0] - size / 2.0, worldCoords[1] - size / 2.0, worldCoords[2]);
|
|
316
|
-
var upperRight = publicAPI.computeDisplayToWorld(renderer, worldCoords[0] + size / 2.0, worldCoords[1] + size / 2.0, worldCoords[2]);
|
|
317
|
-
var radius = 0.0;
|
|
318
|
-
|
|
319
|
-
for (var i = 0; i < 3; i++) {
|
|
320
|
-
radius += (upperRight[i] - lowerLeft[i]) * (upperRight[i] - lowerLeft[i]);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
return Math.sqrt(radius) / 2.0;
|
|
324
|
-
}; // Given display coordinates and a plane, returns the
|
|
325
|
-
// point on the plane that corresponds to display coordinates.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
publicAPI.displayToPlane = function (displayCoords, planePoint, planeNormal) {
|
|
329
|
-
var view = publicAPI.getInteractor().getView();
|
|
330
|
-
var renderer = publicAPI.getInteractor().getCurrentRenderer();
|
|
331
|
-
var camera = renderer.getActiveCamera();
|
|
332
|
-
var cameraFocalPoint = camera.getFocalPoint();
|
|
333
|
-
var cameraPos = camera.getPosition(); // Adapted from vtkPicker
|
|
334
|
-
|
|
335
|
-
var focalPointDispCoords = view.worldToDisplay.apply(view, _toConsumableArray(cameraFocalPoint).concat([renderer]));
|
|
336
|
-
var worldCoords = view.displayToWorld(displayCoords[0], displayCoords[1], focalPointDispCoords[2], // Use focal point for z coord
|
|
337
|
-
renderer); // compute ray from camera to selection
|
|
338
|
-
|
|
339
|
-
var ray = [0, 0, 0];
|
|
340
|
-
|
|
341
|
-
for (var i = 0; i < 3; ++i) {
|
|
342
|
-
ray[i] = worldCoords[i] - cameraPos[i];
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
var dop = camera.getDirectionOfProjection();
|
|
346
|
-
normalize(dop);
|
|
347
|
-
var rayLength = dot(dop, ray);
|
|
348
|
-
var clipRange = camera.getClippingRange();
|
|
349
|
-
var p1World = [0, 0, 0];
|
|
350
|
-
var p2World = [0, 0, 0]; // get line segment coords from ray based on clip range
|
|
351
|
-
|
|
352
|
-
if (camera.getParallelProjection()) {
|
|
353
|
-
var tF = clipRange[0] - rayLength;
|
|
354
|
-
var tB = clipRange[1] - rayLength;
|
|
355
|
-
|
|
356
|
-
for (var _i4 = 0; _i4 < 3; _i4++) {
|
|
357
|
-
p1World[_i4] = worldCoords[_i4] + tF * dop[_i4];
|
|
358
|
-
p2World[_i4] = worldCoords[_i4] + tB * dop[_i4];
|
|
359
|
-
}
|
|
360
|
-
} else {
|
|
361
|
-
var _tF = clipRange[0] / rayLength;
|
|
362
|
-
|
|
363
|
-
var _tB = clipRange[1] / rayLength;
|
|
364
|
-
|
|
365
|
-
for (var _i5 = 0; _i5 < 3; _i5++) {
|
|
366
|
-
p1World[_i5] = cameraPos[_i5] + _tF * ray[_i5];
|
|
367
|
-
p2World[_i5] = cameraPos[_i5] + _tB * ray[_i5];
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
var r = vtkPlane.intersectWithLine(p1World, p2World, planePoint, planeNormal);
|
|
372
|
-
return r.intersection ? r.x : null;
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
publicAPI.handleLeftButtonPress = function (callData) {
|
|
376
|
-
return publicAPI.pressAction(callData);
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
publicAPI.handleLeftButtonRelease = function (callData) {
|
|
380
|
-
return publicAPI.endMoveAction(callData);
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
publicAPI.handleMiddleButtonPress = function (callData) {
|
|
384
|
-
return publicAPI.pressAction(callData);
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
publicAPI.handleMiddleButtonRelease = function (callData) {
|
|
388
|
-
return publicAPI.endMoveAction(callData);
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
publicAPI.handleRightButtonPress = function (callData) {
|
|
392
|
-
return publicAPI.pressAction(callData);
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
publicAPI.handleRightButtonRelease = function (callData) {
|
|
396
|
-
return publicAPI.endMoveAction(callData);
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
publicAPI.handleMouseMove = function (callData) {
|
|
400
|
-
return publicAPI.moveAction(callData);
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
publicAPI.pressAction = function (callData) {
|
|
404
|
-
if (model.widgetState.controlState === WidgetState.IDLE) {
|
|
405
|
-
var handleIndex = model.widgetRep.getEventIntersection(callData);
|
|
406
|
-
|
|
407
|
-
if (handleIndex > -1) {
|
|
408
|
-
model.activeHandleIndex = handleIndex;
|
|
409
|
-
publicAPI.updateWidgetState({
|
|
410
|
-
activeHandleIndex: handleIndex,
|
|
411
|
-
controlState: WidgetState.CROPPING
|
|
412
|
-
});
|
|
413
|
-
return EVENT_ABORT;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
return VOID;
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
publicAPI.moveAction = function (callData) {
|
|
421
|
-
var _model$widgetState2 = model.widgetState,
|
|
422
|
-
controlState = _model$widgetState2.controlState,
|
|
423
|
-
planes = _model$widgetState2.planes,
|
|
424
|
-
activeHandleIndex = _model$widgetState2.activeHandleIndex;
|
|
425
|
-
|
|
426
|
-
if (controlState === WidgetState.IDLE || activeHandleIndex === -1) {
|
|
427
|
-
return VOID;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
var handles = publicAPI.planesToHandles(planes);
|
|
431
|
-
var mouse = [callData.position.x, callData.position.y];
|
|
432
|
-
var handlePos = handles[activeHandleIndex];
|
|
433
|
-
var renderer = publicAPI.getInteractor().getCurrentRenderer();
|
|
434
|
-
var camera = renderer.getActiveCamera();
|
|
435
|
-
var dop = camera.getDirectionOfProjection();
|
|
436
|
-
var point = publicAPI.displayToPlane(mouse, handlePos, dop);
|
|
437
|
-
|
|
438
|
-
if (!point) {
|
|
439
|
-
return EVENT_ABORT;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
var newPlanes = planes.slice(); // activeHandleIndex should be > -1 here
|
|
443
|
-
|
|
444
|
-
if (activeHandleIndex < 6) {
|
|
445
|
-
// face handle, so constrain to axis
|
|
446
|
-
var moveAxis = Math.floor(activeHandleIndex / 2); // Constrain point to axis
|
|
447
|
-
|
|
448
|
-
var orientation = model.volumeMapper.getInputData().getDirection();
|
|
449
|
-
var offset = moveAxis * 3;
|
|
450
|
-
var constraintAxis = orientation.slice(offset, offset + 3);
|
|
451
|
-
var newPos = [0, 0, 0];
|
|
452
|
-
var relMoveVect = [0, 0, 0];
|
|
453
|
-
var projection = [0, 0, 0];
|
|
454
|
-
subtract(point, handlePos, relMoveVect);
|
|
455
|
-
projectVector(relMoveVect, constraintAxis, projection);
|
|
456
|
-
add(handlePos, projection, newPos);
|
|
457
|
-
var indexHandle = worldToIndex(newPos); // set correct plane value
|
|
458
|
-
|
|
459
|
-
newPlanes[activeHandleIndex] = indexHandle[moveAxis];
|
|
460
|
-
} else if (activeHandleIndex < 18) {
|
|
461
|
-
// edge handle, so constrain to plane
|
|
462
|
-
var edgeHandleIndex = activeHandleIndex - 6;
|
|
463
|
-
var fixedAxis = Math.floor(edgeHandleIndex / 4);
|
|
464
|
-
/**
|
|
465
|
-
* edgeHandleIndex: plane, plane
|
|
466
|
-
* 4: xmin, zmin
|
|
467
|
-
* 5: xmin, zmax
|
|
468
|
-
* 6: xmax, zmin
|
|
469
|
-
* 7: xmax, zmax
|
|
470
|
-
* 8: xmin, ymin
|
|
471
|
-
* 9: xmin, ymax
|
|
472
|
-
* 10: xmax, ymin
|
|
473
|
-
* 11: xmax, ymax
|
|
474
|
-
*/
|
|
475
|
-
|
|
476
|
-
var _orientation = model.volumeMapper.getInputData().getDirection();
|
|
477
|
-
|
|
478
|
-
var _offset = fixedAxis * 3;
|
|
479
|
-
|
|
480
|
-
var constraintPlaneNormal = _orientation.slice(_offset, _offset + 3);
|
|
481
|
-
|
|
482
|
-
var _newPos = [0, 0, 0];
|
|
483
|
-
var _relMoveVect = [0, 0, 0];
|
|
484
|
-
var _projection = [0, 0, 0];
|
|
485
|
-
subtract(point, handlePos, _relMoveVect);
|
|
486
|
-
vtkPlane.projectVector(_relMoveVect, constraintPlaneNormal, _projection);
|
|
487
|
-
add(handlePos, _projection, _newPos);
|
|
488
|
-
|
|
489
|
-
var _indexHandle = worldToIndex(_newPos); // get the two planes that are being adjusted
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
var edgeSpec = EDGE_ORDER[edgeHandleIndex % 4].slice();
|
|
493
|
-
var modifiedPlanes = [];
|
|
494
|
-
|
|
495
|
-
for (var i = 0; i < 3; ++i) {
|
|
496
|
-
if (i !== fixedAxis) {
|
|
497
|
-
modifiedPlanes.push(i * 2 + edgeSpec.shift());
|
|
498
|
-
}
|
|
499
|
-
} // set correct plane value
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
modifiedPlanes.forEach(function (planeIndex) {
|
|
503
|
-
// Math.floor(planeIndex / 2) is the corresponding changed
|
|
504
|
-
// coordinate (that dictates the plane position)
|
|
505
|
-
newPlanes[planeIndex] = _indexHandle[Math.floor(planeIndex / 2)];
|
|
506
|
-
});
|
|
507
|
-
} else {
|
|
508
|
-
// corner handles, so no constraints
|
|
509
|
-
var cornerHandleIndex = activeHandleIndex - 18;
|
|
510
|
-
|
|
511
|
-
var _indexHandle2 = worldToIndex(point); // get the three planes that are being adjusted
|
|
512
|
-
|
|
513
|
-
/* eslint-disable no-bitwise */
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
var _modifiedPlanes = [0 + (cornerHandleIndex >> 2 & 0x1), 2 + (cornerHandleIndex >> 1 & 0x1), 4 + (cornerHandleIndex >> 0 & 0x1)];
|
|
517
|
-
/* eslint-enable no-bitwise */
|
|
518
|
-
// set correct plane value
|
|
519
|
-
|
|
520
|
-
_modifiedPlanes.forEach(function (planeIndex) {
|
|
521
|
-
// Math.floor(planeIndex / 2) is the corresponding changed
|
|
522
|
-
// coordinate (that dictates the plane position)
|
|
523
|
-
newPlanes[planeIndex] = _indexHandle2[Math.floor(planeIndex / 2)];
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
publicAPI.setCroppingPlanes.apply(publicAPI, _toConsumableArray(newPlanes));
|
|
528
|
-
return EVENT_ABORT;
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
publicAPI.endMoveAction = function () {
|
|
532
|
-
if (model.widgetState.activeHandleIndex > -1) {
|
|
533
|
-
publicAPI.updateWidgetState({
|
|
534
|
-
activeHandleIndex: -1,
|
|
535
|
-
controlState: WidgetState.IDLE
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
} // ----------------------------------------------------------------------------
|
|
540
|
-
// Object factory
|
|
541
|
-
// ----------------------------------------------------------------------------
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
var DEFAULT_VALUES = {
|
|
545
|
-
// volumeMapper: null,
|
|
546
|
-
handleSize: 5,
|
|
547
|
-
faceHandlesEnabled: false,
|
|
548
|
-
edgeHandlesEnabled: false,
|
|
549
|
-
cornerHandlesEnabled: true
|
|
550
|
-
}; // ----------------------------------------------------------------------------
|
|
551
|
-
|
|
552
|
-
function extend(publicAPI, model) {
|
|
553
|
-
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
554
|
-
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
555
|
-
// Have our default values override whatever is from parent class
|
|
556
|
-
|
|
557
|
-
vtkAbstractWidget.extend(publicAPI, model, DEFAULT_VALUES, initialValues);
|
|
558
|
-
CropWidgetEvents.forEach(function (eventName) {
|
|
559
|
-
return macro.event(publicAPI, model, eventName);
|
|
560
|
-
});
|
|
561
|
-
macro.get(publicAPI, model, ['volumeMapper', 'handleSize', 'faceHandlesEnabled', 'edgeHandlesEnabled', 'cornerHandlesEnabled']); // Object methods
|
|
562
|
-
|
|
563
|
-
vtkImageCroppingRegionsWidget(publicAPI, model);
|
|
564
|
-
} // ----------------------------------------------------------------------------
|
|
565
|
-
|
|
566
|
-
var newInstance = macro.newInstance(extend, 'vtkImageCroppingRegionsWidget'); // ----------------------------------------------------------------------------
|
|
567
|
-
|
|
568
|
-
var vtkImageCroppingRegionsWidget$1 = {
|
|
569
|
-
newInstance: newInstance,
|
|
570
|
-
extend: extend
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
export { vtkImageCroppingRegionsWidget$1 as default, extend, newInstance };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var TextAlign = {
|
|
2
|
-
LEFT: 'LEFT',
|
|
3
|
-
RIGHT: 'RIGHT',
|
|
4
|
-
CENTER: 'CENTER'
|
|
5
|
-
}; // TOP means the text grows upwards and BOTTOM downwards.
|
|
6
|
-
|
|
7
|
-
var VerticalAlign = {
|
|
8
|
-
TOP: 'TOP',
|
|
9
|
-
BOTTOM: 'BOTTOM',
|
|
10
|
-
CENTER: 'CENTER'
|
|
11
|
-
};
|
|
12
|
-
var Constants = {
|
|
13
|
-
TextAlign: TextAlign,
|
|
14
|
-
VerticalAlign: VerticalAlign
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { TextAlign, VerticalAlign, Constants as default };
|