@cornerstonejs/tools 1.63.2 → 1.63.4
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/tools/annotation/KeyImageTool.d.ts +1 -29
- package/dist/cjs/tools/annotation/KeyImageTool.js +3 -30
- package/dist/cjs/tools/annotation/KeyImageTool.js.map +1 -1
- package/dist/cjs/tools/base/AnnotationTool.d.ts +3 -0
- package/dist/cjs/tools/base/AnnotationTool.js +41 -0
- package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
- package/dist/esm/tools/annotation/KeyImageTool.js +3 -30
- package/dist/esm/tools/annotation/KeyImageTool.js.map +1 -1
- package/dist/esm/tools/base/AnnotationTool.js +42 -1
- package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
- package/dist/types/tools/annotation/KeyImageTool.d.ts +1 -29
- package/dist/types/tools/annotation/KeyImageTool.d.ts.map +1 -1
- package/dist/types/tools/base/AnnotationTool.d.ts +3 -0
- package/dist/types/tools/base/AnnotationTool.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/tools/annotation/KeyImageTool.ts +3 -31
- package/src/tools/base/AnnotationTool.ts +68 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.63.
|
|
3
|
+
"version": "1.63.4",
|
|
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.63.
|
|
32
|
+
"@cornerstonejs/core": "^1.63.4",
|
|
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": "752f9beba007fcbd70718545199246df03061ca2"
|
|
63
63
|
}
|
|
@@ -89,37 +89,9 @@ class KeyImageTool extends AnnotationTool {
|
|
|
89
89
|
viewUp
|
|
90
90
|
);
|
|
91
91
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
annotationUID: null as string,
|
|
96
|
-
highlighted: true,
|
|
97
|
-
invalidated: true,
|
|
98
|
-
metadata: {
|
|
99
|
-
toolName: this.getToolName(),
|
|
100
|
-
viewPlaneNormal: <Types.Point3>[...viewPlaneNormal],
|
|
101
|
-
viewUp: <Types.Point3>[...viewUp],
|
|
102
|
-
FrameOfReferenceUID,
|
|
103
|
-
referencedImageId,
|
|
104
|
-
},
|
|
105
|
-
data: {
|
|
106
|
-
text: '',
|
|
107
|
-
handles: {
|
|
108
|
-
points: new Array<Types.Point3>(),
|
|
109
|
-
textBox: {
|
|
110
|
-
hasMoved: false,
|
|
111
|
-
worldPosition: <Types.Point3>[0, 0, 0],
|
|
112
|
-
worldBoundingBox: {
|
|
113
|
-
topLeft: <Types.Point3>[0, 0, 0],
|
|
114
|
-
topRight: <Types.Point3>[0, 0, 0],
|
|
115
|
-
bottomLeft: <Types.Point3>[0, 0, 0],
|
|
116
|
-
bottomRight: <Types.Point3>[0, 0, 0],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
label: '',
|
|
121
|
-
},
|
|
122
|
-
};
|
|
92
|
+
const annotation = KeyImageTool.createAnnotation({
|
|
93
|
+
metadata: { ...viewport.getViewReference(), referencedImageId },
|
|
94
|
+
});
|
|
123
95
|
|
|
124
96
|
addAnnotation(annotation, element);
|
|
125
97
|
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
cache,
|
|
4
4
|
getEnabledElement,
|
|
5
5
|
metaData,
|
|
6
|
+
utilities as csUtils,
|
|
6
7
|
} from '@cornerstonejs/core';
|
|
7
8
|
import type { Types } from '@cornerstonejs/core';
|
|
8
9
|
|
|
@@ -19,11 +20,12 @@ import {
|
|
|
19
20
|
InteractionTypes,
|
|
20
21
|
ToolProps,
|
|
21
22
|
PublicToolProps,
|
|
22
|
-
IToolBinding,
|
|
23
23
|
} from '../../types';
|
|
24
|
+
import { addAnnotation } from '../../stateManagement/annotation/annotationState';
|
|
24
25
|
import { StyleSpecifier } from '../../types/AnnotationStyle';
|
|
26
|
+
import { triggerAnnotationModified } from '../../stateManagement/annotation/helpers/state';
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
/**
|
|
27
29
|
* Abstract class for tools which create and display annotations on the
|
|
28
30
|
* cornerstone3D canvas. In addition, it provides a base class for segmentation
|
|
29
31
|
* tools that require drawing an annotation before running the segmentation strategy
|
|
@@ -34,6 +36,70 @@ import { StyleSpecifier } from '../../types/AnnotationStyle';
|
|
|
34
36
|
* abstract methods.
|
|
35
37
|
*/
|
|
36
38
|
abstract class AnnotationTool extends AnnotationDisplayTool {
|
|
39
|
+
/**
|
|
40
|
+
* Creates a base annotation object, adding in any annotation base data provided
|
|
41
|
+
*/
|
|
42
|
+
public static createAnnotation(...annotationBaseData): Annotation {
|
|
43
|
+
let annotation: Annotation = {
|
|
44
|
+
annotationUID: null as string,
|
|
45
|
+
highlighted: true,
|
|
46
|
+
invalidated: true,
|
|
47
|
+
metadata: {
|
|
48
|
+
toolName: this.toolName,
|
|
49
|
+
},
|
|
50
|
+
data: {
|
|
51
|
+
text: '',
|
|
52
|
+
handles: {
|
|
53
|
+
points: new Array<Types.Point3>(),
|
|
54
|
+
textBox: {
|
|
55
|
+
hasMoved: false,
|
|
56
|
+
worldPosition: <Types.Point3>[0, 0, 0],
|
|
57
|
+
worldBoundingBox: {
|
|
58
|
+
topLeft: <Types.Point3>[0, 0, 0],
|
|
59
|
+
topRight: <Types.Point3>[0, 0, 0],
|
|
60
|
+
bottomLeft: <Types.Point3>[0, 0, 0],
|
|
61
|
+
bottomRight: <Types.Point3>[0, 0, 0],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
label: '',
|
|
66
|
+
},
|
|
67
|
+
} as unknown as Annotation;
|
|
68
|
+
for (const baseData of annotationBaseData) {
|
|
69
|
+
annotation = csUtils.deepMerge(annotation, baseData);
|
|
70
|
+
}
|
|
71
|
+
return annotation;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new annotation for the given viewport. This just adds the
|
|
76
|
+
* viewport reference data to the metadata, and otherwise returns the
|
|
77
|
+
* static class createAnnotation data.
|
|
78
|
+
*/
|
|
79
|
+
public static createAnnotationForViewport(viewport, ...annotationBaseData) {
|
|
80
|
+
return this.createAnnotation(
|
|
81
|
+
{ metadata: viewport.getViewReference() },
|
|
82
|
+
...annotationBaseData
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Creates and adds an annotation of the given type, firing the annotation
|
|
88
|
+
* modified event on the new annotation.
|
|
89
|
+
* This implicitly uses the static class when you call it on the correct
|
|
90
|
+
* base class. For example, you can call the KeyImageTool.createAnnotation
|
|
91
|
+
* method on KeyImageTool.toolName by calling KeyImageTool.createAndAddAnnotation
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
public static createAndAddAnnotation(viewport, ...annotationBaseData) {
|
|
95
|
+
const annotation = this.createAnnotationForViewport(
|
|
96
|
+
viewport,
|
|
97
|
+
...annotationBaseData
|
|
98
|
+
);
|
|
99
|
+
addAnnotation(annotation, viewport.element);
|
|
100
|
+
triggerAnnotationModified(annotation, viewport.element);
|
|
101
|
+
}
|
|
102
|
+
|
|
37
103
|
static toolName;
|
|
38
104
|
// ===================================================================
|
|
39
105
|
// Abstract Methods - Must be implemented.
|