@cornerstonejs/tools 1.21.1 → 1.22.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/eventDispatchers/mouseEventHandlers/mouseDown.js +1 -1
- package/dist/cjs/eventDispatchers/mouseEventHandlers/mouseDown.js.map +1 -1
- package/dist/cjs/tools/MagnifyTool.js +2 -2
- package/dist/cjs/tools/MagnifyTool.js.map +1 -1
- package/dist/cjs/tools/annotation/CobbAngleTool.d.ts +31 -5
- package/dist/cjs/tools/annotation/CobbAngleTool.js +266 -70
- package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/cjs/tools/base/AnnotationTool.d.ts +1 -1
- package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +44 -0
- package/dist/cjs/utilities/math/angle/angleBetweenLines.d.ts +3 -1
- package/dist/cjs/utilities/math/angle/angleBetweenLines.js +18 -1
- package/dist/cjs/utilities/math/angle/angleBetweenLines.js.map +1 -1
- package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDown.js +1 -1
- package/dist/esm/eventDispatchers/mouseEventHandlers/mouseDown.js.map +1 -1
- package/dist/esm/tools/MagnifyTool.js +2 -2
- package/dist/esm/tools/MagnifyTool.js.map +1 -1
- package/dist/esm/tools/annotation/CobbAngleTool.d.ts +31 -5
- package/dist/esm/tools/annotation/CobbAngleTool.js +273 -71
- package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/esm/tools/base/AnnotationTool.d.ts +1 -1
- package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/esm/types/ToolSpecificAnnotationTypes.d.ts +44 -0
- package/dist/esm/utilities/math/angle/angleBetweenLines.d.ts +3 -1
- package/dist/esm/utilities/math/angle/angleBetweenLines.js +19 -2
- package/dist/esm/utilities/math/angle/angleBetweenLines.js.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/eventDispatchers/mouseEventHandlers/mouseDown.ts +1 -1
- package/src/tools/MagnifyTool.ts +2 -2
- package/src/tools/annotation/CobbAngleTool.ts +418 -98
- package/src/tools/base/AnnotationTool.ts +2 -1
- package/src/tools/displayTools/Contour/contourDisplay.ts +0 -1
- package/src/types/ToolSpecificAnnotationTypes.ts +46 -0
- package/src/utilities/math/angle/angleBetweenLines.ts +39 -9
|
@@ -94,7 +94,8 @@ abstract class AnnotationTool extends AnnotationDisplayTool {
|
|
|
94
94
|
abstract toolSelectedCallback(
|
|
95
95
|
evt: EventTypes.InteractionEventType,
|
|
96
96
|
annotation: Annotation,
|
|
97
|
-
interactionType: InteractionTypes
|
|
97
|
+
interactionType: InteractionTypes,
|
|
98
|
+
canvasCoords?: Types.Point2
|
|
98
99
|
): void;
|
|
99
100
|
|
|
100
101
|
/**
|
|
@@ -129,7 +129,6 @@ async function render(
|
|
|
129
129
|
const contourData = segmentation.representationData[Representations.Contour];
|
|
130
130
|
const { geometryIds } = contourData;
|
|
131
131
|
|
|
132
|
-
|
|
133
132
|
// We don't have a good way to handle stack viewports for contours at the moment.
|
|
134
133
|
// Plus, if we add a segmentation to one viewport, it gets added to all the viewports in the toolGroup too.
|
|
135
134
|
if (viewport instanceof StackViewport) {
|
|
@@ -273,6 +273,7 @@ export interface ArrowAnnotation extends Annotation {
|
|
|
273
273
|
};
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
+
|
|
276
277
|
export interface AngleAnnotation extends Annotation {
|
|
277
278
|
data: {
|
|
278
279
|
handles: {
|
|
@@ -298,6 +299,51 @@ export interface AngleAnnotation extends Annotation {
|
|
|
298
299
|
};
|
|
299
300
|
}
|
|
300
301
|
|
|
302
|
+
export interface CobbAngleAnnotation extends Annotation {
|
|
303
|
+
data: {
|
|
304
|
+
handles: {
|
|
305
|
+
points: Types.Point3[];
|
|
306
|
+
activeHandleIndex: number | null;
|
|
307
|
+
textBox: {
|
|
308
|
+
hasMoved: boolean;
|
|
309
|
+
worldPosition: Types.Point3;
|
|
310
|
+
worldBoundingBox: {
|
|
311
|
+
topLeft: Types.Point3;
|
|
312
|
+
topRight: Types.Point3;
|
|
313
|
+
bottomLeft: Types.Point3;
|
|
314
|
+
bottomRight: Types.Point3;
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
label: string;
|
|
319
|
+
cachedStats: {
|
|
320
|
+
[targetId: string]: {
|
|
321
|
+
angle: number;
|
|
322
|
+
arc1Angle: number;
|
|
323
|
+
arc2Angle: number;
|
|
324
|
+
points: {
|
|
325
|
+
world: {
|
|
326
|
+
arc1Start: Types.Point3;
|
|
327
|
+
arc1End: Types.Point3;
|
|
328
|
+
arc2Start: Types.Point3;
|
|
329
|
+
arc2End: Types.Point3;
|
|
330
|
+
arc1Angle: number;
|
|
331
|
+
arc2Angle: number;
|
|
332
|
+
};
|
|
333
|
+
canvas: {
|
|
334
|
+
arc1Start: Types.Point2;
|
|
335
|
+
arc1End: Types.Point2;
|
|
336
|
+
arc2Start: Types.Point2;
|
|
337
|
+
arc2End: Types.Point2;
|
|
338
|
+
arc1Angle: number;
|
|
339
|
+
arc2Angle: number;
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
|
|
301
347
|
export interface ReferenceCursor extends Annotation {
|
|
302
348
|
data: {
|
|
303
349
|
handles: {
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import type { Types } from '@cornerstonejs/core';
|
|
2
|
-
import { vec3 } from 'gl-matrix';
|
|
2
|
+
import { vec2, vec3 } from 'gl-matrix';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type Line2D = [Types.Point2, Types.Point2];
|
|
5
|
+
type Line3D = [Types.Point3, Types.Point3];
|
|
6
|
+
type Line = Line2D | Line3D;
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
* The angle measured is that between the vectors
|
|
9
|
-
* line1[1]->line1[0] AND line2[0]->line2[1].
|
|
10
|
-
* @param line1 - Line = [p1, p2]
|
|
11
|
-
* @param line2 - Line = [p3, p4]
|
|
12
|
-
* @returns The angle between two lines in degrees.
|
|
9
|
+
* Calculates the angle between two 3D lines.
|
|
13
10
|
*/
|
|
14
|
-
|
|
11
|
+
function angleBetween3DLines(line1: Line3D, line2: Line3D): number {
|
|
15
12
|
const [p1, p2] = line1;
|
|
16
13
|
const [p3, p4] = line2;
|
|
17
14
|
|
|
@@ -29,3 +26,36 @@ export default function angleBetweenLines(line1: Line, line2: Line): number {
|
|
|
29
26
|
|
|
30
27
|
return (radian * 180) / Math.PI;
|
|
31
28
|
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Calculates the angle between two 2D lines.
|
|
32
|
+
*/
|
|
33
|
+
function angleBetween2DLines(line1: Line2D, line2: Line2D): number {
|
|
34
|
+
const [p1, p2] = line1;
|
|
35
|
+
const [p3, p4] = line2;
|
|
36
|
+
|
|
37
|
+
const v1 = vec2.sub(vec2.create(), p2, p1);
|
|
38
|
+
const v2 = vec2.sub(vec2.create(), p3, p4);
|
|
39
|
+
|
|
40
|
+
const dot = vec2.dot(v1, v2);
|
|
41
|
+
const v1Length = vec2.length(v1);
|
|
42
|
+
const v2Length = vec2.length(v2);
|
|
43
|
+
|
|
44
|
+
const cos = dot / (v1Length * v2Length);
|
|
45
|
+
return Math.acos(cos) * (180 / Math.PI);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns the angle between two lines in degrees.
|
|
50
|
+
* The angle measured is that between the vectors
|
|
51
|
+
* line1[1]->line1[0] AND line2[0]->line2[1].
|
|
52
|
+
* @param line1 - Line = [p1, p2]
|
|
53
|
+
* @param line2 - Line = [p3, p4]
|
|
54
|
+
* @returns The angle between two lines in degrees.
|
|
55
|
+
*/
|
|
56
|
+
export default function angleBetweenLines(line1: Line, line2: Line): number {
|
|
57
|
+
const is3D = line1[0].length === 3;
|
|
58
|
+
return is3D
|
|
59
|
+
? angleBetween3DLines(line1 as Line3D, line2 as Line3D)
|
|
60
|
+
: angleBetween2DLines(line1 as Line2D, line2 as Line2D);
|
|
61
|
+
}
|