@kitware/vtk.js 24.12.0 → 24.12.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.
|
@@ -1,57 +1,58 @@
|
|
|
1
1
|
import vtkStateBuilder from '../../Core/StateBuilder.js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
builder.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
2
|
+
import { AXES, handleTypeFromName } from './helpers.js';
|
|
3
|
+
|
|
4
|
+
function build() {
|
|
5
|
+
// create our state builder
|
|
6
|
+
var builder = vtkStateBuilder.createBuilder(); // add image data description fields
|
|
7
|
+
|
|
8
|
+
builder.addField({
|
|
9
|
+
name: 'indexToWorldT',
|
|
10
|
+
initialValue: Array(16).fill(0)
|
|
11
|
+
}).addField({
|
|
12
|
+
name: 'worldToIndexT',
|
|
13
|
+
initialValue: Array(16).fill(0)
|
|
14
|
+
}); // make cropping planes a sub-state so we can listen to it
|
|
15
|
+
// separately from the rest of the widget state.
|
|
16
|
+
|
|
17
|
+
var croppingState = vtkStateBuilder.createBuilder().addField({
|
|
18
|
+
name: 'planes',
|
|
19
|
+
// index space
|
|
20
|
+
initialValue: [0, 1, 0, 1, 0, 1]
|
|
21
|
+
}).build(); // add cropping planes state to our primary state
|
|
22
|
+
|
|
23
|
+
builder.addStateFromInstance({
|
|
24
|
+
labels: ['croppingPlanes'],
|
|
25
|
+
name: 'croppingPlanes',
|
|
26
|
+
instance: croppingState
|
|
27
|
+
}); // add all handle states
|
|
28
|
+
// default bounds is [-1, 1] in all dimensions
|
|
29
|
+
|
|
30
|
+
for (var i = -1; i < 2; i++) {
|
|
31
|
+
for (var j = -1; j < 2; j++) {
|
|
32
|
+
for (var k = -1; k < 2; k++) {
|
|
33
|
+
// skip center of box
|
|
34
|
+
if (i !== 0 || j !== 0 || k !== 0) {
|
|
35
|
+
var name = AXES[i + 1] + AXES[j + 1] + AXES[k + 1];
|
|
36
|
+
var type = handleTypeFromName(name); // since handle states are rendered via vtkSphereHandleRepresentation,
|
|
37
|
+
// we can dictate the handle origin, size (scale1), color, and visibility.
|
|
38
|
+
|
|
39
|
+
builder.addStateFromMixin({
|
|
40
|
+
labels: ['handles', name, type],
|
|
41
|
+
mixins: ['name', 'origin', 'color', 'scale1', 'visible', 'manipulator'],
|
|
42
|
+
name: name,
|
|
43
|
+
initialValues: {
|
|
44
|
+
scale1: 10,
|
|
45
|
+
origin: [i, j, k],
|
|
46
|
+
visible: true,
|
|
47
|
+
name: name
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
}
|
|
52
54
|
|
|
53
|
-
var state = (function () {
|
|
54
55
|
return builder.build();
|
|
55
|
-
}
|
|
56
|
+
}
|
|
56
57
|
|
|
57
|
-
export {
|
|
58
|
+
export { build as default };
|
|
@@ -8,7 +8,7 @@ import vtkLineManipulator from '../Manipulators/LineManipulator.js';
|
|
|
8
8
|
import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
|
|
9
9
|
import vtkCroppingOutlineRepresentation from '../Representations/CroppingOutlineRepresentation.js';
|
|
10
10
|
import widgetBehavior from './ImageCroppingWidget/behavior.js';
|
|
11
|
-
import
|
|
11
|
+
import build from './ImageCroppingWidget/state.js';
|
|
12
12
|
import { transformVec3, AXES } from './ImageCroppingWidget/helpers.js';
|
|
13
13
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
14
14
|
|
|
@@ -101,7 +101,7 @@ function vtkImageCroppingWidget(publicAPI, model) {
|
|
|
101
101
|
}); // --- Widget Requirement ---------------------------------------------------
|
|
102
102
|
|
|
103
103
|
model.behavior = widgetBehavior;
|
|
104
|
-
model.widgetState =
|
|
104
|
+
model.widgetState = build(); // Given a view type (geometry, slice, volume), return a description
|
|
105
105
|
// of what representations to create and what widget state to pass
|
|
106
106
|
// to the respective representations.
|
|
107
107
|
|