@cornerstonejs/tools 2.7.4 → 2.8.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.
- package/dist/esm/enums/ChangeTypes.d.ts +2 -1
- package/dist/esm/enums/ChangeTypes.js +1 -0
- package/dist/esm/store/filterToolsWithAnnotationsForElement.js +1 -1
- package/dist/esm/tools/AnnotationEraserTool.js +8 -4
- package/dist/esm/tools/CrosshairsTool.js +1 -1
- package/dist/esm/tools/PanTool.d.ts +0 -1
- package/dist/esm/tools/PanTool.js +0 -5
- package/dist/esm/tools/ZoomTool.js +0 -2
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js +4 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +6 -5
- package/dist/esm/tools/annotation/CircleROITool.js +6 -3
- package/dist/esm/tools/annotation/CobbAngleTool.d.ts +2 -2
- package/dist/esm/tools/annotation/CobbAngleTool.js +19 -19
- package/dist/esm/tools/annotation/EllipticalROITool.js +6 -6
- package/dist/esm/tools/annotation/KeyImageTool.d.ts +1 -2
- package/dist/esm/tools/annotation/KeyImageTool.js +5 -1
- package/dist/esm/tools/annotation/LengthTool.js +4 -1
- package/dist/esm/tools/annotation/LivewireContourTool.js +9 -5
- package/dist/esm/tools/annotation/ProbeTool.js +6 -5
- package/dist/esm/tools/annotation/RectangleROITool.js +3 -2
- package/dist/esm/tools/annotation/SplineROITool.js +4 -4
- package/dist/esm/tools/annotation/VideoRedactionTool.d.ts +2 -2
- package/dist/esm/tools/annotation/VideoRedactionTool.js +27 -29
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +7 -3
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +6 -2
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +6 -2
- package/dist/esm/tools/base/AnnotationDisplayTool.d.ts +1 -1
- package/dist/esm/tools/base/AnnotationDisplayTool.js +2 -2
- package/dist/esm/tools/base/AnnotationTool.d.ts +30 -0
- package/dist/esm/tools/base/AnnotationTool.js +85 -1
- package/dist/esm/tools/base/BaseTool.d.ts +1 -0
- package/dist/esm/tools/base/BaseTool.js +7 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +0 -4
- package/dist/esm/tools/segmentation/BrushTool.js +1 -0
- package/dist/esm/tools/segmentation/CircleScissorsTool.d.ts +4 -2
- package/dist/esm/tools/segmentation/CircleScissorsTool.js +4 -1
- package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +6 -1
- package/dist/esm/tools/segmentation/LabelmapBaseTool.js +6 -1
- package/dist/esm/tools/segmentation/PaintFillTool.js +1 -1
- package/dist/esm/tools/segmentation/RectangleScissorsTool.d.ts +2 -2
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js +6 -2
- package/dist/esm/tools/segmentation/SphereScissorsTool.d.ts +2 -2
- package/dist/esm/tools/segmentation/SphereScissorsTool.js +5 -1
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +2 -0
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js +15 -13
- package/dist/esm/tools/segmentation/strategies/compositions/setValue.js +2 -1
- package/dist/esm/tools/segmentation/strategies/fillRectangle.d.ts +6 -8
- package/dist/esm/tools/segmentation/strategies/fillRectangle.js +29 -30
- package/dist/esm/tools/segmentation/strategies/index.d.ts +2 -2
- package/dist/esm/tools/segmentation/strategies/index.js +2 -2
- package/dist/esm/types/ContourAnnotation.d.ts +2 -0
- package/dist/esm/types/LabelmapToolOperationData.d.ts +2 -0
- package/dist/esm/utilities/math/polyline/planarFreehandROIInternalTypes.d.ts +1 -0
- package/dist/esm/utilities/planar/filterAnnotationsWithinSlice.js +4 -0
- package/dist/esm/utilities/segmentation/createLabelmapMemo.d.ts +44 -0
- package/dist/esm/utilities/segmentation/createLabelmapMemo.js +68 -0
- package/dist/esm/utilities/segmentation/index.d.ts +2 -1
- package/dist/esm/utilities/segmentation/index.js +2 -1
- package/package.json +3 -3
|
@@ -4,6 +4,7 @@ declare enum ChangeTypes {
|
|
|
4
4
|
StatsUpdated = "StatsUpdated",
|
|
5
5
|
InitialSetup = "InitialSetup",
|
|
6
6
|
Completed = "Completed",
|
|
7
|
-
InterpolationUpdated = "InterpolationUpdated"
|
|
7
|
+
InterpolationUpdated = "InterpolationUpdated",
|
|
8
|
+
History = "History"
|
|
8
9
|
}
|
|
9
10
|
export default ChangeTypes;
|
|
@@ -6,5 +6,6 @@ var ChangeTypes;
|
|
|
6
6
|
ChangeTypes["InitialSetup"] = "InitialSetup";
|
|
7
7
|
ChangeTypes["Completed"] = "Completed";
|
|
8
8
|
ChangeTypes["InterpolationUpdated"] = "InterpolationUpdated";
|
|
9
|
+
ChangeTypes["History"] = "History";
|
|
9
10
|
})(ChangeTypes || (ChangeTypes = {}));
|
|
10
11
|
export default ChangeTypes;
|
|
@@ -14,7 +14,7 @@ export default function filterToolsWithAnnotationsForElement(element, tools) {
|
|
|
14
14
|
if (typeof tool.filterInteractableAnnotationsForElement === 'function') {
|
|
15
15
|
annotations = tool.filterInteractableAnnotationsForElement(element, annotations);
|
|
16
16
|
}
|
|
17
|
-
if (annotations
|
|
17
|
+
if (annotations?.length > 0) {
|
|
18
18
|
result.push({ tool, annotations });
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseTool } from './base';
|
|
2
|
-
import { getAnnotations, removeAnnotation, } from '../stateManagement/annotation/annotationState';
|
|
1
|
+
import { BaseTool, AnnotationTool } from './base';
|
|
2
|
+
import { getAnnotations, getAnnotation, removeAnnotation, } from '../stateManagement/annotation/annotationState';
|
|
3
3
|
import { setAnnotationSelected } from '../stateManagement/annotation/annotationSelection';
|
|
4
4
|
import { getToolGroupForViewport } from '../store/ToolGroupManager';
|
|
5
5
|
class AnnotationEraserTool extends BaseTool {
|
|
@@ -30,10 +30,10 @@ class AnnotationEraserTool extends BaseTool {
|
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
32
|
const annotations = getAnnotations(toolName, element);
|
|
33
|
-
|
|
33
|
+
const interactableAnnotations = toolInstance.filterInteractableAnnotationsForElement(element, annotations);
|
|
34
|
+
if (!interactableAnnotations) {
|
|
34
35
|
continue;
|
|
35
36
|
}
|
|
36
|
-
const interactableAnnotations = toolInstance.filterInteractableAnnotationsForElement(element, annotations) || [];
|
|
37
37
|
for (const annotation of interactableAnnotations) {
|
|
38
38
|
if (toolInstance.isPointNearTool(element, annotation, currentPoints.canvas, 10, interactionType)) {
|
|
39
39
|
annotationsToRemove.push(annotation.annotationUID);
|
|
@@ -42,6 +42,10 @@ class AnnotationEraserTool extends BaseTool {
|
|
|
42
42
|
}
|
|
43
43
|
for (const annotationUID of annotationsToRemove) {
|
|
44
44
|
setAnnotationSelected(annotationUID);
|
|
45
|
+
const annotation = getAnnotation(annotationUID);
|
|
46
|
+
AnnotationTool.createAnnotationMemo(element, annotation, {
|
|
47
|
+
deleting: true,
|
|
48
|
+
});
|
|
45
49
|
removeAnnotation(annotationUID);
|
|
46
50
|
}
|
|
47
51
|
evt.preventDefault();
|
|
@@ -67,7 +67,7 @@ class CrosshairsTool extends AnnotationTool {
|
|
|
67
67
|
const { position, focalPoint, viewPlaneNormal } = viewport.getCamera();
|
|
68
68
|
let annotations = this._getAnnotations(enabledElement);
|
|
69
69
|
annotations = this.filterInteractableAnnotationsForElement(element, annotations);
|
|
70
|
-
if (annotations
|
|
70
|
+
if (annotations?.length) {
|
|
71
71
|
removeAnnotation(annotations[0].annotationUID);
|
|
72
72
|
}
|
|
73
73
|
const annotation = {
|
|
@@ -5,7 +5,6 @@ declare class PanTool extends BaseTool {
|
|
|
5
5
|
constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
|
|
6
6
|
touchDragCallback(evt: EventTypes.InteractionEventType): void;
|
|
7
7
|
mouseDragCallback(evt: EventTypes.InteractionEventType): void;
|
|
8
|
-
preMouseDownCallback: (evt: EventTypes.InteractionEventType) => boolean;
|
|
9
8
|
_dragCallback(evt: EventTypes.InteractionEventType): void;
|
|
10
9
|
}
|
|
11
10
|
export default PanTool;
|
|
@@ -5,10 +5,6 @@ class PanTool extends BaseTool {
|
|
|
5
5
|
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
6
6
|
}) {
|
|
7
7
|
super(toolProps, defaultToolProps);
|
|
8
|
-
this.preMouseDownCallback = (evt) => {
|
|
9
|
-
this.memo = null;
|
|
10
|
-
return false;
|
|
11
|
-
};
|
|
12
8
|
}
|
|
13
9
|
touchDragCallback(evt) {
|
|
14
10
|
this._dragCallback(evt);
|
|
@@ -19,7 +15,6 @@ class PanTool extends BaseTool {
|
|
|
19
15
|
_dragCallback(evt) {
|
|
20
16
|
const { element, deltaPoints } = evt.detail;
|
|
21
17
|
const enabledElement = getEnabledElement(element);
|
|
22
|
-
this.memo ||= PanTool.createZoomPanMemo(enabledElement.viewport);
|
|
23
18
|
const deltaPointsWorld = deltaPoints.world;
|
|
24
19
|
if (deltaPointsWorld[0] === 0 &&
|
|
25
20
|
deltaPointsWorld[1] === 0 &&
|
|
@@ -23,7 +23,6 @@ class ZoomTool extends BaseTool {
|
|
|
23
23
|
const camera = enabledElement.viewport.getCamera();
|
|
24
24
|
const { focalPoint } = camera;
|
|
25
25
|
this.initialMousePosWorld = worldPos;
|
|
26
|
-
this.memo = null;
|
|
27
26
|
let dirVec = vec3.fromValues(focalPoint[0] - worldPos[0], focalPoint[1] - worldPos[1], focalPoint[2] - worldPos[2]);
|
|
28
27
|
dirVec = vec3.normalize(vec3.create(), dirVec);
|
|
29
28
|
this.dirVec = dirVec;
|
|
@@ -146,7 +145,6 @@ class ZoomTool extends BaseTool {
|
|
|
146
145
|
const enabledElement = getEnabledElement(element);
|
|
147
146
|
const { viewport } = enabledElement;
|
|
148
147
|
const camera = viewport.getCamera();
|
|
149
|
-
this.memo ||= ZoomTool.createZoomPanMemo(viewport);
|
|
150
148
|
if (camera.parallelProjection) {
|
|
151
149
|
this._dragParallelProjection(evt, viewport, camera);
|
|
152
150
|
}
|
|
@@ -148,12 +148,14 @@ class ArrowAnnotateTool extends AnnotationTool {
|
|
|
148
148
|
}
|
|
149
149
|
annotation.data.text = text;
|
|
150
150
|
triggerAnnotationCompleted(annotation);
|
|
151
|
+
this.createMemo(element, annotation, { newAnnotation: !!this.memo });
|
|
151
152
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
152
153
|
});
|
|
153
154
|
}
|
|
154
155
|
else {
|
|
155
156
|
triggerAnnotationModified(annotation, element);
|
|
156
157
|
}
|
|
158
|
+
this.doneEditMemo();
|
|
157
159
|
this.editData = null;
|
|
158
160
|
this.isDrawing = false;
|
|
159
161
|
};
|
|
@@ -161,7 +163,8 @@ class ArrowAnnotateTool extends AnnotationTool {
|
|
|
161
163
|
this.isDrawing = true;
|
|
162
164
|
const eventDetail = evt.detail;
|
|
163
165
|
const { element } = eventDetail;
|
|
164
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox } = this.editData;
|
|
166
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
|
|
167
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
165
168
|
const { data } = annotation;
|
|
166
169
|
if (movingTextBox) {
|
|
167
170
|
const { deltaPoints } = eventDetail;
|
|
@@ -116,6 +116,7 @@ class BidirectionalTool extends AnnotationTool {
|
|
|
116
116
|
if (newAnnotation && !hasMoved) {
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
+
this.doneEditMemo();
|
|
119
120
|
data.handles.activeHandleIndex = null;
|
|
120
121
|
this._deactivateModify(element);
|
|
121
122
|
this._deactivateDraw(element);
|
|
@@ -166,9 +167,10 @@ class BidirectionalTool extends AnnotationTool {
|
|
|
166
167
|
const eventDetail = evt.detail;
|
|
167
168
|
const { currentPoints, element } = eventDetail;
|
|
168
169
|
const enabledElement = getEnabledElement(element);
|
|
169
|
-
const {
|
|
170
|
+
const { viewport } = enabledElement;
|
|
170
171
|
const { worldToCanvas } = viewport;
|
|
171
|
-
const { annotation, viewportIdsToRender, handleIndex } = this.editData;
|
|
172
|
+
const { annotation, viewportIdsToRender, handleIndex, newAnnotation } = this.editData;
|
|
173
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
172
174
|
const { data } = annotation;
|
|
173
175
|
const worldPos = currentPoints.world;
|
|
174
176
|
data.handles.points[handleIndex] = [...worldPos];
|
|
@@ -222,9 +224,8 @@ class BidirectionalTool extends AnnotationTool {
|
|
|
222
224
|
this.isDrawing = true;
|
|
223
225
|
const eventDetail = evt.detail;
|
|
224
226
|
const { element } = eventDetail;
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox } = this.editData;
|
|
227
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
|
|
228
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
228
229
|
const { data } = annotation;
|
|
229
230
|
if (movingTextBox) {
|
|
230
231
|
const { deltaPoints } = eventDetail;
|
|
@@ -158,6 +158,7 @@ class CircleROITool extends AnnotationTool {
|
|
|
158
158
|
if (newAnnotation && !hasMoved) {
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
+
this.doneEditMemo();
|
|
161
162
|
annotation.highlighted = false;
|
|
162
163
|
data.handles.activeHandleIndex = null;
|
|
163
164
|
this._deactivateModify(element);
|
|
@@ -182,9 +183,10 @@ class CircleROITool extends AnnotationTool {
|
|
|
182
183
|
const { currentPoints } = eventDetail;
|
|
183
184
|
const currentCanvasPoints = currentPoints.canvas;
|
|
184
185
|
const enabledElement = getEnabledElement(element);
|
|
185
|
-
const {
|
|
186
|
+
const { viewport } = enabledElement;
|
|
186
187
|
const { canvasToWorld } = viewport;
|
|
187
|
-
const { annotation, viewportIdsToRender } = this.editData;
|
|
188
|
+
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
189
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
188
190
|
const { data } = annotation;
|
|
189
191
|
data.handles.points = [
|
|
190
192
|
data.handles.points[0],
|
|
@@ -198,7 +200,8 @@ class CircleROITool extends AnnotationTool {
|
|
|
198
200
|
this.isDrawing = true;
|
|
199
201
|
const eventDetail = evt.detail;
|
|
200
202
|
const { element } = eventDetail;
|
|
201
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox } = this.editData;
|
|
203
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
|
|
204
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
202
205
|
const { data } = annotation;
|
|
203
206
|
if (movingTextBox) {
|
|
204
207
|
const { deltaPoints } = eventDetail;
|
|
@@ -23,9 +23,9 @@ declare class CobbAngleTool extends AnnotationTool {
|
|
|
23
23
|
isPointNearTool: (element: HTMLDivElement, annotation: CobbAngleAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
|
|
24
24
|
toolSelectedCallback: (evt: EventTypes.MouseDownEventType, annotation: CobbAngleAnnotation, interactionType: InteractionTypes, canvasCoords: Types.Point2, proximity?: number) => void;
|
|
25
25
|
handleSelectedCallback(evt: EventTypes.MouseDownEventType, annotation: CobbAngleAnnotation, handle: ToolHandle, interactionType?: string): void;
|
|
26
|
-
|
|
26
|
+
_endCallback: (evt: EventTypes.MouseUpEventType | EventTypes.MouseClickEventType) => void;
|
|
27
27
|
_mouseDownCallback: (evt: EventTypes.MouseUpEventType | EventTypes.MouseClickEventType) => void;
|
|
28
|
-
|
|
28
|
+
_dragCallback: (evt: EventTypes.MouseDragEventType | EventTypes.MouseMoveEventType) => void;
|
|
29
29
|
cancel: (element: HTMLDivElement) => string;
|
|
30
30
|
_activateModify: (element: HTMLDivElement) => void;
|
|
31
31
|
_deactivateModify: (element: HTMLDivElement) => void;
|
|
@@ -127,7 +127,7 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
127
127
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
128
128
|
evt.preventDefault();
|
|
129
129
|
};
|
|
130
|
-
this.
|
|
130
|
+
this._endCallback = (evt) => {
|
|
131
131
|
const eventDetail = evt.detail;
|
|
132
132
|
const { element } = eventDetail;
|
|
133
133
|
const { annotation, viewportIdsToRender, newAnnotation, hasMoved } = this.editData;
|
|
@@ -135,6 +135,7 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
135
135
|
if (newAnnotation && !hasMoved) {
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
+
this.doneEditMemo();
|
|
138
139
|
if (this.angleStartedNotYetCompleted && data.handles.points.length < 4) {
|
|
139
140
|
resetElementCursor(element);
|
|
140
141
|
this.editData.handleIndex = data.handles.points.length;
|
|
@@ -184,11 +185,12 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
184
185
|
data.handles.points[2] = data.handles.points[3] = worldPos;
|
|
185
186
|
this.editData.handleIndex = data.handles.points.length - 1;
|
|
186
187
|
};
|
|
187
|
-
this.
|
|
188
|
+
this._dragCallback = (evt) => {
|
|
188
189
|
this.isDrawing = true;
|
|
189
190
|
const eventDetail = evt.detail;
|
|
190
191
|
const { element } = eventDetail;
|
|
191
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, isNearFirstLine, isNearSecondLine, } = this.editData;
|
|
192
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, isNearFirstLine, isNearSecondLine, newAnnotation, } = this.editData;
|
|
193
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
192
194
|
const { data } = annotation;
|
|
193
195
|
if (movingTextBox) {
|
|
194
196
|
const { deltaPoints } = eventDetail;
|
|
@@ -261,30 +263,30 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
261
263
|
};
|
|
262
264
|
this._activateModify = (element) => {
|
|
263
265
|
state.isInteractingWithTool = true;
|
|
264
|
-
element.addEventListener(Events.MOUSE_UP, this.
|
|
265
|
-
element.addEventListener(Events.MOUSE_DRAG, this.
|
|
266
|
-
element.addEventListener(Events.MOUSE_CLICK, this.
|
|
266
|
+
element.addEventListener(Events.MOUSE_UP, this._endCallback);
|
|
267
|
+
element.addEventListener(Events.MOUSE_DRAG, this._dragCallback);
|
|
268
|
+
element.addEventListener(Events.MOUSE_CLICK, this._endCallback);
|
|
267
269
|
};
|
|
268
270
|
this._deactivateModify = (element) => {
|
|
269
271
|
state.isInteractingWithTool = false;
|
|
270
|
-
element.removeEventListener(Events.MOUSE_UP, this.
|
|
271
|
-
element.removeEventListener(Events.MOUSE_DRAG, this.
|
|
272
|
-
element.removeEventListener(Events.MOUSE_CLICK, this.
|
|
272
|
+
element.removeEventListener(Events.MOUSE_UP, this._endCallback);
|
|
273
|
+
element.removeEventListener(Events.MOUSE_DRAG, this._dragCallback);
|
|
274
|
+
element.removeEventListener(Events.MOUSE_CLICK, this._endCallback);
|
|
273
275
|
};
|
|
274
276
|
this._activateDraw = (element) => {
|
|
275
277
|
state.isInteractingWithTool = true;
|
|
276
|
-
element.addEventListener(Events.MOUSE_UP, this.
|
|
277
|
-
element.addEventListener(Events.MOUSE_DRAG, this.
|
|
278
|
-
element.addEventListener(Events.MOUSE_MOVE, this.
|
|
279
|
-
element.addEventListener(Events.MOUSE_CLICK, this.
|
|
278
|
+
element.addEventListener(Events.MOUSE_UP, this._endCallback);
|
|
279
|
+
element.addEventListener(Events.MOUSE_DRAG, this._dragCallback);
|
|
280
|
+
element.addEventListener(Events.MOUSE_MOVE, this._dragCallback);
|
|
281
|
+
element.addEventListener(Events.MOUSE_CLICK, this._endCallback);
|
|
280
282
|
element.addEventListener(Events.MOUSE_DOWN, this._mouseDownCallback);
|
|
281
283
|
};
|
|
282
284
|
this._deactivateDraw = (element) => {
|
|
283
285
|
state.isInteractingWithTool = false;
|
|
284
|
-
element.removeEventListener(Events.MOUSE_UP, this.
|
|
285
|
-
element.removeEventListener(Events.MOUSE_DRAG, this.
|
|
286
|
-
element.removeEventListener(Events.MOUSE_MOVE, this.
|
|
287
|
-
element.removeEventListener(Events.MOUSE_CLICK, this.
|
|
286
|
+
element.removeEventListener(Events.MOUSE_UP, this._endCallback);
|
|
287
|
+
element.removeEventListener(Events.MOUSE_DRAG, this._dragCallback);
|
|
288
|
+
element.removeEventListener(Events.MOUSE_MOVE, this._dragCallback);
|
|
289
|
+
element.removeEventListener(Events.MOUSE_CLICK, this._endCallback);
|
|
288
290
|
element.removeEventListener(Events.MOUSE_DOWN, this._mouseDownCallback);
|
|
289
291
|
};
|
|
290
292
|
this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
|
|
@@ -604,8 +606,6 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
604
606
|
};
|
|
605
607
|
this._activateModify(element);
|
|
606
608
|
hideElementCursor(element);
|
|
607
|
-
const enabledElement = getEnabledElement(element);
|
|
608
|
-
const { renderingEngine } = enabledElement;
|
|
609
609
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
610
610
|
evt.preventDefault();
|
|
611
611
|
}
|
|
@@ -183,8 +183,6 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
183
183
|
};
|
|
184
184
|
this._activateModify(element);
|
|
185
185
|
hideElementCursor(element);
|
|
186
|
-
const enabledElement = getEnabledElement(element);
|
|
187
|
-
const { renderingEngine } = enabledElement;
|
|
188
186
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
189
187
|
evt.preventDefault();
|
|
190
188
|
};
|
|
@@ -196,12 +194,12 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
196
194
|
if (newAnnotation && !hasMoved) {
|
|
197
195
|
return;
|
|
198
196
|
}
|
|
197
|
+
this.doneEditMemo();
|
|
199
198
|
annotation.highlighted = false;
|
|
200
199
|
data.handles.activeHandleIndex = null;
|
|
201
200
|
this._deactivateModify(element);
|
|
202
201
|
this._deactivateDraw(element);
|
|
203
202
|
resetElementCursor(element);
|
|
204
|
-
const { renderingEngine } = getEnabledElement(element);
|
|
205
203
|
this.editData = null;
|
|
206
204
|
this.isDrawing = false;
|
|
207
205
|
if (this.isHandleOutsideImage &&
|
|
@@ -220,9 +218,10 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
220
218
|
const { currentPoints } = eventDetail;
|
|
221
219
|
const currentCanvasPoints = currentPoints.canvas;
|
|
222
220
|
const enabledElement = getEnabledElement(element);
|
|
223
|
-
const {
|
|
221
|
+
const { viewport } = enabledElement;
|
|
224
222
|
const { canvasToWorld } = viewport;
|
|
225
|
-
const { annotation, viewportIdsToRender, centerWorld } = this.editData;
|
|
223
|
+
const { annotation, viewportIdsToRender, centerWorld, newAnnotation } = this.editData;
|
|
224
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
226
225
|
const centerCanvas = viewport.worldToCanvas(centerWorld);
|
|
227
226
|
const { data } = annotation;
|
|
228
227
|
const dX = Math.abs(currentCanvasPoints[0] - centerCanvas[0]);
|
|
@@ -245,7 +244,8 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
245
244
|
this.isDrawing = true;
|
|
246
245
|
const eventDetail = evt.detail;
|
|
247
246
|
const { element } = eventDetail;
|
|
248
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox } = this.editData;
|
|
247
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
|
|
248
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
249
249
|
const { data } = annotation;
|
|
250
250
|
if (movingTextBox) {
|
|
251
251
|
const { deltaPoints } = eventDetail;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Types } from '@cornerstonejs/core';
|
|
2
2
|
import { AnnotationTool } from '../base';
|
|
3
|
-
import type { EventTypes, ToolHandle, PublicToolProps, ToolProps, SVGDrawingHelper } from '../../types';
|
|
4
|
-
import type { Annotation } from '../../types';
|
|
3
|
+
import type { EventTypes, ToolHandle, PublicToolProps, ToolProps, SVGDrawingHelper, Annotation } from '../../types';
|
|
5
4
|
declare class KeyImageTool extends AnnotationTool {
|
|
6
5
|
static toolName: any;
|
|
7
6
|
_throttledCalculateCachedStats: Function;
|
|
@@ -24,7 +24,7 @@ class KeyImageTool extends AnnotationTool {
|
|
|
24
24
|
const { currentPoints, element } = eventDetail;
|
|
25
25
|
const worldPos = currentPoints.world;
|
|
26
26
|
const enabledElement = getEnabledElement(element);
|
|
27
|
-
const { viewport
|
|
27
|
+
const { viewport } = enabledElement;
|
|
28
28
|
const camera = viewport.getCamera();
|
|
29
29
|
const { viewPlaneNormal, viewUp } = camera;
|
|
30
30
|
const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
|
|
@@ -46,6 +46,7 @@ class KeyImageTool extends AnnotationTool {
|
|
|
46
46
|
triggerAnnotationCompleted(annotation);
|
|
47
47
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
48
48
|
});
|
|
49
|
+
this.createMemo(element, annotation, { newAnnotation: true });
|
|
49
50
|
return annotation;
|
|
50
51
|
};
|
|
51
52
|
this.isPointNearTool = (element, annotation, canvasCoords, proximity) => {
|
|
@@ -71,6 +72,7 @@ class KeyImageTool extends AnnotationTool {
|
|
|
71
72
|
this._endCallback = (evt) => {
|
|
72
73
|
const eventDetail = evt.detail;
|
|
73
74
|
const { element } = eventDetail;
|
|
75
|
+
this.doneEditMemo();
|
|
74
76
|
this._deactivateModify(element);
|
|
75
77
|
resetElementCursor(element);
|
|
76
78
|
};
|
|
@@ -87,8 +89,10 @@ class KeyImageTool extends AnnotationTool {
|
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
89
91
|
const annotation = clickedAnnotation;
|
|
92
|
+
this.createMemo(element, annotation);
|
|
90
93
|
this.configuration.changeTextCallback(clickedAnnotation, evt.detail, this._doneChangingTextCallback.bind(this, element, annotation));
|
|
91
94
|
this.isDrawing = false;
|
|
95
|
+
this.doneEditMemo();
|
|
92
96
|
evt.stopImmediatePropagation();
|
|
93
97
|
evt.preventDefault();
|
|
94
98
|
};
|
|
@@ -143,6 +143,7 @@ class LengthTool extends AnnotationTool {
|
|
|
143
143
|
removeAnnotation(annotation.annotationUID);
|
|
144
144
|
}
|
|
145
145
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
146
|
+
this.doneEditMemo();
|
|
146
147
|
if (newAnnotation) {
|
|
147
148
|
triggerAnnotationCompleted(annotation);
|
|
148
149
|
}
|
|
@@ -152,8 +153,10 @@ class LengthTool extends AnnotationTool {
|
|
|
152
153
|
this._dragCallback = (evt) => {
|
|
153
154
|
this.isDrawing = true;
|
|
154
155
|
const eventDetail = evt.detail;
|
|
155
|
-
const {
|
|
156
|
+
const { element } = eventDetail;
|
|
157
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
|
|
156
158
|
const { data } = annotation;
|
|
159
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
157
160
|
if (movingTextBox) {
|
|
158
161
|
const { deltaPoints } = eventDetail;
|
|
159
162
|
const worldPosDelta = deltaPoints.world;
|
|
@@ -114,6 +114,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
114
114
|
const { element } = eventDetail;
|
|
115
115
|
const { annotation, viewportIdsToRender, newAnnotation, contourHoleProcessingEnabled, } = this.editData;
|
|
116
116
|
const { data } = annotation;
|
|
117
|
+
this.doneEditMemo();
|
|
117
118
|
data.handles.activeHandleIndex = null;
|
|
118
119
|
this._deactivateModify(element);
|
|
119
120
|
this._deactivateDraw(element);
|
|
@@ -144,7 +145,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
144
145
|
};
|
|
145
146
|
this._mouseDownCallback = (evt) => {
|
|
146
147
|
const doubleClick = evt.type === Events.MOUSE_DOUBLE_CLICK;
|
|
147
|
-
const { annotation, viewportIdsToRender, worldToSlice, sliceToWorld } = this.editData;
|
|
148
|
+
const { annotation, viewportIdsToRender, worldToSlice, sliceToWorld, newAnnotation, } = this.editData;
|
|
148
149
|
if (this.editData.closed) {
|
|
149
150
|
return;
|
|
150
151
|
}
|
|
@@ -157,6 +158,10 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
157
158
|
const { viewport, renderingEngine } = enabledElement;
|
|
158
159
|
const controlPoints = this.editData.currentPath.getControlPoints();
|
|
159
160
|
let closePath = controlPoints.length >= 2 && doubleClick;
|
|
161
|
+
this.doneEditMemo();
|
|
162
|
+
this.createMemo(element, annotation, {
|
|
163
|
+
newAnnotation: newAnnotation && controlPoints.length === 1,
|
|
164
|
+
});
|
|
160
165
|
if (controlPoints.length >= 2) {
|
|
161
166
|
const closestHandlePoint = {
|
|
162
167
|
index: -1,
|
|
@@ -228,7 +233,8 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
228
233
|
this.isDrawing = true;
|
|
229
234
|
const eventDetail = evt.detail;
|
|
230
235
|
const { element } = eventDetail;
|
|
231
|
-
const { annotation, viewportIdsToRender, handleIndex,
|
|
236
|
+
const { annotation, viewportIdsToRender, movingTextBox, handleIndex, newAnnotation, } = this.editData;
|
|
237
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
232
238
|
const { data } = annotation;
|
|
233
239
|
if (movingTextBox) {
|
|
234
240
|
const { deltaPoints } = eventDetail;
|
|
@@ -265,10 +271,8 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
265
271
|
if (newAnnotation) {
|
|
266
272
|
removeAnnotation(annotation.annotationUID);
|
|
267
273
|
}
|
|
268
|
-
const enabledElement = getEnabledElement(element);
|
|
269
|
-
const { renderingEngine } = enabledElement;
|
|
270
274
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
271
|
-
this.
|
|
275
|
+
this.doneEditMemo();
|
|
272
276
|
this.scissors = null;
|
|
273
277
|
return annotation.annotationUID;
|
|
274
278
|
};
|
|
@@ -75,8 +75,12 @@ class ProbeTool extends AnnotationTool {
|
|
|
75
75
|
};
|
|
76
76
|
this._deactivateModify(element);
|
|
77
77
|
resetElementCursor(element);
|
|
78
|
+
if (newAnnotation) {
|
|
79
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
80
|
+
}
|
|
78
81
|
this.editData = null;
|
|
79
82
|
this.isDrawing = false;
|
|
83
|
+
this.doneEditMemo();
|
|
80
84
|
if (this.isHandleOutsideImage &&
|
|
81
85
|
this.configuration.preventHandleOutsideImage) {
|
|
82
86
|
removeAnnotation(annotation.annotationUID);
|
|
@@ -91,12 +95,11 @@ class ProbeTool extends AnnotationTool {
|
|
|
91
95
|
const eventDetail = evt.detail;
|
|
92
96
|
const { currentPoints, element } = eventDetail;
|
|
93
97
|
const worldPos = currentPoints.world;
|
|
94
|
-
const { annotation, viewportIdsToRender } = this.editData;
|
|
98
|
+
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
95
99
|
const { data } = annotation;
|
|
100
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
96
101
|
data.handles.points[0] = [...worldPos];
|
|
97
102
|
annotation.invalidated = true;
|
|
98
|
-
const enabledElement = getEnabledElement(element);
|
|
99
|
-
const { renderingEngine } = enabledElement;
|
|
100
103
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
101
104
|
};
|
|
102
105
|
this.cancel = (element) => {
|
|
@@ -276,8 +279,6 @@ class ProbeTool extends AnnotationTool {
|
|
|
276
279
|
};
|
|
277
280
|
this._activateModify(element);
|
|
278
281
|
hideElementCursor(element);
|
|
279
|
-
const enabledElement = getEnabledElement(element);
|
|
280
|
-
const { renderingEngine } = enabledElement;
|
|
281
282
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
282
283
|
evt.preventDefault();
|
|
283
284
|
}
|
|
@@ -168,7 +168,7 @@ class RectangleROITool extends AnnotationTool {
|
|
|
168
168
|
this._deactivateModify(element);
|
|
169
169
|
this._deactivateDraw(element);
|
|
170
170
|
resetElementCursor(element);
|
|
171
|
-
|
|
171
|
+
this.doneEditMemo();
|
|
172
172
|
this.editData = null;
|
|
173
173
|
this.isDrawing = false;
|
|
174
174
|
if (this.isHandleOutsideImage &&
|
|
@@ -184,7 +184,8 @@ class RectangleROITool extends AnnotationTool {
|
|
|
184
184
|
this.isDrawing = true;
|
|
185
185
|
const eventDetail = evt.detail;
|
|
186
186
|
const { element } = eventDetail;
|
|
187
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox } = this.editData;
|
|
187
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
|
|
188
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
188
189
|
const { data } = annotation;
|
|
189
190
|
if (movingTextBox) {
|
|
190
191
|
const { deltaPoints } = eventDetail;
|
|
@@ -142,8 +142,6 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
142
142
|
movingTextBox,
|
|
143
143
|
};
|
|
144
144
|
this._activateModify(element);
|
|
145
|
-
const enabledElement = getEnabledElement(element);
|
|
146
|
-
const { renderingEngine } = enabledElement;
|
|
147
145
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
148
146
|
evt.preventDefault();
|
|
149
147
|
};
|
|
@@ -182,6 +180,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
182
180
|
this.fireChangeOnUpdate.changeType = changeType;
|
|
183
181
|
}
|
|
184
182
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
183
|
+
this.doneEditMemo();
|
|
185
184
|
this.editData = null;
|
|
186
185
|
this.isDrawing = false;
|
|
187
186
|
};
|
|
@@ -225,8 +224,8 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
225
224
|
if (data.contour.closed) {
|
|
226
225
|
return;
|
|
227
226
|
}
|
|
227
|
+
this.doneEditMemo();
|
|
228
228
|
const eventDetail = evt.detail;
|
|
229
|
-
const { element } = eventDetail;
|
|
230
229
|
const { currentPoints } = eventDetail;
|
|
231
230
|
const { canvas: canvasPoint, world: worldPoint } = currentPoints;
|
|
232
231
|
let closeContour = data.handles.points.length >= 2 && doubleClick;
|
|
@@ -254,8 +253,9 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
254
253
|
this.isDrawing = true;
|
|
255
254
|
const eventDetail = evt.detail;
|
|
256
255
|
const { element } = eventDetail;
|
|
257
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox } = this.editData;
|
|
256
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
|
|
258
257
|
const { data } = annotation;
|
|
258
|
+
this.createMemo(element, annotation, { newAnnotation });
|
|
259
259
|
if (movingTextBox) {
|
|
260
260
|
const { deltaPoints } = eventDetail;
|
|
261
261
|
const worldPosDelta = deltaPoints.world;
|
|
@@ -19,8 +19,8 @@ declare class VideoRedactionTool extends AnnotationTool {
|
|
|
19
19
|
isPointNearTool: (element: any, annotation: any, canvasCoords: any, proximity: any) => boolean;
|
|
20
20
|
toolSelectedCallback: (evt: any, annotation: any, interactionType?: string) => void;
|
|
21
21
|
handleSelectedCallback: (evt: any, annotation: any, handle: any, interactionType?: string) => void;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
_endCallback: (evt: any) => void;
|
|
23
|
+
_dragCallback: (evt: any) => void;
|
|
24
24
|
cancel(element: any): any;
|
|
25
25
|
_activateDraw: (element: any) => void;
|
|
26
26
|
_deactivateDraw: (element: any) => void;
|