@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
|
@@ -51,7 +51,7 @@ function mouseDown(evt) {
|
|
|
51
51
|
if (moveableAnnotationTools.length > 0) {
|
|
52
52
|
const { tool, annotation } = getAnnotationForSelection(moveableAnnotationTools);
|
|
53
53
|
toggleAnnotationSelection(annotation.annotationUID, isMultiSelect);
|
|
54
|
-
tool.toolSelectedCallback(evt, annotation, 'Mouse');
|
|
54
|
+
tool.toolSelectedCallback(evt, annotation, 'Mouse', canvasCoords);
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
if (activeTool && typeof activeTool.postMouseDownCallback === 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mouseDown.js","sourceRoot":"","sources":["../../../../src/eventDispatchers/mouseEventHandlers/mouseDown.ts"],"names":[],"mappings":";;;;;AAAA,uCAAoC;AACpC,uCAAwC;AAOxC,8FAG8D;AAE9D,0FAAwF;AACxF,gGAA4F;AAG5F,gHAAwF;AACxF,4HAAoG;AACpG,8GAAsF;AACtF,sGAA8E;AAC9E,8GAAsF;AACtF,4FAAoE;AAEpE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAS,CAAC;AA2BtC,SAAwB,SAAS,CAAC,GAAkC;IAElE,IAAI,aAAK,CAAC,qBAAqB,EAAE;QAC/B,OAAO;KACR;IAED,MAAM,UAAU,GAAG,IAAA,oCAA0B,EAAC,GAAG,CAAC,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;YACL,MAAM,gBAAgB,GAAG,IAAI,CAAC;YAC9B,IAAA,2CAAqB,EAAC,aAAa,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;SAC9D;KACF;SAAM;QACL,MAAM,gBAAgB,GAAG,KAAK,CAAC;QAC/B,IAAA,2CAAqB,EAAC,aAAa,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;KAC9D;AACH,CAAC"}
|
|
@@ -56,7 +56,7 @@ class MagnifyTool extends base_1.BaseTool {
|
|
|
56
56
|
const { enabledElement, referencedImageId, viewportIdsToRender, renderingEngine, currentPoints, } = this.editData;
|
|
57
57
|
const { viewport } = enabledElement;
|
|
58
58
|
const { element } = viewport;
|
|
59
|
-
const
|
|
59
|
+
const viewportProperties = viewport.getProperties();
|
|
60
60
|
const { canvas: canvasPos, world: worldPos } = currentPoints;
|
|
61
61
|
let magnifyToolElement;
|
|
62
62
|
magnifyToolElement = element.querySelector('.magnifyTool');
|
|
@@ -81,7 +81,7 @@ class MagnifyTool extends base_1.BaseTool {
|
|
|
81
81
|
magnifyToolElement.style.left = `${canvasPos[0] - this.configuration.magnifyWidth / 2}px`;
|
|
82
82
|
const magnifyViewport = renderingEngine.getViewport(MAGNIFY_VIEWPORT_ID);
|
|
83
83
|
magnifyViewport.setStack([referencedImageId]).then(() => {
|
|
84
|
-
magnifyViewport.setProperties(
|
|
84
|
+
magnifyViewport.setProperties(viewportProperties);
|
|
85
85
|
const { parallelScale } = viewport.getCamera();
|
|
86
86
|
const { focalPoint, position, viewPlaneNormal } = magnifyViewport.getCamera();
|
|
87
87
|
const distance = Math.sqrt(Math.pow(focalPoint[0] - position[0], 2) +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MagnifyTool.js","sourceRoot":"","sources":["../../../src/tools/MagnifyTool.ts"],"names":[],"mappings":";;;;;AAAA,iCAAkC;AAClC,oCAAkC;AAElC,8CAAuE;AAGvE,kEAA8E;AAC9E,+HAAuG;AACvG,oCAAiC;AACj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C;QAE5C,IAAI,iBAAiB,CAAC;QAEtB,IAAI,QAAQ,YAAY,oBAAa,EAAE;YACrC,iBAAiB,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;SACnD;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CAmQF;AAED,WAAW,CAAC,QAAQ,GAAG,SAAS,CAAC;AACjC,kBAAe,WAAW,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Types } from '@cornerstonejs/core';
|
|
2
2
|
import { AnnotationTool } from '../base';
|
|
3
3
|
import { EventTypes, ToolHandle, PublicToolProps, ToolProps, InteractionTypes, SVGDrawingHelper } from '../../types';
|
|
4
|
-
import {
|
|
4
|
+
import { CobbAngleAnnotation } from '../../types/ToolSpecificAnnotationTypes';
|
|
5
5
|
declare class CobbAngleTool extends AnnotationTool {
|
|
6
6
|
static toolName: any;
|
|
7
7
|
touchDragCallback: any;
|
|
@@ -15,14 +15,16 @@ declare class CobbAngleTool extends AnnotationTool {
|
|
|
15
15
|
movingTextBox?: boolean;
|
|
16
16
|
newAnnotation?: boolean;
|
|
17
17
|
hasMoved?: boolean;
|
|
18
|
+
isNearFirstLine?: boolean;
|
|
19
|
+
isNearSecondLine?: boolean;
|
|
18
20
|
} | null;
|
|
19
21
|
isDrawing: boolean;
|
|
20
22
|
isHandleOutsideImage: boolean;
|
|
21
23
|
constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
|
|
22
|
-
addNewAnnotation: (evt: EventTypes.MouseDownActivateEventType) =>
|
|
23
|
-
isPointNearTool: (element: HTMLDivElement, annotation:
|
|
24
|
-
toolSelectedCallback: (evt: EventTypes.MouseDownEventType, annotation:
|
|
25
|
-
handleSelectedCallback(evt: EventTypes.MouseDownEventType, annotation:
|
|
24
|
+
addNewAnnotation: (evt: EventTypes.MouseDownActivateEventType) => CobbAngleAnnotation;
|
|
25
|
+
isPointNearTool: (element: HTMLDivElement, annotation: CobbAngleAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
|
|
26
|
+
toolSelectedCallback: (evt: EventTypes.MouseDownEventType, annotation: CobbAngleAnnotation, interactionType: InteractionTypes, canvasCoords: Types.Point2, proximity?: number) => void;
|
|
27
|
+
handleSelectedCallback(evt: EventTypes.MouseDownEventType, annotation: CobbAngleAnnotation, handle: ToolHandle, interactionType?: string): void;
|
|
26
28
|
_mouseUpCallback: (evt: EventTypes.MouseUpEventType | EventTypes.MouseClickEventType) => void;
|
|
27
29
|
_mouseDownCallback: (evt: EventTypes.MouseUpEventType | EventTypes.MouseClickEventType) => void;
|
|
28
30
|
_mouseDragCallback: (evt: EventTypes.MouseDragEventType | EventTypes.MouseMoveEventType) => void;
|
|
@@ -33,5 +35,29 @@ declare class CobbAngleTool extends AnnotationTool {
|
|
|
33
35
|
_deactivateDraw: (element: HTMLDivElement) => void;
|
|
34
36
|
renderAnnotation: (enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper) => boolean;
|
|
35
37
|
_calculateCachedStats(annotation: any, renderingEngine: any, enabledElement: any): any;
|
|
38
|
+
distanceToLines: ({ viewport, points, canvasCoords, proximity }: {
|
|
39
|
+
viewport: any;
|
|
40
|
+
points: any;
|
|
41
|
+
canvasCoords: any;
|
|
42
|
+
proximity: any;
|
|
43
|
+
}) => {
|
|
44
|
+
distanceToPoint: number;
|
|
45
|
+
distanceToPoint2: number;
|
|
46
|
+
isNearFirstLine: boolean;
|
|
47
|
+
isNearSecondLine: boolean;
|
|
48
|
+
};
|
|
49
|
+
getArcsStartEndPoints: ({ firstLine, secondLine, mid1, mid2, }: {
|
|
50
|
+
firstLine: any;
|
|
51
|
+
secondLine: any;
|
|
52
|
+
mid1: any;
|
|
53
|
+
mid2: any;
|
|
54
|
+
}) => {
|
|
55
|
+
arc1Start: Types.Point2;
|
|
56
|
+
arc1End: Types.Point2;
|
|
57
|
+
arc2Start: Types.Point2;
|
|
58
|
+
arc2End: Types.Point2;
|
|
59
|
+
arc1Angle: number;
|
|
60
|
+
arc2Angle: number;
|
|
61
|
+
};
|
|
36
62
|
}
|
|
37
63
|
export default CobbAngleTool;
|
|
@@ -116,52 +116,39 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
116
116
|
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
117
117
|
const { viewport } = enabledElement;
|
|
118
118
|
const { data } = annotation;
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
start: {
|
|
126
|
-
x: canvasPoint1[0],
|
|
127
|
-
y: canvasPoint1[1],
|
|
128
|
-
},
|
|
129
|
-
end: {
|
|
130
|
-
x: canvasPoint2[0],
|
|
131
|
-
y: canvasPoint2[1],
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
const line2 = {
|
|
135
|
-
start: {
|
|
136
|
-
x: canvasPoint3[0],
|
|
137
|
-
y: canvasPoint3[1],
|
|
138
|
-
},
|
|
139
|
-
end: {
|
|
140
|
-
x: canvasPoint4[0],
|
|
141
|
-
y: canvasPoint4[1],
|
|
142
|
-
},
|
|
143
|
-
};
|
|
144
|
-
const distanceToPoint = lineSegment.distanceToPoint([line1.start.x, line1.start.y], [line1.end.x, line1.end.y], [canvasCoords[0], canvasCoords[1]]);
|
|
145
|
-
const distanceToPoint2 = lineSegment.distanceToPoint([line2.start.x, line2.start.y], [line2.end.x, line2.end.y], [canvasCoords[0], canvasCoords[1]]);
|
|
119
|
+
const { distanceToPoint, distanceToPoint2 } = this.distanceToLines({
|
|
120
|
+
viewport,
|
|
121
|
+
points: data.handles.points,
|
|
122
|
+
canvasCoords,
|
|
123
|
+
proximity,
|
|
124
|
+
});
|
|
146
125
|
if (distanceToPoint <= proximity || distanceToPoint2 <= proximity) {
|
|
147
126
|
return true;
|
|
148
127
|
}
|
|
149
128
|
return false;
|
|
150
129
|
};
|
|
151
|
-
this.toolSelectedCallback = (evt, annotation, interactionType) => {
|
|
130
|
+
this.toolSelectedCallback = (evt, annotation, interactionType, canvasCoords, proximity = 6) => {
|
|
152
131
|
const eventDetail = evt.detail;
|
|
153
132
|
const { element } = eventDetail;
|
|
154
133
|
annotation.highlighted = true;
|
|
155
134
|
const viewportIdsToRender = (0, viewportFilters_1.getViewportIdsWithToolToRender)(element, this.getToolName());
|
|
135
|
+
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
136
|
+
const { renderingEngine, viewport } = enabledElement;
|
|
137
|
+
const { isNearFirstLine, isNearSecondLine } = this.distanceToLines({
|
|
138
|
+
viewport,
|
|
139
|
+
points: annotation.data.handles.points,
|
|
140
|
+
canvasCoords,
|
|
141
|
+
proximity,
|
|
142
|
+
});
|
|
156
143
|
this.editData = {
|
|
157
144
|
annotation,
|
|
158
145
|
viewportIdsToRender,
|
|
159
146
|
movingTextBox: false,
|
|
147
|
+
isNearFirstLine,
|
|
148
|
+
isNearSecondLine,
|
|
160
149
|
};
|
|
161
150
|
this._activateModify(element);
|
|
162
151
|
(0, elementCursor_1.hideElementCursor)(element);
|
|
163
|
-
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
164
|
-
const { renderingEngine } = enabledElement;
|
|
165
152
|
(0, triggerAnnotationRenderForViewportIds_1.default)(renderingEngine, viewportIdsToRender);
|
|
166
153
|
evt.preventDefault();
|
|
167
154
|
};
|
|
@@ -230,7 +217,7 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
230
217
|
this.isDrawing = true;
|
|
231
218
|
const eventDetail = evt.detail;
|
|
232
219
|
const { element } = eventDetail;
|
|
233
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox } = this.editData;
|
|
220
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, isNearFirstLine, isNearSecondLine, } = this.editData;
|
|
234
221
|
const { data } = annotation;
|
|
235
222
|
if (movingTextBox) {
|
|
236
223
|
const { deltaPoints } = eventDetail;
|
|
@@ -242,15 +229,27 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
242
229
|
worldPosition[2] += worldPosDelta[2];
|
|
243
230
|
textBox.hasMoved = true;
|
|
244
231
|
}
|
|
245
|
-
else if (handleIndex === undefined
|
|
232
|
+
else if (handleIndex === undefined &&
|
|
233
|
+
(isNearFirstLine || isNearSecondLine)) {
|
|
246
234
|
const { deltaPoints } = eventDetail;
|
|
247
235
|
const worldPosDelta = deltaPoints.world;
|
|
248
236
|
const points = data.handles.points;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
point
|
|
252
|
-
|
|
253
|
-
|
|
237
|
+
if (isNearFirstLine) {
|
|
238
|
+
const firstLinePoints = [points[0], points[1]];
|
|
239
|
+
firstLinePoints.forEach((point) => {
|
|
240
|
+
point[0] += worldPosDelta[0];
|
|
241
|
+
point[1] += worldPosDelta[1];
|
|
242
|
+
point[2] += worldPosDelta[2];
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else if (isNearSecondLine) {
|
|
246
|
+
const secondLinePoints = [points[2], points[3]];
|
|
247
|
+
secondLinePoints.forEach((point) => {
|
|
248
|
+
point[0] += worldPosDelta[0];
|
|
249
|
+
point[1] += worldPosDelta[1];
|
|
250
|
+
point[2] += worldPosDelta[2];
|
|
251
|
+
});
|
|
252
|
+
}
|
|
254
253
|
annotation.invalidated = true;
|
|
255
254
|
}
|
|
256
255
|
else {
|
|
@@ -265,29 +264,33 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
265
264
|
(0, triggerAnnotationRenderForViewportIds_1.default)(renderingEngine, viewportIdsToRender);
|
|
266
265
|
};
|
|
267
266
|
this.cancel = (element) => {
|
|
268
|
-
if (this.isDrawing) {
|
|
269
|
-
|
|
270
|
-
this._deactivateDraw(element);
|
|
271
|
-
this._deactivateModify(element);
|
|
272
|
-
(0, elementCursor_1.resetElementCursor)(element);
|
|
273
|
-
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
274
|
-
const { data } = annotation;
|
|
275
|
-
annotation.highlighted = false;
|
|
276
|
-
data.handles.activeHandleIndex = null;
|
|
277
|
-
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
278
|
-
const { renderingEngine } = enabledElement;
|
|
279
|
-
(0, triggerAnnotationRenderForViewportIds_1.default)(renderingEngine, viewportIdsToRender);
|
|
280
|
-
if (newAnnotation) {
|
|
281
|
-
const eventType = enums_1.Events.ANNOTATION_COMPLETED;
|
|
282
|
-
const eventDetail = {
|
|
283
|
-
annotation,
|
|
284
|
-
};
|
|
285
|
-
(0, core_1.triggerEvent)(core_1.eventTarget, eventType, eventDetail);
|
|
286
|
-
}
|
|
287
|
-
this.editData = null;
|
|
288
|
-
this.angleStartedNotYetCompleted = false;
|
|
289
|
-
return annotation.annotationUID;
|
|
267
|
+
if (!this.isDrawing) {
|
|
268
|
+
return;
|
|
290
269
|
}
|
|
270
|
+
this.isDrawing = false;
|
|
271
|
+
this._deactivateDraw(element);
|
|
272
|
+
this._deactivateModify(element);
|
|
273
|
+
(0, elementCursor_1.resetElementCursor)(element);
|
|
274
|
+
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
275
|
+
const { data } = annotation;
|
|
276
|
+
if (data.handles.points.length < 4) {
|
|
277
|
+
(0, annotationState_1.removeAnnotation)(annotation.annotationUID);
|
|
278
|
+
}
|
|
279
|
+
annotation.highlighted = false;
|
|
280
|
+
data.handles.activeHandleIndex = null;
|
|
281
|
+
const enabledElement = (0, core_1.getEnabledElement)(element);
|
|
282
|
+
const { renderingEngine } = enabledElement;
|
|
283
|
+
(0, triggerAnnotationRenderForViewportIds_1.default)(renderingEngine, viewportIdsToRender);
|
|
284
|
+
if (newAnnotation) {
|
|
285
|
+
const eventType = enums_1.Events.ANNOTATION_COMPLETED;
|
|
286
|
+
const eventDetail = {
|
|
287
|
+
annotation,
|
|
288
|
+
};
|
|
289
|
+
(0, core_1.triggerEvent)(core_1.eventTarget, eventType, eventDetail);
|
|
290
|
+
}
|
|
291
|
+
this.editData = null;
|
|
292
|
+
this.angleStartedNotYetCompleted = false;
|
|
293
|
+
return annotation.annotationUID;
|
|
291
294
|
};
|
|
292
295
|
this._activateModify = (element) => {
|
|
293
296
|
store_1.state.isInteractingWithTool = true;
|
|
@@ -350,6 +353,26 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
350
353
|
data.cachedStats[targetId].angle == null) {
|
|
351
354
|
data.cachedStats[targetId] = {
|
|
352
355
|
angle: null,
|
|
356
|
+
arc1Angle: null,
|
|
357
|
+
arc2Angle: null,
|
|
358
|
+
points: {
|
|
359
|
+
world: {
|
|
360
|
+
arc1Start: null,
|
|
361
|
+
arc1End: null,
|
|
362
|
+
arc2Start: null,
|
|
363
|
+
arc2End: null,
|
|
364
|
+
arc1Angle: null,
|
|
365
|
+
arc2Angle: null,
|
|
366
|
+
},
|
|
367
|
+
canvas: {
|
|
368
|
+
arc1Start: null,
|
|
369
|
+
arc1End: null,
|
|
370
|
+
arc2Start: null,
|
|
371
|
+
arc2End: null,
|
|
372
|
+
arc1Angle: null,
|
|
373
|
+
arc2Angle: null,
|
|
374
|
+
},
|
|
375
|
+
},
|
|
353
376
|
};
|
|
354
377
|
this._calculateCachedStats(annotation, renderingEngine, enabledElement);
|
|
355
378
|
}
|
|
@@ -374,8 +397,10 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
374
397
|
lineWidth,
|
|
375
398
|
});
|
|
376
399
|
}
|
|
377
|
-
|
|
378
|
-
|
|
400
|
+
const firstLine = [canvasCoordinates[0], canvasCoordinates[1]];
|
|
401
|
+
const secondLine = [canvasCoordinates[2], canvasCoordinates[3]];
|
|
402
|
+
let lineUID = 'line1';
|
|
403
|
+
(0, drawingSvg_1.drawLine)(svgDrawingHelper, annotationUID, lineUID, firstLine[0], firstLine[1], {
|
|
379
404
|
color,
|
|
380
405
|
width: lineWidth,
|
|
381
406
|
lineDash,
|
|
@@ -384,20 +409,32 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
384
409
|
if (canvasCoordinates.length < 4) {
|
|
385
410
|
return renderStatus;
|
|
386
411
|
}
|
|
387
|
-
lineUID = '
|
|
388
|
-
(0, drawingSvg_1.drawLine)(svgDrawingHelper, annotationUID, lineUID,
|
|
412
|
+
lineUID = 'line2';
|
|
413
|
+
(0, drawingSvg_1.drawLine)(svgDrawingHelper, annotationUID, lineUID, secondLine[0], secondLine[1], {
|
|
389
414
|
color,
|
|
390
415
|
width: lineWidth,
|
|
391
416
|
lineDash,
|
|
392
417
|
});
|
|
393
|
-
lineUID = '
|
|
394
|
-
const mid1 = (0, midPoint_1.midPoint2)(
|
|
395
|
-
const mid2 = (0, midPoint_1.midPoint2)(
|
|
418
|
+
lineUID = 'linkLine';
|
|
419
|
+
const mid1 = (0, midPoint_1.midPoint2)(firstLine[0], firstLine[1]);
|
|
420
|
+
const mid2 = (0, midPoint_1.midPoint2)(secondLine[0], secondLine[1]);
|
|
396
421
|
(0, drawingSvg_1.drawLine)(svgDrawingHelper, annotationUID, lineUID, mid1, mid2, {
|
|
397
422
|
color,
|
|
398
423
|
lineWidth: '1',
|
|
399
424
|
lineDash: '1,4',
|
|
400
425
|
});
|
|
426
|
+
const { arc1Start, arc1End, arc2End, arc2Start } = data.cachedStats[targetId].points.canvas;
|
|
427
|
+
const { arc1Angle, arc2Angle } = data.cachedStats[targetId];
|
|
428
|
+
lineUID = 'arc1';
|
|
429
|
+
(0, drawingSvg_1.drawLine)(svgDrawingHelper, annotationUID, lineUID, arc1Start, arc1End, {
|
|
430
|
+
color,
|
|
431
|
+
lineWidth: '1',
|
|
432
|
+
});
|
|
433
|
+
lineUID = 'arc2';
|
|
434
|
+
(0, drawingSvg_1.drawLine)(svgDrawingHelper, annotationUID, lineUID, arc2Start, arc2End, {
|
|
435
|
+
color,
|
|
436
|
+
lineWidth: '1',
|
|
437
|
+
});
|
|
401
438
|
if (!((_a = data.cachedStats[targetId]) === null || _a === void 0 ? void 0 : _a.angle)) {
|
|
402
439
|
continue;
|
|
403
440
|
}
|
|
@@ -422,7 +459,7 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
422
459
|
viewport.canvasToWorld(canvasTextBoxCoords);
|
|
423
460
|
}
|
|
424
461
|
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
425
|
-
const textBoxUID = '
|
|
462
|
+
const textBoxUID = 'cobbAngleText';
|
|
426
463
|
const boundingBox = (0, drawingSvg_1.drawLinkedTextBox)(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
|
|
427
464
|
const { x: left, y: top, width, height } = boundingBox;
|
|
428
465
|
data.handles.textBox.worldBoundingBox = {
|
|
@@ -431,10 +468,142 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
431
468
|
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
432
469
|
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
433
470
|
};
|
|
471
|
+
const arc1TextBoxUID = 'arcAngle1';
|
|
472
|
+
const arc1TextLine = [
|
|
473
|
+
`${arc1Angle.toFixed(2)} ${String.fromCharCode(176)}`,
|
|
474
|
+
];
|
|
475
|
+
const arch1TextPosCanvas = (0, midPoint_1.midPoint2)(arc1Start, arc1End);
|
|
476
|
+
(0, drawingSvg_1.drawTextBox)(svgDrawingHelper, annotationUID, arc1TextBoxUID, arc1TextLine, arch1TextPosCanvas, Object.assign(Object.assign({}, options), { padding: 3 }));
|
|
477
|
+
const arc2TextBoxUID = 'arcAngle2';
|
|
478
|
+
const arc2TextLine = [
|
|
479
|
+
`${arc2Angle.toFixed(2)} ${String.fromCharCode(176)}`,
|
|
480
|
+
];
|
|
481
|
+
const arch2TextPosCanvas = (0, midPoint_1.midPoint2)(arc2Start, arc2End);
|
|
482
|
+
(0, drawingSvg_1.drawTextBox)(svgDrawingHelper, annotationUID, arc2TextBoxUID, arc2TextLine, arch2TextPosCanvas, Object.assign(Object.assign({}, options), { padding: 3 }));
|
|
434
483
|
}
|
|
435
484
|
return renderStatus;
|
|
436
485
|
};
|
|
437
|
-
this.
|
|
486
|
+
this.distanceToLines = ({ viewport, points, canvasCoords, proximity }) => {
|
|
487
|
+
const [point1, point2, point3, point4] = points;
|
|
488
|
+
const canvasPoint1 = viewport.worldToCanvas(point1);
|
|
489
|
+
const canvasPoint2 = viewport.worldToCanvas(point2);
|
|
490
|
+
const canvasPoint3 = viewport.worldToCanvas(point3);
|
|
491
|
+
const canvasPoint4 = viewport.worldToCanvas(point4);
|
|
492
|
+
const line1 = {
|
|
493
|
+
start: {
|
|
494
|
+
x: canvasPoint1[0],
|
|
495
|
+
y: canvasPoint1[1],
|
|
496
|
+
},
|
|
497
|
+
end: {
|
|
498
|
+
x: canvasPoint2[0],
|
|
499
|
+
y: canvasPoint2[1],
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
const line2 = {
|
|
503
|
+
start: {
|
|
504
|
+
x: canvasPoint3[0],
|
|
505
|
+
y: canvasPoint3[1],
|
|
506
|
+
},
|
|
507
|
+
end: {
|
|
508
|
+
x: canvasPoint4[0],
|
|
509
|
+
y: canvasPoint4[1],
|
|
510
|
+
},
|
|
511
|
+
};
|
|
512
|
+
const distanceToPoint = lineSegment.distanceToPoint([line1.start.x, line1.start.y], [line1.end.x, line1.end.y], [canvasCoords[0], canvasCoords[1]]);
|
|
513
|
+
const distanceToPoint2 = lineSegment.distanceToPoint([line2.start.x, line2.start.y], [line2.end.x, line2.end.y], [canvasCoords[0], canvasCoords[1]]);
|
|
514
|
+
let isNearFirstLine = false;
|
|
515
|
+
let isNearSecondLine = false;
|
|
516
|
+
if (distanceToPoint <= proximity) {
|
|
517
|
+
isNearFirstLine = true;
|
|
518
|
+
}
|
|
519
|
+
else if (distanceToPoint2 <= proximity) {
|
|
520
|
+
isNearSecondLine = true;
|
|
521
|
+
}
|
|
522
|
+
return {
|
|
523
|
+
distanceToPoint,
|
|
524
|
+
distanceToPoint2,
|
|
525
|
+
isNearFirstLine,
|
|
526
|
+
isNearSecondLine,
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
this.getArcsStartEndPoints = ({ firstLine, secondLine, mid1, mid2, }) => {
|
|
530
|
+
const linkLine = [mid1, mid2];
|
|
531
|
+
const arc1Angle = (0, angleBetweenLines_1.default)(firstLine, linkLine);
|
|
532
|
+
const arc2Angle = (0, angleBetweenLines_1.default)(secondLine, linkLine);
|
|
533
|
+
const arc1Side = arc1Angle > 90 ? 1 : 0;
|
|
534
|
+
const arc2Side = arc2Angle > 90 ? 0 : 1;
|
|
535
|
+
const midLinkLine = (0, midPoint_1.midPoint2)(linkLine[0], linkLine[1]);
|
|
536
|
+
const linkLineLength = Math.sqrt(Math.pow((linkLine[1][0] - linkLine[0][0]), 2) +
|
|
537
|
+
Math.pow((linkLine[1][1] - linkLine[0][1]), 2));
|
|
538
|
+
const ratio = 0.1;
|
|
539
|
+
const midFirstLine = (0, midPoint_1.midPoint2)(firstLine[0], firstLine[1]);
|
|
540
|
+
const midSecondLine = (0, midPoint_1.midPoint2)(secondLine[0], secondLine[1]);
|
|
541
|
+
const directionVectorStartArc1 = [
|
|
542
|
+
firstLine[arc1Side][0] - midFirstLine[0],
|
|
543
|
+
firstLine[arc1Side][1] - midFirstLine[1],
|
|
544
|
+
];
|
|
545
|
+
const magnitudeStartArc1 = Math.sqrt(Math.pow(directionVectorStartArc1[0], 2) + Math.pow(directionVectorStartArc1[1], 2));
|
|
546
|
+
const normalizedDirectionStartArc1 = [
|
|
547
|
+
directionVectorStartArc1[0] / magnitudeStartArc1,
|
|
548
|
+
directionVectorStartArc1[1] / magnitudeStartArc1,
|
|
549
|
+
];
|
|
550
|
+
const arc1Start = [
|
|
551
|
+
midFirstLine[0] +
|
|
552
|
+
normalizedDirectionStartArc1[0] * linkLineLength * ratio,
|
|
553
|
+
midFirstLine[1] +
|
|
554
|
+
normalizedDirectionStartArc1[1] * linkLineLength * ratio,
|
|
555
|
+
];
|
|
556
|
+
const directionVectorEndArc1 = [
|
|
557
|
+
midLinkLine[0] - mid1[0],
|
|
558
|
+
midLinkLine[1] - mid1[1],
|
|
559
|
+
];
|
|
560
|
+
const magnitudeEndArc1 = Math.sqrt(Math.pow(directionVectorEndArc1[0], 2) + Math.pow(directionVectorEndArc1[1], 2));
|
|
561
|
+
const normalizedDirectionEndArc1 = [
|
|
562
|
+
directionVectorEndArc1[0] / magnitudeEndArc1,
|
|
563
|
+
directionVectorEndArc1[1] / magnitudeEndArc1,
|
|
564
|
+
];
|
|
565
|
+
const arc1End = [
|
|
566
|
+
mid1[0] + normalizedDirectionEndArc1[0] * linkLineLength * ratio,
|
|
567
|
+
mid1[1] + normalizedDirectionEndArc1[1] * linkLineLength * ratio,
|
|
568
|
+
];
|
|
569
|
+
const directionVectorStartArc2 = [
|
|
570
|
+
secondLine[arc2Side][0] - midSecondLine[0],
|
|
571
|
+
secondLine[arc2Side][1] - midSecondLine[1],
|
|
572
|
+
];
|
|
573
|
+
const magnitudeStartArc2 = Math.sqrt(Math.pow(directionVectorStartArc2[0], 2) + Math.pow(directionVectorStartArc2[1], 2));
|
|
574
|
+
const normalizedDirectionStartArc2 = [
|
|
575
|
+
directionVectorStartArc2[0] / magnitudeStartArc2,
|
|
576
|
+
directionVectorStartArc2[1] / magnitudeStartArc2,
|
|
577
|
+
];
|
|
578
|
+
const arc2Start = [
|
|
579
|
+
midSecondLine[0] +
|
|
580
|
+
normalizedDirectionStartArc2[0] * linkLineLength * ratio,
|
|
581
|
+
midSecondLine[1] +
|
|
582
|
+
normalizedDirectionStartArc2[1] * linkLineLength * ratio,
|
|
583
|
+
];
|
|
584
|
+
const directionVectorEndArc2 = [
|
|
585
|
+
midLinkLine[0] - mid2[0],
|
|
586
|
+
midLinkLine[1] - mid2[1],
|
|
587
|
+
];
|
|
588
|
+
const magnitudeEndArc2 = Math.sqrt(Math.pow(directionVectorEndArc2[0], 2) + Math.pow(directionVectorEndArc2[1], 2));
|
|
589
|
+
const normalizedDirectionEndArc2 = [
|
|
590
|
+
directionVectorEndArc2[0] / magnitudeEndArc2,
|
|
591
|
+
directionVectorEndArc2[1] / magnitudeEndArc2,
|
|
592
|
+
];
|
|
593
|
+
const arc2End = [
|
|
594
|
+
mid2[0] + normalizedDirectionEndArc2[0] * linkLineLength * ratio,
|
|
595
|
+
mid2[1] + normalizedDirectionEndArc2[1] * linkLineLength * ratio,
|
|
596
|
+
];
|
|
597
|
+
return {
|
|
598
|
+
arc1Start,
|
|
599
|
+
arc1End,
|
|
600
|
+
arc2Start,
|
|
601
|
+
arc2End,
|
|
602
|
+
arc1Angle: arc1Angle > 90 ? 180 - arc1Angle : arc1Angle,
|
|
603
|
+
arc2Angle: arc2Angle > 90 ? 180 - arc2Angle : arc2Angle,
|
|
604
|
+
};
|
|
605
|
+
};
|
|
606
|
+
this._throttledCalculateCachedStats = (0, throttle_1.default)(this._calculateCachedStats, 25, { trailing: true });
|
|
438
607
|
}
|
|
439
608
|
handleSelectedCallback(evt, annotation, handle, interactionType = 'mouse') {
|
|
440
609
|
const eventDetail = evt.detail;
|
|
@@ -484,13 +653,40 @@ class CobbAngleTool extends base_1.AnnotationTool {
|
|
|
484
653
|
}
|
|
485
654
|
}
|
|
486
655
|
}
|
|
656
|
+
const { viewport } = enabledElement;
|
|
657
|
+
const canvasPoints = data.handles.points.map((p) => viewport.worldToCanvas(p));
|
|
658
|
+
const firstLine = [canvasPoints[0], canvasPoints[1]];
|
|
659
|
+
const secondLine = [canvasPoints[2], canvasPoints[3]];
|
|
660
|
+
const mid1 = (0, midPoint_1.midPoint2)(firstLine[0], firstLine[1]);
|
|
661
|
+
const mid2 = (0, midPoint_1.midPoint2)(secondLine[0], secondLine[1]);
|
|
662
|
+
const { arc1Start, arc1End, arc2End, arc2Start, arc1Angle, arc2Angle } = this.getArcsStartEndPoints({
|
|
663
|
+
firstLine,
|
|
664
|
+
secondLine,
|
|
665
|
+
mid1,
|
|
666
|
+
mid2,
|
|
667
|
+
});
|
|
487
668
|
const { cachedStats } = data;
|
|
488
669
|
const targetIds = Object.keys(cachedStats);
|
|
489
670
|
for (let i = 0; i < targetIds.length; i++) {
|
|
490
671
|
const targetId = targetIds[i];
|
|
491
|
-
const angle = (0, angleBetweenLines_1.default)(seg1, seg2);
|
|
492
672
|
cachedStats[targetId] = {
|
|
493
|
-
angle,
|
|
673
|
+
angle: (0, angleBetweenLines_1.default)(seg1, seg2),
|
|
674
|
+
arc1Angle,
|
|
675
|
+
arc2Angle,
|
|
676
|
+
points: {
|
|
677
|
+
canvas: {
|
|
678
|
+
arc1Start,
|
|
679
|
+
arc1End,
|
|
680
|
+
arc2End,
|
|
681
|
+
arc2Start,
|
|
682
|
+
},
|
|
683
|
+
world: {
|
|
684
|
+
arc1Start: viewport.canvasToWorld(arc1Start),
|
|
685
|
+
arc1End: viewport.canvasToWorld(arc1End),
|
|
686
|
+
arc2End: viewport.canvasToWorld(arc2End),
|
|
687
|
+
arc2Start: viewport.canvasToWorld(arc2Start),
|
|
688
|
+
},
|
|
689
|
+
},
|
|
494
690
|
};
|
|
495
691
|
}
|
|
496
692
|
annotation.invalidated = false;
|