@cornerstonejs/tools 4.21.8 → 4.22.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.
- package/dist/esm/tools/OrientationControllerTool.d.ts +5 -0
- package/dist/esm/tools/OrientationControllerTool.js +10 -0
- package/dist/esm/tools/VolumeCroppingTool.js +21 -13
- package/dist/esm/utilities/vtkjs/AnnotatedRhombicuboctahedronActor/index.js +2 -2
- package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.d.ts +8 -0
- package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.js +35 -4
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +4 -4
|
@@ -18,6 +18,11 @@ declare class OrientationControllerTool extends BaseTool {
|
|
|
18
18
|
showEdgeFaces: boolean;
|
|
19
19
|
showCornerFaces: boolean;
|
|
20
20
|
keepOrientationUp: boolean;
|
|
21
|
+
highlightColor: number[];
|
|
22
|
+
edgeColor: number[];
|
|
23
|
+
cornerColor: number[];
|
|
24
|
+
restingAmbient: number;
|
|
25
|
+
hoverAmbient: number;
|
|
21
26
|
};
|
|
22
27
|
});
|
|
23
28
|
private _getViewportsInfo;
|
|
@@ -78,6 +78,11 @@ class OrientationControllerTool extends BaseTool {
|
|
|
78
78
|
showEdgeFaces: true,
|
|
79
79
|
showCornerFaces: true,
|
|
80
80
|
keepOrientationUp: true,
|
|
81
|
+
highlightColor: [255, 255, 255],
|
|
82
|
+
edgeColor: [200, 200, 200],
|
|
83
|
+
cornerColor: [150, 150, 150],
|
|
84
|
+
restingAmbient: 1.0,
|
|
85
|
+
hoverAmbient: 1.0,
|
|
81
86
|
},
|
|
82
87
|
}) {
|
|
83
88
|
super(toolProps, defaultToolProps);
|
|
@@ -258,6 +263,11 @@ class OrientationControllerTool extends BaseTool {
|
|
|
258
263
|
opacity: this.configuration.opacity ?? 1.0,
|
|
259
264
|
showEdgeFaces: this.configuration.showEdgeFaces !== false,
|
|
260
265
|
showCornerFaces: this.configuration.showCornerFaces !== false,
|
|
266
|
+
highlightColor: this.configuration.highlightColor ?? [255, 255, 255],
|
|
267
|
+
edgeColor: this.configuration.edgeColor ?? [200, 200, 200],
|
|
268
|
+
cornerColor: this.configuration.cornerColor ?? [150, 150, 150],
|
|
269
|
+
restingAmbient: this.configuration.restingAmbient ?? 1.0,
|
|
270
|
+
hoverAmbient: this.configuration.hoverAmbient ?? 1.0,
|
|
261
271
|
});
|
|
262
272
|
}
|
|
263
273
|
addMarkerToViewport(viewportId, renderingEngineId) {
|
|
@@ -66,8 +66,10 @@ class VolumeCroppingTool extends BaseTool {
|
|
|
66
66
|
const enabledElement = getEnabledElement(element);
|
|
67
67
|
const { viewport } = enabledElement;
|
|
68
68
|
this.suppressPlaneRotationForCurrentDrag = isDragOwnedBy(viewport.id, 'orientation-controller');
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const actor = this._getVolumeActor(viewport);
|
|
70
|
+
if (!actor) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
71
73
|
const mapper = actor.getMapper();
|
|
72
74
|
const mouseCanvas = [
|
|
73
75
|
evt.detail.currentPoints.canvas[0],
|
|
@@ -296,12 +298,12 @@ class VolumeCroppingTool extends BaseTool {
|
|
|
296
298
|
if (!viewport) {
|
|
297
299
|
return;
|
|
298
300
|
}
|
|
299
|
-
const
|
|
300
|
-
if (!
|
|
301
|
+
const volumeActor = this._getVolumeActor(viewport);
|
|
302
|
+
if (!volumeActor) {
|
|
301
303
|
console.warn('VolumeCroppingTool: No volume actors found in the viewport.');
|
|
302
304
|
return;
|
|
303
305
|
}
|
|
304
|
-
const imageData =
|
|
306
|
+
const imageData = volumeActor.getMapper().getInputData();
|
|
305
307
|
if (!imageData) {
|
|
306
308
|
console.warn('VolumeCroppingTool: No image data found for volume actor.');
|
|
307
309
|
return;
|
|
@@ -423,9 +425,7 @@ class VolumeCroppingTool extends BaseTool {
|
|
|
423
425
|
this.edgeLines[uid] = { actor, source, key1, key2 };
|
|
424
426
|
}
|
|
425
427
|
});
|
|
426
|
-
const mapper =
|
|
427
|
-
.getDefaultActor()
|
|
428
|
-
.actor.getMapper();
|
|
428
|
+
const mapper = volumeActor.getMapper();
|
|
429
429
|
mapper.addClippingPlane(planeXMin);
|
|
430
430
|
mapper.addClippingPlane(planeXMax);
|
|
431
431
|
mapper.addClippingPlane(planeYMin);
|
|
@@ -883,9 +883,11 @@ class VolumeCroppingTool extends BaseTool {
|
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
885
|
_updateClippingPlanes(viewport) {
|
|
886
|
-
const
|
|
887
|
-
const
|
|
888
|
-
|
|
886
|
+
const actor = this._getVolumeActor(viewport);
|
|
887
|
+
const mapper = this._getVolumeMapper(viewport);
|
|
888
|
+
if (!actor || !mapper) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
889
891
|
const matrix = actor.getMatrix();
|
|
890
892
|
if (!this.configuration.showClippingPlanes) {
|
|
891
893
|
mapper.removeAllClippingPlanes();
|
|
@@ -1022,7 +1024,10 @@ class VolumeCroppingTool extends BaseTool {
|
|
|
1022
1024
|
}
|
|
1023
1025
|
_getVolumeActor(viewport) {
|
|
1024
1026
|
const vp = viewport || this._getViewport();
|
|
1025
|
-
return vp
|
|
1027
|
+
return vp
|
|
1028
|
+
?.getActors?.()
|
|
1029
|
+
?.find((entry) => entry.actor?.getClassName?.() === 'vtkVolume')
|
|
1030
|
+
?.actor;
|
|
1026
1031
|
}
|
|
1027
1032
|
_getVolumeMapper(viewport) {
|
|
1028
1033
|
const actor = this._getVolumeActor(viewport);
|
|
@@ -1039,7 +1044,10 @@ class VolumeCroppingTool extends BaseTool {
|
|
|
1039
1044
|
}
|
|
1040
1045
|
}
|
|
1041
1046
|
_updateClippingPlanesFromFaceSpheres(viewport) {
|
|
1042
|
-
const mapper =
|
|
1047
|
+
const mapper = this._getVolumeMapper(viewport);
|
|
1048
|
+
if (!mapper) {
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1043
1051
|
this.originalClippingPlanes[PLANEINDEX.XMIN].origin = [
|
|
1044
1052
|
...this.sphereStates[SPHEREINDEX.XMIN].point,
|
|
1045
1053
|
];
|
|
@@ -242,7 +242,7 @@ function vtkAnnotatedRhombicuboctahedronActor(publicAPI, model) {
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
if (model.showEdgeFaces !== false) {
|
|
245
|
-
const edgeColor = [200, 200, 200];
|
|
245
|
+
const edgeColor = model.edgeColor ?? [200, 200, 200];
|
|
246
246
|
const edgeData = createEdgeFacesMesh(sourceScale, edgeColor);
|
|
247
247
|
if (edgeData) {
|
|
248
248
|
const edgeFacesActor = vtkActor.newInstance();
|
|
@@ -263,7 +263,7 @@ function vtkAnnotatedRhombicuboctahedronActor(publicAPI, model) {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
if (model.showCornerFaces !== false) {
|
|
266
|
-
const cornerColor = [150, 150, 150];
|
|
266
|
+
const cornerColor = model.cornerColor ?? [150, 150, 150];
|
|
267
267
|
const cornerData = createCornerFacesMesh(sourceScale, cornerColor);
|
|
268
268
|
if (cornerData) {
|
|
269
269
|
const cornerFacesActor = vtkActor.newInstance();
|
|
@@ -18,6 +18,11 @@ export interface OrientationControllerConfig {
|
|
|
18
18
|
opacity: number;
|
|
19
19
|
showEdgeFaces: boolean;
|
|
20
20
|
showCornerFaces: boolean;
|
|
21
|
+
highlightColor?: number[];
|
|
22
|
+
edgeColor?: number[];
|
|
23
|
+
cornerColor?: number[];
|
|
24
|
+
restingAmbient?: number;
|
|
25
|
+
hoverAmbient?: number;
|
|
21
26
|
}
|
|
22
27
|
export interface PickResult {
|
|
23
28
|
pickedActor: vtkActor;
|
|
@@ -39,6 +44,9 @@ export declare class vtkOrientationControllerWidget {
|
|
|
39
44
|
private renderWindows;
|
|
40
45
|
private highlightedFace;
|
|
41
46
|
private mouseHandlers;
|
|
47
|
+
private _highlightColor;
|
|
48
|
+
private _restingAmbient;
|
|
49
|
+
private _hoverAmbient;
|
|
42
50
|
createActors(config: OrientationControllerConfig): vtkActor[];
|
|
43
51
|
addActorsToViewport(viewportId: string, viewport: Types.IVolumeViewport, actors: vtkActor[]): void;
|
|
44
52
|
removeActorsFromViewport(viewportId: string, _viewport: Types.IVolumeViewport): void;
|
|
@@ -16,6 +16,9 @@ export class vtkOrientationControllerWidget {
|
|
|
16
16
|
this.renderWindows = new Map();
|
|
17
17
|
this.highlightedFace = null;
|
|
18
18
|
this.mouseHandlers = new Map();
|
|
19
|
+
this._highlightColor = [255, 255, 255];
|
|
20
|
+
this._restingAmbient = 1.0;
|
|
21
|
+
this._hoverAmbient = 1.0;
|
|
19
22
|
}
|
|
20
23
|
createActors(config) {
|
|
21
24
|
const rgbToHex = (rgb) => {
|
|
@@ -29,7 +32,10 @@ export class vtkOrientationControllerWidget {
|
|
|
29
32
|
const rgbToHexColor = (rgb) => {
|
|
30
33
|
return `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
|
|
31
34
|
};
|
|
32
|
-
const actorFactory = vtkAnnotatedRhombicuboctahedronActor.newInstance(
|
|
35
|
+
const actorFactory = vtkAnnotatedRhombicuboctahedronActor.newInstance({
|
|
36
|
+
edgeColor: config.edgeColor ?? [200, 200, 200],
|
|
37
|
+
cornerColor: config.cornerColor ?? [150, 150, 150],
|
|
38
|
+
});
|
|
33
39
|
const defaultStyle = {
|
|
34
40
|
fontStyle: 'bold',
|
|
35
41
|
fontFamily: 'Arial',
|
|
@@ -79,9 +85,13 @@ export class vtkOrientationControllerWidget {
|
|
|
79
85
|
actorFactory.setShowEdgeFaces(config.showEdgeFaces);
|
|
80
86
|
actorFactory.setShowCornerFaces(config.showCornerFaces);
|
|
81
87
|
const actors = actorFactory.getActors();
|
|
88
|
+
this._highlightColor = config.highlightColor ?? [255, 255, 255];
|
|
89
|
+
this._restingAmbient = config.restingAmbient ?? 1.0;
|
|
90
|
+
this._hoverAmbient = config.hoverAmbient ?? 1.0;
|
|
82
91
|
actors.forEach((actor) => {
|
|
83
92
|
const property = actor.getProperty();
|
|
84
93
|
property.setOpacity(config.opacity);
|
|
94
|
+
property.setAmbient(this._restingAmbient);
|
|
85
95
|
actor.setVisibility(true);
|
|
86
96
|
});
|
|
87
97
|
return actors;
|
|
@@ -462,9 +472,10 @@ export class vtkOrientationControllerWidget {
|
|
|
462
472
|
viewport,
|
|
463
473
|
isMainFace: false,
|
|
464
474
|
};
|
|
465
|
-
|
|
466
|
-
colorArray[offset
|
|
467
|
-
colorArray[offset +
|
|
475
|
+
const hc = this._highlightColor;
|
|
476
|
+
colorArray[offset] = hc[0];
|
|
477
|
+
colorArray[offset + 1] = hc[1];
|
|
478
|
+
colorArray[offset + 2] = hc[2];
|
|
468
479
|
colorArray[offset + 3] = 255;
|
|
469
480
|
colors.modified();
|
|
470
481
|
inputData.modified();
|
|
@@ -533,6 +544,14 @@ export class vtkOrientationControllerWidget {
|
|
|
533
544
|
}
|
|
534
545
|
setupMouseHandlers(viewportId, element, viewport, actors, callbacks) {
|
|
535
546
|
let isMouseDown = false;
|
|
547
|
+
let isCubeHovered = false;
|
|
548
|
+
const setAmbient = (full) => {
|
|
549
|
+
actors.forEach((actor) => {
|
|
550
|
+
const property = actor.getProperty();
|
|
551
|
+
property.setAmbient(full ? this._hoverAmbient : this._restingAmbient);
|
|
552
|
+
});
|
|
553
|
+
viewport.render();
|
|
554
|
+
};
|
|
536
555
|
let didDrag = false;
|
|
537
556
|
let pendingPickResult = null;
|
|
538
557
|
let mouseDownCanvas = null;
|
|
@@ -550,6 +569,10 @@ export class vtkOrientationControllerWidget {
|
|
|
550
569
|
}
|
|
551
570
|
const pickResult = this.pickAtPosition(evt, viewportId, viewport, element, actors);
|
|
552
571
|
if (pickResult) {
|
|
572
|
+
if (!isCubeHovered) {
|
|
573
|
+
isCubeHovered = true;
|
|
574
|
+
setAmbient(true);
|
|
575
|
+
}
|
|
553
576
|
const { pickedActor, cellId, actorIndex } = pickResult;
|
|
554
577
|
this.highlightFace(pickedActor, cellId, viewport, actorIndex === 0);
|
|
555
578
|
if (callbacks.onFaceHover) {
|
|
@@ -557,6 +580,10 @@ export class vtkOrientationControllerWidget {
|
|
|
557
580
|
}
|
|
558
581
|
}
|
|
559
582
|
else {
|
|
583
|
+
if (isCubeHovered) {
|
|
584
|
+
isCubeHovered = false;
|
|
585
|
+
setAmbient(false);
|
|
586
|
+
}
|
|
560
587
|
this.clearHighlight();
|
|
561
588
|
if (callbacks.onFaceHover) {
|
|
562
589
|
callbacks.onFaceHover(null);
|
|
@@ -595,6 +622,10 @@ export class vtkOrientationControllerWidget {
|
|
|
595
622
|
evt.stopPropagation();
|
|
596
623
|
}
|
|
597
624
|
isMouseDown = false;
|
|
625
|
+
if (isCubeHovered) {
|
|
626
|
+
isCubeHovered = false;
|
|
627
|
+
setAmbient(false);
|
|
628
|
+
}
|
|
598
629
|
didDrag = false;
|
|
599
630
|
pendingPickResult = null;
|
|
600
631
|
mouseDownCanvas = null;
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.
|
|
1
|
+
export declare const version = "4.22.0";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.
|
|
1
|
+
export const version = '4.22.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.22.0",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -105,11 +105,11 @@
|
|
|
105
105
|
"lodash.get": "4.4.2"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@cornerstonejs/core": "4.
|
|
108
|
+
"@cornerstonejs/core": "4.22.0",
|
|
109
109
|
"canvas": "3.2.0"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
|
-
"@cornerstonejs/core": "4.
|
|
112
|
+
"@cornerstonejs/core": "4.22.0",
|
|
113
113
|
"@kitware/vtk.js": "34.15.1",
|
|
114
114
|
"@types/d3-array": "3.2.1",
|
|
115
115
|
"@types/d3-interpolate": "3.0.4",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"type": "individual",
|
|
129
129
|
"url": "https://ohif.org/donate"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "e38264452c2d9a0498a90fdbf1268e5ab1a26b2b"
|
|
132
132
|
}
|