@kitware/vtk.js 26.3.2 → 26.4.1

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 (55) hide show
  1. package/Common/Core/CellArray.d.ts +4 -0
  2. package/Common/Core/CellArray.js +4 -0
  3. package/Common/Core/LookupTable.js +4 -2
  4. package/Common/DataModel/Collection.d.ts +118 -0
  5. package/Common/DataModel/Collection.js +113 -0
  6. package/Interaction/Manipulators/CompositeCameraManipulator.d.ts +68 -0
  7. package/Interaction/Manipulators/CompositeGestureManipulator.d.ts +168 -0
  8. package/Interaction/Manipulators/CompositeKeyboardManipulator.d.ts +48 -0
  9. package/Interaction/Manipulators/CompositeMouseManipulator.d.ts +149 -0
  10. package/Interaction/Manipulators/CompositeVRManipulator.d.ts +44 -0
  11. package/Interaction/Manipulators/GestureCameraManipulator.d.ts +34 -0
  12. package/Interaction/Manipulators/MouseBoxSelectorManipulator.d.ts +88 -0
  13. package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.d.ts +32 -0
  14. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.d.ts +33 -0
  15. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.d.ts +33 -0
  16. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.d.ts +67 -0
  17. package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.d.ts +45 -0
  18. package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.d.ts +26 -0
  19. package/Interaction/Manipulators/MouseRangeManipulator.d.ts +53 -0
  20. package/Interaction/Style/InteractorStyleManipulator.d.ts +333 -0
  21. package/Proxy/Core/AbstractRepresentationProxy.d.ts +24 -0
  22. package/Proxy/Core/LookupTableProxy.d.ts +45 -0
  23. package/Proxy/Core/PiecewiseFunctionProxy.d.ts +62 -0
  24. package/Proxy/Core/ProxyManager.d.ts +81 -0
  25. package/Proxy/Core/SourceProxy.d.ts +22 -0
  26. package/Proxy/Core/View2DProxy.d.ts +7 -0
  27. package/Proxy/Core/ViewProxy.d.ts +86 -0
  28. package/Proxy/Representations/SliceRepresentationProxy.d.ts +27 -0
  29. package/Proxy/Representations/VolumeRepresentationProxy.d.ts +44 -0
  30. package/Rendering/Core/AbstractImageMapper/helper.js +127 -0
  31. package/Rendering/Core/AbstractImageMapper.d.ts +82 -0
  32. package/Rendering/Core/AbstractImageMapper.js +42 -0
  33. package/Rendering/Core/CellPicker.js +1 -1
  34. package/Rendering/Core/ImageArrayMapper.d.ts +252 -0
  35. package/Rendering/Core/ImageArrayMapper.js +242 -0
  36. package/Rendering/Core/ImageMapper.d.ts +5 -35
  37. package/Rendering/Core/ImageMapper.js +16 -108
  38. package/Rendering/Core/InteractorStyle/Constants.d.ts +16 -0
  39. package/Rendering/Core/InteractorStyle.d.ts +229 -0
  40. package/Rendering/Core/PointPicker.js +1 -1
  41. package/Rendering/Core/ScalarBarActor.js +4 -2
  42. package/Rendering/Core/Texture.d.ts +5 -0
  43. package/Rendering/Core/Texture.js +3 -1
  44. package/Rendering/OpenGL/ImageMapper.js +13 -7
  45. package/Rendering/OpenGL/PolyDataMapper.js +3 -1
  46. package/Rendering/OpenGL/RenderWindow.d.ts +8 -1
  47. package/Rendering/OpenGL/RenderWindow.js +3 -2
  48. package/Rendering/OpenGL/Texture.js +19 -18
  49. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  50. package/Widgets/Core/StateBuilder.d.ts +29 -0
  51. package/Widgets/Representations/PolyLineRepresentation.js +16 -8
  52. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +0 -11
  53. package/Widgets/Widgets3D/ResliceCursorWidget.js +7 -14
  54. package/index.d.ts +30 -0
  55. package/package.json +1 -1
@@ -9,6 +9,10 @@ export interface ICellArrayInitialValues extends IDataArrayInitialValues {
9
9
  empty?: boolean;
10
10
  }
11
11
 
12
+ /**
13
+ * You are NOT allowed to modify the cell array via `getData()`.
14
+ * Only via `setData` or `insertNextCell`
15
+ */
12
16
  export interface vtkCellArray extends vtkDataArray {
13
17
 
14
18
  /**
@@ -71,6 +71,10 @@ function vtkCellArray(publicAPI, model) {
71
71
  model.cellSizes = extractCellSizes(publicAPI.getData());
72
72
  return model.cellSizes;
73
73
  };
74
+ /**
75
+ * When `resize()` is being used, you then MUST use `insertNextCell()`.
76
+ */
77
+
74
78
 
75
79
  publicAPI.resize = function (requestedNumTuples) {
76
80
  var oldNumTuples = publicAPI.getNumberOfTuples();
@@ -61,7 +61,7 @@ function vtkLookupTable(publicAPI, model) {
61
61
 
62
62
 
63
63
  publicAPI.getNumberOfAvailableColors = function () {
64
- return model.table.length;
64
+ return model.table.length / 4;
65
65
  }; //----------------------------------------------------------------------------
66
66
  // Apply shift/scale to the scalar value v and return the index.
67
67
 
@@ -94,7 +94,7 @@ function vtkLookupTable(publicAPI, model) {
94
94
  }
95
95
 
96
96
  var offset = 4 * index;
97
- return [table[offset], table[offset + 1], table[offset + 2], table[offset + 3]];
97
+ return table.slice(offset, offset + 4);
98
98
  };
99
99
 
100
100
  publicAPI.indexedLookupFunction = function (v, table, p) {
@@ -180,6 +180,7 @@ function vtkLookupTable(publicAPI, model) {
180
180
  ainc = (model.alphaRange[1] - model.alphaRange[0]) / maxIndex;
181
181
  }
182
182
 
183
+ model.table.length = 4 * maxIndex + 16;
183
184
  var hsv = [];
184
185
  var rgba = [];
185
186
 
@@ -213,6 +214,7 @@ function vtkLookupTable(publicAPI, model) {
213
214
 
214
215
  model.numberOfColors = table.getNumberOfTuples();
215
216
  var data = table.getData();
217
+ model.table.length = data.length;
216
218
 
217
219
  for (var i = 0; i < data.length; i++) {
218
220
  model.table[i] = data[i];
@@ -0,0 +1,118 @@
1
+ import { vtkObject } from './../../interfaces';
2
+ import { Nullable } from './../../types';
3
+
4
+ /**
5
+ *
6
+ */
7
+ export interface ICollectionInitialValues {
8
+ collection?: vtkObject[];
9
+ }
10
+
11
+
12
+ export interface vtkCollection extends vtkObject {
13
+
14
+ /**
15
+ * Add item (vtkObject) to the collection
16
+ * @param {vtkObject} item item to be added to the collection
17
+ */
18
+ addItem(item: vtkObject): void;
19
+
20
+ /**
21
+ * Add item (vtkObject) to the collection _at_ the given index.
22
+ * This differs from VTK-C++ where insertItem inserts at position
23
+ * after the provided index value.
24
+ * @param {number} idx index where the new item should be inserted.
25
+ * @param {vtkObject} item item to be inserted
26
+ */
27
+ insertItem(idx: number, item: vtkObject): void;
28
+
29
+ /**
30
+ * Replace an existing item (vtkObject) with a new one
31
+ * @param {number} idx index of item to be replaced
32
+ * @param {vtkObject} item
33
+ */
34
+ replaceItem(idx: number, item: vtkObject): void;
35
+
36
+ /**
37
+ * Remove an existing item from the collection
38
+ * @param {number|vtkObject} inValue index or reference of an item to be removed
39
+ */
40
+ removeItem(inValue: number|vtkObject): void;
41
+
42
+ /**
43
+ * Remove all items from the collection
44
+ */
45
+ removeAllItems(): void;
46
+
47
+ /**
48
+ * Check if a provided item is already present in the collection
49
+ */
50
+ isItemPresent(item: vtkObject): boolean;
51
+
52
+ /**
53
+ * Get the total number of items in the collection
54
+ */
55
+ getNumberOfItems(): number;
56
+
57
+ /**
58
+ * Check if the collection is empty
59
+ */
60
+ empty(): boolean;
61
+
62
+ /**
63
+ * get the current item and provided index, returns null if index is out of bounds
64
+ */
65
+ getItem(idx: number): Nullable<vtkObject>;
66
+
67
+ /**
68
+ * Execute a passed function on every item in the collection
69
+ * @param callbackfn callback function to be executed on every item in the collection
70
+ */
71
+ forEach<T>(callbackfn: (value: T, index: number, array: readonly T[]) => void): void;
72
+
73
+ /**
74
+ * Execute a passed function on every item in the collection, in order to calculate an aggregated return value.
75
+ * @param callbackfn callback function to be used for aggregating a single value from each item in the collection
76
+ * @param initialValue starting value to calculate aggregation
77
+ */
78
+ reduce<T>(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
79
+
80
+ /**
81
+ * Similar to forEach, but returns an array of resulting values.
82
+ * @param callbackfn callback function to execute on each item in the collection, that returns a value.
83
+ */
84
+ map<T>(callbackfn: (value: T, index: number, array: readonly T[]) => void): void;
85
+
86
+ /**
87
+ * Check each element for modified time and update the collection's
88
+ * MTime to the latest timestamp from individual items in the collection.
89
+ */
90
+ updateMTimeWithElements(): void;
91
+ }
92
+
93
+ /**
94
+ * Method used to decorate a given object (publicAPI+model) with vtkCollection characteristics.
95
+ *
96
+ * @param publicAPI object on which methods will be bounds (public)
97
+ * @param model object on which data structure will be bounds (protected)
98
+ * @param {ICollectionInitialValues} [initialValues] (default: {})
99
+ */
100
+ export function extend(publicAPI: object, model: object, initialValues? : ICollectionInitialValues): void;
101
+
102
+ /**
103
+ * Method used to create a new instance of vtkCollection.
104
+ * @param {ICollectionInitialValues} [initialValues] for pre-setting some of its content
105
+ */
106
+ export function newInstance(initialValues? : ICollectionInitialValues): vtkCollection;
107
+
108
+ /**
109
+ * vtkCollection is a container of multiple vtkObject items.
110
+ * This can be useful for encapsulating multiple vtkObjects such as images
111
+ * into a single vtkObject (vtkCollection instance) to be passed as input
112
+ * to other filters and mappers as a single unit.
113
+ */
114
+ export declare const vtkCollection: {
115
+ newInstance: typeof newInstance;
116
+ extend: typeof extend;
117
+ };
118
+ export default vtkCollection;
@@ -0,0 +1,113 @@
1
+ import macro from '../../macros.js';
2
+
3
+ var vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
4
+ // vtkCollection methods
5
+ // ----------------------------------------------------------------------------
6
+
7
+ function vtkCollection(publicAPI, model) {
8
+ // Set our className
9
+ model.classHierarchy.push('vtkCollection');
10
+
11
+ publicAPI.addItem = function (item) {
12
+ model.collection.push(item);
13
+ publicAPI.modified();
14
+ };
15
+
16
+ publicAPI.insertItem = function (idx, item) {
17
+ if (idx < 0 || model.collection.length < idx) {
18
+ vtkErrorMacro('idx out of bounds for insertion.');
19
+ }
20
+
21
+ model.collection.splice(idx, 0, item);
22
+ publicAPI.modified();
23
+ };
24
+
25
+ publicAPI.replaceItem = function (idx, item) {
26
+ model.collection.splice(idx, 1, item);
27
+ publicAPI.modified();
28
+ };
29
+
30
+ publicAPI.removeItem = function (inValue) {
31
+ var idx = typeof inValue === 'number' ? inValue : model.collection.indexOf(inValue);
32
+
33
+ if (idx >= 0 && idx < model.collection.length) {
34
+ model.collection.splice(idx, 1);
35
+ publicAPI.modified();
36
+ } else {
37
+ vtkErrorMacro('idx out of bounds for removeItem.');
38
+ }
39
+ };
40
+
41
+ publicAPI.removeAllItems = function () {
42
+ model.collection = [];
43
+ publicAPI.modified();
44
+ };
45
+
46
+ publicAPI.isItemPresent = function (item) {
47
+ return model.collection.includes(item);
48
+ };
49
+
50
+ publicAPI.getNumberOfItems = function () {
51
+ return model.collection.length;
52
+ };
53
+
54
+ publicAPI.empty = function () {
55
+ return model.collection.length === 0;
56
+ };
57
+
58
+ publicAPI.getItem = function (idx) {
59
+ return model.collection[idx];
60
+ };
61
+
62
+ publicAPI.forEach = function (ftor) {
63
+ model.collection.forEach(ftor); // Call modified() for the collection, since ftor could have modified the elements.
64
+
65
+ publicAPI.updateMTimeWithElements();
66
+ };
67
+
68
+ publicAPI.reduce = function (ftor, initialValue) {
69
+ return model.collection.reduce(ftor, initialValue);
70
+ };
71
+
72
+ publicAPI.map = function (ftor) {
73
+ return model.collection.map(ftor);
74
+ };
75
+
76
+ publicAPI.updateMTimeWithElements = function () {
77
+ var maxMTimeOfItems = 0; // we expect time values to be positive numbers
78
+
79
+ for (var i = 0; i < model.collection.length; ++i) {
80
+ var elem = model.collection[i];
81
+ maxMTimeOfItems = Math.max(maxMTimeOfItems, elem.getMTime());
82
+ }
83
+
84
+ if (maxMTimeOfItems > publicAPI.getMTime()) {
85
+ publicAPI.modified();
86
+ }
87
+ };
88
+ } // ----------------------------------------------------------------------------
89
+ // Object factory
90
+ // ----------------------------------------------------------------------------
91
+
92
+
93
+ var DEFAULT_VALUES = {
94
+ collection: []
95
+ }; // ----------------------------------------------------------------------------
96
+
97
+ function extend(publicAPI, model) {
98
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
99
+ Object.assign(model, DEFAULT_VALUES, initialValues); // Object methods
100
+
101
+ macro.obj(publicAPI, model); // Object specific methods
102
+
103
+ vtkCollection(publicAPI, model);
104
+ } // ----------------------------------------------------------------------------
105
+
106
+ var newInstance = macro.newInstance(extend, 'vtkCollection'); // ----------------------------------------------------------------------------
107
+
108
+ var index = {
109
+ newInstance: newInstance,
110
+ extend: extend
111
+ };
112
+
113
+ export { index as default, extend, newInstance };
@@ -0,0 +1,68 @@
1
+ import vtkInteractorObserver from './../../Rendering/Core/InteractorObserver';
2
+ import vtkRenderer from './../../Rendering/Core/Renderer';
3
+ import { Vector2, Vector3 } from './../../types';
4
+
5
+ export interface vtkCompositeCameraManipulator {
6
+ /**
7
+ * Computes the display center.
8
+ * @param observer
9
+ * @param renderer
10
+ */
11
+ computeDisplayCenter(
12
+ observer: vtkInteractorObserver,
13
+ renderer: vtkRenderer
14
+ ): void;
15
+
16
+ /**
17
+ * Sets the rotation factor.
18
+ * @param factor
19
+ */
20
+ setRotationFactor(factor: number): boolean;
21
+
22
+ /**
23
+ * Gets the rotation factor.
24
+ */
25
+ getRotationFactor(): number;
26
+
27
+ /**
28
+ * Sets the display center.
29
+ * @param center
30
+ */
31
+ setDisplayCenter(center: Vector2): boolean;
32
+ setDisplayCenter(x: number, y: number): boolean;
33
+
34
+ /**
35
+ * Gets the display center.
36
+ */
37
+ getDisplayCenter(): Vector2;
38
+
39
+ /**
40
+ * Sets the center.
41
+ * @param center
42
+ */
43
+ setCenter(center: Vector3): boolean;
44
+ setCenter(x: number, y: number, z: number): boolean;
45
+
46
+ /**
47
+ * Gets the center.
48
+ */
49
+ getCenter(): Vector3;
50
+ }
51
+
52
+ export interface ICompositeCameraManipulatorInitialValues {
53
+ center?: Vector3;
54
+ rotationFactor?: number;
55
+ displayCenter?: Vector2;
56
+ }
57
+
58
+ export function extend(
59
+ publicAPI: object,
60
+ model: object,
61
+ initialValues?: ICompositeCameraManipulatorInitialValues
62
+ ): void;
63
+
64
+ export const vtkCompositeCameraManipulator: {
65
+ extend: typeof extend;
66
+ };
67
+
68
+ export default vtkCompositeCameraManipulator;
@@ -0,0 +1,168 @@
1
+ import vtkInteractorStyle from './../../Rendering/Core/InteractorStyle';
2
+ import vtkRenderer from './../../Rendering/Core/Renderer';
3
+ import vtkRenderWindowInteractor from './../../Rendering/Core/RenderWindowInteractor';
4
+ import { Nullable } from './../../types';
5
+
6
+ export interface vtkCompositeGestureManipulator {
7
+ /**
8
+ * Starts an interaction event.
9
+ */
10
+ startInteraction(): void;
11
+
12
+ /**
13
+ * Ends an interaction event.
14
+ */
15
+ endInteraction(): void;
16
+
17
+ /**
18
+ * Handles a start pinch gesture.
19
+ * @param interactor
20
+ * @param scale
21
+ */
22
+ onStartPinch(interactor: vtkRenderWindowInteractor, scale: number): void;
23
+
24
+ /**
25
+ * Handles a pinch gesture.
26
+ * @param interactor
27
+ * @param renderer
28
+ * @param scale
29
+ */
30
+ onPinch(
31
+ interactor: vtkRenderWindowInteractor,
32
+ renderer: vtkRenderer,
33
+ scale: number
34
+ ): void;
35
+
36
+ /**
37
+ * Handles an end pinch gesture.
38
+ * @param interactor
39
+ */
40
+ onEndPinch(interactor: vtkRenderWindowInteractor): void;
41
+
42
+ /**
43
+ * Handles a start rotate gesture.
44
+ * @param interactor
45
+ * @param rotation
46
+ */
47
+ onStartRotate(interactor: vtkRenderWindowInteractor, rotation: number): void;
48
+
49
+ /**
50
+ * Handles a rotate gesture.
51
+ * @param interactor
52
+ * @param renderer
53
+ * @param rotation
54
+ */
55
+ onRotate(
56
+ interactor: vtkRenderWindowInteractor,
57
+ renderer: vtkRenderer,
58
+ rotation: number
59
+ ): void;
60
+
61
+ /**
62
+ * Handles an end pinch gesture.
63
+ * @param interactor
64
+ */
65
+ onEndRotate(interactor: vtkRenderWindowInteractor): void;
66
+
67
+ /**
68
+ * Handles a start pan gesture.
69
+ * @param interactor
70
+ * @param translation
71
+ */
72
+ onStartPan(interactor: vtkRenderWindowInteractor, translation: number): void;
73
+
74
+ /**
75
+ * Handles a pan gesture.
76
+ * @param interactor
77
+ * @param renderer
78
+ * @param translation
79
+ */
80
+ onPan(
81
+ interactor: vtkRenderWindowInteractor,
82
+ renderer: vtkRenderer,
83
+ translation: number
84
+ ): void;
85
+
86
+ /**
87
+ * Handles an end pan gesture.
88
+ * @param interactor
89
+ */
90
+ onEndPan(interactor: vtkRenderWindowInteractor): void;
91
+
92
+ /**
93
+ * Is pinch enabled.
94
+ */
95
+ isPinchEnabled(): boolean;
96
+
97
+ /**
98
+ * Sets if pinch is enabled.
99
+ * @param pinch
100
+ */
101
+ setPinchEnabled(pinch: boolean): boolean;
102
+
103
+ /**
104
+ * Gets flag if pinch is enabled.
105
+ */
106
+ getPinchEnabled(): boolean;
107
+
108
+ /**
109
+ * Is pan enabled.
110
+ */
111
+ isPanEnabled(): boolean;
112
+
113
+ /**
114
+ * Sets if pan is enabled.
115
+ * @param pan
116
+ */
117
+ setPanEnabled(pan: boolean): boolean;
118
+
119
+ /**
120
+ * Gets flag if pan is enabled.
121
+ */
122
+ getPanEnabled(): boolean;
123
+
124
+ /**
125
+ * Is rotate enabled.
126
+ */
127
+ isRotateEnabled(): boolean;
128
+
129
+ /**
130
+ * Sets if rotate is enabled.
131
+ * @param rotate
132
+ */
133
+ setRotateEnabled(rotate: boolean): boolean;
134
+
135
+ /**
136
+ * Gets flag if rotate is enabled.
137
+ */
138
+ getRotateEnabled(): boolean;
139
+
140
+ /**
141
+ * Sets the interactor style.
142
+ * @param style vtkInteractorStyle
143
+ */
144
+ setInteractorStyle(style: Nullable<vtkInteractorStyle>): boolean;
145
+
146
+ /**
147
+ * Gets the interactor style.
148
+ */
149
+ getInteractorStyle(): Nullable<vtkInteractorStyle>;
150
+ }
151
+
152
+ export interface ICompositeGestureManipulatorInitialValues {
153
+ pinchEnabled?: boolean;
154
+ panEnabled?: boolean;
155
+ rotateEnabled?: boolean;
156
+ }
157
+
158
+ export function extend(
159
+ publicAPI: object,
160
+ model: object,
161
+ initialValues?: ICompositeGestureManipulatorInitialValues
162
+ ): void;
163
+
164
+ export const vtkCompositeGestureManipulator: {
165
+ extend: typeof extend;
166
+ };
167
+
168
+ export default vtkCompositeGestureManipulator;
@@ -0,0 +1,48 @@
1
+ import vtkRenderer from './../../Rendering/Core/Renderer';
2
+ import vtkRenderWindowInteractor from './../../Rendering/Core/RenderWindowInteractor';
3
+
4
+ export interface vtkCompositeKeyboardManipulator {
5
+ /**
6
+ * Handles a keypress event.
7
+ * @param interactor the interactor
8
+ * @param renderer the renderer
9
+ * @param key the key
10
+ */
11
+ onKeyPress(
12
+ interactor: vtkRenderWindowInteractor,
13
+ renderer: vtkRenderer,
14
+ key: KeyboardEvent['key']
15
+ ): void;
16
+
17
+ /**
18
+ * Handles a keydown event.
19
+ * @param interactor the interactor
20
+ * @param renderer the renderer
21
+ * @param key the key
22
+ */
23
+ onKeyDown(
24
+ interactor: vtkRenderWindowInteractor,
25
+ renderer: vtkRenderer,
26
+ key: KeyboardEvent['key']
27
+ ): void;
28
+
29
+ /**
30
+ * Handles a keyup event.
31
+ * @param interactor the interactor
32
+ * @param renderer the renderer
33
+ * @param key the key
34
+ */
35
+ onKeyUp(
36
+ interactor: vtkRenderWindowInteractor,
37
+ renderer: vtkRenderer,
38
+ key: KeyboardEvent['key']
39
+ ): void;
40
+ }
41
+
42
+ export function extend(publicAPI: object, model: object): void;
43
+
44
+ export const vtkCompositeKeyboardManipulator: {
45
+ extend: typeof extend;
46
+ };
47
+
48
+ export default vtkCompositeKeyboardManipulator;