@cornerstonejs/tools 3.10.25 → 3.10.27
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.
|
@@ -6,7 +6,7 @@ import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateMan
|
|
|
6
6
|
import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
|
|
7
7
|
import * as lineSegment from '../../utilities/math/line';
|
|
8
8
|
import angleBetweenLines from '../../utilities/math/angle/angleBetweenLines';
|
|
9
|
-
import { drawHandles as drawHandlesSvg, drawLine as drawLineSvg, drawLinkedTextBox as drawLinkedTextBoxSvg, } from '../../drawingSvg';
|
|
9
|
+
import { drawHandles as drawHandlesSvg, drawLine as drawLineSvg, drawLinkedTextBox as drawLinkedTextBoxSvg, drawPath as drawPathSvg, } from '../../drawingSvg';
|
|
10
10
|
import { state } from '../../store/state';
|
|
11
11
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
12
12
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
@@ -19,6 +19,8 @@ class AngleTool extends AnnotationTool {
|
|
|
19
19
|
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
20
20
|
configuration: {
|
|
21
21
|
shadow: true,
|
|
22
|
+
showAngleArc: false,
|
|
23
|
+
arcOffset: 5,
|
|
22
24
|
preventHandleOutsideImage: false,
|
|
23
25
|
getTextLines: defaultGetTextLines,
|
|
24
26
|
},
|
|
@@ -297,7 +299,7 @@ class AngleTool extends AnnotationTool {
|
|
|
297
299
|
const { annotationUID, data } = annotation;
|
|
298
300
|
const { points, activeHandleIndex } = data.handles;
|
|
299
301
|
styleSpecifier.annotationUID = annotationUID;
|
|
300
|
-
const { color, lineWidth, lineDash } = this.getAnnotationStyle({
|
|
302
|
+
const { color, lineWidth, lineDash, angleArcLineDash } = this.getAnnotationStyle({
|
|
301
303
|
annotation,
|
|
302
304
|
styleSpecifier,
|
|
303
305
|
});
|
|
@@ -349,6 +351,36 @@ class AngleTool extends AnnotationTool {
|
|
|
349
351
|
width: lineWidth,
|
|
350
352
|
lineDash,
|
|
351
353
|
});
|
|
354
|
+
if (this.configuration.showAngleArc) {
|
|
355
|
+
const center = canvasCoordinates[1];
|
|
356
|
+
const offset = this.configuration.arcOffset;
|
|
357
|
+
const radius = Math.min(lineSegment.distanceToPoint([center[0], center[1]], [canvasCoordinates[0][0], canvasCoordinates[0][1]], [canvasCoordinates[2][0], canvasCoordinates[2][1]]), lineSegment.distanceToPoint([center[0], center[1]], [canvasCoordinates[2][0], canvasCoordinates[2][1]], [canvasCoordinates[0][0], canvasCoordinates[0][1]])) / offset;
|
|
358
|
+
const anglePoints = [];
|
|
359
|
+
let startAngle = Math.atan2(canvasCoordinates[0][1] - center[1], canvasCoordinates[0][0] - center[0]);
|
|
360
|
+
let endAngle = Math.atan2(canvasCoordinates[2][1] - center[1], canvasCoordinates[2][0] - center[0]);
|
|
361
|
+
if (endAngle < startAngle) {
|
|
362
|
+
endAngle += 2 * Math.PI;
|
|
363
|
+
}
|
|
364
|
+
const angleDifference = endAngle - startAngle;
|
|
365
|
+
if (angleDifference > Math.PI) {
|
|
366
|
+
const temp = startAngle;
|
|
367
|
+
startAngle = endAngle;
|
|
368
|
+
endAngle = temp + 2 * Math.PI;
|
|
369
|
+
}
|
|
370
|
+
const segments = 32;
|
|
371
|
+
for (let i = 0; i <= segments; i++) {
|
|
372
|
+
const angle = startAngle + (i / segments) * (endAngle - startAngle);
|
|
373
|
+
anglePoints.push([
|
|
374
|
+
center[0] + radius * Math.cos(angle),
|
|
375
|
+
center[1] + radius * Math.sin(angle),
|
|
376
|
+
]);
|
|
377
|
+
}
|
|
378
|
+
drawPathSvg(svgDrawingHelper, annotationUID, '3', anglePoints, {
|
|
379
|
+
color: color,
|
|
380
|
+
width: lineWidth,
|
|
381
|
+
lineDash: angleArcLineDash,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
352
384
|
if (!data.cachedStats[targetId]?.angle) {
|
|
353
385
|
continue;
|
|
354
386
|
}
|
|
@@ -157,6 +157,7 @@ class AnnotationTool extends AnnotationDisplayTool {
|
|
|
157
157
|
const locked = isAnnotationLocked(annotationUID);
|
|
158
158
|
const lineWidth = getStyle('lineWidth');
|
|
159
159
|
const lineDash = getStyle('lineDash');
|
|
160
|
+
const angleArcLineDash = getStyle('angleArcLineDash');
|
|
160
161
|
const color = getStyle('color');
|
|
161
162
|
const markerSize = getStyle('markerSize');
|
|
162
163
|
const shadow = getStyle('shadow');
|
|
@@ -173,6 +174,7 @@ class AnnotationTool extends AnnotationDisplayTool {
|
|
|
173
174
|
shadow,
|
|
174
175
|
textbox: textboxStyle,
|
|
175
176
|
markerSize,
|
|
177
|
+
angleArcLineDash,
|
|
176
178
|
};
|
|
177
179
|
}
|
|
178
180
|
_imagePointNearToolOrHandle(element, annotation, canvasCoords, proximity) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type Modes = '' | 'Active' | 'Passive' | 'Enabled';
|
|
2
2
|
type States = '' | 'Highlighted' | 'Selected' | 'Locked' | 'AutoGenerated';
|
|
3
|
-
type Properties = 'color' | 'colorAutoGenerated' | 'lineWidth' | 'lineWidthAutoGenerated' | 'lineDash' | 'textBoxFontFamily' | 'textBoxFontSize' | 'textBoxColor' | 'textBoxBackground' | 'textBoxLinkLineWidth' | 'textBoxLinkLineDash' | 'locked' | 'fillColor' | 'fillOpacity' | 'textbox' | 'shadow' | 'visibility' | 'markerSize';
|
|
3
|
+
type Properties = 'color' | 'colorAutoGenerated' | 'lineWidth' | 'lineWidthAutoGenerated' | 'lineDash' | 'textBoxFontFamily' | 'textBoxFontSize' | 'textBoxColor' | 'textBoxBackground' | 'textBoxLinkLineWidth' | 'textBoxLinkLineDash' | 'locked' | 'fillColor' | 'fillOpacity' | 'textbox' | 'shadow' | 'visibility' | 'markerSize' | 'angleArcLineDash';
|
|
4
4
|
export type AnnotationStyle = {
|
|
5
5
|
[key in `${Properties}${States}${Modes}`]?: string | number | boolean | Record<string, unknown>;
|
|
6
6
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.27",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"canvas": "^3.1.0"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
-
"@cornerstonejs/core": "^3.10.
|
|
106
|
+
"@cornerstonejs/core": "^3.10.27",
|
|
107
107
|
"@kitware/vtk.js": "32.12.1",
|
|
108
108
|
"@types/d3-array": "^3.0.4",
|
|
109
109
|
"@types/d3-interpolate": "^3.0.1",
|
|
@@ -122,5 +122,5 @@
|
|
|
122
122
|
"type": "individual",
|
|
123
123
|
"url": "https://ohif.org/donate"
|
|
124
124
|
},
|
|
125
|
-
"gitHead": "
|
|
125
|
+
"gitHead": "645eed0568edb1022f63342116ad92b41b6bb262"
|
|
126
126
|
}
|