@cornerstonejs/tools 3.19.5 → 3.20.1
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/enums/Events.d.ts +1 -0
- package/dist/esm/enums/Events.js +1 -0
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +10 -0
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.d.ts +4 -0
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +19 -1
- package/dist/esm/tools/annotation/SplineROITool.d.ts +8 -0
- package/dist/esm/tools/annotation/SplineROITool.js +33 -0
- package/dist/esm/utilities/contourSegmentation/convertContourSegmentation.d.ts +2 -0
- package/dist/esm/utilities/contourSegmentation/convertContourSegmentation.js +49 -0
- package/dist/esm/utilities/contourSegmentation/index.d.ts +2 -1
- package/dist/esm/utilities/contourSegmentation/index.js +2 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -12,6 +12,7 @@ declare enum Events {
|
|
|
12
12
|
ANNOTATION_LOCK_CHANGE = "CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE",
|
|
13
13
|
ANNOTATION_VISIBILITY_CHANGE = "CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE",
|
|
14
14
|
ANNOTATION_RENDERED = "CORNERSTONE_TOOLS_ANNOTATION_RENDERED",
|
|
15
|
+
ANNOTATION_CUT_MERGE_PROCESS_COMPLETED = "CORNERSTONE_TOOLS_ANNOTATION_CUT_MERGE_PROCESS_COMPLETED",
|
|
15
16
|
ANNOTATION_INTERPOLATION_PROCESS_COMPLETED = "CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED",
|
|
16
17
|
INTERPOLATED_ANNOTATIONS_REMOVED = "CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED",
|
|
17
18
|
SEGMENTATION_MODIFIED = "CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",
|
package/dist/esm/enums/Events.js
CHANGED
|
@@ -13,6 +13,7 @@ var Events;
|
|
|
13
13
|
Events["ANNOTATION_LOCK_CHANGE"] = "CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE";
|
|
14
14
|
Events["ANNOTATION_VISIBILITY_CHANGE"] = "CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE";
|
|
15
15
|
Events["ANNOTATION_RENDERED"] = "CORNERSTONE_TOOLS_ANNOTATION_RENDERED";
|
|
16
|
+
Events["ANNOTATION_CUT_MERGE_PROCESS_COMPLETED"] = "CORNERSTONE_TOOLS_ANNOTATION_CUT_MERGE_PROCESS_COMPLETED";
|
|
16
17
|
Events["ANNOTATION_INTERPOLATION_PROCESS_COMPLETED"] = "CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED";
|
|
17
18
|
Events["INTERPOLATED_ANNOTATIONS_REMOVED"] = "CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED";
|
|
18
19
|
Events["SEGMENTATION_MODIFIED"] = "CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED";
|
package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { eventTarget, triggerEvent } from '@cornerstonejs/core';
|
|
1
2
|
import getViewportsForAnnotation from '../../../utilities/getViewportsForAnnotation';
|
|
2
3
|
import { getAllAnnotations } from '../../../stateManagement/annotation/annotationState';
|
|
3
4
|
import { areSameSegment, isContourSegmentationAnnotation, } from '../../../utilities/contourSegmentation';
|
|
@@ -5,6 +6,7 @@ import { getToolGroupForViewport } from '../../../store/ToolGroupManager';
|
|
|
5
6
|
import { findAllIntersectingContours } from '../../../utilities/contourSegmentation/getIntersectingAnnotations';
|
|
6
7
|
import { processMultipleIntersections } from '../../../utilities/contourSegmentation/mergeMultipleAnnotations';
|
|
7
8
|
import { convertContourPolylineToCanvasSpace, createPolylineHole, combinePolylines, } from '../../../utilities/contourSegmentation/sharedOperations';
|
|
9
|
+
import { Events } from '../../../enums';
|
|
8
10
|
const DEFAULT_CONTOUR_SEG_TOOL_NAME = 'PlanarFreehandContourSegmentationTool';
|
|
9
11
|
export default async function contourSegmentationCompletedListener(evt) {
|
|
10
12
|
const sourceAnnotation = evt.detail
|
|
@@ -15,11 +17,19 @@ export default async function contourSegmentationCompletedListener(evt) {
|
|
|
15
17
|
const viewport = getViewport(sourceAnnotation);
|
|
16
18
|
const contourSegmentationAnnotations = getValidContourSegmentationAnnotations(viewport, sourceAnnotation);
|
|
17
19
|
if (!contourSegmentationAnnotations.length) {
|
|
20
|
+
triggerEvent(eventTarget, Events.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED, {
|
|
21
|
+
element: viewport.element,
|
|
22
|
+
sourceAnnotation,
|
|
23
|
+
});
|
|
18
24
|
return;
|
|
19
25
|
}
|
|
20
26
|
const sourcePolyline = convertContourPolylineToCanvasSpace(sourceAnnotation.data.contour.polyline, viewport);
|
|
21
27
|
const intersectingContours = findAllIntersectingContours(viewport, sourcePolyline, contourSegmentationAnnotations);
|
|
22
28
|
if (!intersectingContours.length) {
|
|
29
|
+
triggerEvent(eventTarget, Events.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED, {
|
|
30
|
+
element: viewport.element,
|
|
31
|
+
sourceAnnotation,
|
|
32
|
+
});
|
|
23
33
|
return;
|
|
24
34
|
}
|
|
25
35
|
if (intersectingContours.length > 1) {
|
|
@@ -2,7 +2,11 @@ import type { PublicToolProps } from '../../types';
|
|
|
2
2
|
import SplineROITool from './SplineROITool';
|
|
3
3
|
declare class SplineContourSegmentationTool extends SplineROITool {
|
|
4
4
|
static toolName: string;
|
|
5
|
+
private annotationCutMergeCompletedBinded;
|
|
5
6
|
constructor(toolProps: PublicToolProps);
|
|
6
7
|
protected isContourSegmentationTool(): boolean;
|
|
8
|
+
protected initializeListeners(): void;
|
|
9
|
+
protected removeListeners(): void;
|
|
10
|
+
protected annotationCutMergeCompleted(evt: any): void;
|
|
7
11
|
}
|
|
8
12
|
export default SplineContourSegmentationTool;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { utilities } from '@cornerstonejs/core';
|
|
1
|
+
import { eventTarget, utilities } from '@cornerstonejs/core';
|
|
2
2
|
import SplineROITool from './SplineROITool';
|
|
3
|
+
import { Events } from '../../enums';
|
|
4
|
+
import { convertContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
|
|
3
5
|
class SplineContourSegmentationTool extends SplineROITool {
|
|
4
6
|
static { this.toolName = 'SplineContourSegmentationTool'; }
|
|
5
7
|
constructor(toolProps) {
|
|
@@ -9,9 +11,25 @@ class SplineContourSegmentationTool extends SplineROITool {
|
|
|
9
11
|
},
|
|
10
12
|
}, toolProps);
|
|
11
13
|
super(initialProps);
|
|
14
|
+
this.annotationCutMergeCompletedBinded =
|
|
15
|
+
this.annotationCutMergeCompleted.bind(this);
|
|
12
16
|
}
|
|
13
17
|
isContourSegmentationTool() {
|
|
14
18
|
return true;
|
|
15
19
|
}
|
|
20
|
+
initializeListeners() {
|
|
21
|
+
eventTarget.addEventListener(Events.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED, this.annotationCutMergeCompletedBinded);
|
|
22
|
+
}
|
|
23
|
+
removeListeners() {
|
|
24
|
+
eventTarget.removeEventListener(Events.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED, this.annotationCutMergeCompletedBinded);
|
|
25
|
+
}
|
|
26
|
+
annotationCutMergeCompleted(evt) {
|
|
27
|
+
const { sourceAnnotation: annotation } = evt.detail;
|
|
28
|
+
if (!this.splineToolNames.includes(annotation?.metadata?.toolName) ||
|
|
29
|
+
!this.configuration.simplifiedSpline) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
convertContourSegmentationAnnotation(annotation);
|
|
33
|
+
}
|
|
16
34
|
}
|
|
17
35
|
export default SplineContourSegmentationTool;
|
|
@@ -15,8 +15,10 @@ declare enum SplineToolActions {
|
|
|
15
15
|
}
|
|
16
16
|
declare class SplineROITool extends ContourSegmentationBaseTool {
|
|
17
17
|
static toolName: string;
|
|
18
|
+
protected splineToolNames: string[];
|
|
18
19
|
static SplineTypes: typeof SplineTypesEnum;
|
|
19
20
|
static Actions: typeof SplineToolActions;
|
|
21
|
+
private annotationCompletedBinded;
|
|
20
22
|
_throttledCalculateCachedStats: Function;
|
|
21
23
|
editData: {
|
|
22
24
|
annotation: SplineROIAnnotation;
|
|
@@ -36,6 +38,12 @@ declare class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
36
38
|
contourHoleProcessingEnabled: boolean;
|
|
37
39
|
};
|
|
38
40
|
constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
|
|
41
|
+
protected annotationCompleted(evt: any): void;
|
|
42
|
+
protected initializeListeners(): void;
|
|
43
|
+
protected removeListeners(): void;
|
|
44
|
+
onSetToolEnabled(): void;
|
|
45
|
+
onSetToolActive(): void;
|
|
46
|
+
onSetToolDisabled(): void;
|
|
39
47
|
addNewAnnotation(evt: EventTypes.InteractionEventType): SplineROIAnnotation;
|
|
40
48
|
isPointNearTool: (element: HTMLDivElement, annotation: SplineROIAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
|
|
41
49
|
toolSelectedCallback: (evt: EventTypes.InteractionEventType, annotation: SplineROIAnnotation) => void;
|
|
@@ -18,6 +18,7 @@ import { CatmullRomSpline } from './splines/CatmullRomSpline';
|
|
|
18
18
|
import { BSpline } from './splines/BSpline';
|
|
19
19
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
20
20
|
import { triggerAnnotationRenderForViewportIds } from '../../utilities';
|
|
21
|
+
import { convertContourSegmentationAnnotation } from '../../utilities/contourSegmentation';
|
|
21
22
|
const SPLINE_MIN_POINTS = 3;
|
|
22
23
|
const SPLINE_CLICK_CLOSE_CURVE_DIST = 10;
|
|
23
24
|
const DEFAULT_SPLINE_CONFIG = {
|
|
@@ -49,6 +50,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
49
50
|
configuration: {
|
|
50
51
|
preventHandleOutsideImage: false,
|
|
51
52
|
calculateStats: true,
|
|
53
|
+
simplifiedSpline: false,
|
|
52
54
|
getTextLines: defaultGetTextLines,
|
|
53
55
|
contourHoleAdditionModifierKey: KeyboardBindings.Shift,
|
|
54
56
|
decimate: {
|
|
@@ -101,6 +103,12 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
101
103
|
},
|
|
102
104
|
}) {
|
|
103
105
|
super(toolProps, defaultToolProps);
|
|
106
|
+
this.splineToolNames = [
|
|
107
|
+
'CatmullRomSplineROI',
|
|
108
|
+
'LinearSplineROI',
|
|
109
|
+
'BSplineROI',
|
|
110
|
+
'CardinalSplineROI',
|
|
111
|
+
];
|
|
104
112
|
this.isHandleOutsideImage = false;
|
|
105
113
|
this.fireChangeOnUpdate = null;
|
|
106
114
|
this.isPointNearTool = (element, annotation, canvasCoords, proximity) => {
|
|
@@ -487,6 +495,31 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
487
495
|
return cachedStats;
|
|
488
496
|
};
|
|
489
497
|
this._throttledCalculateCachedStats = throttle(this._calculateCachedStats, 100, { trailing: true });
|
|
498
|
+
this.annotationCompletedBinded = this.annotationCompleted.bind(this);
|
|
499
|
+
}
|
|
500
|
+
annotationCompleted(evt) {
|
|
501
|
+
const { sourceAnnotation: annotation } = evt.detail;
|
|
502
|
+
if (!this.splineToolNames.includes(annotation?.metadata?.toolName) ||
|
|
503
|
+
!this.configuration.simplifiedSpline ||
|
|
504
|
+
!this.isContourSegmentationTool()) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
convertContourSegmentationAnnotation(annotation);
|
|
508
|
+
}
|
|
509
|
+
initializeListeners() {
|
|
510
|
+
eventTarget.addEventListener(Events.ANNOTATION_COMPLETED, this.annotationCompletedBinded);
|
|
511
|
+
}
|
|
512
|
+
removeListeners() {
|
|
513
|
+
eventTarget.removeEventListener(Events.ANNOTATION_COMPLETED, this.annotationCompletedBinded);
|
|
514
|
+
}
|
|
515
|
+
onSetToolEnabled() {
|
|
516
|
+
this.initializeListeners();
|
|
517
|
+
}
|
|
518
|
+
onSetToolActive() {
|
|
519
|
+
this.initializeListeners();
|
|
520
|
+
}
|
|
521
|
+
onSetToolDisabled() {
|
|
522
|
+
this.removeListeners();
|
|
490
523
|
}
|
|
491
524
|
addNewAnnotation(evt) {
|
|
492
525
|
const eventDetail = evt.detail;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { utilities } from '@cornerstonejs/core';
|
|
2
|
+
import { addAnnotation, removeAnnotation } from '../../stateManagement';
|
|
3
|
+
import { removeContourSegmentationAnnotation } from './removeContourSegmentationAnnotation';
|
|
4
|
+
import { addContourSegmentationAnnotation } from './addContourSegmentationAnnotation';
|
|
5
|
+
const DEFAULT_CONTOUR_SEG_TOOL_NAME = 'PlanarFreehandContourSegmentationTool';
|
|
6
|
+
export default function convertContourSegmentationAnnotation(annotation) {
|
|
7
|
+
const { polyline } = annotation.data?.contour || {};
|
|
8
|
+
if (!polyline || polyline.length < 3) {
|
|
9
|
+
console.warn('Skipping creation of new annotation due to invalid polyline:', polyline);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
removeAnnotation(annotation.annotationUID);
|
|
13
|
+
removeContourSegmentationAnnotation(annotation);
|
|
14
|
+
const startPointWorld = polyline[0];
|
|
15
|
+
const endPointWorld = polyline[polyline.length - 1];
|
|
16
|
+
const newAnnotation = {
|
|
17
|
+
metadata: {
|
|
18
|
+
...annotation.metadata,
|
|
19
|
+
toolName: DEFAULT_CONTOUR_SEG_TOOL_NAME,
|
|
20
|
+
originalToolName: annotation.metadata.originalToolName || annotation.metadata.toolName,
|
|
21
|
+
},
|
|
22
|
+
data: {
|
|
23
|
+
cachedStats: {},
|
|
24
|
+
handles: {
|
|
25
|
+
points: [startPointWorld, endPointWorld],
|
|
26
|
+
textBox: annotation.data.handles.textBox
|
|
27
|
+
? { ...annotation.data.handles.textBox }
|
|
28
|
+
: undefined,
|
|
29
|
+
},
|
|
30
|
+
contour: {
|
|
31
|
+
...annotation.data.contour,
|
|
32
|
+
},
|
|
33
|
+
spline: annotation.data.spline,
|
|
34
|
+
segmentation: {
|
|
35
|
+
...annotation.data.segmentation,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
annotationUID: utilities.uuidv4(),
|
|
39
|
+
highlighted: true,
|
|
40
|
+
invalidated: true,
|
|
41
|
+
isLocked: false,
|
|
42
|
+
isVisible: undefined,
|
|
43
|
+
interpolationUID: annotation.interpolationUID,
|
|
44
|
+
interpolationCompleted: annotation.interpolationCompleted,
|
|
45
|
+
};
|
|
46
|
+
addAnnotation(newAnnotation, annotation.metadata.FrameOfReferenceUID);
|
|
47
|
+
addContourSegmentationAnnotation(newAnnotation);
|
|
48
|
+
return newAnnotation;
|
|
49
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import areSameSegment from './areSameSegment';
|
|
2
|
+
import convertContourSegmentationAnnotation from './convertContourSegmentation';
|
|
2
3
|
import { addition, subtraction } from './logicalOperators';
|
|
3
4
|
export { default as isContourSegmentationAnnotation } from './isContourSegmentationAnnotation';
|
|
4
5
|
export { addContourSegmentationAnnotation } from './addContourSegmentationAnnotation';
|
|
@@ -7,5 +8,5 @@ export { findAllIntersectingContours } from './getIntersectingAnnotations';
|
|
|
7
8
|
export { processMultipleIntersections } from './mergeMultipleAnnotations';
|
|
8
9
|
export { contourSegmentationOperation } from './contourSegmentationOperation';
|
|
9
10
|
export * from './sharedOperations';
|
|
10
|
-
export { addition, subtraction, areSameSegment };
|
|
11
|
+
export { addition, subtraction, areSameSegment, convertContourSegmentationAnnotation, };
|
|
11
12
|
export { unifyPolylineSets, unifyMultiplePolylineSets, unifyAnnotationPolylines, subtractPolylineSets, subtractMultiplePolylineSets, subtractAnnotationPolylines, } from './unifyPolylineSets';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import areSameSegment from './areSameSegment';
|
|
2
|
+
import convertContourSegmentationAnnotation from './convertContourSegmentation';
|
|
2
3
|
import { addition, subtraction } from './logicalOperators';
|
|
3
4
|
export { default as isContourSegmentationAnnotation } from './isContourSegmentationAnnotation';
|
|
4
5
|
export { addContourSegmentationAnnotation } from './addContourSegmentationAnnotation';
|
|
@@ -7,5 +8,5 @@ export { findAllIntersectingContours } from './getIntersectingAnnotations';
|
|
|
7
8
|
export { processMultipleIntersections } from './mergeMultipleAnnotations';
|
|
8
9
|
export { contourSegmentationOperation } from './contourSegmentationOperation';
|
|
9
10
|
export * from './sharedOperations';
|
|
10
|
-
export { addition, subtraction, areSameSegment };
|
|
11
|
+
export { addition, subtraction, areSameSegment, convertContourSegmentationAnnotation, };
|
|
11
12
|
export { unifyPolylineSets, unifyMultiplePolylineSets, unifyAnnotationPolylines, subtractPolylineSets, subtractMultiplePolylineSets, subtractAnnotationPolylines, } from './unifyPolylineSets';
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "3.
|
|
1
|
+
export declare const version = "3.20.1";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '3.
|
|
1
|
+
export const version = '3.20.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.1",
|
|
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.
|
|
111
|
+
"@cornerstonejs/core": "^3.20.1",
|
|
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": "1c22473405883f3cd0dada48c7a2edd3b679db2f"
|
|
131
131
|
}
|