@cornerstonejs/tools 4.21.9 → 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.
@@ -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) {
@@ -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
- colorArray[offset] = 255;
466
- colorArray[offset + 1] = 255;
467
- colorArray[offset + 2] = 255;
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;
@@ -1 +1 @@
1
- export declare const version = "4.21.9";
1
+ export declare const version = "4.22.0";
@@ -1 +1 @@
1
- export const version = '4.21.9';
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.21.9",
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.21.9",
108
+ "@cornerstonejs/core": "4.22.0",
109
109
  "canvas": "3.2.0"
110
110
  },
111
111
  "peerDependencies": {
112
- "@cornerstonejs/core": "4.21.9",
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": "a07de5c4e28ad71998f003cb29f5fb838c6abdf4"
131
+ "gitHead": "e38264452c2d9a0498a90fdbf1268e5ab1a26b2b"
132
132
  }