@kitware/vtk.js 24.18.6 → 24.18.9

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.
Files changed (30) hide show
  1. package/Common/DataModel/DataSet/Constants.d.ts +27 -0
  2. package/Common/DataModel/DataSet.d.ts +6 -31
  3. package/Interaction/Widgets/OrientationMarkerWidget.d.ts +1 -1
  4. package/Rendering/Core/CellPicker.js +9 -2
  5. package/Rendering/Core/InteractorObserver.d.ts +132 -0
  6. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +80 -0
  7. package/Rendering/Misc/SynchronizableRenderWindow/{vtkObjectManager.js → ObjectManager.js} +0 -0
  8. package/Rendering/Misc/SynchronizableRenderWindow.js +1 -1
  9. package/Rendering/OpenGL/ImageMapper.js +4 -0
  10. package/Widgets/Core/AbstractWidget.d.ts +187 -0
  11. package/Widgets/Core/AbstractWidgetFactory.d.ts +126 -0
  12. package/Widgets/Core/WidgetManager/Constants.d.ts +27 -0
  13. package/Widgets/Core/WidgetManager.d.ts +216 -0
  14. package/Widgets/Core/WidgetState.d.ts +81 -0
  15. package/Widgets/Widgets3D/AngleWidget/behavior.js +18 -14
  16. package/Widgets/Widgets3D/DistanceWidget/behavior.js +18 -14
  17. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +16 -6
  18. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +17 -7
  19. package/Widgets/Widgets3D/InteractiveOrientationWidget.d.ts +40 -0
  20. package/Widgets/Widgets3D/LabelWidget/behavior.js +12 -9
  21. package/Widgets/Widgets3D/LineWidget/behavior.js +23 -18
  22. package/Widgets/Widgets3D/LineWidget.js +2 -4
  23. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +13 -9
  24. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +12 -14
  25. package/Widgets/Widgets3D/ShapeWidget/behavior.js +9 -10
  26. package/Widgets/Widgets3D/SphereWidget/behavior.js +7 -7
  27. package/Widgets/Widgets3D/SplineWidget/behavior.js +11 -12
  28. package/index.d.ts +9 -0
  29. package/interfaces.d.ts +3 -0
  30. package/package.json +2 -2
@@ -0,0 +1,216 @@
1
+ import vtkAbstractWidget from './AbstractWidget';
2
+ import vtkAbstractWidgetFactory from './AbstractWidgetFactory';
3
+ import vtkCamera from './../../Rendering/Core/Camera';
4
+ import vtkProp from './../../Rendering/Core/Prop';
5
+ import vtkRenderer from './../../Rendering/Core/Renderer';
6
+ import vtkRenderWindow from './../../Rendering/Core/RenderWindow';
7
+ import vtkRenderWindowInteractor from './../../Rendering/Core/RenderWindowInteractor';
8
+ import vtkSelectionNode from './../../Common/DataModel/SelectionNode';
9
+ import vtkWidgetRepresentation from './../Representations/WidgetRepresentation';
10
+ import vtkWidgetState from './WidgetState';
11
+ import { vtkObject } from './../../interfaces';
12
+ import { CaptureOn, ViewTypes } from './WidgetManager/Constants';
13
+ import { Nullable } from './../../types';
14
+
15
+ export interface ISelectedData {
16
+ requestCount: number;
17
+ propID: number;
18
+ compositeID: number;
19
+ prop: vtkProp;
20
+ widget: vtkAbstractWidget;
21
+ representation: vtkWidgetRepresentation;
22
+ selectedState: vtkWidgetState;
23
+ }
24
+
25
+ export interface IRenderingComponents {
26
+ renderer: vtkRenderer;
27
+ renderWindow: vtkRenderWindow;
28
+ interactor: vtkRenderWindowInteractor;
29
+ apiSpecificRenderWindow: vtkRenderWindow;
30
+ camera: vtkCamera;
31
+ }
32
+
33
+ /**
34
+ * Extract the rendering components from the given renderer.
35
+ *
36
+ * @param renderer
37
+ */
38
+ export function extractRenderingComponents(renderer: vtkRenderer): IRenderingComponents;
39
+
40
+ export interface vtkWidgetManager extends vtkObject {
41
+ /**
42
+ * The the captureOn value.
43
+ * `CaptureOn.MOUSE_MOVE`: captures small region when moving mouse
44
+ * `CaptureOn.MOUSE_RELEASE`: captures entire region when mouse button is released
45
+ *
46
+ * @param {CaptureOn} captureOn
47
+ */
48
+ setCaptureOn(captureOn: CaptureOn): boolean;
49
+
50
+ /**
51
+ * Get the captureOn value.
52
+ */
53
+ getCaptureOn(): CaptureOn;
54
+
55
+ /**
56
+ * The the view type.
57
+ *
58
+ * @param {ViewTypes} type
59
+ */
60
+ setViewType(type: ViewTypes): boolean;
61
+
62
+ /**
63
+ * Get the view type.
64
+ */
65
+ getViewType(): ViewTypes;
66
+
67
+ /**
68
+ * Get the current selection.
69
+ */
70
+ getSelections(): vtkSelectionNode[];
71
+
72
+ /**
73
+ * Get all the underlying widgets.
74
+ */
75
+ getWidgets(): vtkAbstractWidget[];
76
+
77
+ /**
78
+ * Get the view id.
79
+ */
80
+ getViewId(): string;
81
+
82
+ /**
83
+ * Returns true if picking is enabled, false otherwise.
84
+ */
85
+ getPickingEnabled(): boolean;
86
+
87
+ /**
88
+ * @deprecated
89
+ */
90
+ getUseSvgLayer(): boolean;
91
+
92
+ /**
93
+ * @deprecated
94
+ */
95
+ setUseSvgLayer(use: boolean): boolean;
96
+
97
+ /**
98
+ * Enable the picking.
99
+ */
100
+ enablePicking(): void;
101
+
102
+ /**
103
+ * Renders all the widgets.
104
+ */
105
+ renderWidgets(): void;
106
+
107
+ /**
108
+ * Disable the picking.
109
+ */
110
+ disablePicking(): void;
111
+
112
+ /**
113
+ * Set the renderer.
114
+ *
115
+ * @param {vtkRenderer} renderer
116
+ */
117
+ setRenderer(renderer: vtkRenderer): void;
118
+
119
+ /**
120
+ * Register a widget on the widget manager instance.
121
+ * Please note that one should link the widget manager to a view before calling this method.
122
+ *
123
+ * @param {vtkAbstractWidgetFactory} widget The abstract widget factory.
124
+ * @param {ViewTypes} [viewType]
125
+ * @param {Object} [initialValues]
126
+ */
127
+ addWidget(
128
+ widget: vtkAbstractWidgetFactory,
129
+ viewType?: ViewTypes,
130
+ initialValues?: object
131
+ ): Nullable<vtkAbstractWidget>;
132
+
133
+ /**
134
+ * Unregister all widgets from the widget manager.
135
+ */
136
+ removeWidgets(): void;
137
+
138
+ /**
139
+ * Remove a widget from the widget manager.
140
+ *
141
+ * @param {vtkAbstractWidget | vtkAbstractWidgetFactory} widget The widget to remove
142
+ */
143
+ removeWidget(widget: vtkAbstractWidget | vtkAbstractWidgetFactory): void;
144
+
145
+ /**
146
+ * Given x and y parameter, get selected data.
147
+ *
148
+ * @param {Number} x
149
+ * @param {Number} y
150
+ */
151
+ getSelectedDataForXY(x: number, y: number): Promise<ISelectedData>;
152
+
153
+ /**
154
+ * @deprecated
155
+ */
156
+ updateSelectionFromXY(x: number, y: number): void;
157
+
158
+ /**
159
+ * @deprecated
160
+ */
161
+ updateSelectionFromMouseEvent(event: MouseEvent): void;
162
+
163
+ /**
164
+ * The all currently selected data.
165
+ */
166
+ getSelectedData(): ISelectedData | {};
167
+
168
+ /**
169
+ * Given the focus to the given widget instance.
170
+ *
171
+ * @param {vtkAbstractWidget | vtkAbstractWidgetFactory} widget The widget instance which should get the focus.
172
+ */
173
+ grabFocus(widget: vtkAbstractWidget | vtkAbstractWidgetFactory): void;
174
+
175
+ /**
176
+ * Release the focus.
177
+ */
178
+ releaseFocus(): void;
179
+ }
180
+
181
+ export interface IWidgetManagerInitialValues {
182
+ captureOn?: CaptureOn;
183
+ viewType?: ViewTypes;
184
+ pickingEnabled?: boolean;
185
+ /**
186
+ * @deprecated
187
+ */
188
+ useSvgLayer?: boolean;
189
+ }
190
+
191
+ /**
192
+ * Method used to decorate a given object (publicAPI+model) with vtkWidgetManager characteristics.
193
+ *
194
+ * @param publicAPI object on which methods will be bounds (public)
195
+ * @param model object on which data structure will be bounds (protected)
196
+ * @param initialValues (default: {})
197
+ */
198
+ export function extend(
199
+ publicAPI: object,
200
+ model: object,
201
+ initialValues?: IWidgetManagerInitialValues
202
+ ): vtkWidgetManager;
203
+
204
+ /**
205
+ * Method used to create a new instance of vtkCellArray
206
+ *
207
+ * @param initialValues for pre-setting some of its content
208
+ */
209
+ export function newInstance(initialValues?: IWidgetManagerInitialValues): vtkWidgetManager;
210
+
211
+ export declare const vtkWidgetManager: {
212
+ newInstance: typeof newInstance;
213
+ extend: typeof extend;
214
+ };
215
+
216
+ export default vtkWidgetManager;
@@ -0,0 +1,81 @@
1
+ import { vtkObject } from './../../interfaces';
2
+
3
+ export interface vtkWidgetState extends vtkObject {
4
+ /**
5
+ * Set the active flag of the widget state instance
6
+ *
7
+ * @param active The active flag
8
+ */
9
+ setActive(active: boolean): boolean;
10
+
11
+ /**
12
+ * Get the active flag of the widget state instance
13
+ */
14
+ getActive(): boolean;
15
+
16
+ /**
17
+ * Bind a state to one or more labels. If no label is provided, the default one will be used.
18
+ *
19
+ * @param {vtkWidgetState} subState The state to bound.
20
+ * @param {String | String[]} [labels] The labels to which the state should be bound.
21
+ */
22
+ bindState(subState: vtkWidgetState, labels?: string | string[]): void;
23
+
24
+ /**
25
+ * Unbind a specific state from the widget state instance
26
+ *
27
+ * @param {vtkWidgetState} subState The state to be unbound.
28
+ */
29
+ unbindState(subState: vtkWidgetState): void;
30
+
31
+ /**
32
+ * Unbind all states from the widget state instance
33
+ */
34
+ unbindAll(): void;
35
+
36
+ /**
37
+ * Activate the widget state instance. Same as calling `vtkWidgetState.setActive(true)`
38
+ */
39
+ activate(): void;
40
+
41
+ /**
42
+ * Deactivate thie widget state instance and all its sub states, except the `excludingState` argument.
43
+ *
44
+ * @param {vtkWidgetState} [excludingState] A sub-state instance that should not be deactivated.
45
+ */
46
+ deactivate(excludingState?: vtkWidgetState): void;
47
+
48
+ /**
49
+ * Activate only the passed in sub state. Every other sub states will be deactivated.
50
+ *
51
+ * @param {vtkWidgetState} subState The sub-state that should be activated.
52
+ */
53
+ activateOnly(subState: vtkWidgetState): void;
54
+
55
+ /**
56
+ * Get every states that are associated with the given label.
57
+ *
58
+ * @param {String} label The label from which to retrieve the states.
59
+ */
60
+ getStatesWithLabel(label: string): vtkWidgetState[];
61
+
62
+ /**
63
+ * Get all the nested states on the widget state instance.
64
+ */
65
+ getAllNestedStates(): vtkWidgetState[];
66
+ }
67
+
68
+ /**
69
+ * Method use to decorate a given object (publicAPI+model) with vtkWidgetState characteristics.
70
+ *
71
+ * @param publicAPI object on which methods will be bounds (public)
72
+ * @param model object on which data structure will be bounds (protected)
73
+ * @param {object} [initialValues] (default: {})
74
+ */
75
+ export function extend(publicAPI: object, model: object, initialValues?: object): vtkWidgetState;
76
+
77
+ export declare const vtkWidgetState: {
78
+ extend: typeof extend;
79
+ };
80
+
81
+ export default vtkWidgetState;
@@ -5,7 +5,7 @@ import vtkPointPicker from '../../../Rendering/Core/PointPicker.js';
5
5
  var MAX_POINTS = 3;
6
6
  function widgetBehavior(publicAPI, model) {
7
7
  model.classHierarchy.push('vtkAngleWidgetProp');
8
- var isDragging = null;
8
+ model._isDragging = false;
9
9
  var picker = vtkPointPicker.newInstance();
10
10
  picker.setPickFromList(1); // --------------------------------------------------------------------------
11
11
  // Display 2D
@@ -46,8 +46,8 @@ function widgetBehavior(publicAPI, model) {
46
46
  newHandle.setColor(moveHandle.getColor());
47
47
  newHandle.setScale1(moveHandle.getScale1());
48
48
  newHandle.setManipulator(manipulator);
49
- } else {
50
- isDragging = true;
49
+ } else if (model.dragable) {
50
+ model._isDragging = true;
51
51
 
52
52
  model._apiSpecificRenderWindow.setCursor('grabbing');
53
53
 
@@ -69,7 +69,8 @@ function widgetBehavior(publicAPI, model) {
69
69
  if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
70
70
  var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
71
71
 
72
- if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
72
+ if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging) && model.activeState.setOrigin // e.g. the line is pickable but not draggable
73
+ ) {
73
74
  model.activeState.setOrigin(worldCoords);
74
75
  publicAPI.invokeInteractionEvent();
75
76
  return macro.EVENT_ABORT;
@@ -87,32 +88,35 @@ function widgetBehavior(publicAPI, model) {
87
88
 
88
89
 
89
90
  publicAPI.handleLeftButtonRelease = function () {
90
- if (isDragging && model.pickable) {
91
+ if (!model.activeState || !model.activeState.getActive() || !model.pickable) {
92
+ return macro.VOID;
93
+ }
94
+
95
+ if (model.hasFocus && model.widgetState.getHandleList().length === MAX_POINTS) {
96
+ publicAPI.loseFocus();
97
+ return macro.VOID;
98
+ }
99
+
100
+ if (model._isDragging) {
91
101
  model._apiSpecificRenderWindow.setCursor('pointer');
92
102
 
93
103
  model.widgetState.deactivate();
94
104
 
95
105
  model._interactor.cancelAnimation(publicAPI);
96
106
 
97
- publicAPI.invokeEndInteractionEvent();
107
+ model._isDragging = false;
98
108
  } else if (model.activeState !== model.widgetState.getMoveHandle()) {
99
109
  model.widgetState.deactivate();
100
110
  }
101
111
 
102
112
  if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
103
- publicAPI.invokeEndInteractionEvent();
104
-
105
113
  model._widgetManager.enablePicking();
106
114
 
107
115
  model._interactor.render();
108
- } // Don't make any more points
109
-
110
-
111
- if (model.widgetState.getHandleList().length === MAX_POINTS) {
112
- publicAPI.loseFocus();
113
116
  }
114
117
 
115
- isDragging = false;
118
+ publicAPI.invokeEndInteractionEvent();
119
+ return macro.EVENT_ABORT;
116
120
  }; // --------------------------------------------------------------------------
117
121
  // Focus API - modeHandle follow mouse when widget has focus
118
122
  // --------------------------------------------------------------------------
@@ -4,7 +4,7 @@ import macro from '../../../macros.js';
4
4
  var MAX_POINTS = 2;
5
5
  function widgetBehavior(publicAPI, model) {
6
6
  model.classHierarchy.push('vtkDistanceWidgetProp');
7
- var isDragging = null; // --------------------------------------------------------------------------
7
+ model._isDragging = false; // --------------------------------------------------------------------------
8
8
  // Display 2D
9
9
  // --------------------------------------------------------------------------
10
10
 
@@ -41,8 +41,8 @@ function widgetBehavior(publicAPI, model) {
41
41
  newHandle.setColor(moveHandle.getColor());
42
42
  newHandle.setScale1(moveHandle.getScale1());
43
43
  newHandle.setManipulator(manipulator);
44
- } else {
45
- isDragging = true;
44
+ } else if (model.dragable) {
45
+ model._isDragging = true;
46
46
 
47
47
  model._apiSpecificRenderWindow.setCursor('grabbing');
48
48
 
@@ -59,17 +59,13 @@ function widgetBehavior(publicAPI, model) {
59
59
  publicAPI.handleMouseMove = function (callData) {
60
60
  var _model$activeState$ge3, _model$activeState2, _model$activeState2$g;
61
61
 
62
- if (model.hasFocus && model.widgetState.getHandleList().length === MAX_POINTS) {
63
- publicAPI.loseFocus();
64
- return macro.VOID;
65
- }
66
-
67
62
  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;
68
63
 
69
64
  if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
70
65
  var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
71
66
 
72
- if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
67
+ if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging) && model.activeState.setOrigin // e.g. the line is pickable but not draggable
68
+ ) {
73
69
  model.activeState.setOrigin(worldCoords);
74
70
  publicAPI.invokeInteractionEvent();
75
71
  return macro.EVENT_ABORT;
@@ -83,27 +79,35 @@ function widgetBehavior(publicAPI, model) {
83
79
 
84
80
 
85
81
  publicAPI.handleLeftButtonRelease = function () {
86
- if (isDragging && model.pickable) {
82
+ if (!model.activeState || !model.activeState.getActive() || !model.pickable) {
83
+ return macro.VOID;
84
+ }
85
+
86
+ if (model.hasFocus && model.widgetState.getHandleList().length === MAX_POINTS) {
87
+ publicAPI.loseFocus();
88
+ return macro.VOID;
89
+ }
90
+
91
+ if (model._isDragging) {
87
92
  model._apiSpecificRenderWindow.setCursor('pointer');
88
93
 
89
94
  model.widgetState.deactivate();
90
95
 
91
96
  model._interactor.cancelAnimation(publicAPI);
92
97
 
93
- publicAPI.invokeEndInteractionEvent();
98
+ model._isDragging = false;
94
99
  } else if (model.activeState !== model.widgetState.getMoveHandle()) {
95
100
  model.widgetState.deactivate();
96
101
  }
97
102
 
98
103
  if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
99
- publicAPI.invokeEndInteractionEvent();
100
-
101
104
  model._widgetManager.enablePicking();
102
105
 
103
106
  model._interactor.render();
104
107
  }
105
108
 
106
- isDragging = false;
109
+ publicAPI.invokeEndInteractionEvent();
110
+ return macro.EVENT_ABORT;
107
111
  }; // --------------------------------------------------------------------------
108
112
  // Focus API - modeHandle follow mouse when widget has focus
109
113
  // --------------------------------------------------------------------------
@@ -3,7 +3,7 @@ import macro from '../../../macros.js';
3
3
  import { handleTypeFromName, AXES, transformVec3, rotateVec3 } from './helpers.js';
4
4
 
5
5
  function widgetBehavior(publicAPI, model) {
6
- var isDragging = null;
6
+ model._isDragging = false;
7
7
 
8
8
  publicAPI.setDisplayCallback = function (callback) {
9
9
  return model.representations[0].setDisplayCallback(callback);
@@ -14,15 +14,19 @@ function widgetBehavior(publicAPI, model) {
14
14
  return macro.VOID;
15
15
  }
16
16
 
17
- isDragging = true;
17
+ if (model.dragable) {
18
+ model._isDragging = true;
18
19
 
19
- model._interactor.requestAnimation(publicAPI);
20
+ model._apiSpecificRenderWindow.setCursor('grabbing');
21
+
22
+ model._interactor.requestAnimation(publicAPI);
23
+ }
20
24
 
21
25
  return macro.EVENT_ABORT;
22
26
  };
23
27
 
24
28
  publicAPI.handleMouseMove = function (callData) {
25
- if (isDragging && model.pickable && model.dragable) {
29
+ if (model._isDragging) {
26
30
  return publicAPI.handleEvent(callData);
27
31
  }
28
32
 
@@ -30,13 +34,19 @@ function widgetBehavior(publicAPI, model) {
30
34
  };
31
35
 
32
36
  publicAPI.handleLeftButtonRelease = function () {
33
- if (isDragging && model.pickable) {
34
- isDragging = false;
37
+ if (!model.activeState || !model.activeState.getActive() || !model.pickable) {
38
+ return macro.VOID;
39
+ }
40
+
41
+ if (model._isDragging) {
42
+ model._isDragging = false;
35
43
 
36
44
  model._interactor.cancelAnimation(publicAPI);
37
45
 
38
46
  model.widgetState.deactivate();
39
47
  }
48
+
49
+ return macro.EVENT_ABORT;
40
50
  };
41
51
 
42
52
  publicAPI.handleEvent = function (callData) {
@@ -12,7 +12,7 @@ import { ViewTypes } from '../Core/WidgetManager/Constants.js';
12
12
 
13
13
  function widgetBehavior(publicAPI, model) {
14
14
  model.classHierarchy.push('vtkPlaneWidget');
15
- var isDragging = null;
15
+ model._isDragging = false;
16
16
 
17
17
  publicAPI.setDisplayCallback = function (callback) {
18
18
  return model.representations[0].setDisplayCallback(callback);
@@ -47,19 +47,24 @@ function widgetBehavior(publicAPI, model) {
47
47
  return macro.VOID;
48
48
  }
49
49
 
50
- isDragging = true;
51
50
  model.lineManipulator.setWidgetOrigin(model.widgetState.getOrigin());
52
51
  model.planeManipulator.setWidgetOrigin(model.widgetState.getOrigin());
53
52
  model.trackballManipulator.reset(callData); // setup trackball delta
54
53
 
55
- model._interactor.requestAnimation(publicAPI);
54
+ if (model.dragable) {
55
+ model._isDragging = true;
56
+
57
+ model._apiSpecificRenderWindow.setCursor('grabbing');
58
+
59
+ model._interactor.requestAnimation(publicAPI);
60
+ }
56
61
 
57
62
  publicAPI.invokeStartInteractionEvent();
58
63
  return macro.EVENT_ABORT;
59
64
  };
60
65
 
61
66
  publicAPI.handleMouseMove = function (callData) {
62
- if (isDragging && model.pickable) {
67
+ if (model._isDragging) {
63
68
  return publicAPI.handleEvent(callData);
64
69
  }
65
70
 
@@ -67,14 +72,19 @@ function widgetBehavior(publicAPI, model) {
67
72
  };
68
73
 
69
74
  publicAPI.handleLeftButtonRelease = function () {
70
- if (isDragging && model.pickable) {
71
- publicAPI.invokeEndInteractionEvent();
75
+ if (!model.activeState || !model.activeState.getActive() || !model.pickable) {
76
+ return macro.VOID;
77
+ }
72
78
 
79
+ if (model._isDragging) {
73
80
  model._interactor.cancelAnimation(publicAPI);
81
+
82
+ model._isDragging = false;
74
83
  }
75
84
 
76
- isDragging = false;
77
85
  model.widgetState.deactivate();
86
+ publicAPI.invokeEndInteractionEvent();
87
+ return macro.EVENT_ABORT;
78
88
  };
79
89
 
80
90
  publicAPI.handleEvent = function (callData) {
@@ -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;
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  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; }
7
7
  function widgetBehavior(publicAPI, model) {
8
8
  model.classHierarchy.push('vtkLabelWidgetProp');
9
- model.isDragging = null; // --------------------------------------------------------------------------
9
+ model._isDragging = false; // --------------------------------------------------------------------------
10
10
  // Public methods
11
11
  // --------------------------------------------------------------------------
12
12
 
@@ -56,8 +56,8 @@ function widgetBehavior(publicAPI, model) {
56
56
  moveHandle.setOrigin(worldCoords);
57
57
  model.widgetState.getText().setOrigin(moveHandle.getOrigin());
58
58
  publicAPI.loseFocus();
59
- } else {
60
- model.isDragging = true;
59
+ } else if (model.dragable) {
60
+ model._isDragging = true;
61
61
 
62
62
  model._apiSpecificRenderWindow.setCursor('grabbing');
63
63
 
@@ -72,27 +72,30 @@ function widgetBehavior(publicAPI, model) {
72
72
 
73
73
 
74
74
  publicAPI.handleLeftButtonRelease = function () {
75
- if (model.isDragging && model.pickable) {
75
+ if (!model.activeState || !model.activeState.getActive() || !model.pickable) {
76
+ return macro.VOID;
77
+ }
78
+
79
+ if (model._isDragging) {
76
80
  model._apiSpecificRenderWindow.setCursor('pointer');
77
81
 
78
82
  model.widgetState.deactivate();
79
83
 
80
84
  model._interactor.cancelAnimation(publicAPI);
81
85
 
82
- publicAPI.invokeEndInteractionEvent();
86
+ model._isDragging = false;
83
87
  } else if (model.activeState !== model.widgetState.getMoveHandle()) {
84
88
  model.widgetState.deactivate();
85
89
  }
86
90
 
87
91
  if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
88
- publicAPI.invokeEndInteractionEvent();
89
-
90
92
  model._widgetManager.enablePicking();
91
93
 
92
94
  model._interactor.render();
93
95
  }
94
96
 
95
- model.isDragging = false;
97
+ publicAPI.invokeEndInteractionEvent();
98
+ return macro.EVENT_ABORT;
96
99
  }; // --------------------------------------------------------------------------
97
100
  // Mouse move: Drag selected handle / Handle follow the mouse
98
101
  // --------------------------------------------------------------------------
@@ -106,7 +109,7 @@ function widgetBehavior(publicAPI, model) {
106
109
  if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
107
110
  var worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
108
111
 
109
- if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model.isDragging)) {
112
+ if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging)) {
110
113
  model.activeState.setOrigin(worldCoords);
111
114
  model.widgetState.getText().setOrigin(model.activeState.getOrigin());
112
115
  publicAPI.invokeInteractionEvent();