@cornerstonejs/tools 3.9.5 → 3.10.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.
@@ -11,7 +11,7 @@ import * as Types from './types';
11
11
  import * as annotation from './stateManagement/annotation';
12
12
  import * as segmentation from './stateManagement/segmentation';
13
13
  import * as splines from './tools/annotation/splines';
14
- import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool } from './tools';
14
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool } from './tools';
15
15
  import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
16
16
  import * as Enums from './enums';
17
- export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, splines, };
17
+ export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, splines, };
package/dist/esm/index.js CHANGED
@@ -11,7 +11,7 @@ import * as Types from './types';
11
11
  import * as annotation from './stateManagement/annotation';
12
12
  import * as segmentation from './stateManagement/segmentation';
13
13
  import * as splines from './tools/annotation/splines';
14
- import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, } from './tools';
14
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, } from './tools';
15
15
  import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
16
16
  import * as Enums from './enums';
17
- export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, splines, };
17
+ export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, splines, };
@@ -55,4 +55,5 @@ import OrientationMarkerTool from './OrientationMarkerTool';
55
55
  import SegmentSelectTool from './segmentation/SegmentSelectTool';
56
56
  import SegmentBidirectionalTool from './segmentation/SegmentBidirectionalTool';
57
57
  import * as strategies from './segmentation/strategies';
58
- export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, strategies, };
58
+ import SegmentLabelTool from './segmentation/SegmentLabelTool';
59
+ export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, SegmentLabelTool, strategies, };
@@ -55,4 +55,5 @@ import OrientationMarkerTool from './OrientationMarkerTool';
55
55
  import SegmentSelectTool from './segmentation/SegmentSelectTool';
56
56
  import SegmentBidirectionalTool from './segmentation/SegmentBidirectionalTool';
57
57
  import * as strategies from './segmentation/strategies';
58
- export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, strategies, };
58
+ import SegmentLabelTool from './segmentation/SegmentLabelTool';
59
+ export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, SegmentLabelTool, strategies, };
@@ -0,0 +1,19 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import { BaseTool } from '../base';
3
+ import type { PublicToolProps, ToolProps, EventTypes, SVGDrawingHelper } from '../../types';
4
+ import type { Segmentation } from '../../types/SegmentationStateTypes';
5
+ declare class SegmentLabelTool extends BaseTool {
6
+ static toolName: any;
7
+ private hoverTimer;
8
+ private data;
9
+ private _editData;
10
+ constructor(toolProps?: PublicToolProps & Record<string, unknown>, defaultToolProps?: ToolProps);
11
+ mouseMoveCallback: (evt: EventTypes.InteractionEventType) => boolean;
12
+ onSetToolEnabled: () => void;
13
+ onSetToolActive: () => void;
14
+ onSetToolDisabled: () => void;
15
+ _setHoveredSegment(evt?: EventTypes.InteractionEventType): void;
16
+ _setHoveredSegmentForType(activeSegmentation: Segmentation, worldPoint: Types.Point3, viewport: Types.IStackViewport | Types.IVolumeViewport): void;
17
+ renderAnnotation(enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper): void;
18
+ }
19
+ export default SegmentLabelTool;
@@ -0,0 +1,132 @@
1
+ import { getEnabledElement } from '@cornerstonejs/core';
2
+ import { BaseTool } from '../base';
3
+ import { triggerSegmentationModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
4
+ import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
5
+ import { getActiveSegmentation } from '../../stateManagement/segmentation/activeSegmentation';
6
+ import { getSegmentIndexAtWorldPoint } from '../../utilities/segmentation';
7
+ import { state } from '../../store/state';
8
+ import { drawLinkedTextBox as drawLinkedTextBoxSvg } from '../../drawingSvg';
9
+ class SegmentLabelTool extends BaseTool {
10
+ constructor(toolProps = {
11
+ data: {
12
+ handles: {
13
+ textBox: {
14
+ worldPosition: [0, 0, 0],
15
+ worldBoundingBox: {
16
+ topLeft: [0, 0, 0],
17
+ topRight: [0, 0, 0],
18
+ bottomLeft: [0, 0, 0],
19
+ bottomRight: [0, 0, 0],
20
+ },
21
+ },
22
+ },
23
+ },
24
+ }, defaultToolProps = {
25
+ supportedInteractionTypes: ['Mouse', 'Touch'],
26
+ configuration: {
27
+ hoverTimeout: 100,
28
+ searchRadius: 6,
29
+ },
30
+ }) {
31
+ super(toolProps, defaultToolProps);
32
+ this.mouseMoveCallback = (evt) => {
33
+ if (this.hoverTimer) {
34
+ clearTimeout(this.hoverTimer);
35
+ }
36
+ this.hoverTimer = setTimeout(() => {
37
+ this._setHoveredSegment(evt);
38
+ this.hoverTimer = null;
39
+ }, this.configuration.hoverTimeout);
40
+ return true;
41
+ };
42
+ this.onSetToolEnabled = () => {
43
+ this.onSetToolActive();
44
+ };
45
+ this.onSetToolActive = () => {
46
+ this.hoverTimer = null;
47
+ };
48
+ this.onSetToolDisabled = () => {
49
+ this.hoverTimer = null;
50
+ };
51
+ this.data = toolProps.data ?? {
52
+ handles: {
53
+ textBox: {
54
+ worldPosition: [0, 0, 0],
55
+ worldBoundingBox: {
56
+ topLeft: [0, 0, 0],
57
+ topRight: [0, 0, 0],
58
+ bottomLeft: [0, 0, 0],
59
+ bottomRight: [0, 0, 0],
60
+ },
61
+ },
62
+ },
63
+ };
64
+ this.hoverTimer = null;
65
+ }
66
+ _setHoveredSegment(evt = {}) {
67
+ if (state.isInteractingWithTool) {
68
+ return;
69
+ }
70
+ const { element, currentPoints } = evt.detail;
71
+ const worldPoint = currentPoints.world;
72
+ const enabledElement = getEnabledElement(element);
73
+ if (!enabledElement) {
74
+ return;
75
+ }
76
+ const { viewport } = enabledElement;
77
+ const activeSegmentation = getActiveSegmentation(viewport.id);
78
+ if (!activeSegmentation) {
79
+ return;
80
+ }
81
+ this._setHoveredSegmentForType(activeSegmentation, worldPoint, viewport);
82
+ }
83
+ _setHoveredSegmentForType(activeSegmentation, worldPoint, viewport) {
84
+ const imageDataInfo = viewport.getImageData();
85
+ if (!imageDataInfo) {
86
+ return;
87
+ }
88
+ const { segmentationId } = activeSegmentation;
89
+ const hoveredSegmentIndex = getSegmentIndexAtWorldPoint(segmentationId, worldPoint, {
90
+ viewport,
91
+ });
92
+ const segment = activeSegmentation.segments[hoveredSegmentIndex];
93
+ const label = segment?.label;
94
+ const canvasCoordinates = viewport.worldToCanvas(worldPoint);
95
+ this._editData = {
96
+ hoveredSegmentIndex,
97
+ hoveredSegmentLabel: label,
98
+ canvasCoordinates,
99
+ worldPoint,
100
+ };
101
+ if (!hoveredSegmentIndex || hoveredSegmentIndex === 0) {
102
+ return;
103
+ }
104
+ const renderingEngine = viewport.getRenderingEngine();
105
+ const viewportIds = renderingEngine.getViewports().map((v) => v.id);
106
+ triggerSegmentationModified(segmentationId);
107
+ triggerAnnotationRenderForViewportIds(viewportIds);
108
+ }
109
+ renderAnnotation(enabledElement, svgDrawingHelper) {
110
+ if (!this._editData) {
111
+ return;
112
+ }
113
+ const { viewport } = enabledElement;
114
+ const { hoveredSegmentIndex, hoveredSegmentLabel, canvasCoordinates, worldPoint, } = this._editData;
115
+ if (!hoveredSegmentIndex) {
116
+ return;
117
+ }
118
+ const textBoxPosition = viewport.worldToCanvas(worldPoint);
119
+ const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, 'segmentSelectLabelAnnotation', 'segmentSelectLabelTextBox', [hoveredSegmentLabel ? hoveredSegmentLabel : '(unnamed segment)'], textBoxPosition, [canvasCoordinates], {}, {});
120
+ const left = canvasCoordinates[0];
121
+ const top = canvasCoordinates[1];
122
+ const { width, height } = boundingBox;
123
+ this.data.handles.textBox.worldBoundingBox = {
124
+ topLeft: viewport.canvasToWorld([left, top]),
125
+ topRight: viewport.canvasToWorld([left + width, top]),
126
+ bottomLeft: viewport.canvasToWorld([left, top + height]),
127
+ bottomRight: viewport.canvasToWorld([left + width, top + height]),
128
+ };
129
+ }
130
+ }
131
+ SegmentLabelTool.toolName = 'SegmentLabelTool';
132
+ export default SegmentLabelTool;
@@ -3,7 +3,6 @@ import { BaseTool } from '../base';
3
3
  import { triggerSegmentationModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
4
4
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
5
5
  import { getActiveSegmentation } from '../../stateManagement/segmentation/activeSegmentation';
6
- import RepresentationTypes from '../../enums/SegmentationRepresentations';
7
6
  import { setActiveSegmentIndex } from '../../stateManagement/segmentation/segmentIndex';
8
7
  import { getHoveredContourSegmentationAnnotation, getSegmentIndexAtLabelmapBorder, getSegmentIndexAtWorldPoint, } from '../../utilities/segmentation';
9
8
  import { state } from '../../store/state';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "3.9.5",
3
+ "version": "3.10.0",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -103,7 +103,7 @@
103
103
  "canvas": "^3.1.0"
104
104
  },
105
105
  "peerDependencies": {
106
- "@cornerstonejs/core": "^3.9.5",
106
+ "@cornerstonejs/core": "^3.10.0",
107
107
  "@kitware/vtk.js": "32.12.1",
108
108
  "@types/d3-array": "^3.0.4",
109
109
  "@types/d3-interpolate": "^3.0.1",
@@ -122,5 +122,5 @@
122
122
  "type": "individual",
123
123
  "url": "https://ohif.org/donate"
124
124
  },
125
- "gitHead": "9901c3e2eb2cf1ec0ff3ebd2466aca755ed3cedb"
125
+ "gitHead": "82188c3f17a27d9d1a70442b06bd209c08f881e2"
126
126
  }