@cornerstonejs/tools 1.77.9 → 1.77.11
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/cjs/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.d.ts +2 -2
- package/dist/cjs/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +24 -6
- package/dist/cjs/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js.map +1 -1
- package/dist/cjs/stateManagement/annotation/annotationState.d.ts +2 -1
- package/dist/cjs/stateManagement/annotation/annotationState.js +21 -9
- package/dist/cjs/stateManagement/annotation/annotationState.js.map +1 -1
- package/dist/cjs/stateManagement/annotation/helpers/state.d.ts +3 -1
- package/dist/cjs/stateManagement/annotation/helpers/state.js +6 -1
- package/dist/cjs/stateManagement/annotation/helpers/state.js.map +1 -1
- package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +24 -6
- package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js.map +1 -1
- package/dist/esm/stateManagement/annotation/annotationState.js +22 -11
- package/dist/esm/stateManagement/annotation/annotationState.js.map +1 -1
- package/dist/esm/stateManagement/annotation/helpers/state.js +5 -1
- package/dist/esm/stateManagement/annotation/helpers/state.js.map +1 -1
- package/dist/types/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.d.ts +2 -2
- package/dist/types/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.d.ts.map +1 -1
- package/dist/types/stateManagement/annotation/annotationState.d.ts +2 -1
- package/dist/types/stateManagement/annotation/annotationState.d.ts.map +1 -1
- package/dist/types/stateManagement/annotation/helpers/state.d.ts +3 -1
- package/dist/types/stateManagement/annotation/helpers/state.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.ts +35 -8
- package/src/stateManagement/annotation/annotationState.ts +35 -17
- package/src/stateManagement/annotation/helpers/state.ts +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.77.
|
|
3
|
+
"version": "1.77.11",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cornerstonejs/core": "^1.77.
|
|
32
|
+
"@cornerstonejs/core": "^1.77.11",
|
|
33
33
|
"@icr/polyseg-wasm": "0.4.0",
|
|
34
34
|
"@types/offscreencanvas": "2019.7.3",
|
|
35
35
|
"comlink": "^4.4.1",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"type": "individual",
|
|
60
60
|
"url": "https://ohif.org/donate"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "8e4edbcf44a2b511a06fa6fedc058cacf5ed9646"
|
|
63
63
|
}
|
|
@@ -285,16 +285,34 @@ class FrameOfReferenceSpecificAnnotationManager implements IAnnotationManager {
|
|
|
285
285
|
*
|
|
286
286
|
* @param groupKey - The group key to remove annotations for (in default manager it is FrameOfReferenceUID).
|
|
287
287
|
* @param toolName - Optional. The name of the tool to remove annotations for.
|
|
288
|
+
*
|
|
289
|
+
* @returns The removed annotations
|
|
288
290
|
*/
|
|
289
|
-
removeAnnotations = (groupKey: string, toolName?: string):
|
|
291
|
+
removeAnnotations = (groupKey: string, toolName?: string): Annotations => {
|
|
290
292
|
const annotations = this.annotations;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
293
|
+
const removedAnnotations = [];
|
|
294
|
+
|
|
295
|
+
if (!annotations[groupKey]) {
|
|
296
|
+
return removedAnnotations;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (toolName) {
|
|
300
|
+
const annotationsForTool = annotations[groupKey][toolName];
|
|
301
|
+
for (const annotation of annotationsForTool) {
|
|
302
|
+
this.removeAnnotation(annotation.annotationUID);
|
|
303
|
+
removedAnnotations.push(annotation);
|
|
304
|
+
}
|
|
305
|
+
} else {
|
|
306
|
+
for (const toolName in annotations[groupKey]) {
|
|
307
|
+
const annotationsForTool = annotations[groupKey][toolName];
|
|
308
|
+
for (const annotation of annotationsForTool) {
|
|
309
|
+
this.removeAnnotation(annotation.annotationUID);
|
|
310
|
+
removedAnnotations.push(annotation);
|
|
311
|
+
}
|
|
296
312
|
}
|
|
297
313
|
}
|
|
314
|
+
|
|
315
|
+
return removedAnnotations;
|
|
298
316
|
};
|
|
299
317
|
|
|
300
318
|
/**
|
|
@@ -407,9 +425,18 @@ class FrameOfReferenceSpecificAnnotationManager implements IAnnotationManager {
|
|
|
407
425
|
|
|
408
426
|
/**
|
|
409
427
|
* Removes all annotations in the annotation state.
|
|
428
|
+
*
|
|
429
|
+
* @returns The removed annotations
|
|
410
430
|
*/
|
|
411
|
-
removeAllAnnotations = ():
|
|
412
|
-
|
|
431
|
+
removeAllAnnotations = (): Annotations => {
|
|
432
|
+
const removedAnnotations = [];
|
|
433
|
+
|
|
434
|
+
for (const annotation of this.getAllAnnotations()) {
|
|
435
|
+
this.removeAnnotation(annotation.annotationUID);
|
|
436
|
+
removedAnnotations.push(annotation);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return removedAnnotations;
|
|
413
440
|
};
|
|
414
441
|
}
|
|
415
442
|
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
triggerEvent,
|
|
3
|
-
eventTarget,
|
|
4
|
-
utilities as csUtils,
|
|
5
|
-
} from '@cornerstonejs/core';
|
|
6
|
-
import { Events } from '../../enums';
|
|
1
|
+
import { utilities as csUtils } from '@cornerstonejs/core';
|
|
7
2
|
import { defaultFrameOfReferenceSpecificAnnotationManager } from './FrameOfReferenceSpecificAnnotationManager';
|
|
8
3
|
import { Annotations, Annotation } from '../../types/AnnotationTypes';
|
|
9
|
-
import { AnnotationRemovedEventDetail } from '../../types/EventTypes';
|
|
10
4
|
import { AnnotationGroupSelector } from '../../types';
|
|
5
|
+
|
|
11
6
|
import {
|
|
12
7
|
triggerAnnotationAddedForElement,
|
|
13
8
|
triggerAnnotationAddedForFOR,
|
|
9
|
+
triggerAnnotationRemoved,
|
|
14
10
|
} from './helpers/state';
|
|
15
11
|
|
|
16
12
|
// our default annotation manager
|
|
@@ -224,15 +220,7 @@ function removeAnnotation(annotationUID: string): void {
|
|
|
224
220
|
|
|
225
221
|
manager.removeAnnotation(annotationUID);
|
|
226
222
|
|
|
227
|
-
|
|
228
|
-
const eventType = Events.ANNOTATION_REMOVED;
|
|
229
|
-
|
|
230
|
-
const eventDetail: AnnotationRemovedEventDetail = {
|
|
231
|
-
annotation,
|
|
232
|
-
annotationManagerUID: manager.uid,
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
triggerEvent(eventTarget, eventType, eventDetail);
|
|
223
|
+
triggerAnnotationRemoved({ annotation, annotationManagerUID: manager.uid });
|
|
236
224
|
}
|
|
237
225
|
|
|
238
226
|
/**
|
|
@@ -251,7 +239,36 @@ function getAnnotation(annotationUID: string): Annotation {
|
|
|
251
239
|
*/
|
|
252
240
|
function removeAllAnnotations(): void {
|
|
253
241
|
const manager = getAnnotationManager();
|
|
254
|
-
manager.removeAllAnnotations();
|
|
242
|
+
const removedAnnotations = manager.removeAllAnnotations();
|
|
243
|
+
|
|
244
|
+
for (const annotation of removedAnnotations) {
|
|
245
|
+
triggerAnnotationRemoved({
|
|
246
|
+
annotation,
|
|
247
|
+
annotationManagerUID: manager.uid,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Removes all annotations associated with the specified group (FrameOfReferenceUID) and tool, or
|
|
254
|
+
* all annotations for the group (FrameOfReferenceUID) if the tool name is not provided.
|
|
255
|
+
* @param toolName - Optional. The name of the tool to remove annotations for.
|
|
256
|
+
* @param annotationGroupSelector - The group (FrameOfReferenceUID) to remove annotations for.
|
|
257
|
+
*/
|
|
258
|
+
function removeAnnotations(
|
|
259
|
+
toolName: string,
|
|
260
|
+
annotationGroupSelector: AnnotationGroupSelector
|
|
261
|
+
): void {
|
|
262
|
+
const manager = getAnnotationManager();
|
|
263
|
+
const groupKey = manager.getGroupKey(annotationGroupSelector);
|
|
264
|
+
const removedAnnotations = manager.removeAnnotations(groupKey, toolName);
|
|
265
|
+
|
|
266
|
+
for (const annotation of removedAnnotations) {
|
|
267
|
+
triggerAnnotationRemoved({
|
|
268
|
+
annotation,
|
|
269
|
+
annotationManagerUID: manager.uid,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
255
272
|
}
|
|
256
273
|
|
|
257
274
|
/**
|
|
@@ -281,6 +298,7 @@ export {
|
|
|
281
298
|
addAnnotation,
|
|
282
299
|
getAnnotation,
|
|
283
300
|
removeAnnotation,
|
|
301
|
+
removeAnnotations,
|
|
284
302
|
removeAllAnnotations,
|
|
285
303
|
// annotation manager
|
|
286
304
|
setAnnotationManager,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
AnnotationModifiedEventDetail,
|
|
13
13
|
AnnotationCompletedEventDetail,
|
|
14
14
|
ContourAnnotationCompletedEventDetail,
|
|
15
|
+
AnnotationRemovedEventDetail,
|
|
15
16
|
} from '../../../types/EventTypes';
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -81,6 +82,17 @@ function triggerAnnotationAddedForFOR(annotation: Annotation) {
|
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Triggers an annotation removed event.
|
|
87
|
+
* @param eventDetail - Event detail
|
|
88
|
+
*/
|
|
89
|
+
function triggerAnnotationRemoved(
|
|
90
|
+
eventDetail: AnnotationRemovedEventDetail
|
|
91
|
+
): void {
|
|
92
|
+
const eventType = Events.ANNOTATION_REMOVED;
|
|
93
|
+
triggerEvent(eventTarget, eventType, eventDetail);
|
|
94
|
+
}
|
|
95
|
+
|
|
84
96
|
/**
|
|
85
97
|
* Triggers an annotation modified event.
|
|
86
98
|
*/
|
|
@@ -143,6 +155,7 @@ function _triggerAnnotationCompleted(
|
|
|
143
155
|
export {
|
|
144
156
|
triggerAnnotationAddedForElement,
|
|
145
157
|
triggerAnnotationAddedForFOR,
|
|
158
|
+
triggerAnnotationRemoved,
|
|
146
159
|
triggerAnnotationModified,
|
|
147
160
|
triggerAnnotationCompleted,
|
|
148
161
|
triggerContourAnnotationCompleted,
|