@kitware/vtk.js 19.8.0 → 20.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +10 -0
- package/Common/Core/Math/index.js +2 -0
- package/Common/Core/Math.d.ts +8 -8
- package/Common/DataModel/ImageData.js +2 -4
- package/Common/DataModel/Plane.d.ts +2 -2
- package/Filters/General/AppendPolyData.js +2 -2
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +1 -1
- package/Rendering/Core/Picker.js +3 -3
- package/Rendering/Core/RenderWindow.js +12 -0
- package/Rendering/OpenGL/HardwareSelector.js +4 -1
- package/Rendering/OpenGL/Renderer.js +0 -5
- package/Rendering/OpenGL/Texture.js +4 -76
- package/Rendering/WebGPU/HardwareSelector.js +17 -13
- package/Rendering/WebGPU/ImageMapper.js +13 -7
- package/Rendering/WebGPU/Renderer.js +0 -5
- package/Rendering/WebGPU/Texture.js +1 -1
- package/Widgets/Representations/CircleContextRepresentation.js +3 -5
- package/Widgets/Representations/ContextRepresentation.js +3 -0
- package/Widgets/Representations/RectangleContextRepresentation.js +2 -2
- package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +28 -0
- package/Widgets/SVG/SVGLandmarkRepresentation.js +39 -21
- package/Widgets/Widgets3D/EllipseWidget/behavior.js +6 -1
- package/Widgets/Widgets3D/EllipseWidget/state.js +22 -2
- package/Widgets/Widgets3D/EllipseWidget.js +29 -21
- package/Widgets/Widgets3D/LineWidget.js +5 -2
- package/Widgets/Widgets3D/PaintWidget/behavior.js +107 -0
- package/Widgets/Widgets3D/PaintWidget/state.js +29 -0
- package/Widgets/Widgets3D/PaintWidget.js +5 -134
- package/Widgets/Widgets3D/PolyLineWidget.js +6 -0
- package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -1
- package/Widgets/Widgets3D/RectangleWidget/state.js +22 -2
- package/Widgets/Widgets3D/RectangleWidget.js +28 -20
- package/Widgets/Widgets3D/ShapeWidget/Constants.js +5 -66
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +131 -117
- package/Widgets/Widgets3D/ShapeWidget.js +37 -15
- package/macros.js +22 -4
- package/package.json +1 -1
package/BREAKING_CHANGES.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## From 19.x to 20
|
|
2
|
+
|
|
3
|
+
In ShapeWidget:
|
|
4
|
+
- `setLabelTextCallback` is replaced by `text` substate.
|
|
5
|
+
- `setPixelScale` has been removed. It should be replaced by point handle `scale1` mixin and `scaleInPixels`.
|
|
6
|
+
- `useHandles` has been removed. It should be replaced by `setHandleVisibility`.
|
|
7
|
+
- `resetAfterPointPlacement` is now false by default.
|
|
8
|
+
|
|
9
|
+
RectangleWidget and EllipseWidget handles now scale up automatically.
|
|
10
|
+
|
|
1
11
|
## From 18.x to 19
|
|
2
12
|
|
|
3
13
|
vtkWidgetRepresentation.updateActorVisibility(...) lost the widgetVisibility parameter.
|
|
@@ -1922,6 +1922,7 @@ function uninitializeBounds(bounds) {
|
|
|
1922
1922
|
bounds[3] = -1.0;
|
|
1923
1923
|
bounds[4] = 1.0;
|
|
1924
1924
|
bounds[5] = -1.0;
|
|
1925
|
+
return bounds;
|
|
1925
1926
|
}
|
|
1926
1927
|
function areBoundsInitialized(bounds) {
|
|
1927
1928
|
return !(bounds[1] - bounds[0] < 0.0);
|
|
@@ -1933,6 +1934,7 @@ function computeBoundsFromPoints(point1, point2, bounds) {
|
|
|
1933
1934
|
bounds[3] = Math.max(point1[1], point2[1]);
|
|
1934
1935
|
bounds[4] = Math.min(point1[2], point2[2]);
|
|
1935
1936
|
bounds[5] = Math.max(point1[2], point2[2]);
|
|
1937
|
+
return bounds;
|
|
1936
1938
|
}
|
|
1937
1939
|
function clampValue(value, minValue, maxValue) {
|
|
1938
1940
|
if (value < minValue) {
|
package/Common/Core/Math.d.ts
CHANGED
|
@@ -657,10 +657,10 @@ export function rgb2lab(rgb: number[], lab: number[]): void;
|
|
|
657
657
|
export function lab2rgb(lab: number[], rgb: number[]): void;
|
|
658
658
|
|
|
659
659
|
/**
|
|
660
|
-
*
|
|
661
|
-
* @param {Number[]} bounds
|
|
660
|
+
* Returns bounds.
|
|
661
|
+
* @param {Number[]} bounds Output array that hold bounds, optionally empty.
|
|
662
662
|
*/
|
|
663
|
-
export function uninitializeBounds(bounds: number[]):
|
|
663
|
+
export function uninitializeBounds(bounds: number[]): number[];
|
|
664
664
|
|
|
665
665
|
/**
|
|
666
666
|
*
|
|
@@ -669,12 +669,12 @@ export function uninitializeBounds(bounds: number[]): void;
|
|
|
669
669
|
export function areBoundsInitialized(bounds: number[]): boolean;
|
|
670
670
|
|
|
671
671
|
/**
|
|
672
|
-
*
|
|
673
|
-
* @param {Number[]} point1
|
|
674
|
-
* @param {Number[]} point2
|
|
675
|
-
* @param {Number[]} bounds
|
|
672
|
+
* Returns bounds.
|
|
673
|
+
* @param {Number[]} point1
|
|
674
|
+
* @param {Number[]} point2
|
|
675
|
+
* @param {Number[]} bounds Output array that hold bounds, optionally empty.
|
|
676
676
|
*/
|
|
677
|
-
export function computeBoundsFromPoints(point1: number[], point2: number[], bounds: number[]):
|
|
677
|
+
export function computeBoundsFromPoints(point1: number[], point2: number[], bounds: number[]): number[];
|
|
678
678
|
|
|
679
679
|
/**
|
|
680
680
|
*
|
|
@@ -326,8 +326,7 @@ function vtkImageData(publicAPI, model) {
|
|
|
326
326
|
var out2 = [0, 0, 0];
|
|
327
327
|
transformMat4(out1, in1, model.indexToWorld);
|
|
328
328
|
transformMat4(out2, in2, model.indexToWorld);
|
|
329
|
-
computeBoundsFromPoints(out1, out2, bout);
|
|
330
|
-
return bout;
|
|
329
|
+
return computeBoundsFromPoints(out1, out2, bout);
|
|
331
330
|
};
|
|
332
331
|
|
|
333
332
|
publicAPI.worldToIndexBounds = function (bin) {
|
|
@@ -339,8 +338,7 @@ function vtkImageData(publicAPI, model) {
|
|
|
339
338
|
var out2 = [0, 0, 0];
|
|
340
339
|
transformMat4(out1, in1, model.worldToIndex);
|
|
341
340
|
transformMat4(out2, in2, model.worldToIndex);
|
|
342
|
-
computeBoundsFromPoints(out1, out2, bout);
|
|
343
|
-
return bout;
|
|
341
|
+
return computeBoundsFromPoints(out1, out2, bout);
|
|
344
342
|
}; // Make sure the transform is correct
|
|
345
343
|
|
|
346
344
|
|
|
@@ -337,9 +337,9 @@ export declare const vtkPlane: {
|
|
|
337
337
|
extend: typeof extend,
|
|
338
338
|
evaluate: typeof evaluate,
|
|
339
339
|
distanceToPlane: typeof distanceToPlane,
|
|
340
|
-
projectPoint: typeof
|
|
340
|
+
projectPoint: typeof projectPoint,
|
|
341
341
|
projectVector: typeof projectVector,
|
|
342
|
-
generalizedProjectPoint: typeof
|
|
342
|
+
generalizedProjectPoint: typeof generalizedProjectPoint,
|
|
343
343
|
intersectWithLine: typeof intersectWithLine,
|
|
344
344
|
intersectWithPlane: typeof intersectWithPlane,
|
|
345
345
|
};
|
|
@@ -102,7 +102,7 @@ function extend(publicAPI, model) {
|
|
|
102
102
|
macro.obj(publicAPI, model);
|
|
103
103
|
vtkCompositeMouseManipulator.extend(publicAPI, model, initialValues);
|
|
104
104
|
vtkCompositeCameraManipulator.extend(publicAPI, model, initialValues);
|
|
105
|
-
macro.setGet(publicAPI, model, ['
|
|
105
|
+
macro.setGet(publicAPI, model, ['flipDirection']); // Object specific methods
|
|
106
106
|
|
|
107
107
|
vtkMouseCameraTrackballZoomManipulator(publicAPI, model);
|
|
108
108
|
} // ----------------------------------------------------------------------------
|
package/Rendering/Core/Picker.js
CHANGED
|
@@ -108,13 +108,13 @@ function vtkPicker(publicAPI, model) {
|
|
|
108
108
|
var camera = renderer.getActiveCamera();
|
|
109
109
|
cameraPos = camera.getPosition();
|
|
110
110
|
cameraFP = camera.getFocalPoint();
|
|
111
|
-
|
|
111
|
+
var dims = view.getViewportSize(renderer);
|
|
112
|
+
var aspect = dims[0] / dims[1];
|
|
113
|
+
displayCoords = renderer.worldToNormalizedDisplay(cameraFP[0], cameraFP[1], cameraFP[2], aspect);
|
|
112
114
|
displayCoords = view.normalizedDisplayToDisplay(displayCoords[0], displayCoords[1], displayCoords[2]);
|
|
113
115
|
selectionZ = displayCoords[2]; // Convert the selection point into world coordinates.
|
|
114
116
|
|
|
115
117
|
var normalizedDisplay = view.displayToNormalizedDisplay(selectionX, selectionY, selectionZ);
|
|
116
|
-
var dims = view.getViewportSize(renderer);
|
|
117
|
-
var aspect = dims[0] / dims[1];
|
|
118
118
|
worldCoords = renderer.normalizedDisplayToWorld(normalizedDisplay[0], normalizedDisplay[1], normalizedDisplay[2], aspect);
|
|
119
119
|
|
|
120
120
|
for (var i = 0; i < 3; i++) {
|
|
@@ -77,9 +77,21 @@ function vtkRenderWindow(publicAPI, model) {
|
|
|
77
77
|
|
|
78
78
|
publicAPI.hasView = function (view) {
|
|
79
79
|
return model.views.indexOf(view) !== -1;
|
|
80
|
+
}; // handle any pre render initializations
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
publicAPI.preRender = function () {
|
|
84
|
+
model.renderers.forEach(function (ren) {
|
|
85
|
+
// make sure we have a camera
|
|
86
|
+
if (!ren.isActiveCameraCreated()) {
|
|
87
|
+
ren.resetCamera();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
80
90
|
};
|
|
81
91
|
|
|
82
92
|
publicAPI.render = function () {
|
|
93
|
+
publicAPI.preRender();
|
|
94
|
+
|
|
83
95
|
if (model.interactor) {
|
|
84
96
|
model.interactor.render();
|
|
85
97
|
} else {
|
|
@@ -361,7 +361,10 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
361
361
|
return false;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
model.openGLRenderer = model.openGLRenderWindow.getViewNodeFor(model.renderer); //
|
|
364
|
+
model.openGLRenderer = model.openGLRenderWindow.getViewNodeFor(model.renderer); // todo revisit making selection part of core
|
|
365
|
+
// then we can do this in core
|
|
366
|
+
|
|
367
|
+
model.openGLRenderWindow.getRenderable().preRender(); // int rgba[4];
|
|
365
368
|
// rwin.getColorBufferSizes(rgba);
|
|
366
369
|
// if (rgba[0] < 8 || rgba[1] < 8 || rgba[2] < 8) {
|
|
367
370
|
// vtkErrorMacro("Color buffer depth must be at least 8 bit. "
|
|
@@ -16,11 +16,6 @@ function vtkOpenGLRenderer(publicAPI, model) {
|
|
|
16
16
|
if (prepass) {
|
|
17
17
|
if (!model.renderable) {
|
|
18
18
|
return;
|
|
19
|
-
} // make sure we have a camera
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (!model.renderable.isActiveCameraCreated()) {
|
|
23
|
-
model.renderable.resetCamera();
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
publicAPI.updateLights();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import Constants from './Texture/Constants.js';
|
|
3
|
+
import HalfFloat from '../../Common/Core/HalfFloat.js';
|
|
3
4
|
import { newInstance as newInstance$1, obj, set, setGet, get, newTypedArray, vtkDebugMacro as vtkDebugMacro$1, vtkErrorMacro as vtkErrorMacro$1, vtkWarningMacro as vtkWarningMacro$1 } from '../../macros.js';
|
|
4
5
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
5
6
|
import { P as isPowerOfTwo, K as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
@@ -14,83 +15,10 @@ var Wrap = Constants.Wrap,
|
|
|
14
15
|
var VtkDataTypes = vtkDataArray.VtkDataTypes;
|
|
15
16
|
var vtkDebugMacro = vtkDebugMacro$1,
|
|
16
17
|
vtkErrorMacro = vtkErrorMacro$1,
|
|
17
|
-
vtkWarningMacro = vtkWarningMacro$1;
|
|
18
|
-
var floatView = new Float32Array(1);
|
|
19
|
-
var int32View = new Int32Array(floatView.buffer);
|
|
20
|
-
/* eslint-disable no-bitwise */
|
|
21
|
-
|
|
22
|
-
/* This method is faster than the OpenEXR implementation (very often
|
|
23
|
-
* used, eg. in Ogre), with the additional benefit of rounding, inspired
|
|
24
|
-
* by James Tursa?s half-precision code. */
|
|
25
|
-
|
|
26
|
-
function toHalf(val) {
|
|
27
|
-
floatView[0] = val;
|
|
28
|
-
var x = int32View[0];
|
|
29
|
-
var bits = x >> 16 & 0x8000;
|
|
30
|
-
/* Get the sign */
|
|
31
|
-
|
|
32
|
-
var m = x >> 12 & 0x07ff;
|
|
33
|
-
/* Keep one extra bit for rounding */
|
|
34
|
-
|
|
35
|
-
var e = x >> 23 & 0xff;
|
|
36
|
-
/* Using int is faster here */
|
|
37
|
-
|
|
38
|
-
/* If zero, or denormal, or exponent underflows too much for a denormal
|
|
39
|
-
* half, return signed zero. */
|
|
40
|
-
|
|
41
|
-
if (e < 103) {
|
|
42
|
-
return bits;
|
|
43
|
-
}
|
|
44
|
-
/* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (e > 142) {
|
|
48
|
-
bits |= 0x7c00;
|
|
49
|
-
/* If exponent was 0xff and one mantissa bit was set, it means NaN,
|
|
50
|
-
* not Inf, so make sure we set one mantissa bit too. */
|
|
51
|
-
|
|
52
|
-
bits |= (e === 255 ? 0 : 1) && x & 0x007fffff;
|
|
53
|
-
return bits;
|
|
54
|
-
}
|
|
55
|
-
/* If exponent underflows but not too much, return a denormal */
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (e < 113) {
|
|
59
|
-
m |= 0x0800;
|
|
60
|
-
/* Extra rounding may overflow and set mantissa to 0 and exponent
|
|
61
|
-
* to 1, which is OK. */
|
|
62
|
-
|
|
63
|
-
bits |= (m >> 114 - e) + (m >> 113 - e & 1);
|
|
64
|
-
return bits;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
bits |= e - 112 << 10 | m >> 1;
|
|
68
|
-
/* Extra rounding. An overflow will set mantissa to 0 and increment
|
|
69
|
-
* the exponent, which is OK. */
|
|
70
|
-
|
|
71
|
-
bits += m & 1;
|
|
72
|
-
return bits;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function fromHalf(h) {
|
|
76
|
-
var s = (h & 0x8000) >> 15;
|
|
77
|
-
var e = (h & 0x7c00) >> 10;
|
|
78
|
-
var f = h & 0x03ff;
|
|
79
|
-
|
|
80
|
-
if (e === 0) {
|
|
81
|
-
return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (e === 0x1f) {
|
|
85
|
-
return f ? NaN : (s ? -1 : 1) * Infinity;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + f / Math.pow(2, 10));
|
|
89
|
-
} // ----------------------------------------------------------------------------
|
|
18
|
+
vtkWarningMacro = vtkWarningMacro$1; // ----------------------------------------------------------------------------
|
|
90
19
|
// vtkOpenGLTexture methods
|
|
91
20
|
// ----------------------------------------------------------------------------
|
|
92
21
|
|
|
93
|
-
|
|
94
22
|
function vtkOpenGLTexture(publicAPI, model) {
|
|
95
23
|
var _this = this;
|
|
96
24
|
|
|
@@ -638,7 +566,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
638
566
|
var _newArray2 = new Uint16Array(pixCount);
|
|
639
567
|
|
|
640
568
|
for (var _i2 = 0; _i2 < pixCount; _i2++) {
|
|
641
|
-
_newArray2[_i2] = toHalf(data[_idx2][_i2]);
|
|
569
|
+
_newArray2[_i2] = HalfFloat.toHalf(data[_idx2][_i2]);
|
|
642
570
|
}
|
|
643
571
|
|
|
644
572
|
pixData.push(_newArray2);
|
|
@@ -721,7 +649,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
721
649
|
|
|
722
650
|
for (var c = 0; c < numComps; c++) {
|
|
723
651
|
if (usingHalf) {
|
|
724
|
-
newArray[joff + ioff + c] = toHalf(fromHalf(data[idx][jlow + ilow + c]) * jmix1 * (1.0 - imix) + fromHalf(data[idx][jlow + ihi + c]) * jmix1 * imix + fromHalf(data[idx][jhi + ilow + c]) * jmix * (1.0 - imix) + fromHalf(data[idx][jhi + ihi + c]) * jmix * imix);
|
|
652
|
+
newArray[joff + ioff + c] = HalfFloat.toHalf(HalfFloat.fromHalf(data[idx][jlow + ilow + c]) * jmix1 * (1.0 - imix) + HalfFloat.fromHalf(data[idx][jlow + ihi + c]) * jmix1 * imix + HalfFloat.fromHalf(data[idx][jhi + ilow + c]) * jmix * (1.0 - imix) + HalfFloat.fromHalf(data[idx][jhi + ihi + c]) * jmix * imix);
|
|
725
653
|
} else {
|
|
726
654
|
newArray[joff + ioff + c] = data[idx][jlow + ilow + c] * jmix1 * (1.0 - imix) + data[idx][jlow + ihi + c] * jmix1 * imix + data[idx][jhi + ilow + c] * jmix * (1.0 - imix) + data[idx][jhi + ihi + c] * jmix * imix;
|
|
727
655
|
}
|
|
@@ -234,28 +234,32 @@ function vtkWebGPUHardwareSelector(publicAPI, model) {
|
|
|
234
234
|
return _context.abrupt("return", false);
|
|
235
235
|
|
|
236
236
|
case 3:
|
|
237
|
+
// todo revisit making selection part of core
|
|
238
|
+
// then we can do this in core
|
|
239
|
+
model.WebGPURenderWindow.getRenderable().preRender();
|
|
240
|
+
|
|
237
241
|
if (model.WebGPURenderWindow.getInitialized()) {
|
|
238
|
-
_context.next =
|
|
242
|
+
_context.next = 8;
|
|
239
243
|
break;
|
|
240
244
|
}
|
|
241
245
|
|
|
242
246
|
model.WebGPURenderWindow.initialize();
|
|
243
|
-
_context.next =
|
|
247
|
+
_context.next = 8;
|
|
244
248
|
return new Promise(function (resolve) {
|
|
245
249
|
return model.WebGPURenderWindow.onInitialized(resolve);
|
|
246
250
|
});
|
|
247
251
|
|
|
248
|
-
case
|
|
252
|
+
case 8:
|
|
249
253
|
webGPURenderer = model.WebGPURenderWindow.getViewNodeFor(renderer);
|
|
250
254
|
|
|
251
255
|
if (webGPURenderer) {
|
|
252
|
-
_context.next =
|
|
256
|
+
_context.next = 11;
|
|
253
257
|
break;
|
|
254
258
|
}
|
|
255
259
|
|
|
256
260
|
return _context.abrupt("return", false);
|
|
257
261
|
|
|
258
|
-
case
|
|
262
|
+
case 11:
|
|
259
263
|
// Initialize renderer for selection.
|
|
260
264
|
// change the renderer's background to black, which will indicate a miss
|
|
261
265
|
originalSuppress = webGPURenderer.getSuppressClear();
|
|
@@ -342,25 +346,25 @@ function vtkWebGPUHardwareSelector(publicAPI, model) {
|
|
|
342
346
|
cLoad = colorBuffer.mapAsync(GPUMapMode.READ);
|
|
343
347
|
|
|
344
348
|
if (!model.captureZValues) {
|
|
345
|
-
_context.next =
|
|
349
|
+
_context.next = 37;
|
|
346
350
|
break;
|
|
347
351
|
}
|
|
348
352
|
|
|
349
353
|
zLoad = zbuffer.mapAsync(GPUMapMode.READ);
|
|
350
|
-
_context.next =
|
|
354
|
+
_context.next = 33;
|
|
351
355
|
return Promise.all([cLoad, zLoad]);
|
|
352
356
|
|
|
353
|
-
case
|
|
357
|
+
case 33:
|
|
354
358
|
result.depthValues = new Float32Array(zbuffer.getMappedRange().slice());
|
|
355
359
|
zbuffer.unmap();
|
|
356
|
-
_context.next =
|
|
360
|
+
_context.next = 39;
|
|
357
361
|
break;
|
|
358
362
|
|
|
359
|
-
case
|
|
360
|
-
_context.next =
|
|
363
|
+
case 37:
|
|
364
|
+
_context.next = 39;
|
|
361
365
|
return cLoad;
|
|
362
366
|
|
|
363
|
-
case
|
|
367
|
+
case 39:
|
|
364
368
|
/* eslint-enable no-undef */
|
|
365
369
|
result.colorValues = new Uint32Array(colorBuffer.getMappedRange().slice());
|
|
366
370
|
colorBuffer.unmap();
|
|
@@ -371,7 +375,7 @@ function vtkWebGPUHardwareSelector(publicAPI, model) {
|
|
|
371
375
|
|
|
372
376
|
return _context.abrupt("return", result);
|
|
373
377
|
|
|
374
|
-
case
|
|
378
|
+
case 43:
|
|
375
379
|
case "end":
|
|
376
380
|
return _context.stop();
|
|
377
381
|
}
|
|
@@ -12,7 +12,7 @@ import { i as identity, t as translate, j as transpose, g as invert, m as multip
|
|
|
12
12
|
import { t as transformMat4, s as subtract } from '../../vendor/gl-matrix/esm/vec4.js';
|
|
13
13
|
|
|
14
14
|
var SlicingMode = Constants.SlicingMode;
|
|
15
|
-
var imgFragTemplate = "\n//VTK::Renderer::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Image::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n[[stage(fragment)]]\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output: fragmentOutput;\n\n //VTK::Image::Sample\n
|
|
15
|
+
var imgFragTemplate = "\n//VTK::Renderer::Dec\n\n//VTK::Mapper::Dec\n\n//VTK::TCoord::Dec\n\n//VTK::Image::Dec\n\n//VTK::RenderEncoder::Dec\n\n//VTK::IOStructs::Dec\n\n[[stage(fragment)]]\nfn main(\n//VTK::IOStructs::Input\n)\n//VTK::IOStructs::Output\n{\n var output: fragmentOutput;\n\n //VTK::Image::Sample\n\n // var computedColor: vec4<f32> = vec4<f32>(1.0,0.7, 0.5, 1.0);\n\n//VTK::RenderEncoder::Impl\n\n return output;\n}\n"; // ----------------------------------------------------------------------------
|
|
16
16
|
// helper methods
|
|
17
17
|
// ----------------------------------------------------------------------------
|
|
18
18
|
|
|
@@ -223,10 +223,16 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
223
223
|
|
|
224
224
|
{
|
|
225
225
|
for (var _i = 0; _i < model.rowLength; _i++) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
colorArray[
|
|
229
|
-
colorArray[
|
|
226
|
+
var _idx = c * model.rowLength * 8 + _i * 4;
|
|
227
|
+
|
|
228
|
+
colorArray[_idx] = 255.0 * tmpTable[_i * 3];
|
|
229
|
+
colorArray[_idx + 1] = 255.0 * tmpTable[_i * 3 + 1];
|
|
230
|
+
colorArray[_idx + 2] = 255.0 * tmpTable[_i * 3 + 2];
|
|
231
|
+
colorArray[_idx + 3] = 255.0;
|
|
232
|
+
|
|
233
|
+
for (var _j = 0; _j < 4; _j++) {
|
|
234
|
+
colorArray[_idx + model.rowLength * 4 + _j] = colorArray[_idx + _j];
|
|
235
|
+
}
|
|
230
236
|
}
|
|
231
237
|
}
|
|
232
238
|
}
|
|
@@ -238,8 +244,8 @@ function vtkWebGPUImageMapper(publicAPI, model) {
|
|
|
238
244
|
colorArray[_i2 * 4 + 2] = grey;
|
|
239
245
|
colorArray[_i2 * 4 + 3] = 255.0;
|
|
240
246
|
|
|
241
|
-
for (var
|
|
242
|
-
colorArray[_i2 * 4 + model.rowLength * 4 +
|
|
247
|
+
for (var _j2 = 0; _j2 < 4; _j2++) {
|
|
248
|
+
colorArray[_i2 * 4 + model.rowLength * 4 + _j2] = colorArray[_i2 * 4 + _j2];
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
251
|
}
|
|
@@ -22,11 +22,6 @@ function vtkWebGPURenderer(publicAPI, model) {
|
|
|
22
22
|
if (prepass) {
|
|
23
23
|
if (!model.renderable) {
|
|
24
24
|
return;
|
|
25
|
-
} // make sure we have a camera
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (!model.renderable.isActiveCameraCreated()) {
|
|
29
|
-
model.renderable.resetCamera();
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
publicAPI.updateLights();
|
|
@@ -89,7 +89,7 @@ function vtkWebGPUTexture(publicAPI, model) {
|
|
|
89
89
|
var bufferWidthInBytes = 256 * Math.floor((currWidthInBytes + 255) / 256);
|
|
90
90
|
var bufferWidth = bufferWidthInBytes / tDetails.elementSize;
|
|
91
91
|
var inWidth = currWidthInBytes / inArray.BYTES_PER_ELEMENT;
|
|
92
|
-
var outArray = macro.newTypedArray(
|
|
92
|
+
var outArray = macro.newTypedArray(inArray.constructor.name, bufferWidth * model.height * model.depth);
|
|
93
93
|
|
|
94
94
|
for (var v = 0; v < model.height * model.depth; v++) {
|
|
95
95
|
if (halfFloat) {
|
|
@@ -2,9 +2,9 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
4
4
|
import vtkCircleSource from '../../Filters/Sources/CircleSource.js';
|
|
5
|
+
import vtkContextRepresentation from './ContextRepresentation.js';
|
|
5
6
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
6
7
|
import vtkGlyph3DMapper from '../../Rendering/Core/Glyph3DMapper.js';
|
|
7
|
-
import vtkHandleRepresentation from './HandleRepresentation.js';
|
|
8
8
|
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
9
9
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
10
10
|
import vtkWidgetRepresentation from './WidgetRepresentation.js';
|
|
@@ -79,7 +79,7 @@ function vtkCircleContextRepresentation(publicAPI, model) {
|
|
|
79
79
|
model.transform = vtkMatrixBuilder.buildFromDegree(); // --------------------------------------------------------------------------
|
|
80
80
|
|
|
81
81
|
publicAPI.setGlyphResolution = macro.chain(publicAPI.setGlyphResolution, function (r) {
|
|
82
|
-
return model.glyph.setResolution(r);
|
|
82
|
+
return model.pipelines.circle.glyph.setResolution(r);
|
|
83
83
|
}); // --------------------------------------------------------------------------
|
|
84
84
|
|
|
85
85
|
publicAPI.setDrawBorder = function (draw) {
|
|
@@ -168,8 +168,6 @@ function vtkCircleContextRepresentation(publicAPI, model) {
|
|
|
168
168
|
// Initialization
|
|
169
169
|
// --------------------------------------------------------------------------
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
publicAPI.setActiveScaleFactor(1);
|
|
173
171
|
} // ----------------------------------------------------------------------------
|
|
174
172
|
// Object factory
|
|
175
173
|
// ----------------------------------------------------------------------------
|
|
@@ -185,7 +183,7 @@ var DEFAULT_VALUES = {
|
|
|
185
183
|
function extend(publicAPI, model) {
|
|
186
184
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
187
185
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
188
|
-
|
|
186
|
+
vtkContextRepresentation.extend(publicAPI, model, initialValues);
|
|
189
187
|
macro.setGet(publicAPI, model, ['glyphResolution', 'defaultScale']);
|
|
190
188
|
macro.get(publicAPI, model, ['glyph', 'mapper', 'actor']); // Object specific methods
|
|
191
189
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
2
|
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
3
|
-
import
|
|
3
|
+
import vtkContextRepresentation from './ContextRepresentation.js';
|
|
4
4
|
import vtkMapper from '../../Rendering/Core/Mapper.js';
|
|
5
5
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
6
6
|
import { a as subtract, d as dot } from '../../vendor/gl-matrix/esm/vec3.js';
|
|
@@ -104,7 +104,7 @@ var DEFAULT_VALUES = {
|
|
|
104
104
|
function extend(publicAPI, model) {
|
|
105
105
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
106
106
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
107
|
-
|
|
107
|
+
vtkContextRepresentation.extend(publicAPI, model, initialValues);
|
|
108
108
|
macro.setGetArray(publicAPI, model, ['color'], 1);
|
|
109
109
|
macro.get(publicAPI, model, ['mapper', 'actor']); // Object specific methods
|
|
110
110
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var VerticalTextAlignment = {
|
|
2
|
+
TOP: 'TOP',
|
|
3
|
+
BOTTOM: 'BOTTOM',
|
|
4
|
+
MIDDLE: 'MIDDLE'
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* fontSize can be a number or a string representing a size in px
|
|
8
|
+
* @param {Number|String} fontSize
|
|
9
|
+
* @returns Number representing the fontSize in pixels
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function fontSizeToPixels(fontProperties) {
|
|
13
|
+
var defaultFontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16;
|
|
14
|
+
|
|
15
|
+
if (fontProperties != null && fontProperties.fontSize) {
|
|
16
|
+
if (typeof fontProperties.fontSize === 'string') {
|
|
17
|
+
if (fontProperties.fontSize.slice(-2) === 'px') {
|
|
18
|
+
return window.devicePixelRatio * parseInt(fontProperties.fontSize, 10);
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
return window.devicePixelRatio * fontProperties.fontSize;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return window.devicePixelRatio * defaultFontSize;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { VerticalTextAlignment, VerticalTextAlignment as default, fontSizeToPixels };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkSVGRepresentation from './SVGRepresentation.js';
|
|
4
|
+
import { fontSizeToPixels, VerticalTextAlignment } from './SVGLandmarkRepresentation/Constants.js';
|
|
4
5
|
|
|
5
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
6
7
|
|
|
@@ -51,23 +52,36 @@ function vtkSVGLandmarkRepresentation(publicAPI, model) {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
var splitText = texts[i].split('\n');
|
|
54
|
-
var
|
|
55
|
+
var fontSize = fontSizeToPixels(model.fontProperties);
|
|
55
56
|
splitText.forEach(function (subText, j) {
|
|
56
57
|
var text = publicAPI.createListenableSvgElement('text', i);
|
|
57
58
|
Object.keys(model.textProps || {}).forEach(function (prop) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (model.offsetText === true && prop === 'dy') {
|
|
61
|
-
propValue = model.textProps.dy + newlineOffset * j;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
text.setAttribute(prop, propValue);
|
|
59
|
+
text.setAttribute(prop, model.textProps[prop]);
|
|
65
60
|
});
|
|
66
61
|
text.setAttribute('x', x);
|
|
67
|
-
text.setAttribute('y', y);
|
|
62
|
+
text.setAttribute('y', y); // Vertical offset (dy) calculation based on VerticalTextAlignment
|
|
63
|
+
|
|
64
|
+
var dy = model.textProps.dy ? model.textProps.dy : 0;
|
|
65
|
+
|
|
66
|
+
switch (model.textProps.verticalAlign) {
|
|
67
|
+
case VerticalTextAlignment.MIDDLE:
|
|
68
|
+
dy -= fontSize * (0.5 * splitText.length - j - 1);
|
|
69
|
+
break;
|
|
70
|
+
|
|
71
|
+
case VerticalTextAlignment.TOP:
|
|
72
|
+
dy += fontSize * (j + 1);
|
|
73
|
+
break;
|
|
74
|
+
|
|
75
|
+
case VerticalTextAlignment.BOTTOM:
|
|
76
|
+
default:
|
|
77
|
+
dy -= fontSize * (splitText.length - j - 1);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
text.setAttribute('dy', dy);
|
|
68
82
|
|
|
69
83
|
if (model.fontProperties != null) {
|
|
70
|
-
text.setAttribute('font-size',
|
|
84
|
+
text.setAttribute('font-size', fontSize);
|
|
71
85
|
text.setAttribute('font-family', model.fontProperties.fontFamily);
|
|
72
86
|
text.setAttribute('font-weight', model.fontProperties.fontStyle);
|
|
73
87
|
text.setAttribute('fill', model.fontProperties.fontColor);
|
|
@@ -91,27 +105,31 @@ function vtkSVGLandmarkRepresentation(publicAPI, model) {
|
|
|
91
105
|
// Object factory
|
|
92
106
|
// ----------------------------------------------------------------------------
|
|
93
107
|
|
|
108
|
+
/**
|
|
109
|
+
* textProps can contain any "svg" attribute (e.g. text-anchor, text-align,
|
|
110
|
+
* alignment-baseline...)
|
|
111
|
+
* @param {*} initialValues
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
|
|
94
115
|
|
|
95
116
|
function defaultValues(initialValues) {
|
|
96
|
-
return _objectSpread({
|
|
97
|
-
circleProps: {
|
|
117
|
+
return _objectSpread(_objectSpread({}, initialValues), {}, {
|
|
118
|
+
circleProps: _objectSpread({
|
|
98
119
|
r: 5,
|
|
99
120
|
stroke: 'red',
|
|
100
121
|
fill: 'red'
|
|
101
|
-
},
|
|
102
|
-
textProps: {
|
|
103
|
-
fill: 'white'
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
}, initialValues);
|
|
122
|
+
}, initialValues.circleProps),
|
|
123
|
+
textProps: _objectSpread({
|
|
124
|
+
fill: 'white'
|
|
125
|
+
}, initialValues.textProps)
|
|
126
|
+
});
|
|
108
127
|
} // ----------------------------------------------------------------------------
|
|
109
128
|
|
|
110
129
|
|
|
111
130
|
function extend(publicAPI, model) {
|
|
112
131
|
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
113
|
-
|
|
114
|
-
vtkSVGRepresentation.extend(publicAPI, model, initialValues);
|
|
132
|
+
vtkSVGRepresentation.extend(publicAPI, model, defaultValues(initialValues));
|
|
115
133
|
macro.setGet(publicAPI, model, ['circleProps', 'fontProperties', 'name', 'textProps']); // Object specific methods
|
|
116
134
|
|
|
117
135
|
vtkSVGLandmarkRepresentation(publicAPI, model);
|
|
@@ -6,7 +6,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
6
6
|
|
|
7
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
8
8
|
function widgetBehavior(publicAPI, model) {
|
|
9
|
-
|
|
9
|
+
model.shapeHandle = model.widgetState.getEllipseHandle();
|
|
10
|
+
model.point1Handle = model.widgetState.getPoint1Handle();
|
|
11
|
+
model.point2Handle = model.widgetState.getPoint2Handle();
|
|
12
|
+
model.point1Handle.setManipulator(model.manipulator);
|
|
13
|
+
model.point2Handle.setManipulator(model.manipulator); // We inherit shapeBehavior
|
|
14
|
+
|
|
10
15
|
widgetBehavior$1(publicAPI, model);
|
|
11
16
|
|
|
12
17
|
var superClass = _objectSpread({}, publicAPI);
|