@cornerstonejs/tools 3.26.1 → 3.27.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.
@@ -1,11 +1,12 @@
1
1
  import { getEnabledElement } from '@cornerstonejs/core';
2
+ import { config as segmentationConfig } from '../../stateManagement/segmentation';
2
3
  import { BaseTool } from '../base';
3
4
  import { triggerSegmentationModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
4
5
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
5
6
  import { getActiveSegmentation } from '../../stateManagement/segmentation/activeSegmentation';
6
7
  import { getSegmentIndexAtWorldPoint } from '../../utilities/segmentation';
7
8
  import { state } from '../../store/state';
8
- import { drawLinkedTextBox as drawLinkedTextBoxSvg } from '../../drawingSvg';
9
+ import { drawTextBox as drawTextBoxSvg } from '../../drawingSvg';
9
10
  class SegmentLabelTool extends BaseTool {
10
11
  constructor(toolProps = {
11
12
  data: {
@@ -90,13 +91,14 @@ class SegmentLabelTool extends BaseTool {
90
91
  viewport,
91
92
  });
92
93
  const segment = activeSegmentation.segments[hoveredSegmentIndex];
94
+ const color = segmentationConfig.color.getSegmentIndexColor(viewport.id, segmentationId, hoveredSegmentIndex);
93
95
  const label = segment?.label;
94
96
  const canvasCoordinates = viewport.worldToCanvas(worldPoint);
95
97
  this._editData = {
96
98
  hoveredSegmentIndex,
97
99
  hoveredSegmentLabel: label,
98
100
  canvasCoordinates,
99
- worldPoint,
101
+ color,
100
102
  };
101
103
  if (!hoveredSegmentIndex || hoveredSegmentIndex === 0) {
102
104
  return;
@@ -111,12 +113,18 @@ class SegmentLabelTool extends BaseTool {
111
113
  return;
112
114
  }
113
115
  const { viewport } = enabledElement;
114
- const { hoveredSegmentIndex, hoveredSegmentLabel, canvasCoordinates, worldPoint, } = this._editData;
116
+ const { hoveredSegmentIndex, hoveredSegmentLabel, canvasCoordinates, color, } = this._editData;
115
117
  if (!hoveredSegmentIndex) {
116
118
  return;
117
119
  }
118
- const textBoxPosition = viewport.worldToCanvas(worldPoint);
119
- const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, 'segmentSelectLabelAnnotation', 'segmentSelectLabelTextBox', [hoveredSegmentLabel ? hoveredSegmentLabel : '(unnamed segment)'], textBoxPosition, [canvasCoordinates], {}, {});
120
+ const offset = -15;
121
+ const textBoxPosition = [
122
+ canvasCoordinates[0] + offset,
123
+ canvasCoordinates[1] + offset,
124
+ ];
125
+ const boundingBox = drawTextBoxSvg(svgDrawingHelper, 'segmentSelectLabelAnnotation', 'segmentSelectLabelTextBox', [hoveredSegmentLabel ?? '(unnamed segment)'], textBoxPosition, {
126
+ color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${color[3]})`,
127
+ });
120
128
  const left = canvasCoordinates[0];
121
129
  const top = canvasCoordinates[1];
122
130
  const { width, height } = boundingBox;
@@ -1 +1 @@
1
- export declare const version = "3.26.1";
1
+ export declare const version = "3.27.0";
@@ -1 +1 @@
1
- export const version = '3.26.1';
1
+ export const version = '3.27.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "3.26.1",
3
+ "version": "3.27.0",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "^3.1.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "^3.26.1",
111
+ "@cornerstonejs/core": "^3.27.0",
112
112
  "@kitware/vtk.js": "32.12.1",
113
113
  "@types/d3-array": "^3.0.4",
114
114
  "@types/d3-interpolate": "^3.0.1",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "36745015409a9516e8df43a1a7b126e7770ac776"
130
+ "gitHead": "877bed9dc602f121a7ec1da9941994d7d49da9ea"
131
131
  }