@cornerstonejs/tools 4.8.3 → 4.8.5
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/eventListeners/segmentation/segmentationRemovedEventListener.d.ts +3 -0
- package/dist/esm/eventListeners/segmentation/segmentationRemovedEventListener.js +11 -0
- package/dist/esm/init.js +4 -0
- package/dist/esm/tools/annotation/LivewireContourTool.js +0 -3
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +5 -1
- package/dist/esm/tools/annotation/SplineROITool.js +0 -3
- package/dist/esm/tools/base/ContourSegmentationBaseTool.d.ts +2 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +23 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +0 -1
- package/dist/esm/utilities/planar/filterAnnotationsWithinSlice.js +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getAllAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
|
|
2
|
+
const segmentationRemovedListener = function (evt) {
|
|
3
|
+
const { segmentationId } = evt.detail;
|
|
4
|
+
const annotationsToRemove = getAllAnnotations().filter((annotation) => segmentationId ===
|
|
5
|
+
annotation?.data?.segmentation
|
|
6
|
+
?.segmentationId);
|
|
7
|
+
annotationsToRemove.forEach((annotation) => {
|
|
8
|
+
removeAnnotation(annotation.annotationUID);
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export default segmentationRemovedListener;
|
package/dist/esm/init.js
CHANGED
|
@@ -9,6 +9,7 @@ import * as ToolGroupManager from './store/ToolGroupManager';
|
|
|
9
9
|
import { defaultSegmentationStateManager } from './stateManagement/segmentation/SegmentationStateManager';
|
|
10
10
|
import segmentationRepresentationModifiedListener from './eventListeners/segmentation/segmentationRepresentationModifiedListener';
|
|
11
11
|
import { setConfig } from './config';
|
|
12
|
+
import segmentationRemovedListener from './eventListeners/segmentation/segmentationRemovedEventListener';
|
|
12
13
|
let csToolsInitialized = false;
|
|
13
14
|
export function init(defaultConfiguration = {}) {
|
|
14
15
|
if (csToolsInitialized) {
|
|
@@ -56,15 +57,18 @@ function _addCornerstoneToolsEventListeners() {
|
|
|
56
57
|
eventTarget.addEventListener(TOOLS_EVENTS.SEGMENTATION_DATA_MODIFIED, segmentationDataModifiedEventListener);
|
|
57
58
|
eventTarget.addEventListener(TOOLS_EVENTS.SEGMENTATION_REPRESENTATION_MODIFIED, segmentationRepresentationModifiedListener);
|
|
58
59
|
eventTarget.addEventListener(TOOLS_EVENTS.SEGMENTATION_REPRESENTATION_ADDED, segmentationRepresentationModifiedListener);
|
|
60
|
+
eventTarget.addEventListener(TOOLS_EVENTS.SEGMENTATION_REMOVED, segmentationRemovedListener);
|
|
59
61
|
}
|
|
60
62
|
function _removeCornerstoneToolsEventListeners() {
|
|
61
63
|
eventTarget.removeEventListener(TOOLS_EVENTS.ANNOTATION_COMPLETED, annotationCompletedListener);
|
|
62
64
|
eventTarget.removeEventListener(TOOLS_EVENTS.ANNOTATION_MODIFIED, annotationModifiedListener);
|
|
63
65
|
eventTarget.removeEventListener(TOOLS_EVENTS.ANNOTATION_SELECTION_CHANGE, annotationSelectionListener);
|
|
64
66
|
eventTarget.removeEventListener(TOOLS_EVENTS.ANNOTATION_SELECTION_CHANGE, annotationSelectionListener);
|
|
67
|
+
eventTarget.removeEventListener(TOOLS_EVENTS.ANNOTATION_REMOVED, annotationRemovedListener);
|
|
65
68
|
eventTarget.removeEventListener(TOOLS_EVENTS.SEGMENTATION_MODIFIED, segmentationModifiedListener);
|
|
66
69
|
eventTarget.removeEventListener(TOOLS_EVENTS.SEGMENTATION_DATA_MODIFIED, segmentationDataModifiedEventListener);
|
|
67
70
|
eventTarget.removeEventListener(TOOLS_EVENTS.SEGMENTATION_REPRESENTATION_MODIFIED, segmentationRepresentationModifiedListener);
|
|
68
71
|
eventTarget.removeEventListener(TOOLS_EVENTS.SEGMENTATION_REPRESENTATION_ADDED, segmentationRepresentationModifiedListener);
|
|
72
|
+
eventTarget.removeEventListener(TOOLS_EVENTS.SEGMENTATION_REMOVED, segmentationRemovedListener);
|
|
69
73
|
}
|
|
70
74
|
export default init;
|
|
@@ -4,7 +4,6 @@ import { removeAnnotation } from '../../stateManagement/annotation/annotationSta
|
|
|
4
4
|
import { drawHandles as drawHandlesSvg, drawLinkedTextBox as drawLinkedTextBoxSvg, } from '../../drawingSvg';
|
|
5
5
|
import { state } from '../../store/state';
|
|
6
6
|
import { Events, KeyboardBindings, ChangeTypes } from '../../enums';
|
|
7
|
-
import { resetElementCursor } from '../../cursors/elementCursor';
|
|
8
7
|
import getMouseModifierKey from '../../eventDispatchers/shared/getMouseModifier';
|
|
9
8
|
import * as math from '../../utilities/math';
|
|
10
9
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
@@ -119,7 +118,6 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
119
118
|
data.handles.activeHandleIndex = null;
|
|
120
119
|
this._deactivateModify(element);
|
|
121
120
|
this._deactivateDraw(element);
|
|
122
|
-
resetElementCursor(element);
|
|
123
121
|
const enabledElement = getEnabledElement(element);
|
|
124
122
|
if ((this.isHandleOutsideImage &&
|
|
125
123
|
this.configuration.preventHandleOutsideImage) ||
|
|
@@ -267,7 +265,6 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
267
265
|
this.isDrawing = false;
|
|
268
266
|
this._deactivateDraw(element);
|
|
269
267
|
this._deactivateModify(element);
|
|
270
|
-
resetElementCursor(element);
|
|
271
268
|
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
272
269
|
if (newAnnotation) {
|
|
273
270
|
removeAnnotation(annotation.annotationUID);
|
|
@@ -259,13 +259,17 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
259
259
|
if (!annotations || !annotations.length) {
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
+
const baseFilteredAnnotations = super.filterInteractableAnnotationsForElement(element, annotations);
|
|
263
|
+
if (!baseFilteredAnnotations || !baseFilteredAnnotations.length) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
262
266
|
const enabledElement = getEnabledElement(element);
|
|
263
267
|
const { viewport } = enabledElement;
|
|
264
268
|
let annotationsToDisplay;
|
|
265
269
|
if (viewport instanceof VolumeViewport) {
|
|
266
270
|
const camera = viewport.getCamera();
|
|
267
271
|
const { spacingInNormalDirection } = csUtils.getTargetVolumeAndSpacingInNormalDir(viewport, camera);
|
|
268
|
-
annotationsToDisplay = this.filterAnnotationsWithinSlice(
|
|
272
|
+
annotationsToDisplay = this.filterAnnotationsWithinSlice(baseFilteredAnnotations, camera, spacingInNormalDirection);
|
|
269
273
|
}
|
|
270
274
|
else {
|
|
271
275
|
annotationsToDisplay = filterAnnotationsForDisplay(viewport, annotations);
|
|
@@ -4,7 +4,6 @@ import { addAnnotation, getChildAnnotations, removeAnnotation, } from '../../sta
|
|
|
4
4
|
import { drawHandles as drawHandlesSvg, drawPolyline as drawPolylineSvg, drawLinkedTextBox as drawLinkedTextBoxSvg, } from '../../drawingSvg';
|
|
5
5
|
import { state } from '../../store/state';
|
|
6
6
|
import { Events, MouseBindings, KeyboardBindings, ChangeTypes, } from '../../enums';
|
|
7
|
-
import { resetElementCursor } from '../../cursors/elementCursor';
|
|
8
7
|
import * as math from '../../utilities/math';
|
|
9
8
|
import throttle from '../../utilities/throttle';
|
|
10
9
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
@@ -170,7 +169,6 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
170
169
|
data.handles.activeHandleIndex = null;
|
|
171
170
|
this._deactivateModify(element);
|
|
172
171
|
this._deactivateDraw(element);
|
|
173
|
-
resetElementCursor(element);
|
|
174
172
|
const enabledElement = getEnabledElement(element);
|
|
175
173
|
const image = this.getTargetImageData(this.getTargetId(enabledElement.viewport));
|
|
176
174
|
const { imageData, dimensions } = image;
|
|
@@ -559,7 +557,6 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
559
557
|
this.isDrawing = false;
|
|
560
558
|
this._deactivateDraw(element);
|
|
561
559
|
this._deactivateModify(element);
|
|
562
|
-
resetElementCursor(element);
|
|
563
560
|
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
564
561
|
if (newAnnotation) {
|
|
565
562
|
removeAnnotation(annotation.annotationUID);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Annotation, EventTypes, PublicToolProps, ToolProps, AnnotationRenderContext } from '../../types';
|
|
1
|
+
import type { Annotation, EventTypes, PublicToolProps, ToolProps, AnnotationRenderContext, Annotations } from '../../types';
|
|
2
2
|
import type { ContourAnnotation } from '../../types/ToolSpecificAnnotationTypes';
|
|
3
3
|
import type { StyleSpecifier } from '../../types/AnnotationStyle';
|
|
4
4
|
import ContourBaseTool from './ContourBaseTool';
|
|
@@ -15,6 +15,7 @@ declare abstract class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
15
15
|
styleSpecifier: StyleSpecifier;
|
|
16
16
|
}): any;
|
|
17
17
|
protected renderAnnotationInstance(renderContext: AnnotationRenderContext): boolean;
|
|
18
|
+
filterInteractableAnnotationsForElement(element: HTMLDivElement, annotations: Annotations): Annotations;
|
|
18
19
|
private _getContourSegmentationStyle;
|
|
19
20
|
}
|
|
20
21
|
export { ContourSegmentationBaseTool as default, ContourSegmentationBaseTool };
|
|
@@ -12,6 +12,7 @@ import { getViewportIdsWithSegmentation } from '../../stateManagement/segmentati
|
|
|
12
12
|
import { getActiveSegmentIndex } from '../../stateManagement/segmentation/getActiveSegmentIndex';
|
|
13
13
|
import { getLockedSegmentIndices } from '../../stateManagement/segmentation/segmentLocking';
|
|
14
14
|
import { getSVGStyleForSegment } from '../../utilities/segmentation/getSVGStyleForSegment';
|
|
15
|
+
import { defaultSegmentationStateManager } from '../../stateManagement/segmentation/SegmentationStateManager';
|
|
15
16
|
class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
16
17
|
static { this.PreviewSegmentIndex = 255; }
|
|
17
18
|
constructor(toolProps, defaultToolProps) {
|
|
@@ -99,6 +100,28 @@ class ContourSegmentationBaseTool extends ContourBaseTool {
|
|
|
99
100
|
}
|
|
100
101
|
return renderResult;
|
|
101
102
|
}
|
|
103
|
+
filterInteractableAnnotationsForElement(element, annotations) {
|
|
104
|
+
if (!annotations || !annotations.length) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const baseFilteredAnnotations = super.filterInteractableAnnotationsForElement(element, annotations);
|
|
108
|
+
if (!baseFilteredAnnotations || !baseFilteredAnnotations.length) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const enabledElement = getEnabledElement(element);
|
|
112
|
+
const { viewport } = enabledElement;
|
|
113
|
+
return baseFilteredAnnotations.filter((annotation) => {
|
|
114
|
+
const segmentationId = annotation?.data
|
|
115
|
+
?.segmentation?.segmentationId;
|
|
116
|
+
if (!segmentationId) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return !!defaultSegmentationStateManager.getSegmentationRepresentation(viewport.id, {
|
|
120
|
+
segmentationId,
|
|
121
|
+
type: SegmentationRepresentations.Contour,
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
102
125
|
_getContourSegmentationStyle(context) {
|
|
103
126
|
const annotation = context.annotation;
|
|
104
127
|
const { segmentationId, segmentIndex } = annotation.data.segmentation;
|
|
@@ -58,7 +58,7 @@ export default function filterAnnotationsWithinSlice(annotations, camera, spacin
|
|
|
58
58
|
continue;
|
|
59
59
|
}
|
|
60
60
|
const point = metadata.planeRestriction?.point ||
|
|
61
|
-
data.handles
|
|
61
|
+
data.handles?.points?.[0] ||
|
|
62
62
|
data.contour?.polyline[0];
|
|
63
63
|
if (!point) {
|
|
64
64
|
annotationsWithinSlice.push(annotation);
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.8.
|
|
1
|
+
export declare const version = "4.8.5";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.8.
|
|
1
|
+
export const version = '4.8.5';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.5",
|
|
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.2.0"
|
|
109
109
|
},
|
|
110
110
|
"peerDependencies": {
|
|
111
|
-
"@cornerstonejs/core": "4.8.
|
|
111
|
+
"@cornerstonejs/core": "4.8.5",
|
|
112
112
|
"@kitware/vtk.js": "32.12.1",
|
|
113
113
|
"@types/d3-array": "3.2.1",
|
|
114
114
|
"@types/d3-interpolate": "3.0.4",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"type": "individual",
|
|
128
128
|
"url": "https://ohif.org/donate"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "e5b8e0b1c96c0a41d84bbdd5918729b384fd96e5"
|
|
131
131
|
}
|