@cornerstonejs/tools 1.51.5 → 1.53.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/drawingSvg/drawPath.d.ts +11 -0
- package/dist/cjs/drawingSvg/drawPath.js +55 -0
- package/dist/cjs/drawingSvg/drawPath.js.map +1 -0
- package/dist/cjs/drawingSvg/drawPolyline.d.ts +1 -1
- package/dist/cjs/drawingSvg/drawPolyline.js +3 -11
- package/dist/cjs/drawingSvg/drawPolyline.js.map +1 -1
- package/dist/cjs/drawingSvg/index.d.ts +2 -1
- package/dist/cjs/drawingSvg/index.js +3 -1
- package/dist/cjs/drawingSvg/index.js.map +1 -1
- package/dist/cjs/enums/ChangeTypes.d.ts +2 -1
- package/dist/cjs/enums/ChangeTypes.js +1 -0
- package/dist/cjs/enums/ChangeTypes.js.map +1 -1
- package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js +1 -1
- package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
- package/dist/cjs/eventDispatchers/shared/getActiveToolForMouseEvent.js.map +1 -1
- package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts +1 -1
- package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +165 -78
- package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -1
- package/dist/cjs/stateManagement/annotation/annotationState.d.ts +6 -1
- package/dist/cjs/stateManagement/annotation/annotationState.js +49 -1
- package/dist/cjs/stateManagement/annotation/annotationState.js.map +1 -1
- package/dist/cjs/stateManagement/annotation/helpers/state.d.ts +4 -2
- package/dist/cjs/stateManagement/annotation/helpers/state.js +16 -4
- package/dist/cjs/stateManagement/annotation/helpers/state.js.map +1 -1
- package/dist/cjs/stateManagement/index.d.ts +6 -1
- package/dist/cjs/stateManagement/index.js +6 -1
- package/dist/cjs/stateManagement/index.js.map +1 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.d.ts +3 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js +3 -2
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/cjs/tools/SegmentationIntersectionTool.js +1 -1
- package/dist/cjs/tools/SegmentationIntersectionTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.d.ts +4 -0
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.js +82 -0
- package/dist/cjs/tools/annotation/LivewireContourSegmentationTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LivewireContourTool.d.ts +13 -11
- package/dist/cjs/tools/annotation/LivewireContourTool.js +78 -65
- package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +3 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/SplineROITool.d.ts +6 -3
- package/dist/cjs/tools/annotation/SplineROITool.js +40 -21
- package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +12 -7
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +24 -18
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +16 -10
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js +19 -7
- package/dist/cjs/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
- package/dist/cjs/tools/annotation/splines/LinearSpline.js +1 -1
- package/dist/cjs/tools/annotation/splines/LinearSpline.js.map +1 -1
- package/dist/cjs/tools/annotation/splines/Spline.d.ts +2 -0
- package/dist/cjs/tools/annotation/splines/Spline.js +7 -3
- package/dist/cjs/tools/annotation/splines/Spline.js.map +1 -1
- package/dist/cjs/tools/base/AnnotationTool.js.map +1 -1
- package/dist/cjs/tools/base/ContourBaseTool.d.ts +1 -0
- package/dist/cjs/tools/base/ContourBaseTool.js +18 -1
- package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -1
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js +4 -0
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourConfig.js +1 -0
- package/dist/cjs/tools/displayTools/Contour/contourConfig.js.map +1 -1
- package/dist/cjs/types/AnnotationTypes.d.ts +2 -0
- package/dist/cjs/types/ContourAnnotation.d.ts +6 -0
- package/dist/cjs/types/ContourAnnotation.js +7 -0
- package/dist/cjs/types/ContourAnnotation.js.map +1 -1
- package/dist/cjs/types/ContourSegmentationAnnotation.d.ts +8 -0
- package/dist/cjs/types/ContourTypes.d.ts +1 -0
- package/dist/cjs/types/EventTypes.d.ts +4 -1
- package/dist/cjs/types/ISpline.d.ts +1 -0
- package/dist/cjs/types/InterpolationTypes.d.ts +2 -0
- package/dist/cjs/types/SplineProps.d.ts +1 -0
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +2 -5
- package/dist/cjs/utilities/contours/getContourHolesDataCanvas.d.ts +3 -0
- package/dist/cjs/utilities/contours/getContourHolesDataCanvas.js +21 -0
- package/dist/cjs/utilities/contours/getContourHolesDataCanvas.js.map +1 -0
- package/dist/cjs/utilities/contours/getContourHolesDataWorld.d.ts +3 -0
- package/dist/cjs/utilities/contours/getContourHolesDataWorld.js +10 -0
- package/dist/cjs/utilities/contours/getContourHolesDataWorld.js.map +1 -0
- package/dist/cjs/utilities/contours/index.d.ts +4 -1
- package/dist/cjs/utilities/contours/index.js +7 -1
- package/dist/cjs/utilities/contours/index.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.js +2 -1
- package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.js +2 -1
- package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js +3 -1
- package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/interpolate.d.ts +8 -0
- package/dist/cjs/utilities/contours/interpolation/interpolate.js +56 -42
- package/dist/cjs/utilities/contours/interpolation/interpolate.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/selectHandles.d.ts +4 -0
- package/dist/cjs/utilities/contours/interpolation/selectHandles.js +170 -0
- package/dist/cjs/utilities/contours/interpolation/selectHandles.js.map +1 -0
- package/dist/cjs/utilities/contours/updateContourPolyline.d.ts +10 -0
- package/dist/cjs/utilities/contours/updateContourPolyline.js +64 -0
- package/dist/cjs/utilities/contours/updateContourPolyline.js.map +1 -0
- package/dist/cjs/utilities/livewire/LivewireScissors.d.ts +2 -1
- package/dist/cjs/utilities/livewire/LivewireScissors.js +46 -24
- package/dist/cjs/utilities/livewire/LivewireScissors.js.map +1 -1
- package/dist/cjs/utilities/math/polyline/containsPoints.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/containsPoints.js +16 -0
- package/dist/cjs/utilities/math/polyline/containsPoints.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getWindingDirection.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getWindingDirection.js +12 -0
- package/dist/cjs/utilities/math/polyline/getWindingDirection.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/index.d.ts +3 -1
- package/dist/cjs/utilities/math/polyline/index.js +5 -1
- package/dist/cjs/utilities/math/polyline/index.js.map +1 -1
- package/dist/cjs/utilities/math/polyline/planarFreehandROIInternalTypes.d.ts +1 -0
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js +13 -3
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -1
- package/dist/esm/drawingSvg/drawPath.js +49 -0
- package/dist/esm/drawingSvg/drawPath.js.map +1 -0
- package/dist/esm/drawingSvg/drawPolyline.js +3 -11
- package/dist/esm/drawingSvg/drawPolyline.js.map +1 -1
- package/dist/esm/drawingSvg/index.js +2 -1
- package/dist/esm/drawingSvg/index.js.map +1 -1
- package/dist/esm/enums/ChangeTypes.js +1 -0
- package/dist/esm/enums/ChangeTypes.js.map +1 -1
- package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js +1 -1
- package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
- package/dist/esm/eventDispatchers/shared/getActiveToolForMouseEvent.js.map +1 -1
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +106 -32
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -1
- package/dist/esm/stateManagement/annotation/annotationState.js +42 -1
- package/dist/esm/stateManagement/annotation/annotationState.js.map +1 -1
- package/dist/esm/stateManagement/annotation/helpers/state.js +15 -4
- package/dist/esm/stateManagement/annotation/helpers/state.js.map +1 -1
- package/dist/esm/stateManagement/index.js +2 -2
- package/dist/esm/stateManagement/index.js.map +1 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js +3 -2
- package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/esm/tools/SegmentationIntersectionTool.js +1 -1
- package/dist/esm/tools/SegmentationIntersectionTool.js.map +1 -1
- package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +81 -0
- package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js.map +1 -1
- package/dist/esm/tools/annotation/LivewireContourTool.js +80 -67
- package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +3 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/annotation/SplineROITool.js +40 -22
- package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +12 -7
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +25 -19
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +16 -10
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js +20 -8
- package/dist/esm/tools/annotation/planarFreehandROITool/renderMethods.js.map +1 -1
- package/dist/esm/tools/annotation/splines/LinearSpline.js +1 -1
- package/dist/esm/tools/annotation/splines/LinearSpline.js.map +1 -1
- package/dist/esm/tools/annotation/splines/Spline.js +5 -1
- package/dist/esm/tools/annotation/splines/Spline.js.map +1 -1
- package/dist/esm/tools/base/AnnotationTool.js.map +1 -1
- package/dist/esm/tools/base/ContourBaseTool.js +20 -3
- package/dist/esm/tools/base/ContourBaseTool.js.map +1 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +4 -0
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/contourConfig.js +1 -0
- package/dist/esm/tools/displayTools/Contour/contourConfig.js.map +1 -1
- package/dist/esm/types/ContourAnnotation.js +6 -1
- package/dist/esm/types/ContourAnnotation.js.map +1 -1
- package/dist/esm/utilities/contours/getContourHolesDataCanvas.js +15 -0
- package/dist/esm/utilities/contours/getContourHolesDataCanvas.js.map +1 -0
- package/dist/esm/utilities/contours/getContourHolesDataWorld.js +6 -0
- package/dist/esm/utilities/contours/getContourHolesDataWorld.js.map +1 -0
- package/dist/esm/utilities/contours/index.js +4 -1
- package/dist/esm/utilities/contours/index.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/createPolylineToolData.js +2 -1
- package/dist/esm/utilities/contours/interpolation/createPolylineToolData.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js +2 -1
- package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/getInterpolationData.js +3 -1
- package/dist/esm/utilities/contours/interpolation/getInterpolationData.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/interpolate.js +57 -43
- package/dist/esm/utilities/contours/interpolation/interpolate.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/selectHandles.js +164 -0
- package/dist/esm/utilities/contours/interpolation/selectHandles.js.map +1 -0
- package/dist/esm/utilities/contours/updateContourPolyline.js +38 -0
- package/dist/esm/utilities/contours/updateContourPolyline.js.map +1 -0
- package/dist/esm/utilities/livewire/LivewireScissors.js +46 -24
- package/dist/esm/utilities/livewire/LivewireScissors.js.map +1 -1
- package/dist/esm/utilities/math/polyline/containsPoints.js +10 -0
- package/dist/esm/utilities/math/polyline/containsPoints.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getWindingDirection.js +6 -0
- package/dist/esm/utilities/math/polyline/getWindingDirection.js.map +1 -0
- package/dist/esm/utilities/math/polyline/index.js +3 -1
- package/dist/esm/utilities/math/polyline/index.js.map +1 -1
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +13 -3
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -1
- package/dist/types/drawingSvg/drawPath.d.ts +12 -0
- package/dist/types/drawingSvg/drawPath.d.ts.map +1 -0
- package/dist/types/drawingSvg/drawPolyline.d.ts +1 -1
- package/dist/types/drawingSvg/drawPolyline.d.ts.map +1 -1
- package/dist/types/drawingSvg/index.d.ts +2 -1
- package/dist/types/drawingSvg/index.d.ts.map +1 -1
- package/dist/types/enums/ChangeTypes.d.ts +2 -1
- package/dist/types/enums/ChangeTypes.d.ts.map +1 -1
- package/dist/types/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts +1 -1
- package/dist/types/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts.map +1 -1
- package/dist/types/stateManagement/annotation/annotationState.d.ts +6 -1
- package/dist/types/stateManagement/annotation/annotationState.d.ts.map +1 -1
- package/dist/types/stateManagement/annotation/helpers/state.d.ts +4 -2
- package/dist/types/stateManagement/annotation/helpers/state.d.ts.map +1 -1
- package/dist/types/stateManagement/index.d.ts +6 -1
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts +3 -1
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts.map +1 -1
- package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts +4 -0
- package/dist/types/tools/annotation/LivewireContourSegmentationTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LivewireContourTool.d.ts +13 -11
- package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/SplineROITool.d.ts +6 -3
- 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/drawLoop.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/renderMethods.d.ts.map +1 -1
- package/dist/types/tools/annotation/splines/Spline.d.ts +2 -0
- package/dist/types/tools/annotation/splines/Spline.d.ts.map +1 -1
- package/dist/types/tools/base/AnnotationTool.d.ts.map +1 -1
- package/dist/types/tools/base/ContourBaseTool.d.ts +1 -0
- package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -1
- package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -1
- package/dist/types/tools/displayTools/Contour/contourConfig.d.ts.map +1 -1
- package/dist/types/types/AnnotationTypes.d.ts +2 -0
- package/dist/types/types/AnnotationTypes.d.ts.map +1 -1
- package/dist/types/types/ContourAnnotation.d.ts +6 -0
- package/dist/types/types/ContourAnnotation.d.ts.map +1 -1
- package/dist/types/types/ContourSegmentationAnnotation.d.ts +8 -0
- package/dist/types/types/ContourSegmentationAnnotation.d.ts.map +1 -1
- package/dist/types/types/ContourTypes.d.ts +1 -0
- package/dist/types/types/ContourTypes.d.ts.map +1 -1
- package/dist/types/types/EventTypes.d.ts +4 -1
- package/dist/types/types/EventTypes.d.ts.map +1 -1
- package/dist/types/types/ISpline.d.ts +1 -0
- package/dist/types/types/ISpline.d.ts.map +1 -1
- package/dist/types/types/InterpolationTypes.d.ts +2 -0
- package/dist/types/types/InterpolationTypes.d.ts.map +1 -1
- package/dist/types/types/SplineProps.d.ts +1 -0
- package/dist/types/types/SplineProps.d.ts.map +1 -1
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +2 -5
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/utilities/contours/getContourHolesDataCanvas.d.ts +4 -0
- package/dist/types/utilities/contours/getContourHolesDataCanvas.d.ts.map +1 -0
- package/dist/types/utilities/contours/getContourHolesDataWorld.d.ts +4 -0
- package/dist/types/utilities/contours/getContourHolesDataWorld.d.ts.map +1 -0
- package/dist/types/utilities/contours/index.d.ts +4 -1
- package/dist/types/utilities/contours/index.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/acceptAutogeneratedInterpolations.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/createPolylineToolData.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/findAnnotationForInterpolation.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/getInterpolationData.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/interpolate.d.ts +8 -0
- package/dist/types/utilities/contours/interpolation/interpolate.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/selectHandles.d.ts +5 -0
- package/dist/types/utilities/contours/interpolation/selectHandles.d.ts.map +1 -0
- package/dist/types/utilities/contours/updateContourPolyline.d.ts +11 -0
- package/dist/types/utilities/contours/updateContourPolyline.d.ts.map +1 -0
- package/dist/types/utilities/livewire/LivewireScissors.d.ts +2 -1
- package/dist/types/utilities/livewire/LivewireScissors.d.ts.map +1 -1
- package/dist/types/utilities/math/polyline/containsPoints.d.ts +3 -0
- package/dist/types/utilities/math/polyline/containsPoints.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getWindingDirection.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getWindingDirection.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/index.d.ts +3 -1
- package/dist/types/utilities/math/polyline/index.d.ts.map +1 -1
- package/dist/types/utilities/math/polyline/planarFreehandROIInternalTypes.d.ts +1 -0
- package/dist/types/utilities/math/polyline/planarFreehandROIInternalTypes.d.ts.map +1 -1
- package/dist/types/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/drawingSvg/drawPath.ts +96 -0
- package/src/drawingSvg/drawPolyline.ts +13 -17
- package/src/drawingSvg/index.ts +2 -0
- package/src/enums/ChangeTypes.ts +4 -0
- package/src/eventDispatchers/keyboardEventHandlers/keyDown.ts +1 -1
- package/src/eventDispatchers/shared/getActiveToolForMouseEvent.ts +1 -1
- package/src/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.ts +194 -58
- package/src/stateManagement/annotation/annotationState.ts +101 -0
- package/src/stateManagement/annotation/helpers/state.ts +33 -3
- package/src/stateManagement/index.js +10 -0
- package/src/store/ToolGroupManager/ToolGroup.ts +9 -2
- package/src/tools/SegmentationIntersectionTool.ts +1 -1
- package/src/tools/annotation/LivewireContourSegmentationTool.ts +151 -0
- package/src/tools/annotation/LivewireContourTool.ts +172 -114
- package/src/tools/annotation/PlanarFreehandROITool.ts +13 -3
- package/src/tools/annotation/SplineROITool.ts +78 -31
- package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +20 -11
- package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +40 -21
- package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +28 -13
- package/src/tools/annotation/planarFreehandROITool/renderMethods.ts +28 -10
- package/src/tools/annotation/splines/LinearSpline.ts +1 -1
- package/src/tools/annotation/splines/Spline.ts +13 -1
- package/src/tools/base/AnnotationTool.ts +1 -0
- package/src/tools/base/ContourBaseTool.ts +45 -3
- package/src/tools/base/ContourSegmentationBaseTool.ts +6 -0
- package/src/tools/displayTools/Contour/contourConfig.ts +1 -0
- package/src/types/AnnotationTypes.ts +14 -0
- package/src/types/ContourAnnotation.ts +13 -0
- package/src/types/ContourSegmentationAnnotation.ts +38 -0
- package/src/types/ContourTypes.ts +3 -0
- package/src/types/EventTypes.ts +9 -0
- package/src/types/ISpline.ts +3 -0
- package/src/types/InterpolationTypes.ts +6 -0
- package/src/types/SplineProps.ts +10 -0
- package/src/types/ToolSpecificAnnotationTypes.ts +7 -5
- package/src/utilities/contours/getContourHolesDataCanvas.ts +33 -0
- package/src/utilities/contours/getContourHolesDataWorld.ts +19 -0
- package/src/utilities/contours/index.ts +6 -0
- package/src/utilities/contours/interpolation/acceptAutogeneratedInterpolations.ts +3 -1
- package/src/utilities/contours/interpolation/createPolylineToolData.ts +7 -1
- package/src/utilities/contours/interpolation/findAnnotationForInterpolation.ts +2 -1
- package/src/utilities/contours/interpolation/getInterpolationData.ts +3 -1
- package/src/utilities/contours/interpolation/interpolate.ts +94 -75
- package/src/utilities/contours/interpolation/selectHandles.ts +240 -0
- package/src/utilities/contours/updateContourPolyline.ts +74 -0
- package/src/utilities/livewire/LivewireScissors.ts +65 -53
- package/src/utilities/math/polyline/containsPoint.ts +1 -1
- package/src/utilities/math/polyline/containsPoints.ts +22 -0
- package/src/utilities/math/polyline/getWindingDirection.ts +14 -0
- package/src/utilities/math/polyline/index.ts +4 -0
- package/src/utilities/math/polyline/planarFreehandROIInternalTypes.ts +1 -0
- package/src/utilities/segmentation/InterpolationManager/InterpolationManager.ts +39 -4
- package/dist/cjs/utilities/contours/PointsArray.d.ts +0 -29
- package/dist/cjs/utilities/contours/PointsArray.js +0 -104
- package/dist/cjs/utilities/contours/PointsArray.js.map +0 -1
- package/dist/esm/utilities/contours/PointsArray.js +0 -98
- package/dist/esm/utilities/contours/PointsArray.js.map +0 -1
- package/dist/types/utilities/contours/PointsArray.d.ts +0 -30
- package/dist/types/utilities/contours/PointsArray.d.ts.map +0 -1
- package/src/utilities/contours/PointsArray.ts +0 -165
|
@@ -6,7 +6,10 @@ import {
|
|
|
6
6
|
} from '@cornerstonejs/core';
|
|
7
7
|
import type { Types } from '@cornerstonejs/core';
|
|
8
8
|
import { vec3 } from 'gl-matrix';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
getChildAnnotations,
|
|
11
|
+
removeAnnotation,
|
|
12
|
+
} from '../../stateManagement/annotation/annotationState';
|
|
10
13
|
import {
|
|
11
14
|
drawHandles as drawHandlesSvg,
|
|
12
15
|
drawPolyline as drawPolylineSvg,
|
|
@@ -37,13 +40,15 @@ import {
|
|
|
37
40
|
getCalibratedScale,
|
|
38
41
|
getCalibratedAreaUnits,
|
|
39
42
|
} from '../../utilities';
|
|
43
|
+
import getMouseModifierKey from '../../eventDispatchers/shared/getMouseModifier';
|
|
40
44
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
41
45
|
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
42
46
|
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
|
|
47
|
+
import { ContourWindingDirection } from '../../types/ContourAnnotation';
|
|
48
|
+
import type { SplineROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
|
|
49
|
+
import type {
|
|
46
50
|
AnnotationModifiedEventDetail,
|
|
51
|
+
ContourAnnotationCompletedEventDetail,
|
|
47
52
|
} from '../../types/EventTypes';
|
|
48
53
|
import { ISpline } from '../../types/ISpline';
|
|
49
54
|
import { CardinalSpline } from './splines/CardinalSpline';
|
|
@@ -51,7 +56,7 @@ import { LinearSpline } from './splines/LinearSpline';
|
|
|
51
56
|
import { CatmullRomSpline } from './splines/CatmullRomSpline';
|
|
52
57
|
import { BSpline } from './splines/BSpline';
|
|
53
58
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
54
|
-
import
|
|
59
|
+
import updateContourPolyline from '../../utilities/contours/updateContourPolyline';
|
|
55
60
|
|
|
56
61
|
const SPLINE_MIN_POINTS = 3;
|
|
57
62
|
const SPLINE_CLICK_CLOSE_CURVE_DIST = 10;
|
|
@@ -93,12 +98,14 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
93
98
|
newAnnotation?: boolean;
|
|
94
99
|
hasMoved?: boolean;
|
|
95
100
|
lastCanvasPoint?: Types.Point2;
|
|
101
|
+
contourHoleProcessingEnabled?: boolean;
|
|
96
102
|
} | null;
|
|
97
103
|
isDrawing: boolean;
|
|
98
104
|
isHandleOutsideImage = false;
|
|
99
105
|
fireChangeOnUpdate: {
|
|
100
106
|
annotationUID: string;
|
|
101
107
|
changeType: ChangeTypes;
|
|
108
|
+
contourHoleProcessingEnabled: boolean;
|
|
102
109
|
} = null;
|
|
103
110
|
|
|
104
111
|
constructor(
|
|
@@ -109,6 +116,11 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
109
116
|
preventHandleOutsideImage: false,
|
|
110
117
|
calculateStats: true,
|
|
111
118
|
getTextLines: defaultGetTextLines,
|
|
119
|
+
/**
|
|
120
|
+
* Specify which modifier key is used to add a hole to a contour. The
|
|
121
|
+
* modifier must be pressed when the first point of a new contour is added.
|
|
122
|
+
*/
|
|
123
|
+
contourHoleAdditionModifierKey: KeyboardBindings.Shift,
|
|
112
124
|
spline: {
|
|
113
125
|
configuration: {
|
|
114
126
|
[SplineTypesEnum.Cardinal]: {
|
|
@@ -176,6 +188,9 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
176
188
|
const eventDetail = evt.detail;
|
|
177
189
|
const { currentPoints, element } = eventDetail;
|
|
178
190
|
const { canvas: canvasPos } = currentPoints;
|
|
191
|
+
const contourHoleProcessingEnabled =
|
|
192
|
+
getMouseModifierKey(evt.detail.event) ===
|
|
193
|
+
this.configuration.contourHoleAdditionModifierKey;
|
|
179
194
|
|
|
180
195
|
const enabledElement = getEnabledElement(element);
|
|
181
196
|
const { renderingEngine } = enabledElement;
|
|
@@ -196,6 +211,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
196
211
|
newAnnotation: true,
|
|
197
212
|
hasMoved: false,
|
|
198
213
|
lastCanvasPoint: canvasPos,
|
|
214
|
+
contourHoleProcessingEnabled,
|
|
199
215
|
};
|
|
200
216
|
|
|
201
217
|
this._activateDraw(element);
|
|
@@ -303,7 +319,12 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
303
319
|
const eventDetail = evt.detail;
|
|
304
320
|
const { element } = eventDetail;
|
|
305
321
|
|
|
306
|
-
const {
|
|
322
|
+
const {
|
|
323
|
+
annotation,
|
|
324
|
+
viewportIdsToRender,
|
|
325
|
+
newAnnotation,
|
|
326
|
+
contourHoleProcessingEnabled,
|
|
327
|
+
} = this.editData;
|
|
307
328
|
const { data } = annotation;
|
|
308
329
|
annotation.autoGenerated = false;
|
|
309
330
|
|
|
@@ -338,6 +359,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
338
359
|
changeType: newAnnotation
|
|
339
360
|
? ChangeTypes.Completed
|
|
340
361
|
: ChangeTypes.HandlesUpdated,
|
|
362
|
+
contourHoleProcessingEnabled,
|
|
341
363
|
};
|
|
342
364
|
|
|
343
365
|
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
@@ -466,14 +488,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
466
488
|
const { deltaPoints } = eventDetail as EventTypes.MouseDragEventDetail;
|
|
467
489
|
const worldPosDelta = deltaPoints.world;
|
|
468
490
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
points.forEach((point) => {
|
|
472
|
-
point[0] += worldPosDelta[0];
|
|
473
|
-
point[1] += worldPosDelta[1];
|
|
474
|
-
point[2] += worldPosDelta[2];
|
|
475
|
-
});
|
|
476
|
-
annotation.invalidated = true;
|
|
491
|
+
this.moveAnnotation(annotation, worldPosDelta);
|
|
477
492
|
} else {
|
|
478
493
|
// Move mode - after double click, and mouse move to draw
|
|
479
494
|
const { currentPoints } = eventDetail;
|
|
@@ -522,11 +537,15 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
522
537
|
/**
|
|
523
538
|
* Triggers an annotation completed event.
|
|
524
539
|
*/
|
|
525
|
-
triggerAnnotationCompleted = (
|
|
540
|
+
triggerAnnotationCompleted = (
|
|
541
|
+
annotation: SplineROIAnnotation,
|
|
542
|
+
contourHoleProcessingEnabled: boolean
|
|
543
|
+
): void => {
|
|
526
544
|
const eventType = Events.ANNOTATION_COMPLETED;
|
|
527
|
-
const eventDetail:
|
|
545
|
+
const eventDetail: ContourAnnotationCompletedEventDetail = {
|
|
528
546
|
annotation,
|
|
529
547
|
changeType: ChangeTypes.Completed,
|
|
548
|
+
contourHoleProcessingEnabled,
|
|
530
549
|
};
|
|
531
550
|
|
|
532
551
|
triggerEvent(eventTarget, eventType, eventDetail);
|
|
@@ -558,10 +577,11 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
558
577
|
triggerChangeEvent = (
|
|
559
578
|
annotation: SplineROIAnnotation,
|
|
560
579
|
enabledElement: Types.IEnabledElement,
|
|
561
|
-
changeType = ChangeTypes.StatsUpdated
|
|
580
|
+
changeType = ChangeTypes.StatsUpdated,
|
|
581
|
+
contourHoleProcessingEnabled
|
|
562
582
|
): void => {
|
|
563
583
|
if (changeType === ChangeTypes.Completed) {
|
|
564
|
-
this.triggerAnnotationCompleted(annotation);
|
|
584
|
+
this.triggerAnnotationCompleted(annotation, contourHoleProcessingEnabled);
|
|
565
585
|
} else {
|
|
566
586
|
this.triggerAnnotationModified(annotation, enabledElement, changeType);
|
|
567
587
|
}
|
|
@@ -658,15 +678,32 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
658
678
|
const { drawPreviewEnabled } = this.configuration.spline;
|
|
659
679
|
const splineType = annotation.data.spline.type;
|
|
660
680
|
const splineConfig = this._getSplineConfig(splineType);
|
|
661
|
-
const spline =
|
|
662
|
-
const splinePolylineCanvas = reverseIfAntiClockwise(
|
|
663
|
-
spline.getPolylinePoints()
|
|
664
|
-
);
|
|
665
|
-
const splinePolylineWorld = splinePolylineCanvas.map((point2) =>
|
|
666
|
-
viewport.canvasToWorld(point2)
|
|
667
|
-
);
|
|
681
|
+
const spline = annotation.data.spline.instance;
|
|
668
682
|
|
|
669
|
-
|
|
683
|
+
// Update current and all child annotations/splines
|
|
684
|
+
if (annotation.invalidated) {
|
|
685
|
+
const splineAnnotationsGroup = [
|
|
686
|
+
annotation,
|
|
687
|
+
...getChildAnnotations(annotation),
|
|
688
|
+
].filter((annotation) =>
|
|
689
|
+
this._isSplineROIAnnotation(annotation)
|
|
690
|
+
) as SplineROIAnnotation[];
|
|
691
|
+
|
|
692
|
+
splineAnnotationsGroup.forEach((annotation) => {
|
|
693
|
+
const spline = this._updateSplineInstance(element, annotation);
|
|
694
|
+
const splinePolylineCanvas = spline.getPolylinePoints();
|
|
695
|
+
|
|
696
|
+
updateContourPolyline(
|
|
697
|
+
annotation,
|
|
698
|
+
{
|
|
699
|
+
points: splinePolylineCanvas,
|
|
700
|
+
closed: data.contour.closed,
|
|
701
|
+
targetWindingDirection: ContourWindingDirection.Clockwise,
|
|
702
|
+
},
|
|
703
|
+
viewport
|
|
704
|
+
);
|
|
705
|
+
});
|
|
706
|
+
}
|
|
670
707
|
|
|
671
708
|
// Let the base class render the contour
|
|
672
709
|
super.renderAnnotationInstance(renderContext);
|
|
@@ -768,7 +805,8 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
768
805
|
this.triggerChangeEvent(
|
|
769
806
|
annotation,
|
|
770
807
|
enabledElement,
|
|
771
|
-
this.fireChangeOnUpdate.changeType
|
|
808
|
+
this.fireChangeOnUpdate.changeType,
|
|
809
|
+
this.fireChangeOnUpdate.contourHoleProcessingEnabled
|
|
772
810
|
);
|
|
773
811
|
this.fireChangeOnUpdate = null;
|
|
774
812
|
}
|
|
@@ -814,9 +852,9 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
814
852
|
|
|
815
853
|
// Add an action to create a new spline data on creating an interpolated
|
|
816
854
|
// instance.
|
|
817
|
-
let
|
|
855
|
+
let onInterpolationComplete;
|
|
818
856
|
if (this.configuration.interpolation?.enabled) {
|
|
819
|
-
|
|
857
|
+
onInterpolationComplete = (annotation) => {
|
|
820
858
|
annotation.data.spline ||= createSpline();
|
|
821
859
|
this.createInterpolatedSplineControl(annotation);
|
|
822
860
|
};
|
|
@@ -830,7 +868,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
830
868
|
spline: createSpline(),
|
|
831
869
|
cachedStats: {},
|
|
832
870
|
},
|
|
833
|
-
|
|
871
|
+
onInterpolationComplete,
|
|
834
872
|
});
|
|
835
873
|
}
|
|
836
874
|
|
|
@@ -990,6 +1028,12 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
990
1028
|
);
|
|
991
1029
|
};
|
|
992
1030
|
|
|
1031
|
+
_isSplineROIAnnotation(
|
|
1032
|
+
annotation: Annotation
|
|
1033
|
+
): annotation is SplineROIAnnotation {
|
|
1034
|
+
return !!(<SplineROIAnnotation>annotation).data?.spline;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
993
1037
|
/**
|
|
994
1038
|
* Get a spline config merged with the default settings.
|
|
995
1039
|
* @param type - Spline type (CARDINAL, CATMULLROM, LINEAR or BSPLINE)
|
|
@@ -1019,7 +1063,10 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
1019
1063
|
spline.closed = !!data.contour.closed;
|
|
1020
1064
|
|
|
1021
1065
|
// Update spline resolution in case it has changed
|
|
1022
|
-
if (
|
|
1066
|
+
if (
|
|
1067
|
+
!spline.fixedResolution &&
|
|
1068
|
+
spline.resolution !== splineConfig.resolution
|
|
1069
|
+
) {
|
|
1023
1070
|
spline.resolution = parseInt(splineConfig.resolution);
|
|
1024
1071
|
annotation.invalidated = true;
|
|
1025
1072
|
}
|
|
@@ -7,14 +7,16 @@ import {
|
|
|
7
7
|
resetElementCursor,
|
|
8
8
|
hideElementCursor,
|
|
9
9
|
} from '../../../cursors/elementCursor';
|
|
10
|
-
import { EventTypes } from '../../../types';
|
|
10
|
+
import type { EventTypes } from '../../../types';
|
|
11
11
|
import { polyline } from '../../../utilities/math';
|
|
12
|
-
import {
|
|
12
|
+
import { ContourWindingDirection } from '../../../types/ContourAnnotation';
|
|
13
|
+
import type { PlanarFreehandROIAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
|
|
13
14
|
import {
|
|
14
15
|
getInterpolatedPoints,
|
|
15
16
|
shouldSmooth,
|
|
16
17
|
} from '../../../utilities/planarFreehandROITool/smoothPoints';
|
|
17
18
|
import triggerAnnotationRenderForViewportIds from '../../../utilities/triggerAnnotationRenderForViewportIds';
|
|
19
|
+
import updateContourPolyline from '../../../utilities/contours/updateContourPolyline';
|
|
18
20
|
import { triggerAnnotationModified } from '../../../stateManagement/annotation/helpers/state';
|
|
19
21
|
|
|
20
22
|
const { getSubPixelSpacingAndXYDirections, addCanvasPointsToArray, getArea } =
|
|
@@ -223,12 +225,16 @@ function finishEditAndStartNewEdit(evt: EventTypes.InteractionEventType): void {
|
|
|
223
225
|
const { annotation, viewportIdsToRender } = this.commonData;
|
|
224
226
|
const { fusedCanvasPoints, editCanvasPoints } = this.editData;
|
|
225
227
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
+
updateContourPolyline(
|
|
229
|
+
annotation,
|
|
230
|
+
{
|
|
231
|
+
points: fusedCanvasPoints,
|
|
232
|
+
closed: true,
|
|
233
|
+
targetWindingDirection: ContourWindingDirection.Clockwise,
|
|
234
|
+
},
|
|
235
|
+
viewport
|
|
228
236
|
);
|
|
229
237
|
|
|
230
|
-
annotation.data.contour.polyline = worldPoints;
|
|
231
|
-
annotation.data.contour.closed = true;
|
|
232
238
|
// If any manual update, triggered on an annotation, then it will be treated as non-autogenerated.
|
|
233
239
|
if (annotation.autoGenerated) {
|
|
234
240
|
annotation.autoGenerated = false;
|
|
@@ -446,12 +452,15 @@ function completeClosedContourEdit(element: HTMLDivElement) {
|
|
|
446
452
|
)
|
|
447
453
|
: fusedCanvasPoints;
|
|
448
454
|
|
|
449
|
-
|
|
450
|
-
|
|
455
|
+
updateContourPolyline(
|
|
456
|
+
annotation,
|
|
457
|
+
{
|
|
458
|
+
points: updatedPoints,
|
|
459
|
+
closed: true,
|
|
460
|
+
targetWindingDirection: ContourWindingDirection.Clockwise,
|
|
461
|
+
},
|
|
462
|
+
viewport
|
|
451
463
|
);
|
|
452
|
-
annotation.data.contour.polyline = worldPoints;
|
|
453
|
-
annotation.data.contour.closed = true;
|
|
454
|
-
annotation.invalidated = true;
|
|
455
464
|
|
|
456
465
|
// If any manual update, triggered on an annotation, then it will be treated as non-autogenerated.
|
|
457
466
|
if (annotation.autoGenerated) {
|
|
@@ -11,12 +11,14 @@ import {
|
|
|
11
11
|
shouldSmooth,
|
|
12
12
|
getInterpolatedPoints,
|
|
13
13
|
} from '../../../utilities/planarFreehandROITool/smoothPoints';
|
|
14
|
+
import getMouseModifierKey from '../../../eventDispatchers/shared/getMouseModifier';
|
|
14
15
|
import triggerAnnotationRenderForViewportIds from '../../../utilities/triggerAnnotationRenderForViewportIds';
|
|
15
|
-
import {
|
|
16
|
+
import { triggerContourAnnotationCompleted } from '../../../stateManagement/annotation/helpers/state';
|
|
16
17
|
import { PlanarFreehandROIAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
|
|
17
18
|
import findOpenUShapedContourVectorToPeak from './findOpenUShapedContourVectorToPeak';
|
|
18
19
|
import { polyline } from '../../../utilities/math';
|
|
19
20
|
import { removeAnnotation } from '../../../stateManagement/annotation/annotationState';
|
|
21
|
+
import { updateContourPolyline } from '../../../utilities/contours/';
|
|
20
22
|
import reverseIfAntiClockwise from '../../../utilities/contours/reverseIfAntiClockwise';
|
|
21
23
|
|
|
22
24
|
const {
|
|
@@ -41,6 +43,9 @@ function activateDraw(
|
|
|
41
43
|
const canvasPos = currentPoints.canvas;
|
|
42
44
|
const enabledElement = getEnabledElement(element);
|
|
43
45
|
const { viewport } = enabledElement;
|
|
46
|
+
const contourHoleProcessingEnabled =
|
|
47
|
+
getMouseModifierKey(evt.detail.event) ===
|
|
48
|
+
this.configuration.contourHoleAdditionModifierKey;
|
|
44
49
|
|
|
45
50
|
const { spacing, xDir, yDir } = getSubPixelSpacingAndXYDirections(
|
|
46
51
|
viewport,
|
|
@@ -50,6 +55,7 @@ function activateDraw(
|
|
|
50
55
|
this.drawData = {
|
|
51
56
|
canvasPoints: [canvasPos],
|
|
52
57
|
polylineIndex: 0,
|
|
58
|
+
contourHoleProcessingEnabled,
|
|
53
59
|
};
|
|
54
60
|
|
|
55
61
|
this.commonData = {
|
|
@@ -171,7 +177,7 @@ function mouseDragDrawCallback(evt: EventTypes.InteractionEventType): void {
|
|
|
171
177
|
*/
|
|
172
178
|
function mouseUpDrawCallback(evt: EventTypes.InteractionEventType): void {
|
|
173
179
|
const { allowOpenContours } = this.configuration;
|
|
174
|
-
const { canvasPoints } = this.drawData;
|
|
180
|
+
const { canvasPoints, contourHoleProcessingEnabled } = this.drawData;
|
|
175
181
|
const firstPoint = canvasPoints[0];
|
|
176
182
|
const lastPoint = canvasPoints[canvasPoints.length - 1];
|
|
177
183
|
const eventDetail = evt.detail;
|
|
@@ -185,16 +191,19 @@ function mouseUpDrawCallback(evt: EventTypes.InteractionEventType): void {
|
|
|
185
191
|
this.configuration.closeContourProximity
|
|
186
192
|
)
|
|
187
193
|
) {
|
|
188
|
-
this.completeDrawOpenContour(element);
|
|
194
|
+
this.completeDrawOpenContour(element, contourHoleProcessingEnabled);
|
|
189
195
|
} else {
|
|
190
|
-
this.completeDrawClosedContour(element);
|
|
196
|
+
this.completeDrawClosedContour(element, contourHoleProcessingEnabled);
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
199
|
|
|
194
200
|
/**
|
|
195
201
|
* Completes the contour being drawn, creating a closed contour annotation. It will return true if contour is completed or false in case contour drawing is halted.
|
|
196
202
|
*/
|
|
197
|
-
function completeDrawClosedContour(
|
|
203
|
+
function completeDrawClosedContour(
|
|
204
|
+
element: HTMLDivElement,
|
|
205
|
+
contourHoleProcessingEnabled: boolean
|
|
206
|
+
): boolean {
|
|
198
207
|
this.removeCrossedLinesOnCompleteDraw();
|
|
199
208
|
const { canvasPoints } = this.drawData;
|
|
200
209
|
|
|
@@ -228,17 +237,20 @@ function completeDrawClosedContour(element: HTMLDivElement): boolean {
|
|
|
228
237
|
// Note: -> This is pretty expensive and may not scale well with hundreds of
|
|
229
238
|
// contours. A future optimisation if we use this for segmentation is to re-do
|
|
230
239
|
// this rendering with the GPU rather than SVG.
|
|
231
|
-
|
|
232
|
-
|
|
240
|
+
|
|
241
|
+
updateContourPolyline(
|
|
242
|
+
annotation,
|
|
243
|
+
{
|
|
244
|
+
points: updatedPoints,
|
|
245
|
+
closed: true,
|
|
246
|
+
},
|
|
247
|
+
viewport
|
|
233
248
|
);
|
|
234
249
|
|
|
235
|
-
annotation.data.contour.polyline = worldPoints;
|
|
236
|
-
annotation.data.contour.closed = true;
|
|
237
|
-
annotation.invalidated = true;
|
|
238
250
|
const { textBox } = annotation.data.handles;
|
|
239
251
|
|
|
240
252
|
if (!textBox.hasMoved) {
|
|
241
|
-
|
|
253
|
+
triggerContourAnnotationCompleted(annotation, contourHoleProcessingEnabled);
|
|
242
254
|
}
|
|
243
255
|
|
|
244
256
|
this.isDrawing = false;
|
|
@@ -280,7 +292,10 @@ function removeCrossedLinesOnCompleteDraw(): void {
|
|
|
280
292
|
/**
|
|
281
293
|
* Completes the contour being drawn, creating an open contour annotation. It will return true if contour is completed or false in case contour drawing is halted.
|
|
282
294
|
*/
|
|
283
|
-
function completeDrawOpenContour(
|
|
295
|
+
function completeDrawOpenContour(
|
|
296
|
+
element: HTMLDivElement,
|
|
297
|
+
contourHoleProcessingEnabled: boolean
|
|
298
|
+
): boolean {
|
|
284
299
|
const { canvasPoints } = this.drawData;
|
|
285
300
|
|
|
286
301
|
// check and halt if necessary the drawing process, last chance to complete drawing and fire events.
|
|
@@ -299,14 +314,18 @@ function completeDrawOpenContour(element: HTMLDivElement): boolean {
|
|
|
299
314
|
// Note: -> This is pretty expensive and may not scale well with hundreds of
|
|
300
315
|
// contours. A future optimisation if we use this for segmentation is to re-do
|
|
301
316
|
// this rendering with the GPU rather than SVG.
|
|
302
|
-
|
|
303
|
-
|
|
317
|
+
|
|
318
|
+
updateContourPolyline(
|
|
319
|
+
annotation,
|
|
320
|
+
{
|
|
321
|
+
points: updatedPoints,
|
|
322
|
+
closed: false,
|
|
323
|
+
},
|
|
324
|
+
viewport
|
|
304
325
|
);
|
|
305
326
|
|
|
306
|
-
annotation.data.contour.polyline = worldPoints;
|
|
307
|
-
annotation.data.contour.closed = false;
|
|
308
|
-
annotation.invalidated = true;
|
|
309
327
|
const { textBox } = annotation.data.handles;
|
|
328
|
+
const worldPoints = annotation.data.contour.polyline;
|
|
310
329
|
|
|
311
330
|
// Add the first and last points to the list of handles. These means they
|
|
312
331
|
// will render handles on mouse hover.
|
|
@@ -322,7 +341,7 @@ function completeDrawOpenContour(element: HTMLDivElement): boolean {
|
|
|
322
341
|
}
|
|
323
342
|
|
|
324
343
|
if (!textBox.hasMoved) {
|
|
325
|
-
|
|
344
|
+
triggerContourAnnotationCompleted(annotation, contourHoleProcessingEnabled);
|
|
326
345
|
}
|
|
327
346
|
|
|
328
347
|
this.isDrawing = false;
|
|
@@ -407,7 +426,7 @@ function applyCreateOnCross(
|
|
|
407
426
|
*/
|
|
408
427
|
function cancelDrawing(element: HTMLElement) {
|
|
409
428
|
const { allowOpenContours } = this.configuration;
|
|
410
|
-
const { canvasPoints } = this.drawData;
|
|
429
|
+
const { canvasPoints, contourHoleProcessingEnabled } = this.drawData;
|
|
411
430
|
const firstPoint = canvasPoints[0];
|
|
412
431
|
const lastPoint = canvasPoints[canvasPoints.length - 1];
|
|
413
432
|
|
|
@@ -419,9 +438,9 @@ function cancelDrawing(element: HTMLElement) {
|
|
|
419
438
|
this.configuration.closeContourProximity
|
|
420
439
|
)
|
|
421
440
|
) {
|
|
422
|
-
this.completeDrawOpenContour(element);
|
|
441
|
+
this.completeDrawOpenContour(element, contourHoleProcessingEnabled);
|
|
423
442
|
} else {
|
|
424
|
-
this.completeDrawClosedContour(element);
|
|
443
|
+
this.completeDrawClosedContour(element, contourHoleProcessingEnabled);
|
|
425
444
|
}
|
|
426
445
|
}
|
|
427
446
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
getInterpolatedPoints,
|
|
16
16
|
} from '../../../utilities/planarFreehandROITool/smoothPoints';
|
|
17
17
|
import triggerAnnotationRenderForViewportIds from '../../../utilities/triggerAnnotationRenderForViewportIds';
|
|
18
|
+
import { updateContourPolyline } from '../../../utilities/contours';
|
|
18
19
|
import findOpenUShapedContourVectorToPeak from './findOpenUShapedContourVectorToPeak';
|
|
19
20
|
import { triggerAnnotationModified } from '../../../stateManagement/annotation/helpers/state';
|
|
20
21
|
|
|
@@ -213,12 +214,17 @@ function openContourEditOverwriteEnd(
|
|
|
213
214
|
const { annotation, viewportIdsToRender } = this.commonData;
|
|
214
215
|
const fusedCanvasPoints = this.fuseEditPointsForOpenContourEndEdit();
|
|
215
216
|
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
updateContourPolyline(
|
|
218
|
+
annotation,
|
|
219
|
+
{
|
|
220
|
+
points: fusedCanvasPoints,
|
|
221
|
+
closed: false,
|
|
222
|
+
},
|
|
223
|
+
viewport
|
|
218
224
|
);
|
|
219
225
|
|
|
220
|
-
annotation.data.contour.polyline
|
|
221
|
-
|
|
226
|
+
const worldPoints = annotation.data.contour.polyline;
|
|
227
|
+
|
|
222
228
|
// Note: Contours generate from fusedCanvasPoints will be in the direction
|
|
223
229
|
// with the last point being the current mouse position
|
|
224
230
|
annotation.data.handles.points = [
|
|
@@ -495,12 +501,17 @@ function finishEditOpenOnSecondCrossing(
|
|
|
495
501
|
const { annotation, viewportIdsToRender } = this.commonData;
|
|
496
502
|
const { fusedCanvasPoints, editCanvasPoints } = this.editData;
|
|
497
503
|
|
|
498
|
-
|
|
499
|
-
|
|
504
|
+
updateContourPolyline(
|
|
505
|
+
annotation,
|
|
506
|
+
{
|
|
507
|
+
points: fusedCanvasPoints,
|
|
508
|
+
closed: false,
|
|
509
|
+
},
|
|
510
|
+
viewport
|
|
500
511
|
);
|
|
501
512
|
|
|
502
|
-
annotation.data.contour.polyline
|
|
503
|
-
|
|
513
|
+
const worldPoints = annotation.data.contour.polyline;
|
|
514
|
+
|
|
504
515
|
annotation.data.handles.points = [
|
|
505
516
|
worldPoints[0],
|
|
506
517
|
worldPoints[worldPoints.length - 1],
|
|
@@ -551,13 +562,17 @@ function completeOpenContourEdit(element: HTMLDivElement) {
|
|
|
551
562
|
)
|
|
552
563
|
: fusedCanvasPoints;
|
|
553
564
|
|
|
554
|
-
|
|
555
|
-
|
|
565
|
+
updateContourPolyline(
|
|
566
|
+
annotation,
|
|
567
|
+
{
|
|
568
|
+
points: updatedPoints,
|
|
569
|
+
closed: false,
|
|
570
|
+
},
|
|
571
|
+
viewport
|
|
556
572
|
);
|
|
557
573
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
annotation.data.contour.closed = false;
|
|
574
|
+
const worldPoints = annotation.data.contour.polyline;
|
|
575
|
+
|
|
561
576
|
annotation.data.handles.points = [
|
|
562
577
|
worldPoints[0],
|
|
563
578
|
worldPoints[worldPoints.length - 1],
|
|
@@ -2,12 +2,14 @@ import type { Types } from '@cornerstonejs/core';
|
|
|
2
2
|
import {
|
|
3
3
|
drawHandles as drawHandlesSvg,
|
|
4
4
|
drawPolyline as drawPolylineSvg,
|
|
5
|
+
drawPath as drawPathSvg,
|
|
5
6
|
} from '../../../drawingSvg';
|
|
6
7
|
import { polyline } from '../../../utilities/math';
|
|
7
8
|
import { findOpenUShapedContourVectorToPeakOnRender } from './findOpenUShapedContourVectorToPeak';
|
|
8
9
|
import { PlanarFreehandROIAnnotation } from '../../../types/ToolSpecificAnnotationTypes';
|
|
9
10
|
import { StyleSpecifier } from '../../../types/AnnotationStyle';
|
|
10
11
|
import { SVGDrawingHelper } from '../../../types';
|
|
12
|
+
import { getContourHolesDataCanvas } from '../../../utilities/contours';
|
|
11
13
|
|
|
12
14
|
const { pointsAreWithinCloseContourProximity } = polyline;
|
|
13
15
|
|
|
@@ -42,7 +44,7 @@ function _getRenderingOptions(
|
|
|
42
44
|
lineDash,
|
|
43
45
|
fillColor,
|
|
44
46
|
fillOpacity,
|
|
45
|
-
|
|
47
|
+
closePath: isClosedContour,
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
return options;
|
|
@@ -106,6 +108,10 @@ function renderClosedContour(
|
|
|
106
108
|
svgDrawingHelper: SVGDrawingHelper,
|
|
107
109
|
annotation: PlanarFreehandROIAnnotation
|
|
108
110
|
): void {
|
|
111
|
+
if (annotation.parentAnnotationUID) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
109
115
|
const { viewport } = enabledElement;
|
|
110
116
|
const options = this._getRenderingOptions(enabledElement, annotation);
|
|
111
117
|
|
|
@@ -114,17 +120,19 @@ function renderClosedContour(
|
|
|
114
120
|
// element on the tool? That feels very weird also as we'd need to manage
|
|
115
121
|
// it/clean them up. Its a pre-optimisation for now and we can tackle it if it
|
|
116
122
|
// becomes a problem.
|
|
117
|
-
const
|
|
123
|
+
const canvasPolyline = annotation.data.contour.polyline.map((worldPos) =>
|
|
118
124
|
viewport.worldToCanvas(worldPos)
|
|
119
125
|
);
|
|
120
126
|
|
|
127
|
+
const childContours = getContourHolesDataCanvas(annotation, viewport);
|
|
128
|
+
const allContours = [canvasPolyline, ...childContours];
|
|
121
129
|
const polylineUID = '1';
|
|
122
130
|
|
|
123
|
-
|
|
131
|
+
drawPathSvg(
|
|
124
132
|
svgDrawingHelper,
|
|
125
133
|
annotation.annotationUID,
|
|
126
134
|
polylineUID,
|
|
127
|
-
|
|
135
|
+
allContours,
|
|
128
136
|
options
|
|
129
137
|
);
|
|
130
138
|
}
|
|
@@ -245,7 +253,7 @@ function renderOpenUShapedContour(
|
|
|
245
253
|
{
|
|
246
254
|
color: options.color,
|
|
247
255
|
width: options.width,
|
|
248
|
-
|
|
256
|
+
closePath: false,
|
|
249
257
|
lineDash: '2,2',
|
|
250
258
|
}
|
|
251
259
|
);
|
|
@@ -262,7 +270,7 @@ function renderOpenUShapedContour(
|
|
|
262
270
|
{
|
|
263
271
|
color: options.color,
|
|
264
272
|
width: options.width,
|
|
265
|
-
|
|
273
|
+
closePath: false,
|
|
266
274
|
lineDash: '2,2',
|
|
267
275
|
}
|
|
268
276
|
);
|
|
@@ -284,7 +292,7 @@ function renderContourBeingDrawn(
|
|
|
284
292
|
|
|
285
293
|
// Override rendering whilst drawing the contour, we don't know if its open
|
|
286
294
|
// or closed yet
|
|
287
|
-
options.
|
|
295
|
+
options.closePath = false;
|
|
288
296
|
|
|
289
297
|
drawPolylineSvg(
|
|
290
298
|
svgDrawingHelper,
|
|
@@ -337,6 +345,7 @@ function renderClosedContourBeingEdited(
|
|
|
337
345
|
svgDrawingHelper,
|
|
338
346
|
annotation
|
|
339
347
|
): void {
|
|
348
|
+
const { viewport } = enabledElement;
|
|
340
349
|
const { fusedCanvasPoints } = this.editData;
|
|
341
350
|
|
|
342
351
|
if (fusedCanvasPoints === undefined) {
|
|
@@ -346,15 +355,24 @@ function renderClosedContourBeingEdited(
|
|
|
346
355
|
return;
|
|
347
356
|
}
|
|
348
357
|
|
|
349
|
-
|
|
358
|
+
// Get the polylines from child annotations (holes)
|
|
359
|
+
const childContours = getContourHolesDataCanvas(annotation, viewport);
|
|
350
360
|
|
|
361
|
+
const allContours = [fusedCanvasPoints, ...childContours];
|
|
362
|
+
const options = this._getRenderingOptions(enabledElement, annotation);
|
|
351
363
|
const polylineUIDToRender = 'preview-1';
|
|
352
364
|
|
|
353
|
-
|
|
365
|
+
// Set `fillOpacity` to zero if it is a child annotation (hole) otherwise
|
|
366
|
+
// it would "close" the hole when editing it
|
|
367
|
+
if (annotation.parentAnnotationUID && options.fillOpacity) {
|
|
368
|
+
options.fillOpacity = 0;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
drawPathSvg(
|
|
354
372
|
svgDrawingHelper,
|
|
355
373
|
annotation.annotationUID,
|
|
356
374
|
polylineUIDToRender,
|
|
357
|
-
|
|
375
|
+
allContours,
|
|
358
376
|
options
|
|
359
377
|
);
|
|
360
378
|
}
|