@cornerstonejs/tools 4.17.1 → 4.17.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/esm/drawingSvg/draw.js +4 -0
- package/dist/esm/drawingSvg/drawTextBox.js +8 -4
- package/dist/esm/tools/annotation/AngleTool.js +15 -29
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js +9 -28
- package/dist/esm/tools/annotation/BidirectionalTool.js +10 -31
- package/dist/esm/tools/annotation/CircleROITool.js +12 -31
- package/dist/esm/tools/annotation/CobbAngleTool.js +14 -32
- package/dist/esm/tools/annotation/EllipticalROITool.js +11 -31
- package/dist/esm/tools/annotation/HeightTool.js +11 -31
- package/dist/esm/tools/annotation/LengthTool.js +10 -30
- package/dist/esm/tools/annotation/LivewireContourTool.js +20 -20
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +8 -21
- package/dist/esm/tools/annotation/ProbeTool.js +3 -5
- package/dist/esm/tools/annotation/RectangleROITool.js +10 -30
- package/dist/esm/tools/annotation/SplineROITool.js +20 -20
- package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +15 -29
- package/dist/esm/tools/base/AnnotationTool.d.ts +11 -0
- package/dist/esm/tools/base/AnnotationTool.js +50 -0
- package/dist/esm/tools/segmentation/CircleROIStartEndThresholdTool.js +15 -31
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +10 -30
- package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +10 -32
- package/dist/esm/utilities/drawing/getTextBoxCoordsCanvas.d.ts +1 -1
- package/dist/esm/utilities/drawing/getTextBoxCoordsCanvas.js +113 -3
- package/dist/esm/utilities/drawing/textBoxOverlapRegistry.d.ts +9 -0
- package/dist/esm/utilities/drawing/textBoxOverlapRegistry.js +20 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +3 -3
- package/dist/esm/tools/segmentation/strategies/__tests__/fillCircle.spec.d.ts +0 -1
- package/dist/esm/tools/segmentation/strategies/__tests__/fillCircle.spec.js +0 -27
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import getSvgDrawingHelper from './getSvgDrawingHelper';
|
|
2
|
+
import { clearTextBoxRegistry } from '../utilities/drawing/textBoxOverlapRegistry';
|
|
2
3
|
function draw(element, fn) {
|
|
3
4
|
const svgDrawingHelper = getSvgDrawingHelper(element);
|
|
5
|
+
if (svgDrawingHelper.svgLayerElement) {
|
|
6
|
+
clearTextBoxRegistry(svgDrawingHelper.svgLayerElement);
|
|
7
|
+
}
|
|
4
8
|
fn(svgDrawingHelper);
|
|
5
9
|
svgDrawingHelper.clearUntouched();
|
|
6
10
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _getHash from './_getHash';
|
|
2
2
|
import setAttributesIfNecessary from './setAttributesIfNecessary';
|
|
3
|
+
import { registerTextBox } from '../utilities/drawing/textBoxOverlapRegistry';
|
|
3
4
|
function drawTextBox(svgDrawingHelper, annotationUID, textUID, textLines, position, options = {}) {
|
|
4
5
|
const mergedOptions = Object.assign({
|
|
5
6
|
fontFamily: 'Helvetica, Arial, sans-serif',
|
|
@@ -11,6 +12,9 @@ function drawTextBox(svgDrawingHelper, annotationUID, textUID, textLines, positi
|
|
|
11
12
|
centerY: true,
|
|
12
13
|
}, options);
|
|
13
14
|
const textGroupBoundingBox = _drawTextGroup(svgDrawingHelper, annotationUID, textUID, textLines, position, mergedOptions);
|
|
15
|
+
if (svgDrawingHelper.svgLayerElement) {
|
|
16
|
+
registerTextBox(svgDrawingHelper.svgLayerElement, textGroupBoundingBox);
|
|
17
|
+
}
|
|
14
18
|
return textGroupBoundingBox;
|
|
15
19
|
}
|
|
16
20
|
function _drawTextGroup(svgDrawingHelper, annotationUID, textUID, textLines = [''], position, options) {
|
|
@@ -71,10 +75,10 @@ function _drawTextGroup(svgDrawingHelper, annotationUID, textUID, textLines = ['
|
|
|
71
75
|
textGroupBoundingBox = _drawTextBackground(textGroup, backgroundStyles);
|
|
72
76
|
}
|
|
73
77
|
return Object.assign({}, textGroupBoundingBox, {
|
|
74
|
-
x,
|
|
75
|
-
y,
|
|
76
|
-
height: textGroupBoundingBox.height
|
|
77
|
-
width: textGroupBoundingBox.width
|
|
78
|
+
x: x + textGroupBoundingBox.x,
|
|
79
|
+
y: y + textGroupBoundingBox.y,
|
|
80
|
+
height: textGroupBoundingBox.height,
|
|
81
|
+
width: textGroupBoundingBox.width,
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
function _createTextElement(svgDrawingHelper, options) {
|
|
@@ -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,
|
|
9
|
+
import { drawHandles as drawHandlesSvg, drawLine as drawLineSvg, 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';
|
|
@@ -354,36 +354,22 @@ class AngleTool extends AnnotationTool {
|
|
|
354
354
|
if (!data.cachedStats[targetId]?.angle) {
|
|
355
355
|
continue;
|
|
356
356
|
}
|
|
357
|
-
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
358
|
-
if (!options.visibility) {
|
|
359
|
-
data.handles.textBox = {
|
|
360
|
-
hasMoved: false,
|
|
361
|
-
worldPosition: [0, 0, 0],
|
|
362
|
-
worldBoundingBox: {
|
|
363
|
-
topLeft: [0, 0, 0],
|
|
364
|
-
topRight: [0, 0, 0],
|
|
365
|
-
bottomLeft: [0, 0, 0],
|
|
366
|
-
bottomRight: [0, 0, 0],
|
|
367
|
-
},
|
|
368
|
-
};
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
357
|
const textLines = this.configuration.getTextLines(data, targetId);
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
358
|
+
const vertexAnchor = [
|
|
359
|
+
canvasCoordinates[1],
|
|
360
|
+
canvasCoordinates[1],
|
|
361
|
+
];
|
|
362
|
+
if (!this.renderLinkedTextBoxAnnotation({
|
|
363
|
+
enabledElement,
|
|
364
|
+
svgDrawingHelper,
|
|
365
|
+
annotation,
|
|
366
|
+
styleSpecifier,
|
|
367
|
+
textLines,
|
|
368
|
+
canvasCoordinates,
|
|
369
|
+
placementPoints: vertexAnchor,
|
|
370
|
+
})) {
|
|
371
|
+
continue;
|
|
376
372
|
}
|
|
377
|
-
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
378
|
-
const textBoxUID = '1';
|
|
379
|
-
const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
|
|
380
|
-
const { x: left, y: top, width, height } = boundingBox;
|
|
381
|
-
data.handles.textBox.worldBoundingBox = {
|
|
382
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
383
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
384
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
385
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
386
|
-
};
|
|
387
373
|
}
|
|
388
374
|
return renderStatus;
|
|
389
375
|
};
|
|
@@ -4,7 +4,7 @@ import { AnnotationTool } from '../base';
|
|
|
4
4
|
import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateManagement/annotation/annotationState';
|
|
5
5
|
import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
|
|
6
6
|
import * as lineSegment from '../../utilities/math/line';
|
|
7
|
-
import { drawHandles as drawHandlesSvg, drawArrow as drawArrowSvg,
|
|
7
|
+
import { drawHandles as drawHandlesSvg, drawArrow as drawArrowSvg, } from '../../drawingSvg';
|
|
8
8
|
import { state } from '../../store/state';
|
|
9
9
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
10
10
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
@@ -331,35 +331,16 @@ class ArrowAnnotateTool extends AnnotationTool {
|
|
|
331
331
|
if (!label) {
|
|
332
332
|
continue;
|
|
333
333
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
bottomLeft: [0, 0, 0],
|
|
343
|
-
bottomRight: [0, 0, 0],
|
|
344
|
-
},
|
|
345
|
-
};
|
|
334
|
+
if (!this.renderLinkedTextBoxAnnotation({
|
|
335
|
+
enabledElement,
|
|
336
|
+
svgDrawingHelper,
|
|
337
|
+
annotation,
|
|
338
|
+
styleSpecifier,
|
|
339
|
+
textLines: [label],
|
|
340
|
+
canvasCoordinates,
|
|
341
|
+
})) {
|
|
346
342
|
continue;
|
|
347
343
|
}
|
|
348
|
-
if (!data.handles.textBox.hasMoved) {
|
|
349
|
-
const canvasTextBoxCoords = canvasCoordinates[1];
|
|
350
|
-
data.handles.textBox.worldPosition =
|
|
351
|
-
viewport.canvasToWorld(canvasTextBoxCoords);
|
|
352
|
-
}
|
|
353
|
-
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
354
|
-
const textBoxUID = '1';
|
|
355
|
-
const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, annotationUID, textBoxUID, [label], textBoxPosition, canvasCoordinates, {}, options);
|
|
356
|
-
const { x: left, y: top, width, height } = boundingBox;
|
|
357
|
-
data.handles.textBox.worldBoundingBox = {
|
|
358
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
359
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
360
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
361
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
362
|
-
};
|
|
363
344
|
}
|
|
364
345
|
return renderStatus;
|
|
365
346
|
};
|
|
@@ -7,12 +7,11 @@ import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateMan
|
|
|
7
7
|
import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
|
|
8
8
|
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
9
9
|
import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../stateManagement/annotation/helpers/state';
|
|
10
|
-
import { drawLine as drawLineSvg, drawHandles as drawHandlesSvg,
|
|
10
|
+
import { drawLine as drawLineSvg, drawHandles as drawHandlesSvg, } from '../../drawingSvg';
|
|
11
11
|
import { state } from '../../store/state';
|
|
12
12
|
import { ChangeTypes, Events, MeasurementType } from '../../enums';
|
|
13
13
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
14
14
|
import * as lineSegment from '../../utilities/math/line';
|
|
15
|
-
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
16
15
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
17
16
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
18
17
|
import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
|
|
@@ -539,40 +538,20 @@ class BidirectionalTool extends AnnotationTool {
|
|
|
539
538
|
shadow,
|
|
540
539
|
}, dataId2);
|
|
541
540
|
renderStatus = true;
|
|
542
|
-
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
543
|
-
if (!options.visibility) {
|
|
544
|
-
data.handles.textBox = {
|
|
545
|
-
hasMoved: false,
|
|
546
|
-
worldPosition: [0, 0, 0],
|
|
547
|
-
worldBoundingBox: {
|
|
548
|
-
topLeft: [0, 0, 0],
|
|
549
|
-
topRight: [0, 0, 0],
|
|
550
|
-
bottomLeft: [0, 0, 0],
|
|
551
|
-
bottomRight: [0, 0, 0],
|
|
552
|
-
},
|
|
553
|
-
};
|
|
554
|
-
continue;
|
|
555
|
-
}
|
|
556
541
|
const textLines = this.configuration.getTextLines(data, targetId);
|
|
557
542
|
if (!textLines || textLines.length === 0) {
|
|
558
543
|
continue;
|
|
559
544
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
545
|
+
if (!this.renderLinkedTextBoxAnnotation({
|
|
546
|
+
enabledElement,
|
|
547
|
+
svgDrawingHelper,
|
|
548
|
+
annotation,
|
|
549
|
+
styleSpecifier,
|
|
550
|
+
textLines,
|
|
551
|
+
canvasCoordinates,
|
|
552
|
+
})) {
|
|
553
|
+
continue;
|
|
565
554
|
}
|
|
566
|
-
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
567
|
-
const textBoxUID = '1';
|
|
568
|
-
const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
|
|
569
|
-
const { x: left, y: top, width, height } = boundingBox;
|
|
570
|
-
data.handles.textBox.worldBoundingBox = {
|
|
571
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
572
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
573
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
574
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
575
|
-
};
|
|
576
555
|
}
|
|
577
556
|
return renderStatus;
|
|
578
557
|
};
|
|
@@ -7,11 +7,10 @@ import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateMan
|
|
|
7
7
|
import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
|
|
8
8
|
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
9
9
|
import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../stateManagement/annotation/helpers/state';
|
|
10
|
-
import { drawCircle as drawCircleSvg, drawHandles as drawHandlesSvg,
|
|
10
|
+
import { drawCircle as drawCircleSvg, drawHandles as drawHandlesSvg, } from '../../drawingSvg';
|
|
11
11
|
import { state } from '../../store/state';
|
|
12
12
|
import { ChangeTypes, Events, MeasurementType } from '../../enums';
|
|
13
13
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
14
|
-
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
15
14
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
16
15
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
17
16
|
import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
|
|
@@ -434,40 +433,22 @@ class CircleROITool extends AnnotationTool {
|
|
|
434
433
|
}
|
|
435
434
|
renderStatus = true;
|
|
436
435
|
if (this.configuration.calculateStats) {
|
|
437
|
-
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
438
|
-
if (!options.visibility) {
|
|
439
|
-
data.handles.textBox = {
|
|
440
|
-
hasMoved: false,
|
|
441
|
-
worldPosition: [0, 0, 0],
|
|
442
|
-
worldBoundingBox: {
|
|
443
|
-
topLeft: [0, 0, 0],
|
|
444
|
-
topRight: [0, 0, 0],
|
|
445
|
-
bottomLeft: [0, 0, 0],
|
|
446
|
-
bottomRight: [0, 0, 0],
|
|
447
|
-
},
|
|
448
|
-
};
|
|
449
|
-
continue;
|
|
450
|
-
}
|
|
451
436
|
const textLines = this.configuration.getTextLines(data, targetId);
|
|
452
437
|
if (!textLines || textLines.length === 0) {
|
|
453
438
|
continue;
|
|
454
439
|
}
|
|
455
|
-
|
|
456
|
-
if (!
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
440
|
+
const linkAnchorPoints = [center, canvasCoordinates[1]];
|
|
441
|
+
if (!this.renderLinkedTextBoxAnnotation({
|
|
442
|
+
enabledElement,
|
|
443
|
+
svgDrawingHelper,
|
|
444
|
+
annotation,
|
|
445
|
+
styleSpecifier,
|
|
446
|
+
textLines,
|
|
447
|
+
canvasCoordinates: linkAnchorPoints,
|
|
448
|
+
placementPoints: canvasCorners,
|
|
449
|
+
})) {
|
|
450
|
+
continue;
|
|
460
451
|
}
|
|
461
|
-
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
462
|
-
const textBoxUID = '1';
|
|
463
|
-
const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, [center, canvasCoordinates[1]], {}, options);
|
|
464
|
-
const { x: left, y: top, width, height } = boundingBox;
|
|
465
|
-
data.handles.textBox.worldBoundingBox = {
|
|
466
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
467
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
468
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
469
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
470
|
-
};
|
|
471
452
|
}
|
|
472
453
|
}
|
|
473
454
|
return renderStatus;
|
|
@@ -9,10 +9,9 @@ import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../st
|
|
|
9
9
|
import * as lineSegment from '../../utilities/math/line';
|
|
10
10
|
import angleBetweenLines from '../../utilities/math/angle/angleBetweenLines';
|
|
11
11
|
import { midPoint2 } from '../../utilities/math/midPoint';
|
|
12
|
-
import { drawHandles as drawHandlesSvg, drawLine as drawLineSvg,
|
|
12
|
+
import { drawHandles as drawHandlesSvg, drawLine as drawLineSvg, drawTextBox as drawTextBoxSvg, } from '../../drawingSvg';
|
|
13
13
|
import { state } from '../../store/state';
|
|
14
14
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
15
|
-
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
16
15
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
17
16
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
18
17
|
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
@@ -403,44 +402,27 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
403
402
|
if (!data.cachedStats[targetId]?.angle) {
|
|
404
403
|
continue;
|
|
405
404
|
}
|
|
406
|
-
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
407
|
-
if (!options.visibility) {
|
|
408
|
-
data.handles.textBox = {
|
|
409
|
-
hasMoved: false,
|
|
410
|
-
worldPosition: [0, 0, 0],
|
|
411
|
-
worldBoundingBox: {
|
|
412
|
-
topLeft: [0, 0, 0],
|
|
413
|
-
topRight: [0, 0, 0],
|
|
414
|
-
bottomLeft: [0, 0, 0],
|
|
415
|
-
bottomRight: [0, 0, 0],
|
|
416
|
-
},
|
|
417
|
-
};
|
|
418
|
-
continue;
|
|
419
|
-
}
|
|
420
405
|
const textLines = this.configuration.getTextLines(data, targetId);
|
|
421
|
-
if (!
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
406
|
+
if (!this.renderLinkedTextBoxAnnotation({
|
|
407
|
+
enabledElement,
|
|
408
|
+
svgDrawingHelper,
|
|
409
|
+
annotation,
|
|
410
|
+
styleSpecifier,
|
|
411
|
+
textLines: textLines ?? [],
|
|
412
|
+
canvasCoordinates,
|
|
413
|
+
textBoxUID: 'cobbAngleText',
|
|
414
|
+
})) {
|
|
415
|
+
continue;
|
|
425
416
|
}
|
|
426
|
-
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
427
|
-
const textBoxUID = 'cobbAngleText';
|
|
428
|
-
const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
|
|
429
|
-
const { x: left, y: top, width, height } = boundingBox;
|
|
430
|
-
data.handles.textBox.worldBoundingBox = {
|
|
431
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
432
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
433
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
434
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
435
|
-
};
|
|
436
417
|
if (this.configuration.showArcLines) {
|
|
418
|
+
const textBoxStyleOptions = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
437
419
|
const arc1TextBoxUID = 'arcAngle1';
|
|
438
420
|
const arc1TextLine = [
|
|
439
421
|
`${arc1Angle.toFixed(2)} ${String.fromCharCode(176)}`,
|
|
440
422
|
];
|
|
441
423
|
const arch1TextPosCanvas = midPoint2(arc1Start, arc1End);
|
|
442
424
|
drawTextBoxSvg(svgDrawingHelper, annotationUID, arc1TextBoxUID, arc1TextLine, arch1TextPosCanvas, {
|
|
443
|
-
...
|
|
425
|
+
...textBoxStyleOptions,
|
|
444
426
|
padding: 3,
|
|
445
427
|
});
|
|
446
428
|
const arc2TextBoxUID = 'arcAngle2';
|
|
@@ -449,7 +431,7 @@ class CobbAngleTool extends AnnotationTool {
|
|
|
449
431
|
];
|
|
450
432
|
const arch2TextPosCanvas = midPoint2(arc2Start, arc2End);
|
|
451
433
|
drawTextBoxSvg(svgDrawingHelper, annotationUID, arc2TextBoxUID, arc2TextLine, arch2TextPosCanvas, {
|
|
452
|
-
...
|
|
434
|
+
...textBoxStyleOptions,
|
|
453
435
|
padding: 3,
|
|
454
436
|
});
|
|
455
437
|
}
|
|
@@ -6,11 +6,10 @@ import { addAnnotation, getAnnotations, removeAnnotation, } from '../../stateMan
|
|
|
6
6
|
import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
|
|
7
7
|
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
8
8
|
import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../stateManagement/annotation/helpers/state';
|
|
9
|
-
import { drawCircle as drawCircleSvg, drawEllipseByCoordinates as drawEllipseSvg, drawHandles as drawHandlesSvg,
|
|
9
|
+
import { drawCircle as drawCircleSvg, drawEllipseByCoordinates as drawEllipseSvg, drawHandles as drawHandlesSvg, } from '../../drawingSvg';
|
|
10
10
|
import { state } from '../../store/state';
|
|
11
11
|
import { ChangeTypes, Events } from '../../enums';
|
|
12
12
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
13
|
-
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
14
13
|
import getWorldWidthAndHeightFromTwoPoints from '../../utilities/planar/getWorldWidthAndHeightFromTwoPoints';
|
|
15
14
|
import { pointInEllipse, getCanvasEllipseCorners, } from '../../utilities/math/ellipse';
|
|
16
15
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
@@ -471,40 +470,21 @@ class EllipticalROITool extends AnnotationTool {
|
|
|
471
470
|
}
|
|
472
471
|
}
|
|
473
472
|
renderStatus = true;
|
|
474
|
-
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
475
|
-
if (!options.visibility) {
|
|
476
|
-
data.handles.textBox = {
|
|
477
|
-
hasMoved: false,
|
|
478
|
-
worldPosition: [0, 0, 0],
|
|
479
|
-
worldBoundingBox: {
|
|
480
|
-
topLeft: [0, 0, 0],
|
|
481
|
-
topRight: [0, 0, 0],
|
|
482
|
-
bottomLeft: [0, 0, 0],
|
|
483
|
-
bottomRight: [0, 0, 0],
|
|
484
|
-
},
|
|
485
|
-
};
|
|
486
|
-
continue;
|
|
487
|
-
}
|
|
488
473
|
const textLines = this.configuration.getTextLines(data, targetId);
|
|
489
474
|
if (!textLines || textLines.length === 0) {
|
|
490
475
|
continue;
|
|
491
476
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
477
|
+
if (!this.renderLinkedTextBoxAnnotation({
|
|
478
|
+
enabledElement,
|
|
479
|
+
svgDrawingHelper,
|
|
480
|
+
annotation,
|
|
481
|
+
styleSpecifier,
|
|
482
|
+
textLines,
|
|
483
|
+
canvasCoordinates,
|
|
484
|
+
placementPoints: canvasCorners,
|
|
485
|
+
})) {
|
|
486
|
+
continue;
|
|
497
487
|
}
|
|
498
|
-
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
499
|
-
const textBoxUID = '1';
|
|
500
|
-
const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
|
|
501
|
-
const { x: left, y: top, width, height } = boundingBox;
|
|
502
|
-
data.handles.textBox.worldBoundingBox = {
|
|
503
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
504
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
505
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
506
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
507
|
-
};
|
|
508
488
|
}
|
|
509
489
|
return renderStatus;
|
|
510
490
|
};
|
|
@@ -8,10 +8,9 @@ import { isAnnotationLocked } from '../../stateManagement/annotation/annotationL
|
|
|
8
8
|
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
9
9
|
import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../stateManagement/annotation/helpers/state';
|
|
10
10
|
import * as lineSegment from '../../utilities/math/line';
|
|
11
|
-
import { drawHandles as drawHandlesSvg, drawHeight as drawHeightSvg,
|
|
11
|
+
import { drawHandles as drawHandlesSvg, drawHeight as drawHeightSvg, } from '../../drawingSvg';
|
|
12
12
|
import { state } from '../../store/state';
|
|
13
13
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
14
|
-
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
15
14
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
16
15
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
17
16
|
import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
|
|
@@ -120,7 +119,7 @@ class HeightTool extends AnnotationTool {
|
|
|
120
119
|
this.isDrawing = true;
|
|
121
120
|
const eventDetail = evt.detail;
|
|
122
121
|
const { element } = eventDetail;
|
|
123
|
-
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation } = this.editData;
|
|
122
|
+
const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
|
|
124
123
|
const { data } = annotation;
|
|
125
124
|
this.createMemo(element, annotation, { newAnnotation });
|
|
126
125
|
if (movingTextBox) {
|
|
@@ -281,36 +280,17 @@ class HeightTool extends AnnotationTool {
|
|
|
281
280
|
console.warn('Rendering Engine has been destroyed');
|
|
282
281
|
return renderStatus;
|
|
283
282
|
}
|
|
284
|
-
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
285
|
-
if (!options.visibility) {
|
|
286
|
-
data.handles.textBox = {
|
|
287
|
-
hasMoved: false,
|
|
288
|
-
worldPosition: [0, 0, 0],
|
|
289
|
-
worldBoundingBox: {
|
|
290
|
-
topLeft: [0, 0, 0],
|
|
291
|
-
topRight: [0, 0, 0],
|
|
292
|
-
bottomLeft: [0, 0, 0],
|
|
293
|
-
bottomRight: [0, 0, 0],
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
283
|
const textLines = this.configuration.getTextLines(data, targetId);
|
|
299
|
-
if (!
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
284
|
+
if (!this.renderLinkedTextBoxAnnotation({
|
|
285
|
+
enabledElement,
|
|
286
|
+
svgDrawingHelper,
|
|
287
|
+
annotation,
|
|
288
|
+
styleSpecifier,
|
|
289
|
+
textLines: textLines ?? [],
|
|
290
|
+
canvasCoordinates,
|
|
291
|
+
})) {
|
|
292
|
+
continue;
|
|
303
293
|
}
|
|
304
|
-
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
305
|
-
const textBoxUID = '1';
|
|
306
|
-
const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
|
|
307
|
-
const { x: left, y: top, width, height } = boundingBox;
|
|
308
|
-
data.handles.textBox.worldBoundingBox = {
|
|
309
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
310
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
311
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
312
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
313
|
-
};
|
|
314
294
|
}
|
|
315
295
|
return renderStatus;
|
|
316
296
|
};
|
|
@@ -8,10 +8,9 @@ import { isAnnotationLocked } from '../../stateManagement/annotation/annotationL
|
|
|
8
8
|
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
9
9
|
import { triggerAnnotationCompleted, triggerAnnotationModified, } from '../../stateManagement/annotation/helpers/state';
|
|
10
10
|
import * as lineSegment from '../../utilities/math/line';
|
|
11
|
-
import { drawHandles as drawHandlesSvg, drawLine as drawLineSvg,
|
|
11
|
+
import { drawHandles as drawHandlesSvg, drawLine as drawLineSvg, } from '../../drawingSvg';
|
|
12
12
|
import { state } from '../../store/state';
|
|
13
13
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
14
|
-
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
15
14
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
16
15
|
import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
|
|
17
16
|
import { getStyleProperty } from '../../stateManagement/annotation/config/helpers';
|
|
@@ -293,36 +292,17 @@ class LengthTool extends AnnotationTool {
|
|
|
293
292
|
console.warn('Rendering Engine has been destroyed');
|
|
294
293
|
return renderStatus;
|
|
295
294
|
}
|
|
296
|
-
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
297
|
-
if (!options.visibility) {
|
|
298
|
-
data.handles.textBox = {
|
|
299
|
-
hasMoved: false,
|
|
300
|
-
worldPosition: [0, 0, 0],
|
|
301
|
-
worldBoundingBox: {
|
|
302
|
-
topLeft: [0, 0, 0],
|
|
303
|
-
topRight: [0, 0, 0],
|
|
304
|
-
bottomLeft: [0, 0, 0],
|
|
305
|
-
bottomRight: [0, 0, 0],
|
|
306
|
-
},
|
|
307
|
-
};
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
295
|
const textLines = this.configuration.getTextLines(data, targetId);
|
|
311
|
-
if (!
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
296
|
+
if (!this.renderLinkedTextBoxAnnotation({
|
|
297
|
+
enabledElement,
|
|
298
|
+
svgDrawingHelper,
|
|
299
|
+
annotation,
|
|
300
|
+
styleSpecifier,
|
|
301
|
+
textLines: textLines ?? [],
|
|
302
|
+
canvasCoordinates,
|
|
303
|
+
})) {
|
|
304
|
+
continue;
|
|
315
305
|
}
|
|
316
|
-
const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
|
|
317
|
-
const textBoxUID = '1';
|
|
318
|
-
const boundingBox = drawLinkedTextBoxSvg(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
|
|
319
|
-
const { x: left, y: top, width, height } = boundingBox;
|
|
320
|
-
data.handles.textBox.worldBoundingBox = {
|
|
321
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
322
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
323
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
324
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
325
|
-
};
|
|
326
306
|
}
|
|
327
307
|
return renderStatus;
|
|
328
308
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
2
|
import { getEnabledElement, utilities as csUtils, VolumeViewport, utilities, triggerEvent, eventTarget, } from '@cornerstonejs/core';
|
|
3
3
|
import { removeAnnotation } from '../../stateManagement/annotation/annotationState';
|
|
4
|
-
import { drawHandles as drawHandlesSvg
|
|
4
|
+
import { drawHandles as drawHandlesSvg } from '../../drawingSvg';
|
|
5
5
|
import { state } from '../../store/state';
|
|
6
6
|
import { Events, KeyboardBindings, ChangeTypes } from '../../enums';
|
|
7
7
|
import getMouseModifierKey from '../../eventDispatchers/shared/getMouseModifier';
|
|
@@ -14,7 +14,6 @@ import { LivewireScissors } from '../../utilities/livewire/LivewireScissors';
|
|
|
14
14
|
import { LivewirePath } from '../../utilities/livewire/LiveWirePath';
|
|
15
15
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
16
16
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
17
|
-
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
18
17
|
import { getCalibratedLengthUnitsAndScale, throttle } from '../../utilities';
|
|
19
18
|
const CLICK_CLOSE_CURVE_SQR_DIST = 10 ** 2;
|
|
20
19
|
class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
@@ -365,32 +364,33 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
365
364
|
}
|
|
366
365
|
return cachedStats;
|
|
367
366
|
};
|
|
368
|
-
this._renderStats = (annotation,
|
|
367
|
+
this._renderStats = (annotation, enabledElement, svgDrawingHelper) => {
|
|
369
368
|
const data = annotation.data;
|
|
369
|
+
const { viewport } = enabledElement;
|
|
370
370
|
const targetId = this.getTargetId(viewport);
|
|
371
|
-
if (!data.contour.closed
|
|
371
|
+
if (!data.contour.closed) {
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
|
+
const styleSpecifier = {
|
|
375
|
+
toolGroupId: this.toolGroupId,
|
|
376
|
+
toolName: this.getToolName(),
|
|
377
|
+
viewportId: enabledElement.viewport.id,
|
|
378
|
+
annotationUID: annotation.annotationUID,
|
|
379
|
+
};
|
|
374
380
|
const textLines = this.configuration.getTextLines(data, targetId);
|
|
375
381
|
if (!textLines || textLines.length === 0) {
|
|
376
382
|
return;
|
|
377
383
|
}
|
|
378
384
|
const canvasCoordinates = data.handles.points.map((p) => viewport.worldToCanvas(p));
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
data.handles.textBox.worldBoundingBox = {
|
|
389
|
-
topLeft: viewport.canvasToWorld([left, top]),
|
|
390
|
-
topRight: viewport.canvasToWorld([left + width, top]),
|
|
391
|
-
bottomLeft: viewport.canvasToWorld([left, top + height]),
|
|
392
|
-
bottomRight: viewport.canvasToWorld([left + width, top + height]),
|
|
393
|
-
};
|
|
385
|
+
this.renderLinkedTextBoxAnnotation({
|
|
386
|
+
enabledElement,
|
|
387
|
+
svgDrawingHelper,
|
|
388
|
+
annotation,
|
|
389
|
+
styleSpecifier,
|
|
390
|
+
textLines,
|
|
391
|
+
canvasCoordinates,
|
|
392
|
+
textBoxUID: 'textBox',
|
|
393
|
+
});
|
|
394
394
|
};
|
|
395
395
|
this.triggerAnnotationModified = (annotation, enabledElement, changeType = ChangeTypes.StatsUpdated) => {
|
|
396
396
|
const { viewportId, renderingEngineId } = enabledElement;
|
|
@@ -618,7 +618,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
618
618
|
else if (annotation.invalidated) {
|
|
619
619
|
this._throttledCalculateCachedStats(annotation, element);
|
|
620
620
|
}
|
|
621
|
-
this._renderStats(annotation,
|
|
621
|
+
this._renderStats(annotation, enabledElement, svgDrawingHelper);
|
|
622
622
|
return true;
|
|
623
623
|
}
|
|
624
624
|
updateAnnotation(livewirePath) {
|