@kitware/vtk.js 26.0.0-beta.1 → 26.0.0-beta.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/Common/Core/ClassHierarchy.js +6 -11
- package/Common/Core/Math/Constants.js +12 -0
- package/Common/Core/Math/index.js +48 -29
- package/Common/Core/Math.d.ts +34 -4
- package/Common/Core/Math.js +2 -1
- package/Common/Core/MatrixBuilder.d.ts +13 -2
- package/Common/Core/MatrixBuilder.js +14 -2
- package/Common/Core/ScalarsToColors.d.ts +1 -3
- package/Common/Core/ScalarsToColors.js +1 -1
- package/Common/DataModel/BoundingBox.js +7 -7
- package/Common/DataModel/EdgeLocator.d.ts +79 -0
- package/Common/DataModel/EdgeLocator.js +85 -0
- package/Common/DataModel/ImageData.js +2 -50
- package/Common/DataModel/IncrementalOctreeNode.d.ts +15 -0
- package/Common/DataModel/IncrementalOctreeNode.js +27 -8
- package/Common/DataModel/IncrementalOctreePointLocator.js +61 -5
- package/Common/DataModel/Polygon.js +2 -2
- package/Common/Transform/Transform.js +51 -0
- package/Common/Transform.js +3 -1
- package/Filters/General/ClipClosedSurface.js +21 -18
- package/Filters/General/ContourTriangulator/helper.js +1 -1
- package/Filters/General/ImageMarchingCubes.js +5 -22
- package/Filters/General/ImageMarchingSquares.js +6 -23
- package/Filters/General.js +6 -0
- package/Imaging/Core/ImageReslice.js +84 -36
- package/Rendering/Core/ColorTransferFunction.d.ts +20 -0
- package/Rendering/Core/ColorTransferFunction.js +76 -7
- package/Rendering/Core/Prop3D.js +6 -1
- package/Rendering/Core/VolumeProperty.js +3 -2
- package/Rendering/OpenGL/PolyDataMapper.js +7 -5
- package/Rendering/OpenGL/RenderWindow.d.ts +25 -1
- package/Rendering/OpenGL/Texture.js +22 -6
- package/Rendering/OpenGL/VolumeMapper.js +3 -1
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/SceneGraph/RenderWindowViewNode.js +8 -2
- package/Rendering/SceneGraph/ViewNode.js +11 -0
- package/Widgets/Core/AbstractWidget.js +1 -1
- package/Widgets/Core/WidgetManager.js +39 -268
- package/Widgets/Representations/WidgetRepresentation.js +19 -7
- package/Widgets/Widgets3D/EllipseWidget.js +0 -7
- package/Widgets/Widgets3D/LabelWidget/behavior.js +0 -7
- package/Widgets/Widgets3D/LabelWidget.js +1 -18
- package/Widgets/Widgets3D/LineWidget/behavior.js +0 -44
- package/Widgets/Widgets3D/LineWidget.js +0 -11
- package/Widgets/Widgets3D/PolyLineWidget.js +0 -10
- package/Widgets/Widgets3D/RectangleWidget.js +0 -7
- package/Widgets/Widgets3D/ShapeWidget.js +1 -1
- package/index.d.ts +1 -0
- package/macros.d.ts +5 -3
- package/macros.js +41 -8
- package/package.json +4 -1
- package/Filters/General/ClipClosedSurface/ccsEdgeLocator.js +0 -40
- package/Widgets/Core/WidgetManager/vdom.js +0 -172
- package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +0 -28
- package/Widgets/SVG/SVGLandmarkRepresentation.js +0 -167
- package/Widgets/SVG/SVGRepresentation.js +0 -163
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import macro from '../../macros.js';
|
|
3
|
-
import vtkSVGRepresentation from './SVGRepresentation.js';
|
|
4
|
-
import { fontSizeToPixels, VerticalTextAlignment } from './SVGLandmarkRepresentation/Constants.js';
|
|
5
|
-
|
|
6
|
-
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; }
|
|
7
|
-
|
|
8
|
-
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; }
|
|
9
|
-
var createSvgElement = vtkSVGRepresentation.createSvgElement; // ----------------------------------------------------------------------------
|
|
10
|
-
// vtkSVGLandmarkRepresentation
|
|
11
|
-
// ----------------------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
function vtkSVGLandmarkRepresentation(publicAPI, model) {
|
|
14
|
-
// Set our className
|
|
15
|
-
model.classHierarchy.push('vtkSVGLandmarkRepresentation');
|
|
16
|
-
|
|
17
|
-
publicAPI.render = function () {
|
|
18
|
-
var list = publicAPI.getRepresentationStates();
|
|
19
|
-
|
|
20
|
-
if (!list.length) {
|
|
21
|
-
return createSvgElement('g');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var coords = [];
|
|
25
|
-
var texts = [];
|
|
26
|
-
list.forEach(function (state, index) {
|
|
27
|
-
if (state.getOrigin && state.getOrigin() && state.getVisible && state.getVisible()) {
|
|
28
|
-
coords.push(state.getOrigin());
|
|
29
|
-
texts.push(state.getText ? state.getText() : "L".concat(index));
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
var state = list[0];
|
|
33
|
-
var isActive = state.getActive();
|
|
34
|
-
return publicAPI.worldPointsToPixelSpace(coords).then(function (pixelSpace) {
|
|
35
|
-
var points2d = pixelSpace.coords;
|
|
36
|
-
var winHeight = pixelSpace.windowSize[1];
|
|
37
|
-
var root = createSvgElement('g');
|
|
38
|
-
|
|
39
|
-
var _loop = function _loop(i) {
|
|
40
|
-
var xy = points2d[i];
|
|
41
|
-
|
|
42
|
-
if (Number.isNaN(xy[0]) || Number.isNaN(xy[1])) {
|
|
43
|
-
return "continue"; // eslint-disable-line
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
var x = xy[0];
|
|
47
|
-
var y = winHeight - xy[1];
|
|
48
|
-
|
|
49
|
-
if (model.circleProps && model.circleProps.visible) {
|
|
50
|
-
var circle = publicAPI.createListenableSvgElement('circle', i);
|
|
51
|
-
Object.keys(model.circleProps || {}).forEach(function (prop) {
|
|
52
|
-
return circle.setAttribute(prop, model.circleProps[prop]);
|
|
53
|
-
});
|
|
54
|
-
circle.setAttribute('cx', x);
|
|
55
|
-
circle.setAttribute('cy', y);
|
|
56
|
-
root.appendChild(circle);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!texts[i]) {
|
|
60
|
-
texts[i] = '';
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var splitText = texts[i].split('\n');
|
|
64
|
-
var fontSize = fontSizeToPixels(model.fontProperties);
|
|
65
|
-
splitText.forEach(function (subText, j) {
|
|
66
|
-
var _model$textProps, _model$textProps2;
|
|
67
|
-
|
|
68
|
-
var text = publicAPI.createListenableSvgElement('text', i);
|
|
69
|
-
Object.keys(model.textProps || {}).forEach(function (prop) {
|
|
70
|
-
text.setAttribute(prop, model.textProps[prop]);
|
|
71
|
-
});
|
|
72
|
-
text.setAttribute('x', x);
|
|
73
|
-
text.setAttribute('y', y); // Vertical offset (dy) calculation based on VerticalTextAlignment
|
|
74
|
-
|
|
75
|
-
var dy = ((_model$textProps = model.textProps) === null || _model$textProps === void 0 ? void 0 : _model$textProps.dy) || 0;
|
|
76
|
-
|
|
77
|
-
switch ((_model$textProps2 = model.textProps) === null || _model$textProps2 === void 0 ? void 0 : _model$textProps2.verticalAlign) {
|
|
78
|
-
case VerticalTextAlignment.MIDDLE:
|
|
79
|
-
dy -= fontSize * (0.5 * splitText.length - j - 1);
|
|
80
|
-
break;
|
|
81
|
-
|
|
82
|
-
case VerticalTextAlignment.TOP:
|
|
83
|
-
dy += fontSize * (j + 1);
|
|
84
|
-
break;
|
|
85
|
-
|
|
86
|
-
case VerticalTextAlignment.BOTTOM:
|
|
87
|
-
default:
|
|
88
|
-
dy -= fontSize * (splitText.length - j - 1);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
text.setAttribute('dy', dy);
|
|
93
|
-
text.setAttribute('font-size', fontSize);
|
|
94
|
-
|
|
95
|
-
if (model.fontProperties && model.fontProperties.fontFamily) {
|
|
96
|
-
text.setAttribute('font-family', model.fontProperties.fontFamily);
|
|
97
|
-
} else if (isActive && model.strokeFontProperties && model.strokeFontProperties.fontFamily) {
|
|
98
|
-
text.setAttribute('font-family', model.strokeFontProperties.fontFamily);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (model.fontProperties && model.fontProperties.fontStyle) {
|
|
102
|
-
text.setAttribute('font-weight', model.fontProperties.fontStyle);
|
|
103
|
-
} else if (isActive && model.strokeFontProperties && model.strokeFontProperties.fontStyle) {
|
|
104
|
-
text.setAttribute('font-weight', model.strokeFontProperties.fontStyle);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (model.fontProperties && model.fontProperties.fontColor) {
|
|
108
|
-
text.setAttribute('fill', model.fontProperties.fontColor);
|
|
109
|
-
} else if (isActive && model.strokeFontProperties && model.strokeFontProperties.fontColor) {
|
|
110
|
-
text.setAttribute('fill', model.strokeFontProperties.fontColor);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
text.textContent = subText;
|
|
114
|
-
root.appendChild(text);
|
|
115
|
-
});
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
for (var i = 0; i < points2d.length; i++) {
|
|
119
|
-
var _ret = _loop(i);
|
|
120
|
-
|
|
121
|
-
if (_ret === "continue") continue;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return root;
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
} // ----------------------------------------------------------------------------
|
|
128
|
-
// Object factory
|
|
129
|
-
// ----------------------------------------------------------------------------
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* textProps can contain any "svg" attribute (e.g. text-anchor, text-align,
|
|
133
|
-
* alignment-baseline...)
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function defaultValues(initialValues) {
|
|
138
|
-
return _objectSpread(_objectSpread({}, initialValues), {}, {
|
|
139
|
-
circleProps: _objectSpread({
|
|
140
|
-
visible: false,
|
|
141
|
-
r: 5,
|
|
142
|
-
stroke: 'red',
|
|
143
|
-
fill: 'red'
|
|
144
|
-
}, initialValues.circleProps),
|
|
145
|
-
fontProperties: _objectSpread({
|
|
146
|
-
fontColor: 'white'
|
|
147
|
-
}, initialValues.fontProperties)
|
|
148
|
-
});
|
|
149
|
-
} // ----------------------------------------------------------------------------
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
function extend(publicAPI, model) {
|
|
153
|
-
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
154
|
-
vtkSVGRepresentation.extend(publicAPI, model, defaultValues(initialValues));
|
|
155
|
-
macro.setGet(publicAPI, model, ['circleProps', 'fontProperties', 'strokeFontProperties', 'textProps']); // Object specific methods
|
|
156
|
-
|
|
157
|
-
vtkSVGLandmarkRepresentation(publicAPI, model);
|
|
158
|
-
} // ----------------------------------------------------------------------------
|
|
159
|
-
|
|
160
|
-
var newInstance = macro.newInstance(extend, 'vtkSVGLandmarkRepresentation'); // ----------------------------------------------------------------------------
|
|
161
|
-
|
|
162
|
-
var vtkSVGLandmarkRepresentation$1 = {
|
|
163
|
-
extend: extend,
|
|
164
|
-
newInstance: newInstance
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export { vtkSVGLandmarkRepresentation$1 as default, extend, newInstance };
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import macro from '../../macros.js';
|
|
2
|
-
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
3
|
-
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
4
|
-
import vtkPixelSpaceCallbackMapper from '../../Rendering/Core/PixelSpaceCallbackMapper.js';
|
|
5
|
-
import vtkWidgetRepresentation from '../Representations/WidgetRepresentation.js';
|
|
6
|
-
import { Behavior } from '../Representations/WidgetRepresentation/Constants.js';
|
|
7
|
-
import { RenderingTypes } from '../Core/WidgetManager/Constants.js';
|
|
8
|
-
|
|
9
|
-
var SVG_XMLNS = 'http://www.w3.org/2000/svg'; // ----------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
function createSvgElement(tag) {
|
|
12
|
-
return {
|
|
13
|
-
name: tag,
|
|
14
|
-
attrs: {},
|
|
15
|
-
eventListeners: {},
|
|
16
|
-
// implies no children if set
|
|
17
|
-
textContent: null,
|
|
18
|
-
children: [],
|
|
19
|
-
setAttribute: function setAttribute(attr, val) {
|
|
20
|
-
this.attrs[attr] = val;
|
|
21
|
-
},
|
|
22
|
-
removeAttribute: function removeAttribute(attr) {
|
|
23
|
-
delete this.attrs[attr];
|
|
24
|
-
},
|
|
25
|
-
appendChild: function appendChild(n) {
|
|
26
|
-
this.children.push(n);
|
|
27
|
-
},
|
|
28
|
-
addEventListeners: function addEventListeners(event, callback) {
|
|
29
|
-
this.eventListeners[event] = callback;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
} // ----------------------------------------------------------------------------
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
function createSvgDomElement(tag) {
|
|
36
|
-
return document.createElementNS(SVG_XMLNS, tag);
|
|
37
|
-
} // ----------------------------------------------------------------------------
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
function defer() {
|
|
41
|
-
var resolve;
|
|
42
|
-
var reject;
|
|
43
|
-
var promise = new Promise(function (res, rej) {
|
|
44
|
-
resolve = res;
|
|
45
|
-
reject = rej;
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
promise: promise,
|
|
49
|
-
resolve: resolve,
|
|
50
|
-
reject: reject
|
|
51
|
-
};
|
|
52
|
-
} // ----------------------------------------------------------------------------
|
|
53
|
-
// vtkSVGRepresentation
|
|
54
|
-
// ----------------------------------------------------------------------------
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
function vtkSVGRepresentation(publicAPI, model) {
|
|
58
|
-
// Set our className
|
|
59
|
-
model.classHierarchy.push('vtkSVGRepresentation');
|
|
60
|
-
var deferred = null;
|
|
61
|
-
model.psActor = vtkActor.newInstance({
|
|
62
|
-
pickable: false,
|
|
63
|
-
_parentProp: publicAPI
|
|
64
|
-
});
|
|
65
|
-
model.psMapper = vtkPixelSpaceCallbackMapper.newInstance();
|
|
66
|
-
model.points = vtkPolyData.newInstance();
|
|
67
|
-
model.psMapper.setInputData(model.points);
|
|
68
|
-
model.psActor.setMapper(model.psMapper);
|
|
69
|
-
model.psMapper.setCallback(function () {
|
|
70
|
-
if (deferred) {
|
|
71
|
-
var d = deferred;
|
|
72
|
-
deferred = null;
|
|
73
|
-
d.resolve({
|
|
74
|
-
coords: arguments.length <= 0 ? undefined : arguments[0],
|
|
75
|
-
camera: arguments.length <= 1 ? undefined : arguments[1],
|
|
76
|
-
aspect: arguments.length <= 2 ? undefined : arguments[2],
|
|
77
|
-
depthValues: arguments.length <= 3 ? undefined : arguments[3],
|
|
78
|
-
windowSize: arguments.length <= 4 ? undefined : arguments[4]
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
publicAPI.addActor(model.psActor); // --------------------------------------------------------------------------
|
|
83
|
-
|
|
84
|
-
publicAPI.worldPointsToPixelSpace = function (points3d) {
|
|
85
|
-
var pts = new Float32Array(points3d.length * 3);
|
|
86
|
-
|
|
87
|
-
for (var i = 0; i < points3d.length; i++) {
|
|
88
|
-
pts[i * 3 + 0] = points3d[i][0];
|
|
89
|
-
pts[i * 3 + 1] = points3d[i][1];
|
|
90
|
-
pts[i * 3 + 2] = points3d[i][2];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
model.points.getPoints().setData(pts);
|
|
94
|
-
model.points.modified();
|
|
95
|
-
deferred = defer();
|
|
96
|
-
return deferred.promise;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
publicAPI.createListenableSvgElement = function (tag, id) {
|
|
100
|
-
var element = createSvgElement(tag);
|
|
101
|
-
|
|
102
|
-
if (model.pickable) {
|
|
103
|
-
element.addEventListeners('mouseenter', function () {
|
|
104
|
-
publicAPI.setHover(id);
|
|
105
|
-
});
|
|
106
|
-
element.addEventListeners('mouseleave', function () {
|
|
107
|
-
if (publicAPI.getHover() === id) {
|
|
108
|
-
publicAPI.setHover(null);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return element;
|
|
114
|
-
}; // --------------------------------------------------------------------------
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
publicAPI.updateActorVisibility = function () {
|
|
118
|
-
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : RenderingTypes.FRONT_BUFFER;
|
|
119
|
-
var ctxVisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
120
|
-
var handleVisible = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
121
|
-
|
|
122
|
-
if (model.behavior === Behavior.CONTEXT) {
|
|
123
|
-
publicAPI.setVisibility(ctxVisible);
|
|
124
|
-
} else if (model.behavior === Behavior.HANDLE) {
|
|
125
|
-
publicAPI.setVisibility(handleVisible);
|
|
126
|
-
}
|
|
127
|
-
}; // --------------------------------------------------------------------------
|
|
128
|
-
// Subclasses must implement this method
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
publicAPI.render = function () {
|
|
132
|
-
throw new Error('Not implemented');
|
|
133
|
-
};
|
|
134
|
-
} // ----------------------------------------------------------------------------
|
|
135
|
-
// Object factory
|
|
136
|
-
// ----------------------------------------------------------------------------
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* 'hover' is not null when a pickable SVG element is mouse hovered.
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
var DEFAULT_VALUES = {
|
|
144
|
-
visibility: true
|
|
145
|
-
}; // ----------------------------------------------------------------------------
|
|
146
|
-
|
|
147
|
-
function extend(publicAPI, model) {
|
|
148
|
-
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
149
|
-
Object.assign(model, DEFAULT_VALUES, initialValues); // Extend methods
|
|
150
|
-
|
|
151
|
-
vtkWidgetRepresentation.extend(publicAPI, model, initialValues);
|
|
152
|
-
macro.setGet(publicAPI, model, ['visibility', 'hover']); // Object specific methods
|
|
153
|
-
|
|
154
|
-
vtkSVGRepresentation(publicAPI, model);
|
|
155
|
-
} // ----------------------------------------------------------------------------
|
|
156
|
-
|
|
157
|
-
var vtkSVGRepresentation$1 = {
|
|
158
|
-
extend: extend,
|
|
159
|
-
createSvgElement: createSvgElement,
|
|
160
|
-
createSvgDomElement: createSvgDomElement
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export { vtkSVGRepresentation$1 as default, extend };
|