@cornerstonejs/tools 1.40.3 → 1.42.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/drawingSvg/drawHandle.d.ts +4 -0
- package/dist/cjs/drawingSvg/drawHandle.js +66 -0
- package/dist/cjs/drawingSvg/drawHandle.js.map +1 -0
- package/dist/cjs/drawingSvg/drawHandles.js +4 -60
- package/dist/cjs/drawingSvg/drawHandles.js.map +1 -1
- package/dist/cjs/drawingSvg/index.d.ts +2 -1
- package/dist/cjs/drawingSvg/index.js +3 -1
- package/dist/cjs/drawingSvg/index.js.map +1 -1
- package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
- package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
- 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/stateManagement/annotation/annotationState.js +3 -0
- package/dist/cjs/stateManagement/annotation/annotationState.js.map +1 -1
- package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
- package/dist/cjs/tools/annotation/BidirectionalTool.js +7 -6
- package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LengthTool.js +4 -3
- package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
- package/dist/cjs/tools/annotation/ProbeTool.js +24 -3
- package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
- package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.d.ts +36 -0
- package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js +483 -0
- package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.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/cjs/types/ToolSpecificAnnotationTypes.d.ts +28 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/utilities/contours/AnnotationToPointData.d.ts +11 -0
- package/dist/cjs/utilities/contours/AnnotationToPointData.js +44 -0
- package/dist/cjs/utilities/contours/AnnotationToPointData.js.map +1 -0
- package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.d.ts +6 -0
- package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js +43 -0
- package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
- package/dist/cjs/utilities/contours/contourFinder.d.ts +7 -0
- package/dist/cjs/utilities/contours/contourFinder.js +68 -0
- package/dist/cjs/utilities/contours/contourFinder.js.map +1 -0
- package/dist/cjs/utilities/contours/detectContourHoles.d.ts +5 -0
- package/dist/cjs/utilities/contours/detectContourHoles.js +78 -0
- package/dist/cjs/utilities/contours/detectContourHoles.js.map +1 -0
- package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.d.ts +4 -0
- package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js +124 -0
- package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
- package/dist/cjs/utilities/contours/index.d.ts +6 -0
- package/dist/cjs/utilities/contours/index.js +17 -0
- package/dist/cjs/utilities/contours/index.js.map +1 -0
- package/dist/cjs/utilities/contours/mergePoints.d.ts +8 -0
- package/dist/cjs/utilities/contours/mergePoints.js +77 -0
- package/dist/cjs/utilities/contours/mergePoints.js.map +1 -0
- package/dist/cjs/utilities/getCalibratedUnits.d.ts +16 -2
- package/dist/cjs/utilities/getCalibratedUnits.js +127 -5
- package/dist/cjs/utilities/getCalibratedUnits.js.map +1 -1
- package/dist/cjs/utilities/index.d.ts +2 -1
- package/dist/cjs/utilities/index.js +3 -1
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +1 -0
- package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js +31 -0
- package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
- package/dist/cjs/utilities/segmentation/createBidirectionalToolData.d.ts +14 -0
- package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js +43 -0
- package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
- package/dist/cjs/utilities/segmentation/findLargestBidirectional.d.ts +1 -0
- package/dist/cjs/utilities/segmentation/findLargestBidirectional.js +94 -0
- package/dist/cjs/utilities/segmentation/findLargestBidirectional.js.map +1 -0
- package/dist/cjs/utilities/segmentation/index.d.ts +4 -1
- package/dist/cjs/utilities/segmentation/index.js +7 -1
- package/dist/cjs/utilities/segmentation/index.js.map +1 -1
- package/dist/cjs/utilities/segmentation/isLineInSegment.d.ts +9 -0
- package/dist/cjs/utilities/segmentation/isLineInSegment.js +55 -0
- package/dist/cjs/utilities/segmentation/isLineInSegment.js.map +1 -0
- package/dist/cjs/utilities/segmentation/segmentContourAction.d.ts +17 -0
- package/dist/cjs/utilities/segmentation/segmentContourAction.js +122 -0
- package/dist/cjs/utilities/segmentation/segmentContourAction.js.map +1 -0
- package/dist/esm/drawingSvg/drawHandle.js +61 -0
- package/dist/esm/drawingSvg/drawHandle.js.map +1 -0
- package/dist/esm/drawingSvg/drawHandles.js +4 -60
- package/dist/esm/drawingSvg/drawHandles.js.map +1 -1
- package/dist/esm/drawingSvg/index.js +2 -1
- package/dist/esm/drawingSvg/index.js.map +1 -1
- package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
- package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stateManagement/annotation/annotationState.js +3 -0
- package/dist/esm/stateManagement/annotation/annotationState.js.map +1 -1
- package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +7 -6
- package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/esm/tools/annotation/LengthTool.js +5 -4
- package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
- package/dist/esm/tools/annotation/ProbeTool.js +24 -3
- package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
- package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +478 -0
- package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js.map +1 -0
- package/dist/esm/tools/index.js +2 -1
- package/dist/esm/tools/index.js.map +1 -1
- package/dist/esm/utilities/contours/AnnotationToPointData.js +39 -0
- package/dist/esm/utilities/contours/AnnotationToPointData.js.map +1 -0
- package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js +41 -0
- package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
- package/dist/esm/utilities/contours/contourFinder.js +63 -0
- package/dist/esm/utilities/contours/contourFinder.js.map +1 -0
- package/dist/esm/utilities/contours/detectContourHoles.js +74 -0
- package/dist/esm/utilities/contours/detectContourHoles.js.map +1 -0
- package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js +117 -0
- package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
- package/dist/esm/utilities/contours/index.js +7 -0
- package/dist/esm/utilities/contours/index.js.map +1 -0
- package/dist/esm/utilities/contours/mergePoints.js +73 -0
- package/dist/esm/utilities/contours/mergePoints.js.map +1 -0
- package/dist/esm/utilities/getCalibratedUnits.js +125 -6
- package/dist/esm/utilities/getCalibratedUnits.js.map +1 -1
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js +25 -0
- package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
- package/dist/esm/utilities/segmentation/createBidirectionalToolData.js +40 -0
- package/dist/esm/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
- package/dist/esm/utilities/segmentation/findLargestBidirectional.js +96 -0
- package/dist/esm/utilities/segmentation/findLargestBidirectional.js.map +1 -0
- package/dist/esm/utilities/segmentation/index.js +4 -1
- package/dist/esm/utilities/segmentation/index.js.map +1 -1
- package/dist/esm/utilities/segmentation/isLineInSegment.js +50 -0
- package/dist/esm/utilities/segmentation/isLineInSegment.js.map +1 -0
- package/dist/esm/utilities/segmentation/segmentContourAction.js +98 -0
- package/dist/esm/utilities/segmentation/segmentContourAction.js.map +1 -0
- package/dist/types/drawingSvg/drawHandle.d.ts +5 -0
- package/dist/types/drawingSvg/drawHandle.d.ts.map +1 -0
- package/dist/types/drawingSvg/drawHandles.d.ts.map +1 -1
- package/dist/types/drawingSvg/index.d.ts +2 -1
- package/dist/types/drawingSvg/index.d.ts.map +1 -1
- package/dist/types/eventDispatchers/keyboardEventHandlers/keyDown.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/stateManagement/annotation/annotationState.d.ts.map +1 -1
- package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/BidirectionalTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/ProbeTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/UltrasoundDirectionalTool.d.ts +37 -0
- package/dist/types/tools/annotation/UltrasoundDirectionalTool.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/types/types/ToolSpecificAnnotationTypes.d.ts +28 -0
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utilities/contours/AnnotationToPointData.d.ts +12 -0
- package/dist/types/utilities/contours/AnnotationToPointData.d.ts.map +1 -0
- package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts +7 -0
- package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts.map +1 -0
- package/dist/types/utilities/contours/contourFinder.d.ts +8 -0
- package/dist/types/utilities/contours/contourFinder.d.ts.map +1 -0
- package/dist/types/utilities/contours/detectContourHoles.d.ts +6 -0
- package/dist/types/utilities/contours/detectContourHoles.d.ts.map +1 -0
- package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts +5 -0
- package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts.map +1 -0
- package/dist/types/utilities/contours/index.d.ts +7 -0
- package/dist/types/utilities/contours/index.d.ts.map +1 -0
- package/dist/types/utilities/contours/mergePoints.d.ts +9 -0
- package/dist/types/utilities/contours/mergePoints.d.ts.map +1 -0
- package/dist/types/utilities/getCalibratedUnits.d.ts +16 -2
- package/dist/types/utilities/getCalibratedUnits.d.ts.map +1 -1
- package/dist/types/utilities/index.d.ts +2 -1
- package/dist/types/utilities/index.d.ts.map +1 -1
- package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +2 -0
- package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts +15 -0
- package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts +2 -0
- package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/index.d.ts +4 -1
- package/dist/types/utilities/segmentation/index.d.ts.map +1 -1
- package/dist/types/utilities/segmentation/isLineInSegment.d.ts +10 -0
- package/dist/types/utilities/segmentation/isLineInSegment.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/segmentContourAction.d.ts +18 -0
- package/dist/types/utilities/segmentation/segmentContourAction.d.ts.map +1 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/drawingSvg/drawHandle.ts +88 -0
- package/src/drawingSvg/drawHandles.ts +9 -75
- package/src/drawingSvg/index.ts +2 -0
- package/src/eventDispatchers/keyboardEventHandlers/keyDown.ts +7 -1
- package/src/index.ts +2 -0
- package/src/stateManagement/annotation/annotationState.ts +3 -0
- package/src/tools/annotation/AngleTool.ts +0 -1
- package/src/tools/annotation/BidirectionalTool.ts +9 -5
- package/src/tools/annotation/LengthTool.ts +6 -8
- package/src/tools/annotation/ProbeTool.ts +31 -7
- package/src/tools/annotation/UltrasoundDirectionalTool.ts +916 -0
- package/src/tools/index.ts +2 -0
- package/src/types/ToolSpecificAnnotationTypes.ts +29 -0
- package/src/types/index.ts +2 -0
- package/src/utilities/contours/AnnotationToPointData.ts +61 -0
- package/src/utilities/contours/RectangleROIStartEndThreshold.ts +60 -0
- package/src/utilities/contours/contourFinder.ts +78 -0
- package/src/utilities/contours/detectContourHoles.ts +147 -0
- package/src/utilities/contours/generateContourSetsFromLabelmap.ts +160 -0
- package/src/utilities/contours/index.ts +14 -0
- package/src/utilities/contours/mergePoints.ts +108 -0
- package/src/utilities/getCalibratedUnits.ts +203 -7
- package/src/utilities/index.ts +2 -0
- package/src/utilities/segmentation/contourAndFindLargestBidirectional.ts +46 -0
- package/src/utilities/segmentation/createBidirectionalToolData.ts +68 -0
- package/src/utilities/segmentation/findLargestBidirectional.ts +159 -0
- package/src/utilities/segmentation/index.ts +6 -0
- package/src/utilities/segmentation/isLineInSegment.ts +84 -0
- package/src/utilities/segmentation/segmentContourAction.ts +169 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.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.42.0",
|
|
33
33
|
"comlink": "^4.4.1",
|
|
34
34
|
"lodash.clonedeep": "4.5.0",
|
|
35
35
|
"lodash.get": "^4.4.2"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"type": "individual",
|
|
54
54
|
"url": "https://ohif.org/donate"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "75102c80b6bc3714f00590b92ccd8d4d52bf1ca2"
|
|
57
57
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
import _getHash from './_getHash';
|
|
4
|
+
import setNewAttributesIfValid from './setNewAttributesIfValid';
|
|
5
|
+
import setAttributesIfNecessary from './setAttributesIfNecessary';
|
|
6
|
+
import { SVGDrawingHelper } from '../types';
|
|
7
|
+
|
|
8
|
+
function drawHandle(
|
|
9
|
+
svgDrawingHelper: SVGDrawingHelper,
|
|
10
|
+
annotationUID: string,
|
|
11
|
+
handleGroupUID: string,
|
|
12
|
+
handle: Types.Point2,
|
|
13
|
+
options = {},
|
|
14
|
+
uniqueIndex
|
|
15
|
+
): void {
|
|
16
|
+
const { color, handleRadius, width, lineWidth, fill, type, opacity } =
|
|
17
|
+
Object.assign(
|
|
18
|
+
{
|
|
19
|
+
color: 'dodgerblue',
|
|
20
|
+
handleRadius: '6',
|
|
21
|
+
width: '2',
|
|
22
|
+
lineWidth: undefined,
|
|
23
|
+
fill: 'transparent',
|
|
24
|
+
type: 'circle',
|
|
25
|
+
opacity: 1,
|
|
26
|
+
},
|
|
27
|
+
options
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// for supporting both lineWidth and width options
|
|
31
|
+
const strokeWidth = lineWidth || width;
|
|
32
|
+
|
|
33
|
+
// variable for the namespace
|
|
34
|
+
const svgns = 'http://www.w3.org/2000/svg';
|
|
35
|
+
const svgNodeHash = _getHash(
|
|
36
|
+
annotationUID,
|
|
37
|
+
'handle',
|
|
38
|
+
`hg-${handleGroupUID}-index-${uniqueIndex}`
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
let attributes;
|
|
42
|
+
if (type === 'circle') {
|
|
43
|
+
attributes = {
|
|
44
|
+
cx: `${handle[0]}`,
|
|
45
|
+
cy: `${handle[1]}`,
|
|
46
|
+
r: handleRadius,
|
|
47
|
+
stroke: color,
|
|
48
|
+
fill,
|
|
49
|
+
'stroke-width': strokeWidth,
|
|
50
|
+
opacity: opacity,
|
|
51
|
+
};
|
|
52
|
+
} else if (type === 'rect') {
|
|
53
|
+
const handleRadiusFloat = parseFloat(handleRadius);
|
|
54
|
+
const side = handleRadiusFloat * 1.5;
|
|
55
|
+
const x = handle[0] - side * 0.5;
|
|
56
|
+
const y = handle[1] - side * 0.5;
|
|
57
|
+
|
|
58
|
+
attributes = {
|
|
59
|
+
x: `${x}`,
|
|
60
|
+
y: `${y}`,
|
|
61
|
+
width: `${side}`,
|
|
62
|
+
height: `${side}`,
|
|
63
|
+
stroke: color,
|
|
64
|
+
fill,
|
|
65
|
+
'stroke-width': strokeWidth,
|
|
66
|
+
rx: `${side * 0.1}`,
|
|
67
|
+
opacity: opacity,
|
|
68
|
+
};
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error(`Unsupported handle type: ${type}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const existingHandleElement = svgDrawingHelper.getSvgNode(svgNodeHash);
|
|
74
|
+
|
|
75
|
+
if (existingHandleElement) {
|
|
76
|
+
setAttributesIfNecessary(attributes, existingHandleElement);
|
|
77
|
+
|
|
78
|
+
svgDrawingHelper.setNodeTouched(svgNodeHash);
|
|
79
|
+
} else {
|
|
80
|
+
const newHandleElement = document.createElementNS(svgns, type);
|
|
81
|
+
|
|
82
|
+
setNewAttributesIfValid(attributes, newHandleElement);
|
|
83
|
+
|
|
84
|
+
svgDrawingHelper.appendNode(newHandleElement, svgNodeHash);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default drawHandle;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Types } from '@cornerstonejs/core';
|
|
2
2
|
|
|
3
|
-
import _getHash from './_getHash';
|
|
4
|
-
import setNewAttributesIfValid from './setNewAttributesIfValid';
|
|
5
|
-
import setAttributesIfNecessary from './setAttributesIfNecessary';
|
|
6
3
|
import { SVGDrawingHelper } from '../types';
|
|
4
|
+
import drawHandle from './drawHandle';
|
|
7
5
|
|
|
8
6
|
function drawHandles(
|
|
9
7
|
svgDrawingHelper: SVGDrawingHelper,
|
|
@@ -12,80 +10,16 @@ function drawHandles(
|
|
|
12
10
|
handlePoints: Array<Types.Point2>,
|
|
13
11
|
options = {}
|
|
14
12
|
): void {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
color: 'dodgerblue',
|
|
19
|
-
handleRadius: '6',
|
|
20
|
-
width: '2',
|
|
21
|
-
lineWidth: undefined,
|
|
22
|
-
fill: 'transparent',
|
|
23
|
-
type: 'circle',
|
|
24
|
-
opacity: 1,
|
|
25
|
-
},
|
|
26
|
-
options
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// for supporting both lineWidth and width options
|
|
30
|
-
const strokeWidth = lineWidth || width;
|
|
31
|
-
|
|
32
|
-
for (let i = 0; i < handlePoints.length; i++) {
|
|
33
|
-
const handle = handlePoints[i];
|
|
34
|
-
|
|
35
|
-
// variable for the namespace
|
|
36
|
-
const svgns = 'http://www.w3.org/2000/svg';
|
|
37
|
-
const svgNodeHash = _getHash(
|
|
13
|
+
handlePoints.forEach((handle, i) => {
|
|
14
|
+
drawHandle(
|
|
15
|
+
svgDrawingHelper,
|
|
38
16
|
annotationUID,
|
|
39
|
-
|
|
40
|
-
|
|
17
|
+
handleGroupUID,
|
|
18
|
+
handle,
|
|
19
|
+
options,
|
|
20
|
+
i
|
|
41
21
|
);
|
|
42
|
-
|
|
43
|
-
let attributes;
|
|
44
|
-
if (type === 'circle') {
|
|
45
|
-
attributes = {
|
|
46
|
-
cx: `${handle[0]}`,
|
|
47
|
-
cy: `${handle[1]}`,
|
|
48
|
-
r: handleRadius,
|
|
49
|
-
stroke: color,
|
|
50
|
-
fill,
|
|
51
|
-
'stroke-width': strokeWidth,
|
|
52
|
-
opacity: opacity,
|
|
53
|
-
};
|
|
54
|
-
} else if (type === 'rect') {
|
|
55
|
-
const handleRadiusFloat = parseFloat(handleRadius);
|
|
56
|
-
const side = handleRadiusFloat * 1.5;
|
|
57
|
-
const x = handle[0] - side * 0.5;
|
|
58
|
-
const y = handle[1] - side * 0.5;
|
|
59
|
-
|
|
60
|
-
attributes = {
|
|
61
|
-
x: `${x}`,
|
|
62
|
-
y: `${y}`,
|
|
63
|
-
width: `${side}`,
|
|
64
|
-
height: `${side}`,
|
|
65
|
-
stroke: color,
|
|
66
|
-
fill,
|
|
67
|
-
'stroke-width': strokeWidth,
|
|
68
|
-
rx: `${side * 0.1}`,
|
|
69
|
-
opacity: opacity,
|
|
70
|
-
};
|
|
71
|
-
} else {
|
|
72
|
-
throw new Error(`Unsupported handle type: ${type}`);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const existingHandleElement = svgDrawingHelper.getSvgNode(svgNodeHash);
|
|
76
|
-
|
|
77
|
-
if (existingHandleElement) {
|
|
78
|
-
setAttributesIfNecessary(attributes, existingHandleElement);
|
|
79
|
-
|
|
80
|
-
svgDrawingHelper.setNodeTouched(svgNodeHash);
|
|
81
|
-
} else {
|
|
82
|
-
const newHandleElement = document.createElementNS(svgns, type);
|
|
83
|
-
|
|
84
|
-
setNewAttributesIfValid(attributes, newHandleElement);
|
|
85
|
-
|
|
86
|
-
svgDrawingHelper.appendNode(newHandleElement, svgNodeHash);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
22
|
+
});
|
|
89
23
|
}
|
|
90
24
|
|
|
91
25
|
export default drawHandles;
|
package/src/drawingSvg/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import drawCircle from './drawCircle';
|
|
|
3
3
|
import drawEllipse from './drawEllipse';
|
|
4
4
|
import drawEllipseByCoordinates from './drawEllipseByCoordinates';
|
|
5
5
|
import drawHandles from './drawHandles';
|
|
6
|
+
import drawHandle from './drawHandle';
|
|
6
7
|
import drawLine from './drawLine';
|
|
7
8
|
import drawPolyline from './drawPolyline';
|
|
8
9
|
import drawLinkedTextBox from './drawLinkedTextBox';
|
|
@@ -19,6 +20,7 @@ export {
|
|
|
19
20
|
drawEllipse,
|
|
20
21
|
drawEllipseByCoordinates,
|
|
21
22
|
drawHandles,
|
|
23
|
+
drawHandle,
|
|
22
24
|
drawLine,
|
|
23
25
|
drawPolyline,
|
|
24
26
|
drawLinkedTextBox,
|
|
@@ -34,7 +34,13 @@ export default function keyDown(evt: KeyDownEventType): void {
|
|
|
34
34
|
if (activeToolsWithEventBinding?.size) {
|
|
35
35
|
const { element } = evt.detail;
|
|
36
36
|
for (const [key, value] of [...activeToolsWithEventBinding.entries()]) {
|
|
37
|
-
|
|
37
|
+
// Calls the method that implements the action, which can be a string
|
|
38
|
+
// in which case it belongs to the tool instance, or a function
|
|
39
|
+
// Call it on the tool instance, with the element and configuration value
|
|
40
|
+
// so that the method can depend on the specific configuration in use.
|
|
41
|
+
const method =
|
|
42
|
+
typeof value.method === 'function' ? value.method : key[value.method];
|
|
43
|
+
method.call(key, element, value);
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
BrushTool,
|
|
57
57
|
AngleTool,
|
|
58
58
|
CobbAngleTool,
|
|
59
|
+
UltrasoundDirectionalTool,
|
|
59
60
|
MagnifyTool,
|
|
60
61
|
AdvancedMagnifyTool,
|
|
61
62
|
ReferenceCursors,
|
|
@@ -111,6 +112,7 @@ export {
|
|
|
111
112
|
ArrowAnnotateTool,
|
|
112
113
|
AngleTool,
|
|
113
114
|
CobbAngleTool,
|
|
115
|
+
UltrasoundDirectionalTool,
|
|
114
116
|
KeyImageTool,
|
|
115
117
|
MagnifyTool,
|
|
116
118
|
AdvancedMagnifyTool,
|
|
@@ -126,6 +126,9 @@ function getNumberOfAnnotations(
|
|
|
126
126
|
* @param annotationUID - The unique identifier for the annotation.
|
|
127
127
|
*/
|
|
128
128
|
function removeAnnotation(annotationUID: string): void {
|
|
129
|
+
if (!annotationUID) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
129
132
|
const manager = getAnnotationManager();
|
|
130
133
|
const annotation = manager.getAnnotation(annotationUID);
|
|
131
134
|
|
|
@@ -1348,19 +1348,23 @@ class BidirectionalTool extends AnnotationTool {
|
|
|
1348
1348
|
}
|
|
1349
1349
|
|
|
1350
1350
|
function defaultGetTextLines(data, targetId): string[] {
|
|
1351
|
-
const { cachedStats } = data;
|
|
1351
|
+
const { cachedStats, label } = data;
|
|
1352
1352
|
const { length, width, unit } = cachedStats[targetId];
|
|
1353
1353
|
|
|
1354
|
+
const textLines = [];
|
|
1355
|
+
if (label) {
|
|
1356
|
+
textLines.push(label);
|
|
1357
|
+
}
|
|
1354
1358
|
if (length === undefined) {
|
|
1355
|
-
return;
|
|
1359
|
+
return textLines;
|
|
1356
1360
|
}
|
|
1357
1361
|
|
|
1358
1362
|
// spaceBetweenSlices & pixelSpacing &
|
|
1359
1363
|
// magnitude in each direction? Otherwise, this is "px"?
|
|
1360
|
-
|
|
1364
|
+
textLines.push(
|
|
1361
1365
|
`L: ${roundNumber(length)} ${unit}`,
|
|
1362
|
-
`W: ${roundNumber(width)} ${unit}
|
|
1363
|
-
|
|
1366
|
+
`W: ${roundNumber(width)} ${unit}`
|
|
1367
|
+
);
|
|
1364
1368
|
|
|
1365
1369
|
return textLines;
|
|
1366
1370
|
}
|
|
@@ -7,10 +7,7 @@ import {
|
|
|
7
7
|
} from '@cornerstonejs/core';
|
|
8
8
|
import type { Types } from '@cornerstonejs/core';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
getCalibratedLengthUnits,
|
|
12
|
-
getCalibratedScale,
|
|
13
|
-
} from '../../utilities/getCalibratedUnits';
|
|
10
|
+
import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
|
|
14
11
|
import roundNumber from '../../utilities/roundNumber';
|
|
15
12
|
import { AnnotationTool } from '../base';
|
|
16
13
|
import throttle from '../../utilities/throttle';
|
|
@@ -818,12 +815,13 @@ class LengthTool extends AnnotationTool {
|
|
|
818
815
|
}
|
|
819
816
|
|
|
820
817
|
const { imageData, dimensions } = image;
|
|
821
|
-
const scale = getCalibratedScale(image);
|
|
822
|
-
|
|
823
|
-
const length = this._calculateLength(worldPos1, worldPos2) / scale;
|
|
824
818
|
|
|
825
819
|
const index1 = transformWorldToIndex(imageData, worldPos1);
|
|
826
820
|
const index2 = transformWorldToIndex(imageData, worldPos2);
|
|
821
|
+
const handles = [index1, index2];
|
|
822
|
+
const { scale, units } = getCalibratedLengthUnitsAndScale(image, handles);
|
|
823
|
+
|
|
824
|
+
const length = this._calculateLength(worldPos1, worldPos2) / scale;
|
|
827
825
|
|
|
828
826
|
this._isInsideVolume(index1, index2, dimensions)
|
|
829
827
|
? (this.isHandleOutsideImage = false)
|
|
@@ -836,7 +834,7 @@ class LengthTool extends AnnotationTool {
|
|
|
836
834
|
// todo: add insideVolume calculation, for removing tool if outside
|
|
837
835
|
cachedStats[targetId] = {
|
|
838
836
|
length,
|
|
839
|
-
unit:
|
|
837
|
+
unit: units,
|
|
840
838
|
};
|
|
841
839
|
}
|
|
842
840
|
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
getAnnotations,
|
|
17
17
|
removeAnnotation,
|
|
18
18
|
} from '../../stateManagement/annotation/annotationState';
|
|
19
|
+
import { getCalibratedProbeUnitsAndValue } from '../../utilities/getCalibratedUnits';
|
|
19
20
|
import {
|
|
20
21
|
drawHandles as drawHandlesSvg,
|
|
21
22
|
drawTextBox as drawTextBoxSvg,
|
|
@@ -590,7 +591,7 @@ class ProbeTool extends AnnotationTool {
|
|
|
590
591
|
index[2] * zMultiple +
|
|
591
592
|
index[1] * yMultiple +
|
|
592
593
|
index[0] * samplesPerPixel;
|
|
593
|
-
|
|
594
|
+
let value =
|
|
594
595
|
samplesPerPixel > 2
|
|
595
596
|
? [
|
|
596
597
|
scalarData[baseIndex],
|
|
@@ -614,11 +615,28 @@ class ProbeTool extends AnnotationTool {
|
|
|
614
615
|
index[2] = viewport.getCurrentImageIdIndex();
|
|
615
616
|
}
|
|
616
617
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
618
|
+
let modalityUnit;
|
|
619
|
+
|
|
620
|
+
if (modality === 'US') {
|
|
621
|
+
const calibratedResults = getCalibratedProbeUnitsAndValue(image, [
|
|
622
|
+
index,
|
|
623
|
+
]);
|
|
624
|
+
|
|
625
|
+
const hasEnhancedRegionValues = calibratedResults.values.every(
|
|
626
|
+
(value) => value !== null
|
|
627
|
+
);
|
|
628
|
+
|
|
629
|
+
value = hasEnhancedRegionValues ? calibratedResults.values : value;
|
|
630
|
+
modalityUnit = hasEnhancedRegionValues
|
|
631
|
+
? calibratedResults.units
|
|
632
|
+
: 'raw';
|
|
633
|
+
} else {
|
|
634
|
+
modalityUnit = getModalityUnit(
|
|
635
|
+
modality,
|
|
636
|
+
annotation.metadata.referencedImageId,
|
|
637
|
+
modalityUnitOptions
|
|
638
|
+
);
|
|
639
|
+
}
|
|
622
640
|
|
|
623
641
|
cachedStats[targetId] = {
|
|
624
642
|
index,
|
|
@@ -664,7 +682,13 @@ function defaultGetTextLines(data, targetId): string[] {
|
|
|
664
682
|
|
|
665
683
|
textLines.push(`(${index[0]}, ${index[1]}, ${index[2]})`);
|
|
666
684
|
|
|
667
|
-
|
|
685
|
+
if (value instanceof Array && modalityUnit instanceof Array) {
|
|
686
|
+
for (let i = 0; i < value.length; i++) {
|
|
687
|
+
textLines.push(`${roundNumber(value[i])} ${modalityUnit[i]}`);
|
|
688
|
+
}
|
|
689
|
+
} else {
|
|
690
|
+
textLines.push(`${roundNumber(value)} ${modalityUnit}`);
|
|
691
|
+
}
|
|
668
692
|
|
|
669
693
|
return textLines;
|
|
670
694
|
}
|