@cornerstonejs/tools 1.40.2 → 1.41.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/index.d.ts +2 -2
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tools/annotation/AngleTool.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/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/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/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tools/annotation/AngleTool.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/getCalibratedUnits.js +125 -6
- package/dist/esm/utilities/getCalibratedUnits.js.map +1 -1
- 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/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tools/annotation/AngleTool.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/utilities/getCalibratedUnits.d.ts +16 -2
- package/dist/types/utilities/getCalibratedUnits.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/drawingSvg/drawHandle.ts +88 -0
- package/src/drawingSvg/drawHandles.ts +9 -75
- package/src/drawingSvg/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/tools/annotation/AngleTool.ts +0 -1
- 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/utilities/getCalibratedUnits.ts +203 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.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.41.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": "a151cd133119685c23a9aa7b739e5b7a55312bd1"
|
|
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,
|
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,
|
|
@@ -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
|
}
|