@cornerstonejs/tools 3.19.0 → 3.19.2
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/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/tools/ZoomTool.js +25 -10
- package/dist/esm/tools/index.d.ts +2 -1
- package/dist/esm/tools/index.js +2 -1
- package/dist/esm/tools/segmentation/LabelmapEditWithContour.d.ts +21 -0
- package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +120 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
package/dist/esm/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import * as Types from './types';
|
|
|
12
12
|
import * as annotation from './stateManagement/annotation';
|
|
13
13
|
import * as segmentation from './stateManagement/segmentation';
|
|
14
14
|
import * as splines from './tools/annotation/splines';
|
|
15
|
-
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, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool } from './tools';
|
|
15
|
+
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, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, LabelMapEditWithContourTool } from './tools';
|
|
16
16
|
import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
|
|
17
17
|
import * as Enums from './enums';
|
|
18
|
-
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, UltrasoundPleuraBLineTool, 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, version, };
|
|
18
|
+
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, UltrasoundPleuraBLineTool, 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, LabelMapEditWithContourTool, splines, version, };
|
package/dist/esm/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import * as Types from './types';
|
|
|
12
12
|
import * as annotation from './stateManagement/annotation';
|
|
13
13
|
import * as segmentation from './stateManagement/segmentation';
|
|
14
14
|
import * as splines from './tools/annotation/splines';
|
|
15
|
-
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, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, } from './tools';
|
|
15
|
+
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, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, LabelMapEditWithContourTool, } from './tools';
|
|
16
16
|
import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
|
|
17
17
|
import * as Enums from './enums';
|
|
18
|
-
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, UltrasoundPleuraBLineTool, 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, version, };
|
|
18
|
+
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, UltrasoundPleuraBLineTool, 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, LabelMapEditWithContourTool, splines, version, };
|
|
@@ -53,21 +53,36 @@ class ZoomTool extends BaseTool {
|
|
|
53
53
|
}
|
|
54
54
|
const imageData = viewport.getImageData();
|
|
55
55
|
let spacing = [1, 1, 1];
|
|
56
|
-
if (imageData) {
|
|
57
|
-
spacing = imageData.spacing;
|
|
58
|
-
}
|
|
59
|
-
const { minZoomScale, maxZoomScale } = this.configuration;
|
|
60
|
-
const t = element.clientHeight * spacing[1] * 0.5;
|
|
61
|
-
const scale = t / parallelScaleToSet;
|
|
62
56
|
let cappedParallelScale = parallelScaleToSet;
|
|
63
57
|
let thresholdExceeded = false;
|
|
64
58
|
if (imageData) {
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
spacing = imageData.spacing;
|
|
60
|
+
const { dimensions } = imageData;
|
|
61
|
+
const imageWidth = dimensions[0] * spacing[0];
|
|
62
|
+
const imageHeight = dimensions[1] * spacing[1];
|
|
63
|
+
const canvasAspect = size[0] / size[1];
|
|
64
|
+
const displayArea = viewport.options?.displayArea;
|
|
65
|
+
const imageAreaScaleX = displayArea?.imageArea?.[0] ?? 1.1;
|
|
66
|
+
const imageAreaScaleY = displayArea?.imageArea?.[1] ?? 1.1;
|
|
67
|
+
const scaledImageWidth = imageWidth * imageAreaScaleX;
|
|
68
|
+
const scaledImageHeight = imageHeight * imageAreaScaleY;
|
|
69
|
+
const scaledImageAspect = scaledImageWidth / scaledImageHeight;
|
|
70
|
+
let minParallelScaleRequired;
|
|
71
|
+
if (scaledImageAspect > canvasAspect) {
|
|
72
|
+
minParallelScaleRequired = (scaledImageWidth / canvasAspect) * 0.5;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
minParallelScaleRequired = scaledImageHeight * 0.5;
|
|
76
|
+
}
|
|
77
|
+
const { minZoomScale, maxZoomScale } = this.configuration;
|
|
78
|
+
const minScaleInWorld = minParallelScaleRequired / maxZoomScale;
|
|
79
|
+
const maxScaleInWorld = minParallelScaleRequired / minZoomScale;
|
|
80
|
+
if (parallelScaleToSet < minScaleInWorld) {
|
|
81
|
+
cappedParallelScale = minScaleInWorld;
|
|
67
82
|
thresholdExceeded = true;
|
|
68
83
|
}
|
|
69
|
-
else if (
|
|
70
|
-
cappedParallelScale =
|
|
84
|
+
else if (parallelScaleToSet > maxScaleInWorld) {
|
|
85
|
+
cappedParallelScale = maxScaleInWorld;
|
|
71
86
|
thresholdExceeded = true;
|
|
72
87
|
}
|
|
73
88
|
}
|
|
@@ -57,4 +57,5 @@ import SegmentSelectTool from './segmentation/SegmentSelectTool';
|
|
|
57
57
|
import SegmentBidirectionalTool from './segmentation/SegmentBidirectionalTool';
|
|
58
58
|
import * as strategies from './segmentation/strategies';
|
|
59
59
|
import SegmentLabelTool from './segmentation/SegmentLabelTool';
|
|
60
|
-
|
|
60
|
+
import LabelMapEditWithContourTool from './segmentation/LabelmapEditWithContour';
|
|
61
|
+
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, UltrasoundPleuraBLineTool, 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, LabelMapEditWithContourTool, strategies, };
|
package/dist/esm/tools/index.js
CHANGED
|
@@ -57,4 +57,5 @@ import SegmentSelectTool from './segmentation/SegmentSelectTool';
|
|
|
57
57
|
import SegmentBidirectionalTool from './segmentation/SegmentBidirectionalTool';
|
|
58
58
|
import * as strategies from './segmentation/strategies';
|
|
59
59
|
import SegmentLabelTool from './segmentation/SegmentLabelTool';
|
|
60
|
-
|
|
60
|
+
import LabelMapEditWithContourTool from './segmentation/LabelmapEditWithContour';
|
|
61
|
+
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, UltrasoundPleuraBLineTool, 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, LabelMapEditWithContourTool, strategies, };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import PlanarFreehandContourSegmentationTool from '../annotation/PlanarFreehandContourSegmentationTool';
|
|
2
|
+
import type { PublicToolProps } from '../../types';
|
|
3
|
+
declare class LabelMapEditWithContourTool extends PlanarFreehandContourSegmentationTool {
|
|
4
|
+
static toolName: string;
|
|
5
|
+
static annotationsToViewportMap: Map<any, any>;
|
|
6
|
+
private onViewportAddedToToolGroupBinded;
|
|
7
|
+
private onSegmentationModifiedBinded;
|
|
8
|
+
static viewportIdsChecked: any[];
|
|
9
|
+
constructor(toolProps?: PublicToolProps);
|
|
10
|
+
protected initializeListeners(): void;
|
|
11
|
+
protected cleanUpListeners(): void;
|
|
12
|
+
protected checkContourSegmentation(viewportId: string): Promise<boolean>;
|
|
13
|
+
protected onViewportAddedToToolGroup(evt: any): void;
|
|
14
|
+
protected onSegmentationModified(evt: any): void;
|
|
15
|
+
onSetToolEnabled(): void;
|
|
16
|
+
onSetToolActive(): void;
|
|
17
|
+
onSetToolDisabled(): void;
|
|
18
|
+
annotationModified(evt: any): void;
|
|
19
|
+
annotationCompleted(evt: any): void;
|
|
20
|
+
}
|
|
21
|
+
export default LabelMapEditWithContourTool;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Events, SegmentationRepresentations } from '../../enums';
|
|
2
|
+
import { eventTarget, utilities, getRenderingEngine, } from '@cornerstonejs/core';
|
|
3
|
+
import PlanarFreehandContourSegmentationTool from '../annotation/PlanarFreehandContourSegmentationTool';
|
|
4
|
+
import BrushTool from './BrushTool';
|
|
5
|
+
import * as segmentation from '../../stateManagement/segmentation';
|
|
6
|
+
import { getSegmentationRepresentationsBySegmentationId } from '../../stateManagement/segmentation/getSegmentationRepresentation';
|
|
7
|
+
class LabelMapEditWithContourTool extends PlanarFreehandContourSegmentationTool {
|
|
8
|
+
static { this.toolName = 'LabelMapEditWithContour'; }
|
|
9
|
+
static { this.annotationsToViewportMap = new Map(); }
|
|
10
|
+
static { this.viewportIdsChecked = []; }
|
|
11
|
+
constructor(toolProps = {}) {
|
|
12
|
+
const initialProps = utilities.deepMerge({
|
|
13
|
+
configuration: {
|
|
14
|
+
calculateStats: false,
|
|
15
|
+
allowOpenContours: false,
|
|
16
|
+
},
|
|
17
|
+
}, toolProps);
|
|
18
|
+
super(initialProps);
|
|
19
|
+
this.onViewportAddedToToolGroupBinded =
|
|
20
|
+
this.onViewportAddedToToolGroup.bind(this);
|
|
21
|
+
this.onSegmentationModifiedBinded = this.onSegmentationModified.bind(this);
|
|
22
|
+
}
|
|
23
|
+
initializeListeners() {
|
|
24
|
+
LabelMapEditWithContourTool.annotationsToViewportMap.clear();
|
|
25
|
+
LabelMapEditWithContourTool.viewportIdsChecked = [];
|
|
26
|
+
eventTarget.addEventListener(Events.ANNOTATION_MODIFIED, this.annotationModified);
|
|
27
|
+
eventTarget.addEventListener(Events.ANNOTATION_COMPLETED, this.annotationCompleted);
|
|
28
|
+
eventTarget.addEventListener(Events.TOOLGROUP_VIEWPORT_ADDED, this.onViewportAddedToToolGroupBinded);
|
|
29
|
+
eventTarget.addEventListener(Events.SEGMENTATION_MODIFIED, this.onSegmentationModifiedBinded);
|
|
30
|
+
}
|
|
31
|
+
cleanUpListeners() {
|
|
32
|
+
LabelMapEditWithContourTool.annotationsToViewportMap.clear();
|
|
33
|
+
LabelMapEditWithContourTool.viewportIdsChecked = [];
|
|
34
|
+
eventTarget.removeEventListener(Events.ANNOTATION_MODIFIED, this.annotationModified);
|
|
35
|
+
eventTarget.removeEventListener(Events.ANNOTATION_COMPLETED, this.annotationCompleted);
|
|
36
|
+
eventTarget.removeEventListener(Events.TOOLGROUP_VIEWPORT_ADDED, this.onViewportAddedToToolGroup.bind(this));
|
|
37
|
+
eventTarget.removeEventListener(Events.SEGMENTATION_MODIFIED, this.onSegmentationModified.bind(this));
|
|
38
|
+
}
|
|
39
|
+
async checkContourSegmentation(viewportId) {
|
|
40
|
+
if (LabelMapEditWithContourTool.viewportIdsChecked.includes(viewportId)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const activeSeg = segmentation.getActiveSegmentation(viewportId);
|
|
44
|
+
if (!activeSeg) {
|
|
45
|
+
console.log('No active segmentation detected');
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
const segmentationId = activeSeg.segmentationId;
|
|
49
|
+
if (!activeSeg.representationData.Contour) {
|
|
50
|
+
LabelMapEditWithContourTool.viewportIdsChecked.push(viewportId);
|
|
51
|
+
await segmentation.addContourRepresentationToViewport(viewportId, [
|
|
52
|
+
{
|
|
53
|
+
segmentationId,
|
|
54
|
+
type: SegmentationRepresentations.Contour,
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
segmentation.addRepresentationData({
|
|
58
|
+
segmentationId,
|
|
59
|
+
type: SegmentationRepresentations.Contour,
|
|
60
|
+
data: {},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
LabelMapEditWithContourTool.viewportIdsChecked.push(viewportId);
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
onViewportAddedToToolGroup(evt) {
|
|
69
|
+
const { toolGroupId, viewportId } = evt.detail;
|
|
70
|
+
if (toolGroupId !== this.toolGroupId) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.checkContourSegmentation(viewportId);
|
|
74
|
+
}
|
|
75
|
+
onSegmentationModified(evt) {
|
|
76
|
+
const { segmentationId } = evt.detail || {};
|
|
77
|
+
if (!segmentationId) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const representations = getSegmentationRepresentationsBySegmentationId(segmentationId);
|
|
81
|
+
if (!representations) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
representations.forEach(async ({ viewportId }) => await this.checkContourSegmentation(viewportId));
|
|
85
|
+
}
|
|
86
|
+
onSetToolEnabled() {
|
|
87
|
+
this.initializeListeners();
|
|
88
|
+
}
|
|
89
|
+
onSetToolActive() {
|
|
90
|
+
this.initializeListeners();
|
|
91
|
+
}
|
|
92
|
+
onSetToolDisabled() {
|
|
93
|
+
this.cleanUpListeners();
|
|
94
|
+
}
|
|
95
|
+
annotationModified(evt) {
|
|
96
|
+
const { annotation, renderingEngineId, viewportId } = evt.detail;
|
|
97
|
+
const viewport = getRenderingEngine(renderingEngineId)?.getViewport(viewportId);
|
|
98
|
+
if (!viewport) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
LabelMapEditWithContourTool.annotationsToViewportMap.set(annotation.annotationUID, viewport);
|
|
102
|
+
}
|
|
103
|
+
annotationCompleted(evt) {
|
|
104
|
+
const { annotation } = evt.detail;
|
|
105
|
+
const { polyline } = annotation.data?.contour || {};
|
|
106
|
+
if (annotation?.metadata?.toolName !== LabelMapEditWithContourTool.toolName) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!polyline) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (LabelMapEditWithContourTool.annotationsToViewportMap.has(annotation.annotationUID)) {
|
|
113
|
+
const viewport = LabelMapEditWithContourTool.annotationsToViewportMap.get(annotation.annotationUID);
|
|
114
|
+
if (polyline.length > 3) {
|
|
115
|
+
BrushTool.viewportContoursToLabelmap(viewport);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export default LabelMapEditWithContourTool;
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "3.19.
|
|
1
|
+
export declare const version = "3.19.2";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '3.19.
|
|
1
|
+
export const version = '3.19.2';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.2",
|
|
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.19.
|
|
111
|
+
"@cornerstonejs/core": "^3.19.2",
|
|
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": "
|
|
130
|
+
"gitHead": "e8c0d83fc0de3d48306a2a13618050400e017ce3"
|
|
131
131
|
}
|