@cornerstonejs/tools 3.15.5 → 3.16.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.
Files changed (38) hide show
  1. package/dist/esm/drawingSvg/drawFan.d.ts +4 -0
  2. package/dist/esm/drawingSvg/drawFan.js +62 -0
  3. package/dist/esm/drawingSvg/drawLine.js +2 -1
  4. package/dist/esm/drawingSvg/index.d.ts +2 -1
  5. package/dist/esm/drawingSvg/index.js +2 -1
  6. package/dist/esm/index.d.ts +2 -2
  7. package/dist/esm/index.js +2 -2
  8. package/dist/esm/tools/annotation/EllipticalROITool.js +17 -14
  9. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.d.ts +64 -0
  10. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +752 -0
  11. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/calculateFanShapeCorners.d.ts +8 -0
  12. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/calculateFanShapeCorners.js +143 -0
  13. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/deriveFanGeometry.d.ts +2 -0
  14. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/deriveFanGeometry.js +32 -0
  15. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction.d.ts +7 -0
  16. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/fanExtraction.js +171 -0
  17. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/generateConvexHullFromContour.d.ts +5 -0
  18. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/generateConvexHullFromContour.js +6 -0
  19. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/segmentLargestUSOutlineFromBuffer.d.ts +2 -0
  20. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/segmentLargestUSOutlineFromBuffer.js +123 -0
  21. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/types.d.ts +41 -0
  22. package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/utils/types.js +0 -0
  23. package/dist/esm/tools/index.d.ts +2 -1
  24. package/dist/esm/tools/index.js +2 -1
  25. package/dist/esm/types/ToolSpecificAnnotationTypes.d.ts +10 -0
  26. package/dist/esm/utilities/index.d.ts +2 -1
  27. package/dist/esm/utilities/index.js +2 -1
  28. package/dist/esm/utilities/math/fan/fanUtils.d.ts +10 -0
  29. package/dist/esm/utilities/math/fan/fanUtils.js +99 -0
  30. package/dist/esm/utilities/math/line/intersectLine.d.ts +1 -1
  31. package/dist/esm/utilities/math/line/intersectLine.js +16 -6
  32. package/dist/esm/utilities/math/polyline/convexHull.d.ts +2 -0
  33. package/dist/esm/utilities/math/polyline/convexHull.js +31 -0
  34. package/dist/esm/utilities/math/polyline/index.d.ts +2 -1
  35. package/dist/esm/utilities/math/polyline/index.js +2 -1
  36. package/dist/esm/version.d.ts +1 -1
  37. package/dist/esm/version.js +1 -1
  38. package/package.json +3 -3
@@ -0,0 +1,4 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import type { SVGDrawingHelper } from '../types';
3
+ declare function drawFan(svgDrawingHelper: SVGDrawingHelper, annotationUID: string, fanUID: string, center: Types.Point2, innerRadius: number, outerRadius: number, startAngle: number, endAngle: number, options?: {}, dataId?: string, zIndex?: number): void;
4
+ export default drawFan;
@@ -0,0 +1,62 @@
1
+ import _getHash from './_getHash';
2
+ import setAttributesIfNecessary from './setAttributesIfNecessary';
3
+ import setNewAttributesIfValid from './setNewAttributesIfValid';
4
+ function drawFan(svgDrawingHelper, annotationUID, fanUID, center, innerRadius, outerRadius, startAngle, endAngle, options = {}, dataId = '', zIndex) {
5
+ const { color, fill, width, lineWidth, lineDash, fillOpacity, strokeOpacity, } = Object.assign({
6
+ color: 'rgb(0, 255, 0)',
7
+ fill: 'transparent',
8
+ width: '2',
9
+ lineDash: undefined,
10
+ lineWidth: undefined,
11
+ strokeOpacity: 1,
12
+ fillOpacity: 1,
13
+ }, options);
14
+ const strokeWidth = lineWidth || width;
15
+ const svgns = 'http://www.w3.org/2000/svg';
16
+ const svgNodeHash = _getHash(annotationUID, 'fan', fanUID);
17
+ const existingFanElement = svgDrawingHelper.getSvgNode(svgNodeHash);
18
+ const startRad = (startAngle * Math.PI) / 180;
19
+ const endRad = (endAngle * Math.PI) / 180;
20
+ const centerX = center[0];
21
+ const centerY = center[1];
22
+ const outerStartX = centerX + outerRadius * Math.cos(startRad);
23
+ const outerStartY = centerY + outerRadius * Math.sin(startRad);
24
+ const outerEndX = centerX + outerRadius * Math.cos(endRad);
25
+ const outerEndY = centerY + outerRadius * Math.sin(endRad);
26
+ const innerStartX = centerX + innerRadius * Math.cos(startRad);
27
+ const innerStartY = centerY + innerRadius * Math.sin(startRad);
28
+ const innerEndX = centerX + innerRadius * Math.cos(endRad);
29
+ const innerEndY = centerY + innerRadius * Math.sin(endRad);
30
+ const largeArcFlag = endAngle - startAngle <= 180 ? 0 : 1;
31
+ let pathData = `M ${outerStartX} ${outerStartY}`;
32
+ pathData += ` A ${outerRadius} ${outerRadius} 0 ${largeArcFlag} 1 ${outerEndX} ${outerEndY}`;
33
+ pathData += ` L ${innerEndX} ${innerEndY}`;
34
+ pathData += ` A ${innerRadius} ${innerRadius} 0 ${largeArcFlag} 0 ${innerStartX} ${innerStartY}`;
35
+ pathData += ` Z`;
36
+ const attributes = {
37
+ d: pathData,
38
+ stroke: color,
39
+ fill,
40
+ 'stroke-width': strokeWidth,
41
+ 'stroke-dasharray': lineDash,
42
+ 'fill-opacity': fillOpacity,
43
+ 'stroke-opacity': strokeOpacity,
44
+ 'mix-blend-mode': 'normal',
45
+ };
46
+ if (existingFanElement) {
47
+ setAttributesIfNecessary(attributes, existingFanElement);
48
+ svgDrawingHelper.setNodeTouched(svgNodeHash);
49
+ }
50
+ else {
51
+ const newFanElement = document.createElementNS(svgns, 'path');
52
+ if (dataId !== '') {
53
+ newFanElement.setAttribute('data-id', dataId);
54
+ }
55
+ if (zIndex !== undefined) {
56
+ newFanElement.style.zIndex = zIndex.toString();
57
+ }
58
+ setNewAttributesIfValid(attributes, newFanElement);
59
+ svgDrawingHelper.appendNode(newFanElement, svgNodeHash);
60
+ }
61
+ }
62
+ export default drawFan;
@@ -5,7 +5,7 @@ export default function drawLine(svgDrawingHelper, annotationUID, lineUID, start
5
5
  if (isNaN(start[0]) || isNaN(start[1]) || isNaN(end[0]) || isNaN(end[1])) {
6
6
  return;
7
7
  }
8
- const { color = 'rgb(0, 255, 0)', width = 10, lineWidth, lineDash, markerStartId = null, markerEndId = null, shadow = false, } = options;
8
+ const { color = 'rgb(0, 255, 0)', width = 10, lineWidth, lineDash, markerStartId = null, markerEndId = null, shadow = false, strokeOpacity = 1, } = options;
9
9
  const strokeWidth = lineWidth || width;
10
10
  const svgns = 'http://www.w3.org/2000/svg';
11
11
  const svgNodeHash = _getHash(annotationUID, 'line', lineUID);
@@ -23,6 +23,7 @@ export default function drawLine(svgDrawingHelper, annotationUID, lineUID, start
23
23
  'stroke-dasharray': lineDash,
24
24
  'marker-start': markerStartId ? `url(#${markerStartId})` : '',
25
25
  'marker-end': markerEndId ? `url(#${markerEndId})` : '',
26
+ 'stroke-opacity': strokeOpacity,
26
27
  };
27
28
  if (existingLine) {
28
29
  setAttributesIfNecessary(attributes, existingLine);
@@ -8,6 +8,7 @@ import drawLine from './drawLine';
8
8
  import drawHeight from './drawHeight';
9
9
  import drawPolyline from './drawPolyline';
10
10
  import drawPath from './drawPath';
11
+ import drawFan from './drawFan';
11
12
  import drawLinkedTextBox from './drawLinkedTextBox';
12
13
  import drawRect from './drawRect';
13
14
  import drawRectByCoordinates from './drawRectByCoordinates';
@@ -16,4 +17,4 @@ import drawArrow from './drawArrow';
16
17
  import drawRedactionRect from './drawRedactionRect';
17
18
  import setAttributesIfNecessary from './setAttributesIfNecessary';
18
19
  import setNewAttributesIfValid from './setNewAttributesIfValid';
19
- export { draw, drawCircle, drawEllipse, drawEllipseByCoordinates, drawHandles, drawHandle, drawLine, drawHeight, drawPolyline, drawPath, drawLinkedTextBox, drawRect, drawRectByCoordinates, drawTextBox, drawArrow, drawRedactionRect, setAttributesIfNecessary, setNewAttributesIfValid, };
20
+ export { draw, drawCircle, drawEllipse, drawEllipseByCoordinates, drawFan, drawHandles, drawHandle, drawLine, drawHeight, drawPolyline, drawPath, drawLinkedTextBox, drawRect, drawRectByCoordinates, drawTextBox, drawArrow, drawRedactionRect, setAttributesIfNecessary, setNewAttributesIfValid, };
@@ -8,6 +8,7 @@ import drawLine from './drawLine';
8
8
  import drawHeight from './drawHeight';
9
9
  import drawPolyline from './drawPolyline';
10
10
  import drawPath from './drawPath';
11
+ import drawFan from './drawFan';
11
12
  import drawLinkedTextBox from './drawLinkedTextBox';
12
13
  import drawRect from './drawRect';
13
14
  import drawRectByCoordinates from './drawRectByCoordinates';
@@ -16,4 +17,4 @@ import drawArrow from './drawArrow';
16
17
  import drawRedactionRect from './drawRedactionRect';
17
18
  import setAttributesIfNecessary from './setAttributesIfNecessary';
18
19
  import setNewAttributesIfValid from './setNewAttributesIfValid';
19
- export { draw, drawCircle, drawEllipse, drawEllipseByCoordinates, drawHandles, drawHandle, drawLine, drawHeight, drawPolyline, drawPath, drawLinkedTextBox, drawRect, drawRectByCoordinates, drawTextBox, drawArrow, drawRedactionRect, setAttributesIfNecessary, setNewAttributesIfValid, };
20
+ export { draw, drawCircle, drawEllipse, drawEllipseByCoordinates, drawFan, drawHandles, drawHandle, drawLine, drawHeight, drawPolyline, drawPath, drawLinkedTextBox, drawRect, drawRectByCoordinates, drawTextBox, drawArrow, drawRedactionRect, setAttributesIfNecessary, setNewAttributesIfValid, };
@@ -12,7 +12,7 @@ import * as Types from './types';
12
12
  import * as annotation from './stateManagement/annotation';
13
13
  import * as segmentation from './stateManagement/segmentation';
14
14
  import * as splines from './tools/annotation/splines';
15
- import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool } from './tools';
15
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool } from './tools';
16
16
  import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
17
17
  import * as Enums from './enums';
18
- export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, splines, version, };
18
+ export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, splines, version, };
package/dist/esm/index.js CHANGED
@@ -12,7 +12,7 @@ import * as Types from './types';
12
12
  import * as annotation from './stateManagement/annotation';
13
13
  import * as segmentation from './stateManagement/segmentation';
14
14
  import * as splines from './tools/annotation/splines';
15
- import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, } from './tools';
15
+ import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, SegmentBidirectionalTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentLabelTool, } from './tools';
16
16
  import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
17
17
  import * as Enums from './enums';
18
- export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, splines, version, };
18
+ export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, SegmentBidirectionalTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LabelTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, SegmentLabelTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, store, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateTool, RegionSegmentPlusTool, RegionSegmentTool, WholeBodySegmentTool, LabelmapBaseTool, splines, version, };
@@ -18,6 +18,7 @@ import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnota
18
18
  import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
19
19
  import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
20
20
  import { BasicStatsCalculator } from '../../utilities/math/basic';
21
+ import { vec2 } from 'gl-matrix';
21
22
  const { transformWorldToIndex } = csUtils;
22
23
  class EllipticalROITool extends AnnotationTool {
23
24
  static { this.toolName = 'EllipticalROI'; }
@@ -104,19 +105,22 @@ class EllipticalROITool extends AnnotationTool {
104
105
  const { data } = annotation;
105
106
  const { points } = data.handles;
106
107
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
107
- const canvasCorners = getCanvasEllipseCorners(canvasCoordinates);
108
- const [canvasPoint1, canvasPoint2] = canvasCorners;
108
+ const [bottom, top, left, right] = canvasCoordinates;
109
+ const w = Math.hypot(left[0] - right[0], left[1] - right[1]);
110
+ const h = Math.hypot(top[0] - bottom[0], top[1] - bottom[1]);
111
+ const angle = Math.atan2(left[1] - right[1], left[0] - right[0]);
112
+ const center = [(left[0] + right[0]) / 2, (top[1] + bottom[1]) / 2];
109
113
  const minorEllipse = {
110
- left: Math.min(canvasPoint1[0], canvasPoint2[0]) + proximity / 2,
111
- top: Math.min(canvasPoint1[1], canvasPoint2[1]) + proximity / 2,
112
- width: Math.abs(canvasPoint1[0] - canvasPoint2[0]) - proximity,
113
- height: Math.abs(canvasPoint1[1] - canvasPoint2[1]) - proximity,
114
+ center,
115
+ xRadius: (w - proximity) / 2,
116
+ yRadius: (h - proximity) / 2,
117
+ angle,
114
118
  };
115
119
  const majorEllipse = {
116
- left: Math.min(canvasPoint1[0], canvasPoint2[0]) - proximity / 2,
117
- top: Math.min(canvasPoint1[1], canvasPoint2[1]) - proximity / 2,
118
- width: Math.abs(canvasPoint1[0] - canvasPoint2[0]) + proximity,
119
- height: Math.abs(canvasPoint1[1] - canvasPoint2[1]) + proximity,
120
+ center,
121
+ xRadius: (w + proximity) / 2,
122
+ yRadius: (h + proximity) / 2,
123
+ angle,
120
124
  };
121
125
  const pointInMinorEllipse = this._pointInEllipseCanvas(minorEllipse, canvasCoords);
122
126
  const pointInMajorEllipse = this._pointInEllipseCanvas(majorEllipse, canvasCoords);
@@ -672,13 +676,12 @@ class EllipticalROITool extends AnnotationTool {
672
676
  triggerAnnotationRenderForViewportIds([viewport.id]);
673
677
  }; }
674
678
  _pointInEllipseCanvas(ellipse, location) {
675
- const xRadius = ellipse.width / 2;
676
- const yRadius = ellipse.height / 2;
679
+ const { xRadius, yRadius, center, angle } = ellipse;
680
+ const rotLocation = vec2.rotate(vec2.create(), location, center, -angle);
677
681
  if (xRadius <= 0.0 || yRadius <= 0.0) {
678
682
  return false;
679
683
  }
680
- const center = [ellipse.left + xRadius, ellipse.top + yRadius];
681
- const normalized = [location[0] - center[0], location[1] - center[1]];
684
+ const normalized = [rotLocation[0] - center[0], rotLocation[1] - center[1]];
682
685
  const inEllipse = (normalized[0] * normalized[0]) / (xRadius * xRadius) +
683
686
  (normalized[1] * normalized[1]) / (yRadius * yRadius) <=
684
687
  1.0;
@@ -0,0 +1,64 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ import { AnnotationTool } from '../../base';
3
+ import type { EventTypes, ToolHandle, PublicToolProps, ToolProps, SVGDrawingHelper, Annotation } from '../../../types';
4
+ import type { UltrasoundPleuraBLineAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
5
+ import type { FanGeometry } from './utils/types';
6
+ type FilterFunction = (imageId: string) => boolean;
7
+ declare class UltrasoundPleuraBLineTool extends AnnotationTool {
8
+ static toolName: string;
9
+ static USPleuraBLineAnnotationType: {
10
+ readonly BLINE: "bLine";
11
+ readonly PLEURA: "pleura";
12
+ };
13
+ _throttledCalculateCachedStats: Function;
14
+ editData: {
15
+ annotation: Annotation;
16
+ viewportIdsToRender: string[];
17
+ handleIndex?: number;
18
+ movingTextBox?: boolean;
19
+ newAnnotation?: boolean;
20
+ hasMoved?: boolean;
21
+ } | null;
22
+ isDrawing: boolean;
23
+ isHandleOutsideImage: boolean;
24
+ activeAnnotationType: string;
25
+ pleuraAnnotations: UltrasoundPleuraBLineAnnotation[];
26
+ bLineAnnotations: UltrasoundPleuraBLineAnnotation[];
27
+ constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
28
+ static filterAnnotations(element: HTMLDivElement, filterFunction?: FilterFunction): UltrasoundPleuraBLineAnnotation[];
29
+ static countAnnotations(element: HTMLDivElement, filterFunction?: FilterFunction): Map<any, any>;
30
+ static deleteAnnotations(element: HTMLDivElement, filterFunction?: FilterFunction): void;
31
+ setActiveAnnotationType(type: string): void;
32
+ getActiveAnnotationType(): string;
33
+ deleteLastAnnotationType(element: HTMLDivElement, type: string): void;
34
+ static hydrate: (viewportId: string, points: Types.Point3[], options?: {
35
+ annotationUID?: string;
36
+ toolInstance?: UltrasoundPleuraBLineTool;
37
+ referencedImageId?: string;
38
+ viewplaneNormal?: Types.Point3;
39
+ viewUp?: Types.Point3;
40
+ }) => UltrasoundPleuraBLineAnnotation;
41
+ addNewAnnotation: (evt: EventTypes.InteractionEventType) => UltrasoundPleuraBLineAnnotation;
42
+ isPointNearTool: (element: HTMLDivElement, annotation: UltrasoundPleuraBLineAnnotation, canvasCoords: Types.Point2, proximity: number) => boolean;
43
+ toolSelectedCallback: (evt: EventTypes.InteractionEventType, annotation: UltrasoundPleuraBLineAnnotation) => void;
44
+ handleSelectedCallback(evt: EventTypes.InteractionEventType, annotation: UltrasoundPleuraBLineAnnotation, handle: ToolHandle): void;
45
+ _endCallback: (evt: EventTypes.InteractionEventType) => void;
46
+ isInsideFanShape(viewport: any, point: Types.Point3): boolean;
47
+ _dragCallback: (evt: EventTypes.InteractionEventType) => void;
48
+ cancel: (element: HTMLDivElement) => string;
49
+ _activateModify: (element: HTMLDivElement) => void;
50
+ _deactivateModify: (element: HTMLDivElement) => void;
51
+ _activateDraw: (element: HTMLDivElement) => void;
52
+ _deactivateDraw: (element: HTMLDivElement) => void;
53
+ updateFanGeometryConfiguration(fanGeometry: FanGeometry): void;
54
+ deriveFanGeometryFromViewport(viewport: any): void;
55
+ isFanShapeGeometryParametersValid(fanGeometry?: FanGeometry): boolean;
56
+ getFanShapeGeometryParameters(viewport: any): boolean;
57
+ calculateBLinePleuraPercentage(viewport: any): number;
58
+ getColorForLineType(annotation: UltrasoundPleuraBLineAnnotation): any;
59
+ getIndexToCanvasRatio(viewport: any): number;
60
+ drawDepthGuide(svgDrawingHelper: SVGDrawingHelper, viewport: any): void;
61
+ renderAnnotation: (enabledElement: Types.IEnabledElement, svgDrawingHelper: SVGDrawingHelper) => boolean;
62
+ _isInsideVolume(index1: any, index2: any, dimensions: any): boolean;
63
+ }
64
+ export default UltrasoundPleuraBLineTool;