@cornerstonejs/tools 1.43.6 → 1.44.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/index.d.ts +2 -2
- package/dist/cjs/index.js +5 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.d.ts +3 -1
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js +7 -2
- package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.d.ts +2 -1
- package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.js +23 -9
- package/dist/cjs/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
- package/dist/cjs/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +14 -1
- package/dist/cjs/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
- package/dist/cjs/tools/annotation/AngleTool.js +4 -3
- package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
- package/dist/cjs/tools/annotation/ArrowAnnotateTool.js +4 -3
- package/dist/cjs/tools/annotation/ArrowAnnotateTool.js.map +1 -1
- package/dist/cjs/tools/annotation/BidirectionalTool.js +4 -4
- package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/cjs/tools/annotation/CircleROITool.js +4 -3
- package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/CobbAngleTool.js +4 -3
- package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/cjs/tools/annotation/DragProbeTool.js +4 -1
- package/dist/cjs/tools/annotation/DragProbeTool.js.map +1 -1
- package/dist/cjs/tools/annotation/EllipticalROITool.js +4 -3
- package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/KeyImageTool.js +4 -1
- package/dist/cjs/tools/annotation/KeyImageTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LengthTool.js +4 -4
- package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.d.ts +6 -0
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.js +14 -0
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.js.map +1 -0
- package/dist/cjs/tools/annotation/LivewireContourTool.d.ts +14 -5
- package/dist/cjs/tools/annotation/LivewireContourTool.js +126 -159
- package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +8 -0
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js +24 -0
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -0
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +16 -6
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +104 -134
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/ProbeTool.js +1 -1
- package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
- package/dist/cjs/tools/annotation/RectangleROITool.js +4 -3
- package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/SplineContourSegmentationTool.d.ts +8 -0
- package/dist/cjs/tools/annotation/SplineContourSegmentationTool.js +23 -0
- package/dist/cjs/tools/annotation/SplineContourSegmentationTool.js.map +1 -0
- package/dist/cjs/tools/annotation/SplineROITool.d.ts +15 -8
- package/dist/cjs/tools/annotation/SplineROITool.js +168 -240
- package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +5 -5
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +4 -4
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +7 -7
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js +19 -15
- package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
- package/dist/cjs/tools/base/AnnotationTool.d.ts +15 -0
- package/dist/cjs/tools/base/AnnotationTool.js +24 -0
- package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
- package/dist/cjs/tools/base/ContourBaseTool.d.ts +19 -0
- package/dist/cjs/tools/base/ContourBaseTool.js +130 -0
- package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -0
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.d.ts +18 -0
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js +139 -0
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -0
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +1 -0
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/cjs/tools/index.d.ts +4 -1
- package/dist/cjs/tools/index.js +7 -1
- package/dist/cjs/tools/index.js.map +1 -1
- package/dist/cjs/types/ContourAnnotation.d.ts +11 -0
- package/dist/cjs/types/ContourAnnotation.js +3 -0
- package/dist/cjs/types/ContourAnnotation.js.map +1 -0
- package/dist/cjs/types/ContourSegmentationAnnotation.d.ts +11 -0
- package/dist/cjs/types/ContourSegmentationAnnotation.js +3 -0
- package/dist/cjs/types/ContourSegmentationAnnotation.js.map +1 -0
- package/dist/cjs/types/ContourTypes.d.ts +4 -1
- package/dist/cjs/types/SegmentationStateTypes.d.ts +1 -1
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +11 -52
- package/dist/cjs/types/index.d.ts +3 -1
- package/dist/cjs/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
- package/dist/cjs/utilities/pointInSurroundingSphereCallback.d.ts +4 -0
- package/dist/cjs/utilities/pointInSurroundingSphereCallback.js +70 -0
- package/dist/cjs/utilities/pointInSurroundingSphereCallback.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +7 -2
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +20 -7
- package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js.map +1 -1
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +13 -1
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js.map +1 -1
- package/dist/esm/tools/annotation/AngleTool.js +4 -3
- package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js +4 -3
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js.map +1 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +4 -4
- package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/esm/tools/annotation/CircleROITool.js +4 -3
- package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/CobbAngleTool.js +4 -3
- package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/esm/tools/annotation/DragProbeTool.js +4 -1
- package/dist/esm/tools/annotation/DragProbeTool.js.map +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +4 -3
- package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/esm/tools/annotation/KeyImageTool.js +4 -1
- package/dist/esm/tools/annotation/KeyImageTool.js.map +1 -1
- package/dist/esm/tools/annotation/LengthTool.js +4 -4
- package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
- package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +9 -0
- package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js.map +1 -0
- package/dist/esm/tools/annotation/LivewireContourTool.js +123 -160
- package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +19 -0
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -0
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +104 -134
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/annotation/ProbeTool.js +1 -1
- package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
- package/dist/esm/tools/annotation/RectangleROITool.js +4 -3
- package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +18 -0
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.js.map +1 -0
- package/dist/esm/tools/annotation/SplineROITool.js +153 -227
- package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +5 -5
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +4 -4
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +7 -7
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEndEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js +19 -15
- package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
- package/dist/esm/tools/base/AnnotationTool.js +24 -0
- package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
- package/dist/esm/tools/base/ContourBaseTool.js +122 -0
- package/dist/esm/tools/base/ContourBaseTool.js.map +1 -0
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +131 -0
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +1 -0
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/esm/tools/index.js +4 -1
- package/dist/esm/tools/index.js.map +1 -1
- package/dist/esm/types/ContourAnnotation.js +2 -0
- package/dist/esm/types/ContourAnnotation.js.map +1 -0
- package/dist/esm/types/ContourSegmentationAnnotation.js +2 -0
- package/dist/esm/types/ContourSegmentationAnnotation.js.map +1 -0
- package/dist/esm/utilities/pointInSurroundingSphereCallback.js +64 -0
- package/dist/esm/utilities/pointInSurroundingSphereCallback.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts +3 -1
- package/dist/types/stateManagement/segmentation/SegmentationStateManager.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/config/segmentationVisibility.d.ts +2 -1
- package/dist/types/stateManagement/segmentation/config/segmentationVisibility.d.ts.map +1 -1
- package/dist/types/stateManagement/segmentation/helpers/normalizeSegmentationInput.d.ts.map +1 -1
- package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/ArrowAnnotateTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/CobbAngleTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/DragProbeTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/EllipticalROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/KeyImageTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts +7 -0
- package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts.map +1 -0
- package/dist/types/tools/annotation/LivewireContourTool.d.ts +14 -5
- package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +9 -0
- package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts.map +1 -0
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts +16 -6
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/RectangleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/SplineContourSegmentationTool.d.ts +9 -0
- package/dist/types/tools/annotation/SplineContourSegmentationTool.d.ts.map +1 -0
- package/dist/types/tools/annotation/SplineROITool.d.ts +15 -8
- package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/openContourEndEditLoop.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/renderMethods.d.ts.map +1 -1
- package/dist/types/tools/base/AnnotationTool.d.ts +15 -0
- package/dist/types/tools/base/AnnotationTool.d.ts.map +1 -1
- package/dist/types/tools/base/ContourBaseTool.d.ts +20 -0
- package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -0
- package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts +19 -0
- package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -0
- package/dist/types/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
- package/dist/types/tools/index.d.ts +4 -1
- package/dist/types/tools/index.d.ts.map +1 -1
- package/dist/types/types/ContourAnnotation.d.ts +12 -0
- package/dist/types/types/ContourAnnotation.d.ts.map +1 -0
- package/dist/types/types/ContourSegmentationAnnotation.d.ts +12 -0
- package/dist/types/types/ContourSegmentationAnnotation.d.ts.map +1 -0
- package/dist/types/types/ContourTypes.d.ts +4 -1
- package/dist/types/types/ContourTypes.d.ts.map +1 -1
- package/dist/types/types/SegmentationStateTypes.d.ts +1 -1
- package/dist/types/types/SegmentationStateTypes.d.ts.map +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +11 -52
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +3 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
- package/dist/types/utilities/pointInSurroundingSphereCallback.d.ts +5 -0
- package/dist/types/utilities/pointInSurroundingSphereCallback.d.ts.map +1 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +6 -0
- package/src/stateManagement/segmentation/SegmentationStateManager.ts +11 -2
- package/src/stateManagement/segmentation/config/segmentationVisibility.ts +52 -6
- package/src/stateManagement/segmentation/helpers/normalizeSegmentationInput.ts +27 -1
- package/src/tools/annotation/AngleTool.ts +4 -3
- package/src/tools/annotation/ArrowAnnotateTool.ts +4 -3
- package/src/tools/annotation/BidirectionalTool.ts +4 -4
- package/src/tools/annotation/CircleROITool.ts +4 -3
- package/src/tools/annotation/CobbAngleTool.ts +4 -3
- package/src/tools/annotation/DragProbeTool.ts +4 -1
- package/src/tools/annotation/EllipticalROITool.ts +4 -3
- package/src/tools/annotation/KeyImageTool.ts +4 -1
- package/src/tools/annotation/LengthTool.ts +4 -5
- package/src/tools/annotation/LivewireContourSegmentationTool.ts +13 -0
- package/src/tools/annotation/LivewireContourTool.ts +75 -150
- package/src/tools/annotation/PlanarFreehandContourSegmentationTool.ts +30 -0
- package/src/tools/annotation/PlanarFreehandROITool.ts +153 -187
- package/src/tools/annotation/ProbeTool.ts +1 -1
- package/src/tools/annotation/RectangleROITool.ts +4 -3
- package/src/tools/annotation/SplineContourSegmentationTool.ts +28 -0
- package/src/tools/annotation/SplineROITool.ts +172 -282
- package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +7 -5
- package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +4 -4
- package/src/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.ts +3 -1
- package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +12 -9
- package/src/tools/annotation/planarFreehandROITool/openContourEndEditLoop.ts +5 -2
- package/src/tools/annotation/planarFreehandROITool/renderMethods.ts +19 -14
- package/src/tools/base/AnnotationTool.ts +35 -0
- package/src/tools/base/ContourBaseTool.ts +226 -0
- package/src/tools/base/ContourSegmentationBaseTool.ts +276 -0
- package/src/tools/displayTools/Contour/contourDisplay.ts +1 -0
- package/src/tools/index.ts +6 -0
- package/src/types/ContourAnnotation.ts +13 -0
- package/src/types/ContourSegmentationAnnotation.ts +14 -0
- package/src/types/ContourTypes.ts +8 -1
- package/src/types/SegmentationStateTypes.ts +1 -1
- package/src/types/ToolSpecificAnnotationTypes.ts +17 -53
- package/src/types/index.ts +12 -0
- package/src/utilities/pointInSurroundingSphereCallback.ts +188 -0
|
@@ -68,7 +68,9 @@ export function findOpenUShapedContourVectorToPeakOnRender(
|
|
|
68
68
|
annotation: PlanarFreehandROIAnnotation
|
|
69
69
|
): Types.Point3[] {
|
|
70
70
|
const { viewport } = enabledElement;
|
|
71
|
-
const canvasPoints = annotation.data.polyline.map(
|
|
71
|
+
const canvasPoints = annotation.data.contour.polyline.map(
|
|
72
|
+
viewport.worldToCanvas
|
|
73
|
+
);
|
|
72
74
|
|
|
73
75
|
return findOpenUShapedContourVectorToPeak(canvasPoints, viewport);
|
|
74
76
|
}
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
resetElementCursor,
|
|
7
7
|
hideElementCursor,
|
|
8
8
|
} from '../../../cursors/elementCursor';
|
|
9
|
-
import type { EventTypes
|
|
9
|
+
import type { EventTypes } from '../../../types';
|
|
10
|
+
import { PlanarFreehandROIAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
|
|
10
11
|
import { vec3, vec2 } from 'gl-matrix';
|
|
11
12
|
import { polyline } from '../../../utilities/math';
|
|
12
13
|
import {
|
|
@@ -23,7 +24,7 @@ const { addCanvasPointsToArray, getSubPixelSpacingAndXYDirections } = polyline;
|
|
|
23
24
|
*/
|
|
24
25
|
function activateOpenContourEdit(
|
|
25
26
|
evt: EventTypes.InteractionEventType,
|
|
26
|
-
annotation:
|
|
27
|
+
annotation: PlanarFreehandROIAnnotation,
|
|
27
28
|
viewportIdsToRender: string[]
|
|
28
29
|
): void {
|
|
29
30
|
this.isEditingOpen = true;
|
|
@@ -34,7 +35,9 @@ function activateOpenContourEdit(
|
|
|
34
35
|
const enabledElement = getEnabledElement(element);
|
|
35
36
|
const { viewport } = enabledElement;
|
|
36
37
|
|
|
37
|
-
const prevCanvasPoints = annotation.data.polyline.map(
|
|
38
|
+
const prevCanvasPoints = annotation.data.contour.polyline.map(
|
|
39
|
+
viewport.worldToCanvas
|
|
40
|
+
);
|
|
38
41
|
|
|
39
42
|
const { spacing, xDir, yDir } = getSubPixelSpacingAndXYDirections(
|
|
40
43
|
viewport,
|
|
@@ -213,8 +216,8 @@ function openContourEditOverwriteEnd(
|
|
|
213
216
|
viewport.canvasToWorld(canvasPoint)
|
|
214
217
|
);
|
|
215
218
|
|
|
216
|
-
annotation.data.polyline = worldPoints;
|
|
217
|
-
annotation.data.
|
|
219
|
+
annotation.data.contour.polyline = worldPoints;
|
|
220
|
+
annotation.data.contour.closed = false;
|
|
218
221
|
// Note: Contours generate from fusedCanvasPoints will be in the direction
|
|
219
222
|
// with the last point being the current mouse position
|
|
220
223
|
annotation.data.handles.points = [
|
|
@@ -495,8 +498,8 @@ function finishEditOpenOnSecondCrossing(
|
|
|
495
498
|
viewport.canvasToWorld(canvasPoint)
|
|
496
499
|
);
|
|
497
500
|
|
|
498
|
-
annotation.data.polyline = worldPoints;
|
|
499
|
-
annotation.data.
|
|
501
|
+
annotation.data.contour.polyline = worldPoints;
|
|
502
|
+
annotation.data.contour.closed = false;
|
|
500
503
|
annotation.data.handles.points = [
|
|
501
504
|
worldPoints[0],
|
|
502
505
|
worldPoints[worldPoints.length - 1],
|
|
@@ -550,8 +553,8 @@ function completeOpenContourEdit(element: HTMLDivElement) {
|
|
|
550
553
|
const worldPoints = updatedPoints.map((canvasPoint) =>
|
|
551
554
|
viewport.canvasToWorld(canvasPoint)
|
|
552
555
|
);
|
|
553
|
-
annotation.data.polyline = worldPoints;
|
|
554
|
-
annotation.data.
|
|
556
|
+
annotation.data.contour.polyline = worldPoints;
|
|
557
|
+
annotation.data.contour.closed = false;
|
|
555
558
|
annotation.data.handles.points = [
|
|
556
559
|
worldPoints[0],
|
|
557
560
|
worldPoints[worldPoints.length - 1],
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
ToolHandle,
|
|
9
9
|
TextBoxHandle,
|
|
10
10
|
} from '../../../types';
|
|
11
|
+
import { PlanarFreehandROIAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
|
|
11
12
|
import { polyline } from '../../../utilities/math';
|
|
12
13
|
|
|
13
14
|
const { getSubPixelSpacingAndXYDirections } = polyline;
|
|
@@ -18,7 +19,7 @@ const { getSubPixelSpacingAndXYDirections } = polyline;
|
|
|
18
19
|
*/
|
|
19
20
|
function activateOpenContourEndEdit(
|
|
20
21
|
evt: EventTypes.InteractionEventType,
|
|
21
|
-
annotation:
|
|
22
|
+
annotation: PlanarFreehandROIAnnotation,
|
|
22
23
|
viewportIdsToRender: string[],
|
|
23
24
|
handle: ToolHandle | null
|
|
24
25
|
): void {
|
|
@@ -34,7 +35,9 @@ function activateOpenContourEndEdit(
|
|
|
34
35
|
this.configuration.subPixelResolution
|
|
35
36
|
);
|
|
36
37
|
|
|
37
|
-
const canvasPoints = annotation.data.polyline.map(
|
|
38
|
+
const canvasPoints = annotation.data.contour.polyline.map(
|
|
39
|
+
viewport.worldToCanvas
|
|
40
|
+
);
|
|
38
41
|
const handleIndexGrabbed = annotation.data.handles.activeHandleIndex;
|
|
39
42
|
|
|
40
43
|
// If 0, invert point direction, if 1, keep point direction the same.
|
|
@@ -28,17 +28,21 @@ function _getRenderingOptions(
|
|
|
28
28
|
annotationUID: annotation.annotationUID,
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
const lineWidth
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const { lineWidth, lineDash, color, fillColor, fillOpacity } =
|
|
32
|
+
this.getAnnotationStyle({
|
|
33
|
+
annotation,
|
|
34
|
+
styleSpecifier,
|
|
35
|
+
});
|
|
34
36
|
|
|
35
|
-
const
|
|
37
|
+
const { closed: isClosedContour } = annotation.data.contour;
|
|
36
38
|
|
|
37
39
|
const options = {
|
|
38
|
-
color
|
|
39
|
-
width: lineWidth
|
|
40
|
-
lineDash
|
|
41
|
-
|
|
40
|
+
color,
|
|
41
|
+
width: lineWidth,
|
|
42
|
+
lineDash,
|
|
43
|
+
fillColor,
|
|
44
|
+
fillOpacity,
|
|
45
|
+
connectLastToFirst: isClosedContour,
|
|
42
46
|
};
|
|
43
47
|
|
|
44
48
|
return options;
|
|
@@ -57,7 +61,9 @@ function renderContour(
|
|
|
57
61
|
return;
|
|
58
62
|
}
|
|
59
63
|
// Check if the contour is an open contour
|
|
60
|
-
if (annotation.data.
|
|
64
|
+
if (annotation.data.contour.closed) {
|
|
65
|
+
this.renderClosedContour(enabledElement, svgDrawingHelper, annotation);
|
|
66
|
+
} else {
|
|
61
67
|
// If its an open contour, check i its a U-shaped contour
|
|
62
68
|
if (annotation.data.isOpenUShapeContour) {
|
|
63
69
|
calculateUShapeContourVectorToPeakIfNotPresent(
|
|
@@ -74,8 +80,6 @@ function renderContour(
|
|
|
74
80
|
// If not a U-shaped contour, render standard open contour.
|
|
75
81
|
this.renderOpenContour(enabledElement, svgDrawingHelper, annotation);
|
|
76
82
|
}
|
|
77
|
-
} else {
|
|
78
|
-
this.renderClosedContour(enabledElement, svgDrawingHelper, annotation);
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -110,7 +114,7 @@ function renderClosedContour(
|
|
|
110
114
|
// element on the tool? That feels very weird also as we'd need to manage
|
|
111
115
|
// it/clean them up. Its a pre-optimisation for now and we can tackle it if it
|
|
112
116
|
// becomes a problem.
|
|
113
|
-
const canvasPoints = annotation.data.polyline.map((worldPos) =>
|
|
117
|
+
const canvasPoints = annotation.data.contour.polyline.map((worldPos) =>
|
|
114
118
|
viewport.worldToCanvas(worldPos)
|
|
115
119
|
);
|
|
116
120
|
|
|
@@ -136,7 +140,7 @@ function renderOpenContour(
|
|
|
136
140
|
const { viewport } = enabledElement;
|
|
137
141
|
const options = this._getRenderingOptions(enabledElement, annotation);
|
|
138
142
|
|
|
139
|
-
const canvasPoints = annotation.data.polyline.map((worldPos) =>
|
|
143
|
+
const canvasPoints = annotation.data.contour.polyline.map((worldPos) =>
|
|
140
144
|
viewport.worldToCanvas(worldPos)
|
|
141
145
|
);
|
|
142
146
|
|
|
@@ -212,7 +216,8 @@ function renderOpenUShapedContour(
|
|
|
212
216
|
annotation: PlanarFreehandROIAnnotation
|
|
213
217
|
): void {
|
|
214
218
|
const { viewport } = enabledElement;
|
|
215
|
-
const {
|
|
219
|
+
const { openUShapeContourVectorToPeak } = annotation.data;
|
|
220
|
+
const { polyline } = annotation.data.contour;
|
|
216
221
|
|
|
217
222
|
this.renderOpenContour(enabledElement, svgDrawingHelper, annotation);
|
|
218
223
|
|
|
@@ -310,6 +310,41 @@ abstract class AnnotationTool extends AnnotationDisplayTool {
|
|
|
310
310
|
return typeof scalingModule?.suvbw === 'number';
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
+
/**
|
|
314
|
+
* Get the style that will be applied to all annotations such as length, cobb
|
|
315
|
+
* angle, arrow annotate, etc. when rendered on a canvas or svg layer
|
|
316
|
+
*/
|
|
317
|
+
protected getAnnotationStyle(context: {
|
|
318
|
+
annotation: Annotation;
|
|
319
|
+
styleSpecifier: StyleSpecifier;
|
|
320
|
+
}) {
|
|
321
|
+
const { annotation, styleSpecifier } = context;
|
|
322
|
+
const getStyle = (property) =>
|
|
323
|
+
this.getStyle(property, styleSpecifier, annotation);
|
|
324
|
+
const { annotationUID } = annotation;
|
|
325
|
+
const visibility = isAnnotationVisible(annotationUID);
|
|
326
|
+
const locked = isAnnotationLocked(annotation);
|
|
327
|
+
|
|
328
|
+
const lineWidth = getStyle('lineWidth') as number;
|
|
329
|
+
const lineDash = getStyle('lineDash') as string;
|
|
330
|
+
const color = getStyle('color') as string;
|
|
331
|
+
const shadow = getStyle('shadow') as boolean;
|
|
332
|
+
const textboxStyle = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
|
|
333
|
+
|
|
334
|
+
return {
|
|
335
|
+
visibility,
|
|
336
|
+
locked,
|
|
337
|
+
color,
|
|
338
|
+
lineWidth,
|
|
339
|
+
lineDash,
|
|
340
|
+
lineOpacity: 1,
|
|
341
|
+
fillColor: color,
|
|
342
|
+
fillOpacity: 0,
|
|
343
|
+
shadow,
|
|
344
|
+
textbox: textboxStyle,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
313
348
|
/**
|
|
314
349
|
* Returns true if the `canvasCoords` are near a handle or selectable part of the tool
|
|
315
350
|
*
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { getEnabledElement } from '@cornerstonejs/core';
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
3
|
+
import {
|
|
4
|
+
addAnnotation,
|
|
5
|
+
getAnnotations,
|
|
6
|
+
} from '../../stateManagement/annotation/annotationState';
|
|
7
|
+
import {
|
|
8
|
+
Annotation,
|
|
9
|
+
ContourAnnotation,
|
|
10
|
+
EventTypes,
|
|
11
|
+
PublicToolProps,
|
|
12
|
+
ToolProps,
|
|
13
|
+
SVGDrawingHelper,
|
|
14
|
+
} from '../../types';
|
|
15
|
+
import { drawPolyline as drawPolylineSvg } from '../../drawingSvg';
|
|
16
|
+
import { StyleSpecifier } from '../../types/AnnotationStyle';
|
|
17
|
+
import AnnotationTool from './AnnotationTool';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A contour base class responsible for rendering contour instances such as
|
|
21
|
+
* spline, freehand and livewire.
|
|
22
|
+
*/
|
|
23
|
+
abstract class ContourBaseTool extends AnnotationTool {
|
|
24
|
+
constructor(toolProps: PublicToolProps, defaultToolProps: ToolProps) {
|
|
25
|
+
super(toolProps, defaultToolProps);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* it is used to draw the annotation in each request animation frame. It
|
|
30
|
+
* calculates the updated cached statistics if data is invalidated and cache it.
|
|
31
|
+
* @param enabledElement - The Cornerstone's enabledElement.
|
|
32
|
+
* @param svgDrawingHelper - The svgDrawingHelper providing the context for drawing.
|
|
33
|
+
*/
|
|
34
|
+
public renderAnnotation(
|
|
35
|
+
enabledElement: Types.IEnabledElement,
|
|
36
|
+
svgDrawingHelper: SVGDrawingHelper
|
|
37
|
+
): boolean {
|
|
38
|
+
let renderStatus = false;
|
|
39
|
+
const { viewport } = enabledElement;
|
|
40
|
+
const { element } = viewport;
|
|
41
|
+
|
|
42
|
+
// If rendering engine has been destroyed while rendering
|
|
43
|
+
if (!viewport.getRenderingEngine()) {
|
|
44
|
+
console.warn('Rendering Engine has been destroyed');
|
|
45
|
+
return renderStatus;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let annotations = getAnnotations(this.getToolName(), element);
|
|
49
|
+
|
|
50
|
+
if (!annotations?.length) {
|
|
51
|
+
return renderStatus;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
annotations = this.filterInteractableAnnotationsForElement(
|
|
55
|
+
element,
|
|
56
|
+
annotations
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
if (!annotations?.length) {
|
|
60
|
+
return renderStatus;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const targetId = this.getTargetId(viewport);
|
|
64
|
+
const styleSpecifier: StyleSpecifier = {
|
|
65
|
+
toolGroupId: this.toolGroupId,
|
|
66
|
+
toolName: this.getToolName(),
|
|
67
|
+
viewportId: enabledElement.viewport.id,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
for (let i = 0; i < annotations.length; i++) {
|
|
71
|
+
const annotation = annotations[i] as Annotation;
|
|
72
|
+
|
|
73
|
+
styleSpecifier.annotationUID = annotation.annotationUID;
|
|
74
|
+
|
|
75
|
+
const annotationStyle = this.getAnnotationStyle({
|
|
76
|
+
annotation,
|
|
77
|
+
styleSpecifier,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (!annotationStyle.visibility) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const annotationRendered = this.renderAnnotationInstance({
|
|
85
|
+
enabledElement,
|
|
86
|
+
targetId,
|
|
87
|
+
annotation,
|
|
88
|
+
annotationStyle,
|
|
89
|
+
svgDrawingHelper,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
renderStatus ||= annotationRendered;
|
|
93
|
+
annotation.invalidated = false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return renderStatus;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
protected createAnnotation(evt: EventTypes.InteractionEventType): Annotation {
|
|
100
|
+
const eventDetail = evt.detail;
|
|
101
|
+
const { currentPoints, element } = eventDetail;
|
|
102
|
+
const { world: worldPos } = currentPoints;
|
|
103
|
+
|
|
104
|
+
const enabledElement = getEnabledElement(element);
|
|
105
|
+
const { viewport } = enabledElement;
|
|
106
|
+
|
|
107
|
+
const camera = viewport.getCamera();
|
|
108
|
+
const { viewPlaneNormal, viewUp } = camera;
|
|
109
|
+
|
|
110
|
+
const referencedImageId = this.getReferencedImageId(
|
|
111
|
+
viewport,
|
|
112
|
+
worldPos,
|
|
113
|
+
viewPlaneNormal,
|
|
114
|
+
viewUp
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
|
|
118
|
+
|
|
119
|
+
return <ContourAnnotation>{
|
|
120
|
+
highlighted: true,
|
|
121
|
+
invalidated: true,
|
|
122
|
+
metadata: {
|
|
123
|
+
toolName: this.getToolName(),
|
|
124
|
+
viewPlaneNormal: <Types.Point3>[...viewPlaneNormal],
|
|
125
|
+
viewUp: <Types.Point3>[...viewUp],
|
|
126
|
+
FrameOfReferenceUID,
|
|
127
|
+
referencedImageId,
|
|
128
|
+
},
|
|
129
|
+
data: {
|
|
130
|
+
handles: {
|
|
131
|
+
points: [],
|
|
132
|
+
activeHandleIndex: null,
|
|
133
|
+
textBox: {
|
|
134
|
+
hasMoved: false,
|
|
135
|
+
worldPosition: <Types.Point3>[0, 0, 0],
|
|
136
|
+
worldBoundingBox: {
|
|
137
|
+
topLeft: <Types.Point3>[0, 0, 0],
|
|
138
|
+
topRight: <Types.Point3>[0, 0, 0],
|
|
139
|
+
bottomLeft: <Types.Point3>[0, 0, 0],
|
|
140
|
+
bottomRight: <Types.Point3>[0, 0, 0],
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
contour: {
|
|
145
|
+
polyline: [],
|
|
146
|
+
closed: false,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Add the annotation to the annotation manager.
|
|
154
|
+
* @param annotation - Contour annotation that is being added
|
|
155
|
+
* @param element - HTMLDivElement
|
|
156
|
+
*/
|
|
157
|
+
protected addAnnotation(
|
|
158
|
+
annotation: Annotation,
|
|
159
|
+
element: HTMLDivElement
|
|
160
|
+
): string {
|
|
161
|
+
// Just to give a chance for child classes to override it
|
|
162
|
+
return addAnnotation(annotation, element);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Cancel an annotation when drawing.
|
|
167
|
+
* @param annotation - Contour annotation that is being added
|
|
168
|
+
* @param element - HTMLDivElement
|
|
169
|
+
*/
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
171
|
+
protected cancelAnnotation(annotation: Annotation): void {
|
|
172
|
+
// noop method just to give a chance for child classes to override it
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Get polyline points in world space.
|
|
177
|
+
* Just to give a chance for child classes to override it.
|
|
178
|
+
* @param annotation - Contour annotation
|
|
179
|
+
* @returns Polyline points in world space
|
|
180
|
+
*/
|
|
181
|
+
protected getPolylinePoints(annotation: ContourAnnotation): Types.Point3[] {
|
|
182
|
+
// Attenttion: `contour.polyline` is the new way to store a polyline but it
|
|
183
|
+
// may be undefined because it was `data.polyline` before (fallback)
|
|
184
|
+
return annotation.data.contour?.polyline ?? annotation.data.polyline;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Render a contour segmentation instance
|
|
189
|
+
*/
|
|
190
|
+
protected renderAnnotationInstance(renderContext: {
|
|
191
|
+
enabledElement: Types.IEnabledElement;
|
|
192
|
+
targetId: string;
|
|
193
|
+
annotation: Annotation;
|
|
194
|
+
annotationStyle: Record<string, any>;
|
|
195
|
+
svgDrawingHelper: SVGDrawingHelper;
|
|
196
|
+
}): boolean {
|
|
197
|
+
const { enabledElement, annotationStyle, svgDrawingHelper } = renderContext;
|
|
198
|
+
const annotation = renderContext.annotation as ContourAnnotation;
|
|
199
|
+
const { annotationUID } = annotation;
|
|
200
|
+
const { viewport } = enabledElement;
|
|
201
|
+
const { worldToCanvas } = viewport;
|
|
202
|
+
const polylineCanvasPoints = this.getPolylinePoints(annotation).map(
|
|
203
|
+
(point) => worldToCanvas(point)
|
|
204
|
+
);
|
|
205
|
+
const { lineWidth, lineDash, color, fillColor, fillOpacity } =
|
|
206
|
+
annotationStyle;
|
|
207
|
+
|
|
208
|
+
drawPolylineSvg(
|
|
209
|
+
svgDrawingHelper,
|
|
210
|
+
annotationUID,
|
|
211
|
+
'contourPolyline',
|
|
212
|
+
polylineCanvasPoints,
|
|
213
|
+
{
|
|
214
|
+
color,
|
|
215
|
+
lineDash,
|
|
216
|
+
lineWidth: Math.max(0.1, lineWidth),
|
|
217
|
+
fillColor: fillColor,
|
|
218
|
+
fillOpacity,
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export { ContourBaseTool as default, ContourBaseTool };
|