@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
|
@@ -1,49 +1,46 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
|
-
|
|
3
2
|
import {
|
|
4
3
|
getEnabledElement,
|
|
5
|
-
triggerEvent,
|
|
6
|
-
eventTarget,
|
|
7
4
|
utilities as csUtils,
|
|
8
5
|
VolumeViewport,
|
|
9
6
|
} from '@cornerstonejs/core';
|
|
10
7
|
import type { Types } from '@cornerstonejs/core';
|
|
8
|
+
|
|
11
9
|
import { removeAnnotation } from '../../stateManagement/annotation/annotationState';
|
|
12
10
|
import { drawHandles as drawHandlesSvg } from '../../drawingSvg';
|
|
13
11
|
import { state } from '../../store';
|
|
14
|
-
import { Events, ChangeTypes } from '../../enums';
|
|
12
|
+
import { Events, KeyboardBindings, ChangeTypes } from '../../enums';
|
|
15
13
|
import { resetElementCursor } from '../../cursors/elementCursor';
|
|
16
14
|
import type {
|
|
17
|
-
Annotation,
|
|
18
15
|
EventTypes,
|
|
19
16
|
ToolHandle,
|
|
20
17
|
PublicToolProps,
|
|
21
18
|
ToolProps,
|
|
22
19
|
SVGDrawingHelper,
|
|
23
20
|
} from '../../types';
|
|
21
|
+
import getMouseModifierKey from '../../eventDispatchers/shared/getMouseModifier';
|
|
24
22
|
import { math, triggerAnnotationRenderForViewportIds } from '../../utilities';
|
|
25
23
|
import findHandlePolylineIndex from '../../utilities/contours/findHandlePolylineIndex';
|
|
26
24
|
import { LivewireContourAnnotation } from '../../types/ToolSpecificAnnotationTypes';
|
|
25
|
+
import { ContourWindingDirection } from '../../types/ContourAnnotation';
|
|
27
26
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from '../../
|
|
31
|
-
import reverseIfAntiClockwise from '../../utilities/contours/reverseIfAntiClockwise';
|
|
27
|
+
triggerAnnotationModified,
|
|
28
|
+
triggerContourAnnotationCompleted,
|
|
29
|
+
} from '../../stateManagement/annotation/helpers/state';
|
|
32
30
|
|
|
33
31
|
import { LivewireScissors } from '../../utilities/livewire/LivewireScissors';
|
|
34
32
|
import { LivewirePath } from '../../utilities/livewire/LiveWirePath';
|
|
35
33
|
import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters';
|
|
36
34
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
37
|
-
|
|
38
|
-
const { isEqual } = csUtils;
|
|
35
|
+
import updateContourPolyline from '../../utilities/contours/updateContourPolyline';
|
|
39
36
|
|
|
40
37
|
const CLICK_CLOSE_CURVE_SQR_DIST = 10 ** 2; // px
|
|
41
38
|
|
|
42
39
|
class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
43
40
|
public static toolName: string;
|
|
44
|
-
|
|
41
|
+
protected scissors: LivewireScissors;
|
|
45
42
|
/** The scissors from the right handle, used for editing */
|
|
46
|
-
|
|
43
|
+
protected scissorsRight: LivewireScissors;
|
|
47
44
|
|
|
48
45
|
touchDragCallback: any;
|
|
49
46
|
mouseDragCallback: any;
|
|
@@ -62,6 +59,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
62
59
|
worldToSlice?: (point: Types.Point3) => Types.Point2;
|
|
63
60
|
sliceToWorld?: (point: Types.Point2) => Types.Point3;
|
|
64
61
|
originalPath?: Types.Point3[];
|
|
62
|
+
contourHoleProcessingEnabled?: boolean;
|
|
65
63
|
} | null;
|
|
66
64
|
isDrawing: boolean;
|
|
67
65
|
isHandleOutsideImage = false;
|
|
@@ -72,13 +70,67 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
72
70
|
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
73
71
|
configuration: {
|
|
74
72
|
preventHandleOutsideImage: false,
|
|
73
|
+
/**
|
|
74
|
+
* Specify which modifier key is used to add a hole to a contour. The
|
|
75
|
+
* modifier must be pressed when the first point of a new contour is added.
|
|
76
|
+
*/
|
|
77
|
+
contourHoleAdditionModifierKey: KeyboardBindings.Shift,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Configuring this to a value larger than 0 will snap handles to nearby
|
|
81
|
+
* livewire points, within the given rectangle surrounding the clicked point.
|
|
82
|
+
* If set to 0, then the exact clicked point will be used instead, which may
|
|
83
|
+
* not be an edge and can result in jagged outlines.
|
|
84
|
+
* The unit is image pixels (index).
|
|
85
|
+
*/
|
|
86
|
+
snapHandleNearby: 2,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Interpolation is only available for segmentation versions of these
|
|
90
|
+
* tools. To use it on the segmentation tools, set enabled to true,
|
|
91
|
+
* and create two livewire contours in the same segment index, separated
|
|
92
|
+
* by at least one slice.
|
|
93
|
+
*/
|
|
94
|
+
interpolation: {
|
|
95
|
+
enabled: false,
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Set the nearestEdge to snap interpolated handles to an edge within
|
|
99
|
+
* the given number of pixels. Setting to 0 disables snap to pixel
|
|
100
|
+
* for interpolation and the interpolated point will be used directly.
|
|
101
|
+
* Setting to too large a value may result in many points outside the contour
|
|
102
|
+
* being chosen.
|
|
103
|
+
*/
|
|
104
|
+
nearestEdge: 2,
|
|
105
|
+
/**
|
|
106
|
+
* Set to true to show the interpolated polyline, which can be useful
|
|
107
|
+
* when understanding the nearest edge and
|
|
108
|
+
*/
|
|
109
|
+
showInterpolationPolyline: false,
|
|
110
|
+
},
|
|
111
|
+
actions: {
|
|
112
|
+
undo: {
|
|
113
|
+
method: 'undo',
|
|
114
|
+
bindings: [
|
|
115
|
+
{
|
|
116
|
+
key: 'Escape',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
75
121
|
},
|
|
76
122
|
}
|
|
77
123
|
) {
|
|
78
124
|
super(toolProps, defaultToolProps);
|
|
79
125
|
}
|
|
80
126
|
|
|
81
|
-
protected setupBaseEditData(
|
|
127
|
+
protected setupBaseEditData(
|
|
128
|
+
worldPos,
|
|
129
|
+
element,
|
|
130
|
+
annotation,
|
|
131
|
+
rightPos?,
|
|
132
|
+
contourHoleProcessingEnabled?
|
|
133
|
+
) {
|
|
82
134
|
const enabledElement = getEnabledElement(element);
|
|
83
135
|
const { viewport } = enabledElement;
|
|
84
136
|
|
|
@@ -196,6 +248,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
196
248
|
this.editData?.handleIndex ?? annotation.handles?.activeHandleIndex,
|
|
197
249
|
worldToSlice,
|
|
198
250
|
sliceToWorld,
|
|
251
|
+
contourHoleProcessingEnabled,
|
|
199
252
|
};
|
|
200
253
|
}
|
|
201
254
|
|
|
@@ -214,9 +267,18 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
214
267
|
const { currentPoints, element } = eventDetail;
|
|
215
268
|
const { world: worldPos } = currentPoints;
|
|
216
269
|
const { renderingEngine } = getEnabledElement(element);
|
|
217
|
-
const annotation = this.createAnnotation(evt)
|
|
270
|
+
const annotation = this.createAnnotation(evt);
|
|
271
|
+
const contourHoleProcessingEnabled =
|
|
272
|
+
getMouseModifierKey(evt.detail.event) ===
|
|
273
|
+
this.configuration.contourHoleAdditionModifierKey;
|
|
218
274
|
|
|
219
|
-
this.setupBaseEditData(
|
|
275
|
+
this.setupBaseEditData(
|
|
276
|
+
worldPos,
|
|
277
|
+
element,
|
|
278
|
+
annotation,
|
|
279
|
+
undefined,
|
|
280
|
+
contourHoleProcessingEnabled
|
|
281
|
+
);
|
|
220
282
|
this.addAnnotation(annotation, element);
|
|
221
283
|
|
|
222
284
|
this._activateDraw(element);
|
|
@@ -335,11 +397,19 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
335
397
|
evt.preventDefault();
|
|
336
398
|
};
|
|
337
399
|
|
|
338
|
-
_endCallback = (
|
|
400
|
+
_endCallback = (
|
|
401
|
+
evt: EventTypes.InteractionEventType,
|
|
402
|
+
clearAnnotation = false
|
|
403
|
+
): void => {
|
|
339
404
|
const eventDetail = evt.detail;
|
|
340
405
|
const { element } = eventDetail;
|
|
341
406
|
|
|
342
|
-
const {
|
|
407
|
+
const {
|
|
408
|
+
annotation,
|
|
409
|
+
viewportIdsToRender,
|
|
410
|
+
newAnnotation,
|
|
411
|
+
contourHoleProcessingEnabled,
|
|
412
|
+
} = this.editData;
|
|
343
413
|
const { data } = annotation;
|
|
344
414
|
|
|
345
415
|
data.handles.activeHandleIndex = null;
|
|
@@ -353,21 +423,17 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
353
423
|
const { renderingEngine } = enabledElement;
|
|
354
424
|
|
|
355
425
|
if (
|
|
356
|
-
this.isHandleOutsideImage &&
|
|
357
|
-
|
|
426
|
+
(this.isHandleOutsideImage &&
|
|
427
|
+
this.configuration.preventHandleOutsideImage) ||
|
|
428
|
+
clearAnnotation
|
|
358
429
|
) {
|
|
359
430
|
removeAnnotation(annotation.annotationUID);
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const { worldToSlice } = this.editData;
|
|
365
|
-
if (worldToSlice) {
|
|
366
|
-
reverseIfAntiClockwise(
|
|
367
|
-
data.handles.points.map(worldToSlice),
|
|
368
|
-
data.handles.points,
|
|
369
|
-
data.contour.polyline
|
|
431
|
+
this.clearEditData();
|
|
432
|
+
triggerAnnotationRenderForViewportIds(
|
|
433
|
+
renderingEngine,
|
|
434
|
+
viewportIdsToRender
|
|
370
435
|
);
|
|
436
|
+
return;
|
|
371
437
|
}
|
|
372
438
|
|
|
373
439
|
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
@@ -376,48 +442,21 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
376
442
|
? ChangeTypes.Completed
|
|
377
443
|
: ChangeTypes.HandlesUpdated;
|
|
378
444
|
|
|
379
|
-
this.triggerChangeEvent(
|
|
445
|
+
this.triggerChangeEvent(
|
|
446
|
+
annotation,
|
|
447
|
+
enabledElement,
|
|
448
|
+
changeType,
|
|
449
|
+
contourHoleProcessingEnabled
|
|
450
|
+
);
|
|
451
|
+
this.clearEditData();
|
|
452
|
+
};
|
|
380
453
|
|
|
454
|
+
protected clearEditData() {
|
|
381
455
|
this.editData = null;
|
|
382
456
|
this.scissors = null;
|
|
383
457
|
this.scissorsRight = null;
|
|
384
458
|
this.isDrawing = false;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Triggers an annotation completed event.
|
|
389
|
-
*/
|
|
390
|
-
triggerAnnotationCompleted = (
|
|
391
|
-
annotation: LivewireContourAnnotation
|
|
392
|
-
): void => {
|
|
393
|
-
const eventType = Events.ANNOTATION_COMPLETED;
|
|
394
|
-
const eventDetail: AnnotationCompletedEventDetail = {
|
|
395
|
-
annotation,
|
|
396
|
-
changeType: ChangeTypes.Completed,
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
triggerEvent(eventTarget, eventType, eventDetail);
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Triggers an annotation modified event.
|
|
404
|
-
*/
|
|
405
|
-
triggerAnnotationModified = (
|
|
406
|
-
annotation: LivewireContourAnnotation,
|
|
407
|
-
enabledElement: Types.IEnabledElement,
|
|
408
|
-
changeType = ChangeTypes.StatsUpdated
|
|
409
|
-
): void => {
|
|
410
|
-
const { viewportId, renderingEngineId } = enabledElement;
|
|
411
|
-
const eventType = Events.ANNOTATION_MODIFIED;
|
|
412
|
-
const eventDetail: AnnotationModifiedEventDetail = {
|
|
413
|
-
annotation,
|
|
414
|
-
viewportId,
|
|
415
|
-
renderingEngineId,
|
|
416
|
-
changeType,
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
triggerEvent(eventTarget, eventType, eventDetail);
|
|
420
|
-
};
|
|
459
|
+
}
|
|
421
460
|
|
|
422
461
|
/**
|
|
423
462
|
* Triggers an annotation complete or modified event based on changeType.
|
|
@@ -425,12 +464,20 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
425
464
|
triggerChangeEvent = (
|
|
426
465
|
annotation: LivewireContourAnnotation,
|
|
427
466
|
enabledElement: Types.IEnabledElement,
|
|
428
|
-
changeType = ChangeTypes.StatsUpdated
|
|
467
|
+
changeType = ChangeTypes.StatsUpdated,
|
|
468
|
+
contourHoleProcessingEnabled = false
|
|
429
469
|
): void => {
|
|
430
470
|
if (changeType === ChangeTypes.Completed) {
|
|
431
|
-
|
|
471
|
+
triggerContourAnnotationCompleted(
|
|
472
|
+
annotation,
|
|
473
|
+
contourHoleProcessingEnabled
|
|
474
|
+
);
|
|
432
475
|
} else {
|
|
433
|
-
|
|
476
|
+
triggerAnnotationModified(
|
|
477
|
+
annotation,
|
|
478
|
+
enabledElement.viewport.element,
|
|
479
|
+
changeType
|
|
480
|
+
);
|
|
434
481
|
}
|
|
435
482
|
};
|
|
436
483
|
|
|
@@ -485,25 +532,24 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
485
532
|
}
|
|
486
533
|
}
|
|
487
534
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
this.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
if (smoothPathCount) {
|
|
496
|
-
this.editData.currentPath.removeLastPoints(smoothPathCount);
|
|
497
|
-
annotation.data.contour.polyline.splice(
|
|
498
|
-
annotation.data.contour.polyline.length - smoothPathCount,
|
|
499
|
-
smoothPathCount
|
|
535
|
+
const { snapHandleNearby } = this.configuration;
|
|
536
|
+
// Snap the handles as they get created, but not during edit
|
|
537
|
+
if (snapHandleNearby && !this.editData.closed) {
|
|
538
|
+
const currentPath = new LivewirePath();
|
|
539
|
+
const snapPoint = this.scissors.findMinNearby(
|
|
540
|
+
worldToSlice(worldPosOriginal),
|
|
541
|
+
1
|
|
500
542
|
);
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
543
|
+
const pathPoints = this.scissors.findPathToPoint(snapPoint);
|
|
544
|
+
currentPath.addPoints(pathPoints);
|
|
545
|
+
currentPath.prependPath(this.editData.confirmedPath);
|
|
546
|
+
worldPos = sliceToWorld(snapPoint);
|
|
547
|
+
this.editData.currentPath = currentPath;
|
|
505
548
|
}
|
|
506
549
|
|
|
550
|
+
this.editData.closed = this.editData.closed || closePath;
|
|
551
|
+
this.editData.confirmedPath = this.editData.currentPath;
|
|
552
|
+
|
|
507
553
|
// Add the current cursor position as a new control point after clicking
|
|
508
554
|
const lastPoint = this.editData.currentPath.getLastPoint();
|
|
509
555
|
|
|
@@ -518,7 +564,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
518
564
|
|
|
519
565
|
if (this.editData.closed) {
|
|
520
566
|
// Update the annotation because `editData` will be set to null
|
|
521
|
-
this.
|
|
567
|
+
this.updateAnnotation(this.editData.confirmedPath);
|
|
522
568
|
this._endCallback(evt);
|
|
523
569
|
}
|
|
524
570
|
|
|
@@ -624,7 +670,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
624
670
|
|
|
625
671
|
const { activeHandleIndex } = data.handles;
|
|
626
672
|
if (activeHandleIndex === null || activeHandleIndex === undefined) {
|
|
627
|
-
data.
|
|
673
|
+
data.handles.activeHandleIndex = handleIndex;
|
|
628
674
|
} else if (activeHandleIndex !== handleIndex) {
|
|
629
675
|
throw new Error(
|
|
630
676
|
`Trying to edit a different handle than the one currently being edited ${handleIndex}!==${data.handles.activeHandleIndex}`
|
|
@@ -769,26 +815,23 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
769
815
|
enabledElement: Types.IEnabledElement,
|
|
770
816
|
svgDrawingHelper: SVGDrawingHelper
|
|
771
817
|
): boolean {
|
|
772
|
-
const { viewport } = enabledElement;
|
|
773
|
-
const { element } = viewport;
|
|
774
|
-
|
|
775
818
|
// Update the annotation that is in editData (being edited)
|
|
776
|
-
this.
|
|
819
|
+
this.updateAnnotation(this.editData?.currentPath);
|
|
777
820
|
|
|
778
821
|
return super.renderAnnotation(enabledElement, svgDrawingHelper);
|
|
779
822
|
}
|
|
780
823
|
|
|
781
824
|
protected isContourSegmentationTool(): boolean {
|
|
782
|
-
// Disable contour
|
|
825
|
+
// Disable contour segmentation behavior because it shall be activated only
|
|
783
826
|
// for LivewireContourSegmentationTool
|
|
784
827
|
return false;
|
|
785
828
|
}
|
|
786
829
|
|
|
787
|
-
protected createAnnotation(evt: EventTypes.InteractionEventType)
|
|
830
|
+
protected createAnnotation(evt: EventTypes.InteractionEventType) {
|
|
788
831
|
const contourSegmentationAnnotation = super.createAnnotation(evt);
|
|
789
832
|
const { world: worldPos } = evt.detail.currentPoints;
|
|
790
833
|
|
|
791
|
-
|
|
834
|
+
const annotation = <LivewireContourAnnotation>csUtils.deepMerge(
|
|
792
835
|
contourSegmentationAnnotation,
|
|
793
836
|
{
|
|
794
837
|
data: {
|
|
@@ -798,6 +841,21 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
798
841
|
},
|
|
799
842
|
}
|
|
800
843
|
);
|
|
844
|
+
return annotation;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Clears any in progress edits, mostly used to get rid of accidentally started
|
|
849
|
+
* contours that happen on clicking not quite the right handle point.
|
|
850
|
+
* Eventually this is to be replaced with a proper undo, once that framework
|
|
851
|
+
* is available.
|
|
852
|
+
*/
|
|
853
|
+
public undo(element, config, evt) {
|
|
854
|
+
if (!this.editData) {
|
|
855
|
+
// TODO - proper undo
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
this._endCallback(evt, true);
|
|
801
859
|
}
|
|
802
860
|
|
|
803
861
|
/**
|
|
@@ -808,14 +866,15 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
808
866
|
protected renderAnnotationInstance(renderContext: {
|
|
809
867
|
enabledElement: Types.IEnabledElement;
|
|
810
868
|
targetId: string;
|
|
811
|
-
annotation:
|
|
869
|
+
annotation: LivewireContourAnnotation;
|
|
812
870
|
annotationStyle: Record<string, any>;
|
|
813
871
|
svgDrawingHelper: SVGDrawingHelper;
|
|
814
872
|
}): boolean {
|
|
815
|
-
const { enabledElement, svgDrawingHelper, annotationStyle } =
|
|
873
|
+
const { annotation, enabledElement, svgDrawingHelper, annotationStyle } =
|
|
874
|
+
renderContext;
|
|
875
|
+
|
|
816
876
|
const { viewport } = enabledElement;
|
|
817
877
|
const { worldToCanvas } = viewport;
|
|
818
|
-
const annotation = renderContext.annotation as LivewireContourAnnotation;
|
|
819
878
|
const { annotationUID, data, highlighted } = annotation;
|
|
820
879
|
const { handles } = data;
|
|
821
880
|
const newAnnotation = this.editData?.newAnnotation;
|
|
@@ -851,30 +910,29 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
851
910
|
return true;
|
|
852
911
|
}
|
|
853
912
|
|
|
854
|
-
|
|
855
|
-
element: HTMLDivElement,
|
|
856
|
-
livewirePath: LivewirePath
|
|
857
|
-
) {
|
|
913
|
+
protected updateAnnotation(livewirePath: LivewirePath) {
|
|
858
914
|
if (!this.editData || !livewirePath) {
|
|
859
915
|
return;
|
|
860
916
|
}
|
|
861
917
|
|
|
862
918
|
const { annotation, sliceToWorld } = this.editData;
|
|
919
|
+
let { pointArray: imagePoints } = livewirePath;
|
|
863
920
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
for (let i = 0, len = imagePoints.length; i < len; i++) {
|
|
868
|
-
const imagePoint = imagePoints[i];
|
|
869
|
-
const worldPoint = sliceToWorld(imagePoint);
|
|
870
|
-
worldPolylinePoints.push(worldPoint);
|
|
921
|
+
if (imagePoints.length > 1) {
|
|
922
|
+
imagePoints = [...imagePoints, imagePoints[0]];
|
|
871
923
|
}
|
|
872
924
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
925
|
+
updateContourPolyline(
|
|
926
|
+
annotation,
|
|
927
|
+
{
|
|
928
|
+
points: imagePoints,
|
|
929
|
+
closed: annotation.data.contour.closed,
|
|
930
|
+
targetWindingDirection: ContourWindingDirection.Clockwise,
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
canvasToWorld: sliceToWorld,
|
|
934
|
+
}
|
|
935
|
+
);
|
|
878
936
|
}
|
|
879
937
|
}
|
|
880
938
|
|
|
@@ -46,6 +46,7 @@ import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScale
|
|
|
46
46
|
import { getModalityUnit } from '../../utilities/getModalityUnit';
|
|
47
47
|
import { BasicStatsCalculator } from '../../utilities/math/basic';
|
|
48
48
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
49
|
+
import { KeyboardBindings, ChangeTypes } from '../../enums';
|
|
49
50
|
|
|
50
51
|
const { pointCanProjectOnLine } = polyline;
|
|
51
52
|
const { EPSILON } = CONSTANTS;
|
|
@@ -79,7 +80,7 @@ const PARALLEL_THRESHOLD = 1 - EPSILON;
|
|
|
79
80
|
*
|
|
80
81
|
* The result of smoothing will be removal of some of the outliers
|
|
81
82
|
* Changing tool configuration (see below) you can fine-tune the smoothing process by changing knotsRatioPercentageOnAdd and knotsRatioPercentageOnEdit value, which smaller values produces a more agressive smoothing.
|
|
82
|
-
* A smaller value of knotsRatioPercentageOnAdd/knotsRatioPercentageOnEdit produces a more
|
|
83
|
+
* A smaller value of knotsRatioPercentageOnAdd/knotsRatioPercentageOnEdit produces a more aggressive smoothing.
|
|
83
84
|
*
|
|
84
85
|
* ```js
|
|
85
86
|
* cornerstoneTools.addTool(PlanarFreehandROITool)
|
|
@@ -98,7 +99,7 @@ const PARALLEL_THRESHOLD = 1 - EPSILON;
|
|
|
98
99
|
* ],
|
|
99
100
|
* })
|
|
100
101
|
*
|
|
101
|
-
* // set smoothing
|
|
102
|
+
* // set smoothing aggressiveness while adding new annotation (ps: this does not change if smoothing is ON or OFF)
|
|
102
103
|
* toolGroup.setToolConfiguration(PlanarFreehandROITool.toolName, {
|
|
103
104
|
* smoothing: { knotsRatioPercentageOnAdd: 30 },
|
|
104
105
|
* });
|
|
@@ -177,6 +178,11 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
177
178
|
configuration: {
|
|
178
179
|
shadow: true,
|
|
179
180
|
preventHandleOutsideImage: false,
|
|
181
|
+
/**
|
|
182
|
+
* Specify which modifier key is used to add a hole to a contour. The
|
|
183
|
+
* modifier must be pressed when the first point of a new contour is added.
|
|
184
|
+
*/
|
|
185
|
+
contourHoleAdditionModifierKey: KeyboardBindings.Shift,
|
|
180
186
|
alwaysRenderOpenContourHandles: {
|
|
181
187
|
// When true, always render end points when you have an open contour, rather
|
|
182
188
|
// than just rendering a line.
|
|
@@ -823,7 +829,11 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
823
829
|
};
|
|
824
830
|
}
|
|
825
831
|
|
|
826
|
-
triggerAnnotationModified(
|
|
832
|
+
triggerAnnotationModified(
|
|
833
|
+
annotation,
|
|
834
|
+
enabledElement.element,
|
|
835
|
+
ChangeTypes.StatsUpdated
|
|
836
|
+
);
|
|
827
837
|
|
|
828
838
|
annotation.invalidated = false;
|
|
829
839
|
|