@kitware/vtk.js 23.4.2 → 23.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/Core/Math/Constants.js +12 -0
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Common/Core/ScalarsToColors/Constants.d.ts +18 -0
- package/Common/DataModel/AbstractPointLocator.d.ts +54 -0
- package/Common/DataModel/AbstractPointLocator.js +40 -0
- package/Common/DataModel/BoundingBox.d.ts +659 -0
- package/Common/DataModel/Collection.d.ts +118 -0
- package/Common/DataModel/Collection.js +113 -0
- package/Common/DataModel/DataSet/Constants.d.ts +27 -0
- package/Common/DataModel/EdgeLocator.d.ts +79 -0
- package/Common/DataModel/EdgeLocator.js +85 -0
- package/Common/DataModel/ITKHelper.d.ts +54 -0
- package/Common/DataModel/IncrementalOctreeNode.d.ts +297 -0
- package/Common/DataModel/IncrementalOctreeNode.js +640 -0
- package/Common/DataModel/IncrementalOctreePointLocator.d.ts +61 -0
- package/Common/DataModel/IncrementalOctreePointLocator.js +398 -0
- package/Common/DataModel/Locator.d.ts +43 -0
- package/Common/DataModel/Locator.js +37 -0
- package/Common/DataModel/Plane.js +1 -1
- package/Common/DataModel/PolyData/Constants.d.ts +6 -0
- package/Common/DataModel/PolyLine.d.ts +63 -0
- package/Common/DataModel/PolyLine.js +77 -0
- package/Common/DataModel/Polygon/Constants.js +12 -0
- package/Common/DataModel/Polygon.js +1 -1
- package/Common/DataModel/Quad/Constants.js +9 -0
- package/Common/DataModel/Quad.d.ts +91 -0
- package/Common/DataModel/Quad.js +235 -0
- package/Common/DataModel/SelectionNode/Constants.d.ts +27 -0
- package/Common/DataModel/Spline1D/Constants.js +17 -0
- package/Common/DataModel/Spline3D/Constants.d.ts +9 -0
- package/Common/Transform/Transform.js +51 -0
- package/Filters/Core/PolyDataNormals.js +124 -0
- package/Filters/General/ClipClosedSurface/Constants.js +10 -0
- package/Filters/General/ClipClosedSurface.d.ts +95 -0
- package/Filters/General/ClipClosedSurface.js +972 -0
- package/Filters/General/ContourTriangulator/Constants.js +6 -0
- package/Filters/General/ContourTriangulator/helper.js +1951 -0
- package/Filters/General/ContourTriangulator.d.ts +136 -0
- package/Filters/General/ContourTriangulator.js +202 -0
- package/Filters/General/ImageMarchingCubes.js +1 -1
- package/Filters/General/MoleculeToRepresentation.js +1 -1
- package/Filters/General/OBBTree/OBBNode.js +82 -0
- package/Filters/General/OBBTree/helper.js +92 -0
- package/Filters/General/OBBTree.js +1243 -0
- package/Filters/General/TubeFilter.js +1 -1
- package/Filters/Sources/LineSource.js +1 -1
- package/Filters/Sources/PlaneSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/Interaction/Manipulators/CompositeCameraManipulator.d.ts +68 -0
- package/Interaction/Manipulators/CompositeGestureManipulator.d.ts +168 -0
- package/Interaction/Manipulators/CompositeKeyboardManipulator.d.ts +48 -0
- package/Interaction/Manipulators/CompositeMouseManipulator.d.ts +149 -0
- package/Interaction/Manipulators/CompositeVRManipulator.d.ts +44 -0
- package/Interaction/Manipulators/GestureCameraManipulator.d.ts +34 -0
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseBoxSelectorManipulator.d.ts +88 -0
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.d.ts +32 -0
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.d.ts +33 -0
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.d.ts +33 -0
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.d.ts +67 -0
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.d.ts +45 -0
- package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.d.ts +26 -0
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseRangeManipulator.d.ts +53 -0
- package/Interaction/Style/InteractorStyleImage.d.ts +107 -0
- package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
- package/Interaction/Style/InteractorStyleManipulator.d.ts +348 -0
- package/Interaction/Style/InteractorStyleTrackballCamera.d.ts +170 -0
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +1 -1
- package/Interaction/Widgets/LabelRepresentation.js +1 -1
- package/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +11 -0
- package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +1 -1
- package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +1 -1
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +1 -1
- package/Proxy/Core/AbstractRepresentationProxy.d.ts +24 -0
- package/Proxy/Core/LookupTableProxy.d.ts +45 -0
- package/Proxy/Core/PiecewiseFunctionProxy.d.ts +62 -0
- package/Proxy/Core/ProxyManager.d.ts +115 -0
- package/Proxy/Core/SourceProxy.d.ts +22 -0
- package/Proxy/Core/View2DProxy.d.ts +7 -0
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Proxy/Core/ViewProxy.d.ts +86 -0
- package/Proxy/Representations/SliceRepresentationProxy.d.ts +27 -0
- package/Proxy/Representations/VolumeRepresentationProxy.d.ts +44 -0
- package/README.md +2 -2
- package/Rendering/Core/AbstractImageMapper/helper.js +127 -0
- package/Rendering/Core/AbstractImageMapper.d.ts +82 -0
- package/Rendering/Core/AbstractImageMapper.js +44 -0
- package/Rendering/Core/Camera.js +1 -1
- package/Rendering/Core/CellPicker.js +1 -1
- package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
- package/Rendering/Core/ColorTransferFunction/Constants.d.ts +17 -0
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate/Constants.d.ts +14 -0
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/Glyph3DMapper/Constants.d.ts +17 -0
- package/Rendering/Core/Glyph3DMapper.js +1 -1
- package/Rendering/Core/HardwareSelector.d.ts +84 -0
- package/Rendering/Core/ImageArrayMapper.d.ts +253 -0
- package/Rendering/Core/ImageArrayMapper.js +242 -0
- package/Rendering/Core/ImageMapper/Constants.d.ts +14 -0
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/ImageProperty/Constants.d.ts +9 -0
- package/Rendering/Core/ImageResliceMapper/Constants.d.ts +11 -0
- package/Rendering/Core/ImageResliceMapper/Constants.js +11 -0
- package/Rendering/Core/ImageResliceMapper.d.ts +245 -0
- package/Rendering/Core/ImageResliceMapper.js +70 -0
- package/Rendering/Core/InteractorObserver.d.ts +132 -0
- package/Rendering/Core/InteractorStyle/Constants.d.ts +16 -0
- package/Rendering/Core/InteractorStyle.d.ts +229 -0
- package/Rendering/Core/Light.js +1 -1
- package/Rendering/Core/Mapper/Constants.d.ts +26 -0
- package/Rendering/Core/Mapper.js +1 -1
- package/Rendering/Core/Picker.js +1 -1
- package/Rendering/Core/Prop/Constants.d.ts +9 -0
- package/Rendering/Core/Prop/Constants.js +9 -0
- package/Rendering/Core/Property/Constants.d.ts +24 -0
- package/Rendering/Core/Property2D/Constants.d.ts +9 -0
- package/Rendering/Core/RenderWindow.js +1 -1
- package/Rendering/Core/RenderWindowInteractor/Constants.d.ts +31 -0
- package/Rendering/Core/Renderer.js +1 -1
- package/Rendering/Core/VolumeMapper/Constants.d.ts +20 -0
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/Core/VolumeProperty/Constants.d.ts +16 -0
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +129 -0
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +131 -0
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +80 -0
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +763 -0
- package/Rendering/OpenGL/HardwareSelector/Constants.d.ts +8 -0
- package/Rendering/OpenGL/HardwareSelector.d.ts +339 -0
- package/Rendering/OpenGL/ImageResliceMapper.js +996 -0
- package/Rendering/OpenGL/PolyDataMapper.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/RenderWindow/Constants.d.ts +10 -0
- package/Rendering/OpenGL/RenderWindow/Constants.js +13 -0
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +70 -0
- package/Rendering/OpenGL/RenderWindow.d.ts +9 -2
- package/Rendering/OpenGL/RenderWindow.js +2 -1
- package/Rendering/OpenGL/glsl/vtkImageResliceMapperFS.glsl.js +3 -0
- package/Rendering/OpenGL/glsl/vtkImageResliceMapperVS.glsl.js +3 -0
- package/Rendering/WebGPU/Actor2D.js +151 -0
- package/Rendering/WebGPU/BufferManager.js +1 -1
- package/Rendering/WebGPU/CellArrayMapper.js +853 -0
- package/Rendering/WebGPU/IndexBuffer.js +397 -0
- package/Rendering/WebGPU/PolyDataMapper2D.js +99 -0
- package/Rendering/WebGPU/RenderWindow.js +3 -1
- package/Rendering/WebGPU/SimpleMapper.js +290 -0
- package/Widgets/Core/AbstractWidget.d.ts +187 -0
- package/Widgets/Core/AbstractWidgetFactory.d.ts +131 -0
- package/Widgets/Core/StateBuilder/color3Mixin.js +24 -0
- package/Widgets/Core/StateBuilder/orientationMixin.js +1 -1
- package/Widgets/Core/StateBuilder.d.ts +29 -0
- package/Widgets/Core/WidgetManager/Constants.d.ts +27 -0
- package/Widgets/Core/WidgetManager.d.ts +231 -0
- package/Widgets/Core/WidgetState.d.ts +81 -0
- package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
- package/Widgets/Manipulators/AbstractManipulator.js +57 -0
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Manipulators/TrackballManipulator.js +1 -1
- package/Widgets/Representations/GlyphRepresentation.js +325 -0
- package/Widgets/Representations/LineHandleRepresentation.js +116 -0
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
- package/Widgets/Representations/WidgetRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget.js +1 -1
- package/Widgets/Widgets3D/InteractiveOrientationWidget.d.ts +40 -0
- package/Widgets/Widgets3D/LabelWidget/behavior.js +157 -0
- package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
- package/Widgets/Widgets3D/LabelWidget.js +78 -0
- package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -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/index.d.ts +133 -74
- package/package.json +1 -1
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import macro from '../../macros.js';
|
|
3
|
+
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
4
|
+
import vtkGlyph3DMapper from '../../Rendering/Core/Glyph3DMapper.js';
|
|
5
|
+
import vtkHandleRepresentation from './HandleRepresentation.js';
|
|
6
|
+
import vtkContextRepresentation from './ContextRepresentation.js';
|
|
7
|
+
import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
|
|
8
|
+
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
9
|
+
import { ScalarMode } from '../../Rendering/Core/Mapper/Constants.js';
|
|
10
|
+
import { getPixelWorldHeightAtCoord } from '../Core/WidgetManager.js';
|
|
11
|
+
import vtkWidgetRepresentation, { allocateArray } from './WidgetRepresentation.js';
|
|
12
|
+
import { Behavior } from './WidgetRepresentation/Constants.js';
|
|
13
|
+
import { OrientationModes } from '../../Rendering/Core/Glyph3DMapper/Constants.js';
|
|
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; }
|
|
18
|
+
// vtkGlyphRepresentation methods
|
|
19
|
+
// ----------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
function origin(publicAPI, model) {
|
|
22
|
+
return function (polyData, states) {
|
|
23
|
+
var points = allocateArray(polyData, 'points', states.length).getData();
|
|
24
|
+
var j = 0;
|
|
25
|
+
|
|
26
|
+
for (var i = 0; i < states.length; ++i) {
|
|
27
|
+
var coord = states[i].getOrigin(model.scaleInPixels && model.displayScaleParams);
|
|
28
|
+
points[j++] = coord[0];
|
|
29
|
+
points[j++] = coord[1];
|
|
30
|
+
points[j++] = coord[2];
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function noPosition(publicAPI, model) {
|
|
35
|
+
return function (polyData, states) {
|
|
36
|
+
allocateArray(polyData, 'points', 0);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function color3(publicAPI, model) {
|
|
40
|
+
return function (polyData, states) {
|
|
41
|
+
model._pipeline.mapper.setColorByArrayName('color');
|
|
42
|
+
|
|
43
|
+
var colorArray = allocateArray(polyData, 'color', states.length, 'Uint8Array', // RGBA
|
|
44
|
+
4);
|
|
45
|
+
var colors = colorArray.getData();
|
|
46
|
+
var j = 0;
|
|
47
|
+
|
|
48
|
+
for (var i = 0; i < states.length; ++i) {
|
|
49
|
+
var c3 = states[i].getColor3();
|
|
50
|
+
|
|
51
|
+
if (states[i].getActive() && model.useActiveColor) {
|
|
52
|
+
c3 = model.activeColor;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
colors[j++] = c3[0];
|
|
56
|
+
colors[j++] = c3[1];
|
|
57
|
+
colors[j++] = c3[2];
|
|
58
|
+
colors[j++] = states[i].getOpacity();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
colorArray.dataChange();
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function color(publicAPI, model) {
|
|
65
|
+
return function (polyData, states) {
|
|
66
|
+
model._pipeline.mapper.setColorByArrayName('color');
|
|
67
|
+
|
|
68
|
+
var colors = allocateArray(polyData, 'color', states.length).getData();
|
|
69
|
+
|
|
70
|
+
for (var i = 0; i < states.length; ++i) {
|
|
71
|
+
var c = states[i].getColor();
|
|
72
|
+
|
|
73
|
+
if (states[i].getActive() && model.useActiveColor) {
|
|
74
|
+
c = model.activeColor;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
colors[i] = c;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function noColor(publicAPI, model) {
|
|
82
|
+
return function (polyData, states) {
|
|
83
|
+
model._pipeline.mapper.setColorByArrayName(null);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function scale3(publicAPI, model) {
|
|
87
|
+
return function (polyData, states) {
|
|
88
|
+
model._pipeline.mapper.setScaleArray('scale');
|
|
89
|
+
|
|
90
|
+
model._pipeline.mapper.setScaleFactor(1);
|
|
91
|
+
|
|
92
|
+
model._pipeline.mapper.setScaling(true);
|
|
93
|
+
|
|
94
|
+
model._pipeline.mapper.setScaleMode(vtkGlyph3DMapper.ScaleModes.SCALE_BY_COMPONENTS);
|
|
95
|
+
|
|
96
|
+
var scales = allocateArray(polyData, 'scale', states.length, 'Float32Array', 3).getData();
|
|
97
|
+
var j = 0;
|
|
98
|
+
|
|
99
|
+
for (var i = 0; i < states.length; ++i) {
|
|
100
|
+
var _state$getScale, _state$getScale2;
|
|
101
|
+
|
|
102
|
+
var state = states[i];
|
|
103
|
+
var scaleFactor = state.getActive() ? model.activeScaleFactor : 1;
|
|
104
|
+
|
|
105
|
+
if (publicAPI.getScaleInPixels()) {
|
|
106
|
+
scaleFactor *= getPixelWorldHeightAtCoord(state.getOrigin(), model.displayScaleParams);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
var scale = (_state$getScale = (_state$getScale2 = state.getScale3) === null || _state$getScale2 === void 0 ? void 0 : _state$getScale2.call(state)) !== null && _state$getScale !== void 0 ? _state$getScale : model.defaultScale;
|
|
110
|
+
scales[j++] = scaleFactor * scale[0];
|
|
111
|
+
scales[j++] = scaleFactor * scale[1];
|
|
112
|
+
scales[j++] = scaleFactor * scale[2];
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function scale1(publicAPI, model) {
|
|
117
|
+
return function (polyData, states) {
|
|
118
|
+
model._pipeline.mapper.setScaleArray('scale');
|
|
119
|
+
|
|
120
|
+
model._pipeline.mapper.setScaleFactor(1);
|
|
121
|
+
|
|
122
|
+
model._pipeline.mapper.setScaling(true);
|
|
123
|
+
|
|
124
|
+
var scales = allocateArray(polyData, 'scale', states.length).getData();
|
|
125
|
+
|
|
126
|
+
for (var i = 0; i < states.length; ++i) {
|
|
127
|
+
var _state$getScale3, _state$getScale4;
|
|
128
|
+
|
|
129
|
+
var state = states[i];
|
|
130
|
+
var scaleFactor = state.getActive() ? model.activeScaleFactor : 1;
|
|
131
|
+
|
|
132
|
+
if (publicAPI.getScaleInPixels()) {
|
|
133
|
+
scaleFactor *= getPixelWorldHeightAtCoord(state.getOrigin(), model.displayScaleParams);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var scale = (_state$getScale3 = (_state$getScale4 = state.getScale1) === null || _state$getScale4 === void 0 ? void 0 : _state$getScale4.call(state)) !== null && _state$getScale3 !== void 0 ? _state$getScale3 : model.defaultScale;
|
|
137
|
+
scales[i] = scaleFactor * scale;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function noScale(publicAPI, model) {
|
|
142
|
+
return function (polyData, states) {
|
|
143
|
+
model._pipeline.mapper.setScaleArray(null);
|
|
144
|
+
|
|
145
|
+
model._pipeline.mapper.setScaleFactor(model.defaultScale);
|
|
146
|
+
|
|
147
|
+
model._pipeline.mapper.setScaling(model.defaultScale !== 1);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function direction(publicAPI, model) {
|
|
151
|
+
return function (polyData, states) {
|
|
152
|
+
model._pipeline.mapper.setOrientationArray('orientation');
|
|
153
|
+
|
|
154
|
+
model._pipeline.mapper.setOrientationMode(OrientationModes.MATRIX);
|
|
155
|
+
|
|
156
|
+
var orientation = allocateArray(polyData, 'orientation', states.length, 'Float32Array', 9).getData();
|
|
157
|
+
|
|
158
|
+
for (var i = 0; i < states.length; ++i) {
|
|
159
|
+
var state = states[i];
|
|
160
|
+
var right = state.getRight ? state.getRight() : [1, 0, 0];
|
|
161
|
+
var up = state.getUp ? state.getUp() : [0, 1, 0];
|
|
162
|
+
var dir = state.getDirection ? state.getDirection() : [0, 0, 1];
|
|
163
|
+
orientation.set(right, 9 * i);
|
|
164
|
+
orientation.set(up, 9 * i + 3);
|
|
165
|
+
orientation.set(dir, 9 * i + 6);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function noOrientation(publicAPI, model) {
|
|
170
|
+
return function (polyData, states) {
|
|
171
|
+
model._pipeline.mapper.setOrientationArray(null);
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function vtkGlyphRepresentation(publicAPI, model) {
|
|
176
|
+
// Set our className
|
|
177
|
+
model.classHierarchy.push('vtkGlyphRepresentation');
|
|
178
|
+
|
|
179
|
+
var superClass = _objectSpread({}, publicAPI);
|
|
180
|
+
|
|
181
|
+
var internalPolyData = vtkPolyData.newInstance({
|
|
182
|
+
mtime: 0
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
function hasMixin(states) {
|
|
186
|
+
for (var _len = arguments.length, requiredMixins = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
187
|
+
requiredMixins[_key - 1] = arguments[_key];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return requiredMixins.every(function (requiredMixin) {
|
|
191
|
+
var _states$, _states$$;
|
|
192
|
+
|
|
193
|
+
return ((_states$ = states[0]) === null || _states$ === void 0 ? void 0 : (_states$$ = _states$["get".concat(macro.capitalize(requiredMixin))]) === null || _states$$ === void 0 ? void 0 : _states$$.call(_states$)) != null;
|
|
194
|
+
});
|
|
195
|
+
} // --------------------------------------------------------------------------
|
|
196
|
+
// Generic rendering pipeline
|
|
197
|
+
// --------------------------------------------------------------------------
|
|
198
|
+
// --------------------------------------------------------------------------
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
publicAPI.getRepresentationStates = function () {
|
|
202
|
+
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
|
|
203
|
+
return superClass.getRepresentationStates(input).filter(function (state) {
|
|
204
|
+
var _state$getOrigin, _state$isVisible, _state$isVisible2;
|
|
205
|
+
|
|
206
|
+
return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = (_state$isVisible2 = state.isVisible) === null || _state$isVisible2 === void 0 ? void 0 : _state$isVisible2.call(state)) !== null && _state$isVisible !== void 0 ? _state$isVisible : true);
|
|
207
|
+
});
|
|
208
|
+
}; // --------------------------------------------------------------------------
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
publicAPI.getMixins = function (states) {
|
|
212
|
+
var glyphProperties = {};
|
|
213
|
+
|
|
214
|
+
if (hasMixin(states, 'origin')) {
|
|
215
|
+
glyphProperties.position = model.applyMixin.origin;
|
|
216
|
+
} else {
|
|
217
|
+
glyphProperties.position = model.applyMixin.noPosition;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (hasMixin(states, 'color3')) {
|
|
221
|
+
glyphProperties.color = model.applyMixin.color3;
|
|
222
|
+
} else if (hasMixin(states, 'color')) {
|
|
223
|
+
glyphProperties.color = model.applyMixin.color;
|
|
224
|
+
} else {
|
|
225
|
+
glyphProperties.color = model.applyMixin.noColor;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (hasMixin(states, 'scale3')) {
|
|
229
|
+
glyphProperties.scale = model.applyMixin.scale3;
|
|
230
|
+
} else if (hasMixin(states, 'scale1')) {
|
|
231
|
+
glyphProperties.scale = model.applyMixin.scale1;
|
|
232
|
+
} else {
|
|
233
|
+
glyphProperties.scale = model.applyMixin.noScale;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (hasMixin(states, 'direction')) {
|
|
237
|
+
glyphProperties.orientation = model.applyMixin.direction;
|
|
238
|
+
} else {
|
|
239
|
+
glyphProperties.orientation = model.applyMixin.noOrientation;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return glyphProperties;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
publicAPI.requestData = function (inData, outData) {
|
|
246
|
+
var states = publicAPI.getRepresentationStates(inData[0]);
|
|
247
|
+
outData[0] = internalPolyData;
|
|
248
|
+
var glyphProperties = publicAPI.getMixins(states);
|
|
249
|
+
Object.values(glyphProperties).forEach(function (property) {
|
|
250
|
+
return property(internalPolyData, states);
|
|
251
|
+
});
|
|
252
|
+
internalPolyData.getPoints().modified();
|
|
253
|
+
internalPolyData.modified();
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
vtkWidgetRepresentation.connectPipeline(model._pipeline);
|
|
257
|
+
publicAPI.addActor(model._pipeline.actor);
|
|
258
|
+
} // ----------------------------------------------------------------------------
|
|
259
|
+
// Object factory
|
|
260
|
+
// ----------------------------------------------------------------------------
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
function defaultValues(publicAPI, model, initialValues) {
|
|
264
|
+
var _initialValues$_pipel, _initialValues$_pipel2, _initialValues$_pipel3, _initialValues$_pipel4, _initialValues$_pipel5, _initialValues$_pipel6, _initialValues$_pipel7, _initialValues$_pipel8, _initialValues$applyM, _initialValues$applyM2, _initialValues$applyM3, _initialValues$applyM4, _initialValues$applyM5, _initialValues$applyM6, _initialValues$applyM7, _initialValues$applyM8, _initialValues$applyM9, _initialValues$applyM10, _initialValues$applyM11, _initialValues$applyM12, _initialValues$applyM13, _initialValues$applyM14, _initialValues$applyM15, _initialValues$applyM16, _initialValues$applyM17, _initialValues$applyM18, _initialValues$applyM19, _initialValues$applyM20;
|
|
265
|
+
|
|
266
|
+
return _objectSpread(_objectSpread({
|
|
267
|
+
defaultScale: 1
|
|
268
|
+
}, initialValues), {}, {
|
|
269
|
+
_pipeline: _objectSpread({
|
|
270
|
+
source: (_initialValues$_pipel = (_initialValues$_pipel2 = initialValues._pipeline) === null || _initialValues$_pipel2 === void 0 ? void 0 : _initialValues$_pipel2.source) !== null && _initialValues$_pipel !== void 0 ? _initialValues$_pipel : publicAPI,
|
|
271
|
+
glyph: (_initialValues$_pipel3 = (_initialValues$_pipel4 = initialValues._pipeline) === null || _initialValues$_pipel4 === void 0 ? void 0 : _initialValues$_pipel4.glyph) !== null && _initialValues$_pipel3 !== void 0 ? _initialValues$_pipel3 : // in case glyph was provided
|
|
272
|
+
vtkSphereSource.newInstance({
|
|
273
|
+
phiResolution: 8,
|
|
274
|
+
thetaResolution: 8
|
|
275
|
+
}),
|
|
276
|
+
mapper: (_initialValues$_pipel5 = (_initialValues$_pipel6 = initialValues._pipeline) === null || _initialValues$_pipel6 === void 0 ? void 0 : _initialValues$_pipel6.mapper) !== null && _initialValues$_pipel5 !== void 0 ? _initialValues$_pipel5 : // in case mapper was provided
|
|
277
|
+
vtkGlyph3DMapper.newInstance({
|
|
278
|
+
scalarMode: ScalarMode.USE_POINT_FIELD_DATA
|
|
279
|
+
}),
|
|
280
|
+
actor: (_initialValues$_pipel7 = (_initialValues$_pipel8 = initialValues._pipeline) === null || _initialValues$_pipel8 === void 0 ? void 0 : _initialValues$_pipel8.actor) !== null && _initialValues$_pipel7 !== void 0 ? _initialValues$_pipel7 : // in case actor was provided
|
|
281
|
+
vtkActor.newInstance({
|
|
282
|
+
parentProp: publicAPI
|
|
283
|
+
})
|
|
284
|
+
}, initialValues._pipeline),
|
|
285
|
+
applyMixin: _objectSpread({
|
|
286
|
+
origin: (_initialValues$applyM = (_initialValues$applyM2 = initialValues.applyMixin) === null || _initialValues$applyM2 === void 0 ? void 0 : _initialValues$applyM2.origin) !== null && _initialValues$applyM !== void 0 ? _initialValues$applyM : origin(publicAPI, model),
|
|
287
|
+
noPosition: (_initialValues$applyM3 = (_initialValues$applyM4 = initialValues.applyMixin) === null || _initialValues$applyM4 === void 0 ? void 0 : _initialValues$applyM4.noPosition) !== null && _initialValues$applyM3 !== void 0 ? _initialValues$applyM3 : noPosition(),
|
|
288
|
+
color3: (_initialValues$applyM5 = (_initialValues$applyM6 = initialValues.applyMixin) === null || _initialValues$applyM6 === void 0 ? void 0 : _initialValues$applyM6.color3) !== null && _initialValues$applyM5 !== void 0 ? _initialValues$applyM5 : color3(publicAPI, model),
|
|
289
|
+
color: (_initialValues$applyM7 = (_initialValues$applyM8 = initialValues.applyMixin) === null || _initialValues$applyM8 === void 0 ? void 0 : _initialValues$applyM8.color) !== null && _initialValues$applyM7 !== void 0 ? _initialValues$applyM7 : color(publicAPI, model),
|
|
290
|
+
noColor: (_initialValues$applyM9 = (_initialValues$applyM10 = initialValues.applyMixin) === null || _initialValues$applyM10 === void 0 ? void 0 : _initialValues$applyM10.noColor) !== null && _initialValues$applyM9 !== void 0 ? _initialValues$applyM9 : noColor(publicAPI, model),
|
|
291
|
+
scale3: (_initialValues$applyM11 = (_initialValues$applyM12 = initialValues.applyMixin) === null || _initialValues$applyM12 === void 0 ? void 0 : _initialValues$applyM12.scale3) !== null && _initialValues$applyM11 !== void 0 ? _initialValues$applyM11 : scale3(publicAPI, model),
|
|
292
|
+
scale1: (_initialValues$applyM13 = (_initialValues$applyM14 = initialValues.applyMixin) === null || _initialValues$applyM14 === void 0 ? void 0 : _initialValues$applyM14.scale1) !== null && _initialValues$applyM13 !== void 0 ? _initialValues$applyM13 : scale1(publicAPI, model),
|
|
293
|
+
noScale: (_initialValues$applyM15 = (_initialValues$applyM16 = initialValues.applyMixin) === null || _initialValues$applyM16 === void 0 ? void 0 : _initialValues$applyM16.noScale) !== null && _initialValues$applyM15 !== void 0 ? _initialValues$applyM15 : noScale(publicAPI, model),
|
|
294
|
+
direction: (_initialValues$applyM17 = (_initialValues$applyM18 = initialValues.applyMixin) === null || _initialValues$applyM18 === void 0 ? void 0 : _initialValues$applyM18.direction) !== null && _initialValues$applyM17 !== void 0 ? _initialValues$applyM17 : direction(publicAPI, model),
|
|
295
|
+
noOrientation: (_initialValues$applyM19 = (_initialValues$applyM20 = initialValues.applyMixin) === null || _initialValues$applyM20 === void 0 ? void 0 : _initialValues$applyM20.noOrientation) !== null && _initialValues$applyM19 !== void 0 ? _initialValues$applyM19 : noOrientation(publicAPI, model)
|
|
296
|
+
}, initialValues.applyMixin)
|
|
297
|
+
});
|
|
298
|
+
} // ----------------------------------------------------------------------------
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
function extend(publicAPI, model) {
|
|
302
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
303
|
+
|
|
304
|
+
if (initialValues.behavior === Behavior.CONTEXT) {
|
|
305
|
+
vtkContextRepresentation.extend(publicAPI, model, defaultValues(publicAPI, model, initialValues));
|
|
306
|
+
} else {
|
|
307
|
+
vtkHandleRepresentation.extend(publicAPI, model, defaultValues(publicAPI, model, initialValues));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
macro.setGet(publicAPI, model._pipeline, ['defaultScale']);
|
|
311
|
+
macro.get(publicAPI, model._pipeline, ['glyph', 'mapper', 'actor']); // Expose the mixin functions to allow overwriting
|
|
312
|
+
|
|
313
|
+
macro.setGet(publicAPI, model.applyMixin, Object.keys(model.applyMixin)); // Object specific methods
|
|
314
|
+
|
|
315
|
+
vtkGlyphRepresentation(publicAPI, model);
|
|
316
|
+
} // ----------------------------------------------------------------------------
|
|
317
|
+
|
|
318
|
+
var newInstance = macro.newInstance(extend, 'vtkGlyphRepresentation'); // ----------------------------------------------------------------------------
|
|
319
|
+
|
|
320
|
+
var vtkGlyphRepresentation$1 = {
|
|
321
|
+
newInstance: newInstance,
|
|
322
|
+
extend: extend
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
export { color, color3, vtkGlyphRepresentation$1 as default, direction, extend, newInstance, noColor, noOrientation, noPosition, noScale, origin, scale1, scale3 };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import macro from '../../macros.js';
|
|
3
|
+
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
4
|
+
import vtkGlyphRepresentation from './GlyphRepresentation.js';
|
|
5
|
+
import vtkPixelSpaceCallbackMapper from '../../Rendering/Core/PixelSpaceCallbackMapper.js';
|
|
6
|
+
import vtkCylinderSource from '../../Filters/Sources/CylinderSource.js';
|
|
7
|
+
import { allocateArray } from './WidgetRepresentation.js';
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
var INFINITE_RATIO = 100000; // ----------------------------------------------------------------------------
|
|
13
|
+
// vtkLineHandleRepresentation methods
|
|
14
|
+
// ----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
function vtkLineHandleRepresentation(publicAPI, model) {
|
|
17
|
+
// Set our className
|
|
18
|
+
model.classHierarchy.push('vtkLineHandleRepresentation'); // --------------------------------------------------------------------------
|
|
19
|
+
// Generic rendering pipeline
|
|
20
|
+
// --------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* displayActors and displayMappers are used to render objects in HTML, allowing objects
|
|
24
|
+
* to be 'rendered' internally in a VTK scene without being visible on the final output
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
model.displayMapper = vtkPixelSpaceCallbackMapper.newInstance();
|
|
28
|
+
model.displayActor = vtkActor.newInstance({
|
|
29
|
+
parentProp: publicAPI
|
|
30
|
+
}); // model.displayActor.getProperty().setOpacity(0); // don't show in 3D
|
|
31
|
+
|
|
32
|
+
model.displayActor.setMapper(model.displayMapper);
|
|
33
|
+
model.displayMapper.setInputConnection(publicAPI.getOutputPort());
|
|
34
|
+
publicAPI.addActor(model.displayActor);
|
|
35
|
+
model.alwaysVisibleActors = [model.displayActor]; // --------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
publicAPI.setGlyphResolution = macro.chain(publicAPI.setGlyphResolution, model._pipeline.glyph.setThetaResolution, model._pipeline.glyph.setPhiResolution); // --------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
function callbackProxy(coords) {
|
|
40
|
+
if (model.displayCallback) {
|
|
41
|
+
var filteredList = [];
|
|
42
|
+
var states = publicAPI.getRepresentationStates();
|
|
43
|
+
|
|
44
|
+
for (var i = 0; i < states.length; i++) {
|
|
45
|
+
if (states[i].getActive()) {
|
|
46
|
+
filteredList.push(coords[i]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (filteredList.length) {
|
|
51
|
+
model.displayCallback(filteredList);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
model.displayCallback();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
publicAPI.setDisplayCallback = function (callback) {
|
|
60
|
+
model.displayCallback = callback;
|
|
61
|
+
model.displayMapper.setCallback(callback ? callbackProxy : null);
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Overwrite scale3 to optionally make lines infinite
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
var superScale3 = publicAPI.getScale3();
|
|
69
|
+
publicAPI.setScale3(function (polyData, states) {
|
|
70
|
+
superScale3(polyData, states);
|
|
71
|
+
|
|
72
|
+
if (model.infiniteLine) {
|
|
73
|
+
var scales = allocateArray(polyData, 'scale', states.length, 'Float32Array', 3).getData();
|
|
74
|
+
|
|
75
|
+
for (var i = 0; i < states.length; ++i) {
|
|
76
|
+
scales[3 * i + 2] = INFINITE_RATIO;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
} // ----------------------------------------------------------------------------
|
|
81
|
+
// Object factory
|
|
82
|
+
// ----------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
function defaultValues(initialValues) {
|
|
86
|
+
var _initialValues$glyphR;
|
|
87
|
+
|
|
88
|
+
return _objectSpread({
|
|
89
|
+
infiniteLine: true,
|
|
90
|
+
glyphResolution: 4,
|
|
91
|
+
_pipeline: {
|
|
92
|
+
glyph: vtkCylinderSource.newInstance({
|
|
93
|
+
resolution: (_initialValues$glyphR = initialValues.glyphResolution) !== null && _initialValues$glyphR !== void 0 ? _initialValues$glyphR : 4,
|
|
94
|
+
direction: [0, 0, 1]
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
}, initialValues);
|
|
98
|
+
} // ----------------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
function extend(publicAPI, model) {
|
|
102
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
103
|
+
vtkGlyphRepresentation.extend(publicAPI, model, defaultValues(initialValues));
|
|
104
|
+
macro.setGet(publicAPI, model, ['infiniteLine', 'glyphResolution']); // Object specific methods
|
|
105
|
+
|
|
106
|
+
vtkLineHandleRepresentation(publicAPI, model);
|
|
107
|
+
} // ----------------------------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
var newInstance = macro.newInstance(extend, 'vtkLineHandleRepresentation'); // ----------------------------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
var vtkLineHandleRepresentation$1 = {
|
|
112
|
+
newInstance: newInstance,
|
|
113
|
+
extend: extend
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { vtkLineHandleRepresentation$1 as default, extend, newInstance };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
3
|
import macro from '../../macros.js';
|
|
4
|
-
import {
|
|
4
|
+
import { j as subtract, Q as multiplyAccumulate, g as normalize, k as cross } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
6
6
|
import vtkCylinderSource from '../../Filters/Sources/CylinderSource.js';
|
|
7
7
|
import vtkMapper from '../../Rendering/Core/Mapper.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkProp from '../../Rendering/Core/Prop.js';
|
|
4
|
-
import {
|
|
4
|
+
import { j as subtract, d as dot } from '../../Common/Core/Math/index.js';
|
|
5
5
|
import { Behavior } from './WidgetRepresentation/Constants.js';
|
|
6
6
|
import { RenderingTypes } from '../Core/WidgetManager/Constants.js';
|
|
7
7
|
import { CATEGORIES } from '../../Rendering/Core/Mapper/CoincidentTopologyHelper.js';
|
|
@@ -3,7 +3,7 @@ import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
|
3
3
|
import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
|
|
4
4
|
import vtkPolyLineRepresentation from '../Representations/PolyLineRepresentation.js';
|
|
5
5
|
import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
|
|
6
|
-
import {
|
|
6
|
+
import { j as subtract, R as angleBetweenVectors } from '../../Common/Core/Math/index.js';
|
|
7
7
|
import widgetBehavior from './AngleWidget/behavior.js';
|
|
8
8
|
import generateState from './AngleWidget/state.js';
|
|
9
9
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import vtkAbstractWidgetFactory from './../Core/AbstractWidgetFactory';
|
|
2
|
+
import { Bounds } from './../../types';
|
|
3
|
+
import { ViewTypes } from './../Core/WidgetManager/Constants';
|
|
4
|
+
|
|
5
|
+
export interface vtkInteractiveOrientationWidget extends vtkAbstractWidgetFactory {
|
|
6
|
+
/**
|
|
7
|
+
* Set the widget bounds
|
|
8
|
+
*
|
|
9
|
+
* @param {Bounds} bounds The widget bounds
|
|
10
|
+
*/
|
|
11
|
+
setBounds(bounds: Bounds): void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {ViewTypes} viewType
|
|
15
|
+
*/
|
|
16
|
+
getRepresentationForViewType(viewType: ViewTypes): unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Method use to decorate a given object (publicAPI+model) with vtkInteractiveOrientationWidget characteristics.
|
|
21
|
+
*
|
|
22
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
23
|
+
* @param model object on which data structure will be bounds (protected)
|
|
24
|
+
* @param {object} [initialValues] (default: {})
|
|
25
|
+
*/
|
|
26
|
+
export function extend(publicAPI: object, model: object, initialValues? : Record<string, unknown>): void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new instance of vtkInteractiveOrientationWidget
|
|
30
|
+
*
|
|
31
|
+
* @param {object} [initialValues] for pre-setting some of its content
|
|
32
|
+
*/
|
|
33
|
+
export function newInstance(initialValues? : Record<string, unknown>): vtkInteractiveOrientationWidget;
|
|
34
|
+
|
|
35
|
+
export declare const vtkInteractiveOrientationWidget: {
|
|
36
|
+
newInstance: typeof newInstance,
|
|
37
|
+
extend: typeof extend,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default vtkInteractiveOrientationWidget;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import macro from '../../../macros.js';
|
|
2
|
+
|
|
3
|
+
function widgetBehavior(publicAPI, model) {
|
|
4
|
+
model.classHierarchy.push('vtkLabelWidgetProp');
|
|
5
|
+
model._isDragging = false; // --------------------------------------------------------------------------
|
|
6
|
+
// Public methods
|
|
7
|
+
// --------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
publicAPI.setText = function (text) {
|
|
10
|
+
model.widgetState.getText().setText(text);
|
|
11
|
+
|
|
12
|
+
model._interactor.render();
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
publicAPI.getText = function () {
|
|
16
|
+
return model.widgetState.getText().getText();
|
|
17
|
+
}; // --------------------------------------------------------------------------
|
|
18
|
+
// Display 2D
|
|
19
|
+
// --------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
publicAPI.setDisplayCallback = function (callback) {
|
|
23
|
+
return model.representations[0].setDisplayCallback(callback);
|
|
24
|
+
}; // --------------------------------------------------------------------------
|
|
25
|
+
// Interactor events
|
|
26
|
+
// --------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
function ignoreKey(e) {
|
|
30
|
+
return e.altKey || e.controlKey || e.shiftKey;
|
|
31
|
+
} // --------------------------------------------------------------------------
|
|
32
|
+
// Left press: Select handle to drag / Place text handle
|
|
33
|
+
// --------------------------------------------------------------------------
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
publicAPI.handleLeftButtonPress = function (e) {
|
|
37
|
+
var _model$activeState$ge, _model$activeState, _model$activeState$ge2;
|
|
38
|
+
|
|
39
|
+
if (!model.activeState || !model.activeState.getActive() || !model.pickable || ignoreKey(e)) {
|
|
40
|
+
return macro.VOID;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
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;
|
|
44
|
+
|
|
45
|
+
if (model.activeState === model.widgetState.getMoveHandle() && manipulator) {
|
|
46
|
+
var worldCoords = manipulator.handleEvent(e, model._apiSpecificRenderWindow); // Commit handle to location
|
|
47
|
+
|
|
48
|
+
var moveHandle = model.widgetState.getMoveHandle();
|
|
49
|
+
moveHandle.setOrigin(worldCoords);
|
|
50
|
+
model.widgetState.getText().setOrigin(moveHandle.getOrigin());
|
|
51
|
+
publicAPI.loseFocus();
|
|
52
|
+
} else if (model.dragable) {
|
|
53
|
+
model._isDragging = true;
|
|
54
|
+
|
|
55
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
56
|
+
|
|
57
|
+
model._interactor.requestAnimation(publicAPI);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
publicAPI.invokeStartInteractionEvent();
|
|
61
|
+
return macro.EVENT_ABORT;
|
|
62
|
+
}; // --------------------------------------------------------------------------
|
|
63
|
+
// Left release: Finish drag
|
|
64
|
+
// --------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
publicAPI.handleLeftButtonRelease = function () {
|
|
68
|
+
if (!model.activeState || !model.activeState.getActive() || !model.pickable) {
|
|
69
|
+
return macro.VOID;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (model._isDragging) {
|
|
73
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
74
|
+
|
|
75
|
+
model.widgetState.deactivate();
|
|
76
|
+
|
|
77
|
+
model._interactor.cancelAnimation(publicAPI);
|
|
78
|
+
|
|
79
|
+
model._isDragging = false;
|
|
80
|
+
} else if (model.activeState !== model.widgetState.getMoveHandle()) {
|
|
81
|
+
model.widgetState.deactivate();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
85
|
+
model._widgetManager.enablePicking();
|
|
86
|
+
|
|
87
|
+
model._interactor.render();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
publicAPI.invokeEndInteractionEvent();
|
|
91
|
+
return macro.EVENT_ABORT;
|
|
92
|
+
}; // --------------------------------------------------------------------------
|
|
93
|
+
// Mouse move: Drag selected handle / Handle follow the mouse
|
|
94
|
+
// --------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
publicAPI.handleMouseMove = function (callData) {
|
|
98
|
+
var _model$activeState$ge3, _model$activeState2, _model$activeState2$g;
|
|
99
|
+
|
|
100
|
+
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;
|
|
101
|
+
|
|
102
|
+
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
103
|
+
var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
104
|
+
|
|
105
|
+
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging)) {
|
|
106
|
+
model.activeState.setOrigin(worldCoords);
|
|
107
|
+
model.widgetState.getText().setOrigin(model.activeState.getOrigin());
|
|
108
|
+
publicAPI.invokeInteractionEvent();
|
|
109
|
+
return macro.EVENT_ABORT;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return macro.VOID;
|
|
114
|
+
}; // --------------------------------------------------------------------------
|
|
115
|
+
// Focus API
|
|
116
|
+
// --------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
publicAPI.reset = function () {
|
|
120
|
+
model.widgetState.getMoveHandle().setOrigin(null);
|
|
121
|
+
model.widgetState.getText().setOrigin(null);
|
|
122
|
+
model.widgetState.getText().setText('');
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
publicAPI.grabFocus = function () {
|
|
126
|
+
if (!model.hasFocus) {
|
|
127
|
+
publicAPI.reset();
|
|
128
|
+
model.activeState = model.widgetState.getMoveHandle();
|
|
129
|
+
model.widgetState.getMoveHandle().activate();
|
|
130
|
+
|
|
131
|
+
model._interactor.requestAnimation(publicAPI);
|
|
132
|
+
|
|
133
|
+
publicAPI.invokeStartInteractionEvent();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
model.hasFocus = true;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
publicAPI.loseFocus = function () {
|
|
140
|
+
if (model.hasFocus) {
|
|
141
|
+
model._interactor.cancelAnimation(publicAPI);
|
|
142
|
+
|
|
143
|
+
publicAPI.invokeEndInteractionEvent();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
model.widgetState.deactivate();
|
|
147
|
+
model.widgetState.getMoveHandle().deactivate();
|
|
148
|
+
model.activeState = null;
|
|
149
|
+
model.hasFocus = false;
|
|
150
|
+
|
|
151
|
+
model._widgetManager.enablePicking();
|
|
152
|
+
|
|
153
|
+
model._interactor.render();
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export { widgetBehavior as default };
|