@cornerstonejs/tools 1.35.2 → 1.35.3
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/drawEllipse.js +6 -42
- package/dist/cjs/drawingSvg/drawEllipse.js.map +1 -1
- package/dist/cjs/drawingSvg/drawEllipseByCoordinates.d.ts +4 -0
- package/dist/cjs/drawingSvg/drawEllipseByCoordinates.js +53 -0
- package/dist/cjs/drawingSvg/drawEllipseByCoordinates.js.map +1 -0
- 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/tools/annotation/EllipticalROITool.js +2 -12
- package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/esm/drawingSvg/drawEllipse.js +6 -42
- package/dist/esm/drawingSvg/drawEllipse.js.map +1 -1
- package/dist/esm/drawingSvg/drawEllipseByCoordinates.js +48 -0
- package/dist/esm/drawingSvg/drawEllipseByCoordinates.js.map +1 -0
- package/dist/esm/drawingSvg/index.js +2 -1
- package/dist/esm/drawingSvg/index.js.map +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +3 -13
- package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/types/drawingSvg/drawEllipse.d.ts.map +1 -1
- package/dist/types/drawingSvg/drawEllipseByCoordinates.d.ts +5 -0
- package/dist/types/drawingSvg/drawEllipseByCoordinates.d.ts.map +1 -0
- package/dist/types/drawingSvg/index.d.ts +2 -1
- package/dist/types/drawingSvg/index.d.ts.map +1 -1
- package/dist/types/tools/annotation/EllipticalROITool.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/drawEllipse.ts +15 -55
- package/src/drawingSvg/drawEllipseByCoordinates.ts +73 -0
- package/src/drawingSvg/index.ts +2 -0
- package/src/tools/annotation/EllipticalROITool.ts +5 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.3",
|
|
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.35.
|
|
32
|
+
"@cornerstonejs/core": "^1.35.3",
|
|
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": "8c78a01f328ad05b05c4664fce746281ed381829"
|
|
57
57
|
}
|
|
@@ -2,8 +2,7 @@ import type { Types } from '@cornerstonejs/core';
|
|
|
2
2
|
import { SVGDrawingHelper } from '../types';
|
|
3
3
|
|
|
4
4
|
import _getHash from './_getHash';
|
|
5
|
-
import
|
|
6
|
-
import setNewAttributesIfValid from './setNewAttributesIfValid';
|
|
5
|
+
import drawEllipseByCoordinates from './drawEllipseByCoordinates';
|
|
7
6
|
|
|
8
7
|
function drawEllipse(
|
|
9
8
|
svgDrawingHelper: SVGDrawingHelper,
|
|
@@ -13,59 +12,20 @@ function drawEllipse(
|
|
|
13
12
|
corner2: Types.Point2,
|
|
14
13
|
options = {},
|
|
15
14
|
dataId = ''
|
|
16
|
-
)
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const svgns = 'http://www.w3.org/2000/svg';
|
|
31
|
-
const svgNodeHash = _getHash(annotationUID, 'ellipse', ellipseUID);
|
|
32
|
-
const existingEllipse = svgDrawingHelper.getSvgNode(svgNodeHash);
|
|
33
|
-
|
|
34
|
-
const w = Math.abs(corner1[0] - corner2[0]);
|
|
35
|
-
const h = Math.abs(corner1[1] - corner2[1]);
|
|
36
|
-
const xMin = Math.min(corner1[0], corner2[0]);
|
|
37
|
-
const yMin = Math.min(corner1[1], corner2[1]);
|
|
38
|
-
|
|
39
|
-
const center = [xMin + w / 2, yMin + h / 2];
|
|
40
|
-
const radiusX = w / 2;
|
|
41
|
-
const radiusY = h / 2;
|
|
42
|
-
|
|
43
|
-
const attributes = {
|
|
44
|
-
cx: `${center[0]}`,
|
|
45
|
-
cy: `${center[1]}`,
|
|
46
|
-
rx: `${radiusX}`,
|
|
47
|
-
ry: `${radiusY}`,
|
|
48
|
-
stroke: color,
|
|
49
|
-
fill: 'transparent',
|
|
50
|
-
'stroke-width': strokeWidth,
|
|
51
|
-
'stroke-dasharray': lineDash,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
if (existingEllipse) {
|
|
55
|
-
setAttributesIfNecessary(attributes, existingEllipse);
|
|
56
|
-
|
|
57
|
-
svgDrawingHelper.setNodeTouched(svgNodeHash);
|
|
58
|
-
} else {
|
|
59
|
-
const svgEllipseElement = document.createElementNS(svgns, 'ellipse');
|
|
60
|
-
|
|
61
|
-
if (dataId !== '') {
|
|
62
|
-
svgEllipseElement.setAttribute('data-id', dataId);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
setNewAttributesIfValid(attributes, svgEllipseElement);
|
|
66
|
-
|
|
67
|
-
svgDrawingHelper.appendNode(svgEllipseElement, svgNodeHash);
|
|
68
|
-
}
|
|
15
|
+
){
|
|
16
|
+
const top: Types.Point2 = [ (corner1[0] + corner2[0]) / 2, corner1[1] ];
|
|
17
|
+
const bottom: Types.Point2 = [ (corner1[0] + corner2[0]) / 2, corner2[1] ];
|
|
18
|
+
const left: Types.Point2 = [ corner1[0], (corner1[1] + corner2[1]) / 2];
|
|
19
|
+
const right: Types.Point2 = [ corner2[0], (corner1[1] + corner2[1]) / 2];
|
|
20
|
+
|
|
21
|
+
drawEllipseByCoordinates(
|
|
22
|
+
svgDrawingHelper,
|
|
23
|
+
annotationUID,
|
|
24
|
+
ellipseUID,
|
|
25
|
+
[bottom, top, left, right],
|
|
26
|
+
options = {},
|
|
27
|
+
dataId = ''
|
|
28
|
+
)
|
|
69
29
|
}
|
|
70
30
|
|
|
71
31
|
export default drawEllipse;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
2
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
3
|
+
import { SVGDrawingHelper } from '../types';
|
|
4
|
+
|
|
5
|
+
import _getHash from './_getHash';
|
|
6
|
+
import setAttributesIfNecessary from './setAttributesIfNecessary';
|
|
7
|
+
import setNewAttributesIfValid from './setNewAttributesIfValid';
|
|
8
|
+
|
|
9
|
+
function drawEllipseByCoordinates(
|
|
10
|
+
svgDrawingHelper: SVGDrawingHelper,
|
|
11
|
+
annotationUID: string,
|
|
12
|
+
ellipseUID: string,
|
|
13
|
+
canvasCoordinates: [Types.Point2, Types.Point2, Types.Point2, Types.Point2],
|
|
14
|
+
options = {},
|
|
15
|
+
dataId = ''
|
|
16
|
+
): void {
|
|
17
|
+
const { color, width, lineWidth, lineDash } = Object.assign(
|
|
18
|
+
{
|
|
19
|
+
color: 'dodgerblue',
|
|
20
|
+
width: '2',
|
|
21
|
+
lineWidth: undefined,
|
|
22
|
+
lineDash: undefined,
|
|
23
|
+
},
|
|
24
|
+
options
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// for supporting both lineWidth and width options
|
|
28
|
+
const strokeWidth = lineWidth || width;
|
|
29
|
+
|
|
30
|
+
const svgns = 'http://www.w3.org/2000/svg';
|
|
31
|
+
const svgNodeHash = _getHash(annotationUID, 'ellipse', ellipseUID);
|
|
32
|
+
const existingEllipse = svgDrawingHelper.getSvgNode(svgNodeHash);
|
|
33
|
+
|
|
34
|
+
const [bottom, top, left, right] = canvasCoordinates;
|
|
35
|
+
|
|
36
|
+
const w = Math.hypot(left[0] - right[0], left[1] - right[1]);
|
|
37
|
+
const h = Math.hypot(top[0] - bottom[0], top[1] - bottom[1]);
|
|
38
|
+
const angle = Math.atan2(left[1] - right[1], left[0] - right[0]) * 180 / Math.PI;
|
|
39
|
+
|
|
40
|
+
const center = [(left[0] + right[0]) / 2 , ( top[1] + bottom[1] ) / 2];
|
|
41
|
+
const radiusX = w / 2;
|
|
42
|
+
const radiusY = h / 2;
|
|
43
|
+
|
|
44
|
+
const attributes = {
|
|
45
|
+
cx: `${center[0]}`,
|
|
46
|
+
cy: `${center[1]}`,
|
|
47
|
+
rx: `${radiusX}`,
|
|
48
|
+
ry: `${radiusY}`,
|
|
49
|
+
stroke: color,
|
|
50
|
+
fill: 'transparent',
|
|
51
|
+
'transform': `rotate(${angle} ${center[0]} ${center[1]})`,
|
|
52
|
+
'stroke-width': strokeWidth,
|
|
53
|
+
'stroke-dasharray': lineDash,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
if (existingEllipse) {
|
|
57
|
+
setAttributesIfNecessary(attributes, existingEllipse);
|
|
58
|
+
|
|
59
|
+
svgDrawingHelper.setNodeTouched(svgNodeHash);
|
|
60
|
+
} else {
|
|
61
|
+
const svgEllipseElement = document.createElementNS(svgns, 'ellipse');
|
|
62
|
+
|
|
63
|
+
if (dataId !== '') {
|
|
64
|
+
svgEllipseElement.setAttribute('data-id', dataId);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
setNewAttributesIfValid(attributes, svgEllipseElement);
|
|
68
|
+
|
|
69
|
+
svgDrawingHelper.appendNode(svgEllipseElement, svgNodeHash);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default drawEllipseByCoordinates;
|
package/src/drawingSvg/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import draw from './draw';
|
|
2
2
|
import drawCircle from './drawCircle';
|
|
3
3
|
import drawEllipse from './drawEllipse';
|
|
4
|
+
import drawEllipseByCoordinates from './drawEllipseByCoordinates';
|
|
4
5
|
import drawHandles from './drawHandles';
|
|
5
6
|
import drawLine from './drawLine';
|
|
6
7
|
import drawPolyline from './drawPolyline';
|
|
@@ -16,6 +17,7 @@ export {
|
|
|
16
17
|
draw,
|
|
17
18
|
drawCircle,
|
|
18
19
|
drawEllipse,
|
|
20
|
+
drawEllipseByCoordinates,
|
|
19
21
|
drawHandles,
|
|
20
22
|
drawLine,
|
|
21
23
|
drawPolyline,
|
|
@@ -24,7 +24,7 @@ import { isAnnotationLocked } from '../../stateManagement/annotation/annotationL
|
|
|
24
24
|
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
25
25
|
import {
|
|
26
26
|
drawCircle as drawCircleSvg,
|
|
27
|
-
|
|
27
|
+
drawEllipseByCoordinates as drawEllipseSvg,
|
|
28
28
|
drawHandles as drawHandlesSvg,
|
|
29
29
|
drawLinkedTextBox as drawLinkedTextBoxSvg,
|
|
30
30
|
} from '../../drawingSvg';
|
|
@@ -787,18 +787,9 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
787
787
|
);
|
|
788
788
|
let canvasCorners;
|
|
789
789
|
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
canvasCoordinates[3], // top
|
|
794
|
-
canvasCoordinates[0], // left
|
|
795
|
-
canvasCoordinates[1], // right
|
|
796
|
-
]);
|
|
797
|
-
} else {
|
|
798
|
-
canvasCorners = <Array<Types.Point2>>(
|
|
799
|
-
getCanvasEllipseCorners(canvasCoordinates) // bottom, top, left, right, keep as is
|
|
800
|
-
);
|
|
801
|
-
}
|
|
790
|
+
canvasCorners = <Array<Types.Point2>>(
|
|
791
|
+
getCanvasEllipseCorners(canvasCoordinates) // bottom, top, left, right, keep as is
|
|
792
|
+
);
|
|
802
793
|
|
|
803
794
|
const { centerPointRadius } = this.configuration;
|
|
804
795
|
|
|
@@ -905,8 +896,7 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
905
896
|
svgDrawingHelper,
|
|
906
897
|
annotationUID,
|
|
907
898
|
ellipseUID,
|
|
908
|
-
|
|
909
|
-
canvasCorners[1],
|
|
899
|
+
canvasCoordinates,
|
|
910
900
|
{
|
|
911
901
|
color,
|
|
912
902
|
lineDash,
|