@cornerstonejs/tools 1.60.0 → 1.61.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/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tools/AnnotationEraserTool.d.ts +10 -0
- package/dist/cjs/tools/AnnotationEraserTool.js +55 -0
- package/dist/cjs/tools/AnnotationEraserTool.js.map +1 -0
- package/dist/cjs/tools/index.d.ts +2 -1
- package/dist/cjs/tools/index.js +3 -1
- package/dist/cjs/tools/index.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tools/AnnotationEraserTool.js +53 -0
- package/dist/esm/tools/AnnotationEraserTool.js.map +1 -0
- package/dist/esm/tools/index.js +2 -1
- package/dist/esm/tools/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tools/AnnotationEraserTool.d.ts +11 -0
- package/dist/types/tools/AnnotationEraserTool.d.ts.map +1 -0
- package/dist/types/tools/index.d.ts +2 -1
- package/dist/types/tools/index.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/index.ts +2 -0
- package/src/tools/AnnotationEraserTool.ts +96 -0
- package/src/tools/index.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.61.0",
|
|
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.
|
|
32
|
+
"@cornerstonejs/core": "^1.61.0",
|
|
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": "1d273f1e4ab80b7416020a4b801fbacbcb5f1ff7"
|
|
63
63
|
}
|
package/src/index.ts
CHANGED
|
@@ -69,6 +69,7 @@ import {
|
|
|
69
69
|
OrientationMarkerTool,
|
|
70
70
|
OverlayGridTool,
|
|
71
71
|
SegmentationIntersectionTool,
|
|
72
|
+
EraserTool,
|
|
72
73
|
SegmentSelectTool,
|
|
73
74
|
} from './tools';
|
|
74
75
|
|
|
@@ -126,6 +127,7 @@ export {
|
|
|
126
127
|
ReferenceCursors,
|
|
127
128
|
ReferenceLines,
|
|
128
129
|
ScaleOverlayTool,
|
|
130
|
+
EraserTool,
|
|
129
131
|
// Segmentation Display
|
|
130
132
|
SegmentationDisplayTool,
|
|
131
133
|
// Segmentation Editing Tools
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { BaseTool } from './base';
|
|
2
|
+
import { EventTypes, PublicToolProps, ToolProps } from '../types';
|
|
3
|
+
import { ToolGroupManager } from '../store';
|
|
4
|
+
import {
|
|
5
|
+
getAnnotations,
|
|
6
|
+
removeAnnotation,
|
|
7
|
+
} from '../stateManagement/annotation/annotationState';
|
|
8
|
+
import { setAnnotationSelected } from '../stateManagement/annotation/annotationSelection';
|
|
9
|
+
|
|
10
|
+
class AnnotationEraserTool extends BaseTool {
|
|
11
|
+
static toolName;
|
|
12
|
+
constructor(
|
|
13
|
+
toolProps: PublicToolProps = {},
|
|
14
|
+
defaultToolProps: ToolProps = {
|
|
15
|
+
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
16
|
+
}
|
|
17
|
+
) {
|
|
18
|
+
super(toolProps, defaultToolProps);
|
|
19
|
+
}
|
|
20
|
+
preMouseDownCallback = (evt: EventTypes.InteractionEventType): boolean => {
|
|
21
|
+
return this._deleteNearbyAnnotations(evt, 'mouse');
|
|
22
|
+
};
|
|
23
|
+
preTouchStartCallback = (evt: EventTypes.InteractionEventType): boolean => {
|
|
24
|
+
return this._deleteNearbyAnnotations(evt, 'touch');
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
_deleteNearbyAnnotations(
|
|
28
|
+
evt: EventTypes.InteractionEventType,
|
|
29
|
+
interactionType: string
|
|
30
|
+
): boolean {
|
|
31
|
+
const { renderingEngineId, viewportId, element, currentPoints } =
|
|
32
|
+
evt.detail;
|
|
33
|
+
|
|
34
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(
|
|
35
|
+
viewportId,
|
|
36
|
+
renderingEngineId
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (!toolGroup) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const tools = toolGroup._toolInstances;
|
|
44
|
+
const annotationsToRemove = [];
|
|
45
|
+
|
|
46
|
+
for (const toolName in tools) {
|
|
47
|
+
const toolInstance = tools[toolName];
|
|
48
|
+
|
|
49
|
+
if (
|
|
50
|
+
typeof toolInstance.isPointNearTool !== 'function' ||
|
|
51
|
+
typeof toolInstance.filterInteractableAnnotationsForElement !==
|
|
52
|
+
'function'
|
|
53
|
+
) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const annotations = getAnnotations(toolName, element);
|
|
58
|
+
|
|
59
|
+
if (!annotations) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const interactableAnnotations =
|
|
64
|
+
toolInstance.filterInteractableAnnotationsForElement(
|
|
65
|
+
element,
|
|
66
|
+
annotations
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
for (const annotation of interactableAnnotations) {
|
|
70
|
+
if (
|
|
71
|
+
toolInstance.isPointNearTool(
|
|
72
|
+
element,
|
|
73
|
+
annotation,
|
|
74
|
+
currentPoints.canvas,
|
|
75
|
+
10,
|
|
76
|
+
interactionType
|
|
77
|
+
)
|
|
78
|
+
) {
|
|
79
|
+
annotationsToRemove.push(annotation.annotationUID);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
for (const annotationUID of annotationsToRemove) {
|
|
85
|
+
setAnnotationSelected(annotationUID);
|
|
86
|
+
removeAnnotation(annotationUID);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
evt.preventDefault();
|
|
90
|
+
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
AnnotationEraserTool.toolName = 'Eraser';
|
|
96
|
+
export default AnnotationEraserTool;
|
package/src/tools/index.ts
CHANGED
|
@@ -37,6 +37,7 @@ import AngleTool from './annotation/AngleTool';
|
|
|
37
37
|
import CobbAngleTool from './annotation/CobbAngleTool';
|
|
38
38
|
import UltrasoundDirectionalTool from './annotation/UltrasoundDirectionalTool';
|
|
39
39
|
import KeyImageTool from './annotation/KeyImageTool';
|
|
40
|
+
import AnnotationEraserTool from './AnnotationEraserTool';
|
|
40
41
|
|
|
41
42
|
// Segmentation DisplayTool
|
|
42
43
|
import SegmentationDisplayTool from './displayTools/SegmentationDisplayTool';
|
|
@@ -90,6 +91,7 @@ export {
|
|
|
90
91
|
CobbAngleTool,
|
|
91
92
|
UltrasoundDirectionalTool,
|
|
92
93
|
KeyImageTool,
|
|
94
|
+
AnnotationEraserTool as EraserTool,
|
|
93
95
|
// Segmentations Display
|
|
94
96
|
SegmentationDisplayTool,
|
|
95
97
|
// Segmentations Tools
|