@kitware/vtk.js 24.8.0 → 24.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ import vtkPolyData from './PolyData';
2
+ import vtkImageData from './ImageData';
3
+
4
+ export interface IOptions {
5
+ pointDataName: string;
6
+ scalarArrayName: string;
7
+ cellDataName: string;
8
+ }
9
+
10
+ /**
11
+ * Converts an itk-wasm Image to a vtk.js vtkImageData.
12
+ * Requires an itk-wasm Image as input.
13
+ * @param itkImage
14
+ * @param {IOptions} [options]
15
+ */
16
+ export function convertItkToVtkImage(itkImage: any, options?: IOptions): vtkImageData;
17
+
18
+ /**
19
+ * Converts a vtk.js vtkImageData to an itk-wasm Image.
20
+ * Requires a vtk.js vtkImageData as input.
21
+ * @param {vtkImageData} vtkImage
22
+ * @param {IOptions} [options]
23
+ */
24
+ export function convertVtkToItkImage(vtkImage: vtkImageData, options?: IOptions): any;
25
+
26
+ /**
27
+ * Converts an itk-wasm PolyData to a vtk.js vtkPolyData.
28
+ * Requires an itk-wasm PolyData as input.
29
+ * @param itkPolyData
30
+ * @param {IOptions} [options]
31
+ */
32
+ export function convertItkToVtkPolyData(itkPolyData: any, options?: IOptions): vtkPolyData;
33
+
34
+ /**
35
+ * Converts a vtk.js vtkPolyData to an itk-wasm PolyData.
36
+ * Requires a vtk.js vtkPolyData as input.
37
+ *
38
+ * @param {vtkPolyData} polyData
39
+ * @param {IOptions} [options]
40
+ */
41
+ export function convertVtkToItkPolyData(polyData: vtkPolyData, options?: IOptions): any;
42
+
43
+
44
+ /**
45
+ * vtkITKHelper is a helper which provides a set of functions to work with
46
+ * itk-wasm module.
47
+ */
48
+ export declare const vtkITKHelper: {
49
+ convertItkToVtkImage: typeof convertItkToVtkImage,
50
+ convertVtkToItkImage: typeof convertVtkToItkImage,
51
+ convertItkToVtkPolyData: typeof convertItkToVtkPolyData,
52
+ convertVtkToItkPolyData: typeof convertVtkToItkPolyData,
53
+ };
54
+ export default vtkITKHelper;
@@ -18,9 +18,13 @@ function vtkMouseRangeManipulator(publicAPI, model) {
18
18
 
19
19
 
20
20
  function processDelta(listener, delta) {
21
- var oldValue = listener.getValue(); // Apply scale and cached delta to current delta
21
+ var oldValue = listener.getValue(); // if exponential scroll is enabled, we raise our scale to the
22
+ // exponent of the net delta of the interaction. The further away
23
+ // the user's cursor is from the start of the interaction, the more
24
+ // their movements will effect the value.
22
25
 
23
- var newDelta = delta * listener.scale + incrementalDelta.get(listener);
26
+ var scalingFactor = listener.exponentialScroll ? Math.pow(listener.scale, Math.log2(Math.abs(model.interactionNetDelta) + 2)) : listener.scale;
27
+ var newDelta = delta * scalingFactor + incrementalDelta.get(listener);
24
28
  var value = oldValue + newDelta; // Compute new value based on step
25
29
 
26
30
  var difference = value - listener.min;
@@ -52,6 +56,7 @@ function vtkMouseRangeManipulator(publicAPI, model) {
52
56
 
53
57
  publicAPI.setHorizontalListener = function (min, max, step, getValue, setValue) {
54
58
  var scale = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
59
+ var exponentialScroll = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
55
60
  var getFn = Number.isFinite(getValue) ? function () {
56
61
  return getValue;
57
62
  } : getValue;
@@ -61,7 +66,8 @@ function vtkMouseRangeManipulator(publicAPI, model) {
61
66
  step: step,
62
67
  getValue: getFn,
63
68
  setValue: setValue,
64
- scale: scale
69
+ scale: scale,
70
+ exponentialScroll: exponentialScroll
65
71
  };
66
72
  incrementalDelta.set(model.horizontalListener, 0);
67
73
  publicAPI.modified();
@@ -70,6 +76,7 @@ function vtkMouseRangeManipulator(publicAPI, model) {
70
76
 
71
77
  publicAPI.setVerticalListener = function (min, max, step, getValue, setValue) {
72
78
  var scale = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
79
+ var exponentialScroll = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
73
80
  var getFn = Number.isFinite(getValue) ? function () {
74
81
  return getValue;
75
82
  } : getValue;
@@ -79,7 +86,8 @@ function vtkMouseRangeManipulator(publicAPI, model) {
79
86
  step: step,
80
87
  getValue: getFn,
81
88
  setValue: setValue,
82
- scale: scale
89
+ scale: scale,
90
+ exponentialScroll: exponentialScroll
83
91
  };
84
92
  incrementalDelta.set(model.verticalListener, 0);
85
93
  publicAPI.modified();
@@ -88,6 +96,7 @@ function vtkMouseRangeManipulator(publicAPI, model) {
88
96
 
89
97
  publicAPI.setScrollListener = function (min, max, step, getValue, setValue) {
90
98
  var scale = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
99
+ var exponentialScroll = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
91
100
  var getFn = Number.isFinite(getValue) ? function () {
92
101
  return getValue;
93
102
  } : getValue;
@@ -97,7 +106,8 @@ function vtkMouseRangeManipulator(publicAPI, model) {
97
106
  step: step,
98
107
  getValue: getFn,
99
108
  setValue: setValue,
100
- scale: scale
109
+ scale: scale,
110
+ exponentialScroll: exponentialScroll
101
111
  };
102
112
  incrementalDelta.set(model.scrollListener, 0);
103
113
  publicAPI.modified();
@@ -140,6 +150,7 @@ function vtkMouseRangeManipulator(publicAPI, model) {
140
150
 
141
151
  publicAPI.onButtonDown = function (interactor, renderer, position) {
142
152
  model.previousPosition = position;
153
+ model.interactionNetDelta = 0;
143
154
  var glRenderWindow = interactor.getView(); // Ratio is the dom size vs renderwindow size
144
155
 
145
156
  var ratio = glRenderWindow.getContainerSize()[0] / glRenderWindow.getSize()[0]; // Get proper pixel range used by viewport in rw size space
@@ -216,12 +227,14 @@ function vtkMouseRangeManipulator(publicAPI, model) {
216
227
  if (model.horizontalListener) {
217
228
  var dxNorm = (position.x - model.previousPosition.x) / model.containerSize[0];
218
229
  var dx = scaleDeltaToRange(model.horizontalListener, dxNorm);
230
+ model.interactionNetDelta += dx;
219
231
  processDelta(model.horizontalListener, dx);
220
232
  }
221
233
 
222
234
  if (model.verticalListener) {
223
235
  var dyNorm = (position.y - model.previousPosition.y) / model.containerSize[1];
224
236
  var dy = scaleDeltaToRange(model.verticalListener, dyNorm);
237
+ model.interactionNetDelta += dy;
225
238
  processDelta(model.verticalListener, dy);
226
239
  }
227
240
 
@@ -234,10 +247,14 @@ function vtkMouseRangeManipulator(publicAPI, model) {
234
247
  return;
235
248
  }
236
249
 
250
+ model.interactionNetDelta += delta * model.scrollListener.step;
237
251
  processDelta(model.scrollListener, delta * model.scrollListener.step);
238
252
  };
239
253
 
240
- publicAPI.onStartScroll = publicAPI.onScroll;
254
+ publicAPI.onStartScroll = function (payload) {
255
+ model.interactionNetDelta = 0;
256
+ publicAPI.onScroll(payload);
257
+ };
241
258
  } // ----------------------------------------------------------------------------
242
259
  // Object factory
243
260
  // ----------------------------------------------------------------------------
package/index.d.ts CHANGED
@@ -26,6 +26,7 @@
26
26
  /// <reference path="./Common/DataModel/DataSetAttributes/FieldData.d.ts" />
27
27
  /// <reference path="./Common/DataModel/DataSetAttributes.d.ts" />
28
28
  /// <reference path="./Common/DataModel/ImageData.d.ts" />
29
+ /// <reference path="./Common/DataModel/ITKHelper.d.ts" />
29
30
  /// <reference path="./Common/DataModel/KochanekSpline1D.d.ts" />
30
31
  /// <reference path="./Common/DataModel/Line.d.ts" />
31
32
  /// <reference path="./Common/DataModel/PiecewiseFunction.d.ts" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "24.8.0",
3
+ "version": "24.9.0",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",