@cornerstonejs/tools 1.48.1 → 1.49.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/enums/AnnotationStyleStates.d.ts +2 -1
- package/dist/cjs/enums/AnnotationStyleStates.js +1 -0
- package/dist/cjs/enums/AnnotationStyleStates.js.map +1 -1
- package/dist/cjs/enums/ChangeTypes.d.ts +8 -0
- package/dist/cjs/enums/ChangeTypes.js +12 -0
- package/dist/cjs/enums/ChangeTypes.js.map +1 -0
- package/dist/cjs/enums/Events.d.ts +2 -0
- package/dist/cjs/enums/Events.js +2 -0
- package/dist/cjs/enums/Events.js.map +1 -1
- package/dist/cjs/enums/index.d.ts +2 -1
- package/dist/cjs/enums/index.js +3 -1
- package/dist/cjs/enums/index.js.map +1 -1
- package/dist/cjs/eventDispatchers/annotationInterpolationEventDispatcher.d.ts +5 -0
- package/dist/cjs/eventDispatchers/annotationInterpolationEventDispatcher.js +23 -0
- package/dist/cjs/eventDispatchers/annotationInterpolationEventDispatcher.js.map +1 -0
- package/dist/cjs/eventDispatchers/index.d.ts +2 -1
- package/dist/cjs/eventDispatchers/index.js +3 -1
- package/dist/cjs/eventDispatchers/index.js.map +1 -1
- package/dist/cjs/init.js +3 -0
- package/dist/cjs/init.js.map +1 -1
- package/dist/cjs/stateManagement/annotation/config/getState.js +3 -0
- package/dist/cjs/stateManagement/annotation/config/getState.js.map +1 -1
- package/dist/cjs/tools/annotation/LivewireContourTool.d.ts +1 -1
- package/dist/cjs/tools/annotation/LivewireContourTool.js +1 -1
- package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js +1 -0
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +2 -2
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +9 -4
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/SplineROITool.d.ts +4 -1
- package/dist/cjs/tools/annotation/SplineROITool.js +68 -34
- package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +12 -3
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +9 -5
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +3 -3
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/base/ContourBaseTool.js +4 -0
- package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -1
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js +21 -9
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourConfig.js +8 -3
- package/dist/cjs/tools/displayTools/Contour/contourConfig.js.map +1 -1
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js +0 -1
- package/dist/cjs/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/cjs/types/AnnotationStyle.d.ts +2 -2
- package/dist/cjs/types/AnnotationTypes.d.ts +1 -0
- package/dist/cjs/types/ContourSegmentationAnnotation.d.ts +1 -0
- package/dist/cjs/types/ContourTypes.d.ts +3 -0
- package/dist/cjs/types/EventTypes.d.ts +19 -1
- package/dist/cjs/types/InterpolationTypes.d.ts +18 -0
- package/dist/cjs/types/InterpolationTypes.js +3 -0
- package/dist/cjs/types/InterpolationTypes.js.map +1 -0
- package/dist/cjs/types/ToolSpecificAnnotationTypes.d.ts +14 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/utilities/contours/PointsArray.d.ts +29 -0
- package/dist/cjs/utilities/contours/PointsArray.js +104 -0
- package/dist/cjs/utilities/contours/PointsArray.js.map +1 -0
- package/dist/cjs/utilities/contours/index.d.ts +3 -1
- package/dist/cjs/utilities/contours/index.js +28 -1
- package/dist/cjs/utilities/contours/index.js.map +1 -1
- package/dist/cjs/utilities/contours/interpolation/acceptAutogeneratedInterpolations.d.ts +3 -0
- package/dist/cjs/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js +11 -0
- package/dist/cjs/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js.map +1 -0
- package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.d.ts +2 -0
- package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.js +39 -0
- package/dist/cjs/utilities/contours/interpolation/createPolylineToolData.js.map +1 -0
- package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.d.ts +7 -0
- package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.js +107 -0
- package/dist/cjs/utilities/contours/interpolation/findAnnotationForInterpolation.js.map +1 -0
- package/dist/cjs/utilities/contours/interpolation/getInterpolationData.d.ts +7 -0
- package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js +30 -0
- package/dist/cjs/utilities/contours/interpolation/getInterpolationData.js.map +1 -0
- package/dist/cjs/utilities/contours/interpolation/getInterpolationDataCollection.d.ts +4 -0
- package/dist/cjs/utilities/contours/interpolation/getInterpolationDataCollection.js +21 -0
- package/dist/cjs/utilities/contours/interpolation/getInterpolationDataCollection.js.map +1 -0
- package/dist/cjs/utilities/contours/interpolation/index.d.ts +2 -0
- package/dist/cjs/utilities/contours/interpolation/index.js +9 -0
- package/dist/cjs/utilities/contours/interpolation/index.js.map +1 -0
- package/dist/cjs/utilities/contours/interpolation/interpolate.d.ts +3 -0
- package/dist/cjs/utilities/contours/interpolation/interpolate.js +343 -0
- package/dist/cjs/utilities/contours/interpolation/interpolate.js.map +1 -0
- package/dist/cjs/utilities/contours/reverseIfAntiClockwise.d.ts +2 -0
- package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js +34 -0
- package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js.map +1 -0
- package/dist/cjs/utilities/getViewportForAnnotation.d.ts +2 -0
- package/dist/cjs/utilities/getViewportForAnnotation.js +19 -0
- package/dist/cjs/utilities/getViewportForAnnotation.js.map +1 -0
- package/dist/cjs/utilities/index.d.ts +2 -1
- package/dist/cjs/utilities/index.js +3 -1
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js +2 -1
- package/dist/cjs/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
- package/dist/cjs/utilities/planarFreehandROITool/index.d.ts +3 -3
- package/dist/cjs/utilities/planarFreehandROITool/index.js +4 -4
- package/dist/cjs/utilities/planarFreehandROITool/index.js.map +1 -1
- package/dist/cjs/utilities/planarFreehandROITool/smoothAnnotation.d.ts +3 -0
- package/dist/cjs/utilities/planarFreehandROITool/{interpolateAnnotation.js → smoothAnnotation.js} +5 -5
- package/dist/cjs/utilities/planarFreehandROITool/smoothAnnotation.js.map +1 -0
- package/dist/cjs/utilities/planarFreehandROITool/{interpolatePoints.d.ts → smoothPoints.d.ts} +1 -1
- package/dist/cjs/utilities/planarFreehandROITool/{interpolatePoints.js → smoothPoints.js} +11 -8
- package/dist/cjs/utilities/planarFreehandROITool/smoothPoints.js.map +1 -0
- package/dist/cjs/utilities/polyData/utils.d.ts +2 -1
- package/dist/cjs/utilities/polyData/utils.js +4 -2
- package/dist/cjs/utilities/polyData/utils.js.map +1 -1
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts +11 -0
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js +159 -0
- package/dist/cjs/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -0
- package/dist/cjs/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.d.ts +2 -0
- package/dist/cjs/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js +96 -0
- package/dist/cjs/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js.map +1 -0
- package/dist/cjs/utilities/triggerAnnotationRenderForViewportIds.js +7 -2
- package/dist/cjs/utilities/triggerAnnotationRenderForViewportIds.js.map +1 -1
- package/dist/esm/enums/AnnotationStyleStates.js +1 -0
- package/dist/esm/enums/AnnotationStyleStates.js.map +1 -1
- package/dist/esm/enums/ChangeTypes.js +10 -0
- package/dist/esm/enums/ChangeTypes.js.map +1 -0
- package/dist/esm/enums/Events.js +2 -0
- package/dist/esm/enums/Events.js.map +1 -1
- package/dist/esm/enums/index.js +2 -1
- package/dist/esm/enums/index.js.map +1 -1
- package/dist/esm/eventDispatchers/annotationInterpolationEventDispatcher.js +18 -0
- package/dist/esm/eventDispatchers/annotationInterpolationEventDispatcher.js.map +1 -0
- package/dist/esm/eventDispatchers/index.js +2 -1
- package/dist/esm/eventDispatchers/index.js.map +1 -1
- package/dist/esm/init.js +3 -0
- package/dist/esm/init.js.map +1 -1
- package/dist/esm/stateManagement/annotation/config/getState.js +3 -0
- package/dist/esm/stateManagement/annotation/config/getState.js.map +1 -1
- package/dist/esm/tools/annotation/LivewireContourTool.js +2 -2
- package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +1 -0
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +9 -4
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/annotation/SplineROITool.js +55 -23
- package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +11 -2
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +8 -4
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +2 -2
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/esm/tools/base/ContourBaseTool.js +4 -0
- package/dist/esm/tools/base/ContourBaseTool.js.map +1 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +12 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/contourConfig.js +8 -3
- package/dist/esm/tools/displayTools/Contour/contourConfig.js.map +1 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +0 -1
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js.map +1 -1
- package/dist/esm/types/InterpolationTypes.js +2 -0
- package/dist/esm/types/InterpolationTypes.js.map +1 -0
- package/dist/esm/utilities/contours/PointsArray.js +98 -0
- package/dist/esm/utilities/contours/PointsArray.js.map +1 -0
- package/dist/esm/utilities/contours/index.js +3 -1
- package/dist/esm/utilities/contours/index.js.map +1 -1
- package/dist/esm/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js +5 -0
- package/dist/esm/utilities/contours/interpolation/acceptAutogeneratedInterpolations.js.map +1 -0
- package/dist/esm/utilities/contours/interpolation/createPolylineToolData.js +36 -0
- package/dist/esm/utilities/contours/interpolation/createPolylineToolData.js.map +1 -0
- package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js +102 -0
- package/dist/esm/utilities/contours/interpolation/findAnnotationForInterpolation.js.map +1 -0
- package/dist/esm/utilities/contours/interpolation/getInterpolationData.js +27 -0
- package/dist/esm/utilities/contours/interpolation/getInterpolationData.js.map +1 -0
- package/dist/esm/utilities/contours/interpolation/getInterpolationDataCollection.js +15 -0
- package/dist/esm/utilities/contours/interpolation/getInterpolationDataCollection.js.map +1 -0
- package/dist/esm/utilities/contours/interpolation/index.js +3 -0
- package/dist/esm/utilities/contours/interpolation/index.js.map +1 -0
- package/dist/esm/utilities/contours/interpolation/interpolate.js +314 -0
- package/dist/esm/utilities/contours/interpolation/interpolate.js.map +1 -0
- package/dist/esm/utilities/contours/reverseIfAntiClockwise.js +31 -0
- package/dist/esm/utilities/contours/reverseIfAntiClockwise.js.map +1 -0
- package/dist/esm/utilities/getViewportForAnnotation.js +16 -0
- package/dist/esm/utilities/getViewportForAnnotation.js.map +1 -0
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js +1 -1
- package/dist/esm/utilities/planar/filterAnnotationsForDisplay.js.map +1 -1
- package/dist/esm/utilities/planarFreehandROITool/index.js +3 -3
- package/dist/esm/utilities/planarFreehandROITool/index.js.map +1 -1
- package/dist/esm/utilities/planarFreehandROITool/{interpolateAnnotation.js → smoothAnnotation.js} +4 -4
- package/dist/esm/utilities/planarFreehandROITool/smoothAnnotation.js.map +1 -0
- package/dist/esm/utilities/planarFreehandROITool/{interpolatePoints.js → smoothPoints.js} +9 -6
- package/dist/esm/utilities/planarFreehandROITool/smoothPoints.js.map +1 -0
- package/dist/esm/utilities/polyData/utils.js +4 -2
- package/dist/esm/utilities/polyData/utils.js.map +1 -1
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +150 -0
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js.map +1 -0
- package/dist/esm/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js +67 -0
- package/dist/esm/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.js.map +1 -0
- package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js +7 -2
- package/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js.map +1 -1
- package/dist/types/enums/AnnotationStyleStates.d.ts +2 -1
- package/dist/types/enums/AnnotationStyleStates.d.ts.map +1 -1
- package/dist/types/enums/ChangeTypes.d.ts +9 -0
- package/dist/types/enums/ChangeTypes.d.ts.map +1 -0
- package/dist/types/enums/Events.d.ts +2 -0
- package/dist/types/enums/Events.d.ts.map +1 -1
- package/dist/types/enums/index.d.ts +2 -1
- package/dist/types/eventDispatchers/annotationInterpolationEventDispatcher.d.ts +6 -0
- package/dist/types/eventDispatchers/annotationInterpolationEventDispatcher.d.ts.map +1 -0
- package/dist/types/eventDispatchers/index.d.ts +2 -1
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/stateManagement/annotation/config/getState.d.ts.map +1 -1
- package/dist/types/tools/annotation/LivewireContourTool.d.ts +1 -1
- package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts +2 -2
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/SplineROITool.d.ts +4 -1
- 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/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/tools/displayTools/Contour/contourDisplay.d.ts.map +1 -1
- package/dist/types/types/AnnotationStyle.d.ts +2 -2
- package/dist/types/types/AnnotationStyle.d.ts.map +1 -1
- package/dist/types/types/AnnotationTypes.d.ts +1 -0
- package/dist/types/types/AnnotationTypes.d.ts.map +1 -1
- package/dist/types/types/ContourSegmentationAnnotation.d.ts +1 -0
- package/dist/types/types/ContourSegmentationAnnotation.d.ts.map +1 -1
- package/dist/types/types/ContourTypes.d.ts +3 -0
- package/dist/types/types/ContourTypes.d.ts.map +1 -1
- package/dist/types/types/EventTypes.d.ts +19 -1
- package/dist/types/types/EventTypes.d.ts.map +1 -1
- package/dist/types/types/InterpolationTypes.d.ts +19 -0
- package/dist/types/types/InterpolationTypes.d.ts.map +1 -0
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts +14 -0
- package/dist/types/types/ToolSpecificAnnotationTypes.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utilities/contours/PointsArray.d.ts +30 -0
- package/dist/types/utilities/contours/PointsArray.d.ts.map +1 -0
- package/dist/types/utilities/contours/index.d.ts +3 -1
- package/dist/types/utilities/contours/index.d.ts.map +1 -1
- package/dist/types/utilities/contours/interpolation/acceptAutogeneratedInterpolations.d.ts +4 -0
- package/dist/types/utilities/contours/interpolation/acceptAutogeneratedInterpolations.d.ts.map +1 -0
- package/dist/types/utilities/contours/interpolation/createPolylineToolData.d.ts +3 -0
- package/dist/types/utilities/contours/interpolation/createPolylineToolData.d.ts.map +1 -0
- package/dist/types/utilities/contours/interpolation/findAnnotationForInterpolation.d.ts +8 -0
- package/dist/types/utilities/contours/interpolation/findAnnotationForInterpolation.d.ts.map +1 -0
- package/dist/types/utilities/contours/interpolation/getInterpolationData.d.ts +8 -0
- package/dist/types/utilities/contours/interpolation/getInterpolationData.d.ts.map +1 -0
- package/dist/types/utilities/contours/interpolation/getInterpolationDataCollection.d.ts +5 -0
- package/dist/types/utilities/contours/interpolation/getInterpolationDataCollection.d.ts.map +1 -0
- package/dist/types/utilities/contours/interpolation/index.d.ts +3 -0
- package/dist/types/utilities/contours/interpolation/index.d.ts.map +1 -0
- package/dist/types/utilities/contours/interpolation/interpolate.d.ts +4 -0
- package/dist/types/utilities/contours/interpolation/interpolate.d.ts.map +1 -0
- package/dist/types/utilities/contours/reverseIfAntiClockwise.d.ts +3 -0
- package/dist/types/utilities/contours/reverseIfAntiClockwise.d.ts.map +1 -0
- package/dist/types/utilities/getViewportForAnnotation.d.ts +3 -0
- package/dist/types/utilities/getViewportForAnnotation.d.ts.map +1 -0
- package/dist/types/utilities/index.d.ts +2 -1
- package/dist/types/utilities/index.d.ts.map +1 -1
- package/dist/types/utilities/planar/filterAnnotationsForDisplay.d.ts.map +1 -1
- package/dist/types/utilities/planarFreehandROITool/index.d.ts +3 -3
- package/dist/types/utilities/planarFreehandROITool/index.d.ts.map +1 -1
- package/dist/types/utilities/planarFreehandROITool/smoothAnnotation.d.ts +4 -0
- package/dist/types/utilities/planarFreehandROITool/smoothAnnotation.d.ts.map +1 -0
- package/dist/types/utilities/planarFreehandROITool/{interpolatePoints.d.ts → smoothPoints.d.ts} +2 -2
- package/dist/types/utilities/planarFreehandROITool/smoothPoints.d.ts.map +1 -0
- package/dist/types/utilities/polyData/utils.d.ts +2 -1
- package/dist/types/utilities/polyData/utils.d.ts.map +1 -1
- package/dist/types/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts +12 -0
- package/dist/types/utilities/segmentation/InterpolationManager/InterpolationManager.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.d.ts +3 -0
- package/dist/types/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.d.ts.map +1 -0
- package/dist/types/utilities/triggerAnnotationRenderForViewportIds.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/enums/AnnotationStyleStates.ts +3 -0
- package/src/enums/ChangeTypes.ts +32 -0
- package/src/enums/Events.ts +16 -0
- package/src/enums/index.js +2 -0
- package/src/eventDispatchers/annotationInterpolationEventDispatcher.ts +42 -0
- package/src/eventDispatchers/index.js +2 -0
- package/src/init.ts +3 -0
- package/src/stateManagement/annotation/config/getState.ts +16 -2
- package/src/tools/annotation/LivewireContourTool.ts +3 -8
- package/src/tools/annotation/PlanarFreehandContourSegmentationTool.ts +6 -0
- package/src/tools/annotation/PlanarFreehandROITool.ts +47 -25
- package/src/tools/annotation/SplineROITool.ts +91 -29
- package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +15 -3
- package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +10 -6
- package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +3 -3
- package/src/tools/base/ContourBaseTool.ts +4 -0
- package/src/tools/base/ContourSegmentationBaseTool.ts +11 -1
- package/src/tools/displayTools/Contour/contourConfig.ts +8 -3
- package/src/tools/displayTools/Contour/contourDisplay.ts +1 -3
- package/src/types/AnnotationStyle.ts +3 -1
- package/src/types/AnnotationTypes.ts +2 -0
- package/src/types/ContourSegmentationAnnotation.ts +1 -0
- package/src/types/ContourTypes.ts +8 -0
- package/src/types/EventTypes.ts +43 -0
- package/src/types/InterpolationTypes.ts +42 -0
- package/src/types/ToolSpecificAnnotationTypes.ts +15 -0
- package/src/types/index.ts +6 -0
- package/src/utilities/contours/PointsArray.ts +165 -0
- package/src/utilities/contours/index.ts +4 -1
- package/src/utilities/contours/interpolation/acceptAutogeneratedInterpolations.ts +16 -0
- package/src/utilities/contours/interpolation/createPolylineToolData.ts +56 -0
- package/src/utilities/contours/interpolation/findAnnotationForInterpolation.ts +225 -0
- package/src/utilities/contours/interpolation/getInterpolationData.ts +75 -0
- package/src/utilities/contours/interpolation/getInterpolationDataCollection.ts +31 -0
- package/src/utilities/contours/interpolation/index.ts +3 -0
- package/src/utilities/contours/interpolation/interpolate.ts +695 -0
- package/src/utilities/contours/reverseIfAntiClockwise.ts +50 -0
- package/src/utilities/getViewportForAnnotation.ts +29 -0
- package/src/utilities/index.ts +2 -0
- package/src/utilities/livewire/LivewireScissors.ts +1 -1
- package/src/utilities/planar/filterAnnotationsForDisplay.ts +6 -1
- package/src/utilities/planarFreehandROITool/index.ts +3 -3
- package/src/utilities/planarFreehandROITool/{interpolateAnnotation.ts → smoothAnnotation.ts} +5 -3
- package/src/utilities/planarFreehandROITool/{interpolatePoints.ts → smoothPoints.ts} +12 -6
- package/src/utilities/polyData/utils.ts +12 -5
- package/src/utilities/segmentation/InterpolationManager/InterpolationManager.ts +207 -0
- package/src/utilities/segmentation/InterpolationManager/deleteRelatedAnnotations.ts +97 -0
- package/src/utilities/triggerAnnotationRenderForViewportIds.ts +7 -2
- package/dist/cjs/utilities/planarFreehandROITool/interpolateAnnotation.d.ts +0 -3
- package/dist/cjs/utilities/planarFreehandROITool/interpolateAnnotation.js.map +0 -1
- package/dist/cjs/utilities/planarFreehandROITool/interpolatePoints.js.map +0 -1
- package/dist/esm/utilities/planarFreehandROITool/interpolateAnnotation.js.map +0 -1
- package/dist/esm/utilities/planarFreehandROITool/interpolatePoints.js.map +0 -1
- package/dist/types/utilities/planarFreehandROITool/interpolateAnnotation.d.ts +0 -4
- package/dist/types/utilities/planarFreehandROITool/interpolateAnnotation.d.ts.map +0 -1
- package/dist/types/utilities/planarFreehandROITool/interpolatePoints.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.0",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@cornerstonejs/core": "^1.
|
|
32
|
+
"@cornerstonejs/core": "^1.49.0",
|
|
33
33
|
"comlink": "^4.4.1",
|
|
34
34
|
"lodash.clonedeep": "4.5.0",
|
|
35
35
|
"lodash.get": "^4.4.2"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"type": "individual",
|
|
54
54
|
"url": "https://ohif.org/donate"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "718c297a32f861b3ecc4500e0da07ba6ecf4d589"
|
|
57
57
|
}
|
|
@@ -11,12 +11,15 @@
|
|
|
11
11
|
* The annotation has been selected by the user;
|
|
12
12
|
* Locked:
|
|
13
13
|
* The annotation has been locked;
|
|
14
|
+
* AutoGenerated:
|
|
15
|
+
* The annotation has been auto generated;
|
|
14
16
|
*/
|
|
15
17
|
enum AnnotationStyleStates {
|
|
16
18
|
Default = '',
|
|
17
19
|
Highlighted = 'Highlighted',
|
|
18
20
|
Selected = 'Selected',
|
|
19
21
|
Locked = 'Locked',
|
|
22
|
+
AutoGenerated = 'AutoGenerated',
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export default AnnotationStyleStates;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChangeTypes defines the types of changes occurring on annotation and
|
|
3
|
+
* segmentation data.
|
|
4
|
+
*/
|
|
5
|
+
enum ChangeTypes {
|
|
6
|
+
/**
|
|
7
|
+
* Interaction events are done when the user is actively interacting with
|
|
8
|
+
* an annotation, and probably means the event shouldn't be handled/used.
|
|
9
|
+
*/
|
|
10
|
+
Interaction = 'Interaction',
|
|
11
|
+
/**
|
|
12
|
+
* HandlesUpdated occurs when the handle data is added or removed, or moved around
|
|
13
|
+
*/
|
|
14
|
+
HandlesUpdated = 'HandlesUpdated',
|
|
15
|
+
/**
|
|
16
|
+
* StatsUpdated occurs when the stats are updated/calculated. This can be used
|
|
17
|
+
* to ignore stats calculations changes occurring on initial load, while still
|
|
18
|
+
* rendering other updates.
|
|
19
|
+
*/
|
|
20
|
+
StatsUpdated = 'StatsUpdated',
|
|
21
|
+
/**
|
|
22
|
+
* InitialSetup occurs when an annotation has been created initially and
|
|
23
|
+
* has the first render/data calculation being applied.
|
|
24
|
+
*/
|
|
25
|
+
InitialSetup = 'InitialSetup',
|
|
26
|
+
/**
|
|
27
|
+
* Completed occurs only for the annotation completed event, just to identify it
|
|
28
|
+
*/
|
|
29
|
+
Completed = 'Completed',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ChangeTypes;
|
package/src/enums/Events.ts
CHANGED
|
@@ -96,6 +96,22 @@ enum Events {
|
|
|
96
96
|
*/
|
|
97
97
|
ANNOTATION_RENDERED = 'CORNERSTONE_TOOLS_ANNOTATION_RENDERED',
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Triggers on the eventTarget when an annotation interpolation process completed.
|
|
101
|
+
* Make use of {@link EventTypes.AnnotationInterpolationCompletedEventType | Annotation Interpolation process Completed Event Type}
|
|
102
|
+
* for typing your event listeners for this annotation interpolation complete event, and see what
|
|
103
|
+
* event detail is included in {@link EventTypes.AnnotationInterpolationCompletedEventDetail | Annotation interpolation process Event Detail}.
|
|
104
|
+
*/
|
|
105
|
+
ANNOTATION_INTERPOLATION_PROCESS_COMPLETED = 'CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED',
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Triggers on the eventTarget when interpolated annotations are removed.
|
|
109
|
+
* Make use of {@link EventTypes.AnnotationInterpolationRemovedEventType | Annotation Interpolation Removed Event Type}
|
|
110
|
+
* for typing your event listeners for this interpolated annotation removed event, and see what
|
|
111
|
+
* event detail is included in {@link EventTypes.AnnotationInterpolationRemovedEventDetail | Annotation interpolation removed Event Detail}.
|
|
112
|
+
*/
|
|
113
|
+
INTERPOLATED_ANNOTATIONS_REMOVED = 'CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED',
|
|
114
|
+
|
|
99
115
|
///////////////////////////////////////
|
|
100
116
|
// Segmentations Events
|
|
101
117
|
///////////////////////////////////////
|
package/src/enums/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import Events from './Events';
|
|
|
5
5
|
import SegmentationRepresentations from './SegmentationRepresentations';
|
|
6
6
|
import { Swipe } from './Touch';
|
|
7
7
|
import StrategyCallbacks from './StrategyCallbacks';
|
|
8
|
+
import ChangeTypes from './ChangeTypes';
|
|
8
9
|
|
|
9
10
|
export {
|
|
10
11
|
MouseBindings,
|
|
@@ -15,4 +16,5 @@ export {
|
|
|
15
16
|
SegmentationRepresentations,
|
|
16
17
|
Swipe,
|
|
17
18
|
StrategyCallbacks,
|
|
19
|
+
ChangeTypes,
|
|
18
20
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { eventTarget } from '@cornerstonejs/core';
|
|
2
|
+
import Events from '../enums/Events';
|
|
3
|
+
import InterpolationManager from '../utilities/segmentation/InterpolationManager/InterpolationManager';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The enable and disable add/remove the event listeners that dispatch the
|
|
7
|
+
* required events to the interpolation manager.
|
|
8
|
+
*/
|
|
9
|
+
const enable = function () {
|
|
10
|
+
eventTarget.addEventListener(
|
|
11
|
+
Events.ANNOTATION_COMPLETED,
|
|
12
|
+
InterpolationManager.handleAnnotationCompleted as EventListener
|
|
13
|
+
);
|
|
14
|
+
eventTarget.addEventListener(
|
|
15
|
+
Events.ANNOTATION_MODIFIED,
|
|
16
|
+
InterpolationManager.handleAnnotationUpdate as EventListener
|
|
17
|
+
);
|
|
18
|
+
eventTarget.addEventListener(
|
|
19
|
+
Events.ANNOTATION_REMOVED,
|
|
20
|
+
InterpolationManager.handleAnnotationDelete as EventListener
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const disable = function () {
|
|
25
|
+
eventTarget.removeEventListener(
|
|
26
|
+
Events.ANNOTATION_COMPLETED,
|
|
27
|
+
InterpolationManager.handleAnnotationCompleted as EventListener
|
|
28
|
+
);
|
|
29
|
+
eventTarget.removeEventListener(
|
|
30
|
+
Events.ANNOTATION_MODIFIED,
|
|
31
|
+
InterpolationManager.handleAnnotationUpdate as EventListener
|
|
32
|
+
);
|
|
33
|
+
eventTarget.removeEventListener(
|
|
34
|
+
Events.ANNOTATION_REMOVED,
|
|
35
|
+
InterpolationManager.handleAnnotationDelete as EventListener
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
enable,
|
|
41
|
+
disable,
|
|
42
|
+
};
|
|
@@ -4,6 +4,7 @@ import keyboardToolEventDispatcher from './keyboardToolEventDispatcher';
|
|
|
4
4
|
import cameraModifiedEventDispatcher from './cameraModifiedEventDispatcher';
|
|
5
5
|
import imageSpacingCalibratedEventDispatcher from './imageSpacingCalibratedEventDispatcher';
|
|
6
6
|
import touchToolEventDispatcher from './touchToolEventDispatcher';
|
|
7
|
+
import annotationInterpolationEventDispatcher from './annotationInterpolationEventDispatcher';
|
|
7
8
|
|
|
8
9
|
export {
|
|
9
10
|
imageRenderedEventDispatcher,
|
|
@@ -12,4 +13,5 @@ export {
|
|
|
12
13
|
cameraModifiedEventDispatcher,
|
|
13
14
|
imageSpacingCalibratedEventDispatcher,
|
|
14
15
|
touchToolEventDispatcher,
|
|
16
|
+
annotationInterpolationEventDispatcher,
|
|
15
17
|
};
|
package/src/init.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
segmentationModifiedListener,
|
|
13
13
|
annotationModifiedListener,
|
|
14
14
|
} from './eventListeners';
|
|
15
|
+
import { annotationInterpolationEventDispatcher } from './eventDispatchers';
|
|
15
16
|
|
|
16
17
|
import * as ToolGroupManager from './store/ToolGroupManager';
|
|
17
18
|
|
|
@@ -74,6 +75,7 @@ function _addCornerstoneEventListeners(): void {
|
|
|
74
75
|
|
|
75
76
|
eventTarget.addEventListener(elementEnabledEvent, addEnabledElement);
|
|
76
77
|
eventTarget.addEventListener(elementDisabledEvent, removeEnabledElement);
|
|
78
|
+
annotationInterpolationEventDispatcher.enable();
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
/**
|
|
@@ -87,6 +89,7 @@ function _removeCornerstoneEventListeners(): void {
|
|
|
87
89
|
|
|
88
90
|
eventTarget.removeEventListener(elementEnabledEvent, addEnabledElement);
|
|
89
91
|
eventTarget.removeEventListener(elementDisabledEvent, removeEnabledElement);
|
|
92
|
+
annotationInterpolationEventDispatcher.disable();
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
/**
|
|
@@ -5,9 +5,19 @@ import { AnnotationStyleStates } from '../../../enums';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Given a Annotation object, return the annotationStyle State that it
|
|
8
|
-
* should be in based on its data
|
|
8
|
+
* should be in based on its data.
|
|
9
|
+
* The ordering of states is:
|
|
10
|
+
* * Highlighted
|
|
11
|
+
* * Selected
|
|
12
|
+
* * Locked
|
|
13
|
+
* * Autogenerated
|
|
14
|
+
* * Default
|
|
15
|
+
* So the first one that applies will be returned.
|
|
16
|
+
* For the autogenerated state, it depends on the autoGenerated flag on the
|
|
17
|
+
* annotation, so once that is gone/false, the annotation will go to default.
|
|
18
|
+
*
|
|
9
19
|
* @param annotation - The annotation that we want to style.
|
|
10
|
-
* @returns The state of the annotation whether it is Default, Highlighted, Locked, or
|
|
20
|
+
* @returns The state of the annotation whether it is Default, Highlighted, Locked, Selected, or AutoGenerated.
|
|
11
21
|
*/
|
|
12
22
|
function getState(annotation?: Annotation): AnnotationStyleStates {
|
|
13
23
|
if (annotation) {
|
|
@@ -22,6 +32,10 @@ function getState(annotation?: Annotation): AnnotationStyleStates {
|
|
|
22
32
|
if (isAnnotationLocked(annotation)) {
|
|
23
33
|
return AnnotationStyleStates.Locked;
|
|
24
34
|
}
|
|
35
|
+
|
|
36
|
+
if (annotation.data && annotation.autoGenerated) {
|
|
37
|
+
return AnnotationStyleStates.AutoGenerated;
|
|
38
|
+
}
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
return AnnotationStyleStates.Default;
|
|
@@ -11,9 +11,9 @@ import type { Types } from '@cornerstonejs/core';
|
|
|
11
11
|
import { removeAnnotation } from '../../stateManagement/annotation/annotationState';
|
|
12
12
|
import { drawHandles as drawHandlesSvg } from '../../drawingSvg';
|
|
13
13
|
import { state } from '../../store';
|
|
14
|
-
import { Events } from '../../enums';
|
|
14
|
+
import { Events, ChangeTypes } from '../../enums';
|
|
15
15
|
import { resetElementCursor } from '../../cursors/elementCursor';
|
|
16
|
-
import {
|
|
16
|
+
import type {
|
|
17
17
|
Annotation,
|
|
18
18
|
EventTypes,
|
|
19
19
|
ToolHandle,
|
|
@@ -89,12 +89,6 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
89
89
|
|
|
90
90
|
this.isDrawing = true;
|
|
91
91
|
|
|
92
|
-
const defaultActor = viewport.getDefaultActor();
|
|
93
|
-
|
|
94
|
-
// if (!defaultActor || !csUtils.isImageActor(defaultActor)) {
|
|
95
|
-
// throw new Error('Default actor must be an image actor');
|
|
96
|
-
// }
|
|
97
|
-
|
|
98
92
|
const viewportImageData = viewport.getImageData();
|
|
99
93
|
const { imageData: vtkImageData } = viewportImageData;
|
|
100
94
|
let worldToSlice: (point: Types.Point3) => Types.Point2;
|
|
@@ -337,6 +331,7 @@ class LivewireContourTool extends ContourSegmentationBaseTool {
|
|
|
337
331
|
const eventType = Events.ANNOTATION_COMPLETED;
|
|
338
332
|
const eventDetail: AnnotationCompletedEventDetail = {
|
|
339
333
|
annotation,
|
|
334
|
+
changeType: ChangeTypes.Completed,
|
|
340
335
|
};
|
|
341
336
|
|
|
342
337
|
triggerEvent(eventTarget, eventType, eventDetail);
|
|
@@ -10,6 +10,12 @@ class PlanarFreehandContourSegmentationTool extends PlanarFreehandROITool {
|
|
|
10
10
|
{
|
|
11
11
|
configuration: {
|
|
12
12
|
calculateStats: false,
|
|
13
|
+
/**
|
|
14
|
+
* Allow open contours false means to not allow a final/complete
|
|
15
|
+
* annotation to be done as an open contour. This does not mean
|
|
16
|
+
* that the contour won't be open during creation.
|
|
17
|
+
*/
|
|
18
|
+
allowOpenContours: false,
|
|
13
19
|
},
|
|
14
20
|
},
|
|
15
21
|
toolProps
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
AnnotationCompletedEventDetail,
|
|
31
31
|
AnnotationModifiedEventDetail,
|
|
32
32
|
} from '../../types/EventTypes';
|
|
33
|
-
import {
|
|
33
|
+
import type {
|
|
34
34
|
EventTypes,
|
|
35
35
|
ToolHandle,
|
|
36
36
|
Annotation,
|
|
@@ -68,23 +68,23 @@ const PARALLEL_THRESHOLD = 1 - EPSILON;
|
|
|
68
68
|
* or similar methods.
|
|
69
69
|
*
|
|
70
70
|
* PlanarFreehandROITool annotation can be smoothed on drawing completion. This is a configured based approach.
|
|
71
|
-
* The
|
|
72
|
-
* -
|
|
73
|
-
* -
|
|
74
|
-
* -
|
|
75
|
-
* -
|
|
71
|
+
* The smoothing process uses b-spline algorithm and consider 4 configurations properties:
|
|
72
|
+
* - smoothing.smoothOnAdd: to tell whether it should be smoothed or not (for editing it is considered the property smoothOnEdit) (default: false)
|
|
73
|
+
* - smoothing.smoothOnEdit: to tell whether it should be smoothed or not when editing (default: false)
|
|
74
|
+
* - smoothing.knotsRatioPercentageOnAdd: percentage of points from Segment that are likely to be considered knots during smoothing (for editing it is considered the property knotsRatioPercentageOnEdit) ( default: 40)
|
|
75
|
+
* - smoothing.knotsRatioPercentageOnEdit: same as knotsRatioPercentageOnAdd but applicable only when editing the tool (default: 40)
|
|
76
76
|
*
|
|
77
|
-
* So, with that said the
|
|
78
|
-
* - drawing is done (i.e mouse is released) and
|
|
79
|
-
* - edit drawing is done (i.e mouse is released) and
|
|
80
|
-
*
|
|
81
|
-
* -
|
|
82
|
-
* -
|
|
77
|
+
* So, with that said the smoothing might occur when:
|
|
78
|
+
* - drawing is done (i.e mouse is released) and smoothing.smoothOnAdd is true. smoothing algorithm uses knotsRatioPercentageOnAdd
|
|
79
|
+
* - edit drawing is done (i.e mouse is released) and smoothing.smoothOnEdit is true. smoothing algorithm uses knotsRatioPercentageOnEdit and its only applied to changed segment
|
|
80
|
+
* smoothing does not occur when:
|
|
81
|
+
* - smoothing.smoothOnAdd is false and drawing is completed
|
|
82
|
+
* - smoothing.smoothOnEdit is false and edit is completed
|
|
83
83
|
* - drawing still happening (editing or not)
|
|
84
84
|
*
|
|
85
|
-
* The result of
|
|
86
|
-
* Changing tool configuration (see below) you can fine-tune the
|
|
87
|
-
* A smaller value of knotsRatioPercentageOnAdd/knotsRatioPercentageOnEdit produces a more agressive
|
|
85
|
+
* The result of smoothing will be removal of some of the outliers
|
|
86
|
+
* 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.
|
|
87
|
+
* A smaller value of knotsRatioPercentageOnAdd/knotsRatioPercentageOnEdit produces a more agressive smoothing.
|
|
88
88
|
*
|
|
89
89
|
* ```js
|
|
90
90
|
* cornerstoneTools.addTool(PlanarFreehandROITool)
|
|
@@ -103,14 +103,14 @@ const PARALLEL_THRESHOLD = 1 - EPSILON;
|
|
|
103
103
|
* ],
|
|
104
104
|
* })
|
|
105
105
|
*
|
|
106
|
-
* // set
|
|
106
|
+
* // set smoothing agressiveness while adding new annotation (ps: this does not change if smoothing is ON or OFF)
|
|
107
107
|
* toolGroup.setToolConfiguration(PlanarFreehandROITool.toolName, {
|
|
108
|
-
*
|
|
108
|
+
* smoothing: { knotsRatioPercentageOnAdd: 30 },
|
|
109
109
|
* });
|
|
110
110
|
*
|
|
111
|
-
* // set
|
|
111
|
+
* // set smoothing to be ON while editing only
|
|
112
112
|
* toolGroup.setToolConfiguration(PlanarFreehandROITool.toolName, {
|
|
113
|
-
*
|
|
113
|
+
* smoothing: { smoothOnAdd: false, smoothOnEdit: true },
|
|
114
114
|
* });
|
|
115
115
|
* ```
|
|
116
116
|
*
|
|
@@ -129,7 +129,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
129
129
|
isEditingClosed = false;
|
|
130
130
|
isEditingOpen = false;
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
protected activateDraw: (
|
|
133
133
|
evt: EventTypes.InteractionEventType,
|
|
134
134
|
annotation: PlanarFreehandROIAnnotation,
|
|
135
135
|
viewportIdsToRender: string[]
|
|
@@ -195,19 +195,41 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
195
195
|
// The proximity at which we fallback to the simplest grabbing logic for
|
|
196
196
|
// determining what index of the contour to start editing.
|
|
197
197
|
checkCanvasEditFallbackProximity: 6,
|
|
198
|
+
// For closed contours, make them clockwise
|
|
199
|
+
// This can be useful if contours are compared between slices, eg for
|
|
200
|
+
// interpolation, and does not cause problems otherwise so defaulting to true.
|
|
201
|
+
makeClockWise: true,
|
|
198
202
|
// The relative distance that points should be dropped along the polyline
|
|
199
203
|
// in units of the image pixel spacing. A value of 1 means that nodes must
|
|
200
204
|
// be placed no closed than the image spacing apart. A value of 4 means that 4
|
|
201
205
|
// nodes should be placed within the space of one image pixel size. A higher
|
|
202
|
-
// value gives more
|
|
206
|
+
// value gives more finesse to the tool/smoother lines, but the value cannot
|
|
203
207
|
// be infinite as the lines become very computationally expensive to draw.
|
|
204
208
|
subPixelResolution: 4,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Smoothing is used to remove jagged irregularities in the polyline,
|
|
211
|
+
* as opposed to interpolation, which is used to create new polylines
|
|
212
|
+
* between existing polylines.
|
|
213
|
+
*/
|
|
214
|
+
smoothing: {
|
|
215
|
+
smoothOnAdd: false,
|
|
216
|
+
smoothOnEdit: false, // used for edit only
|
|
208
217
|
knotsRatioPercentageOnAdd: 40,
|
|
209
218
|
knotsRatioPercentageOnEdit: 40,
|
|
210
219
|
},
|
|
220
|
+
/**
|
|
221
|
+
* Interpolation is the creation of new segmentations in between the
|
|
222
|
+
* existing segmentations/indices. Note that this does not apply to
|
|
223
|
+
* ROI values, since those annotations are individual annotations, not
|
|
224
|
+
* connected in any way to each other, whereas segmentations are intended
|
|
225
|
+
* to be connected 2d + 1 dimension (time or space or other) volumes.
|
|
226
|
+
*/
|
|
227
|
+
interpolation: {
|
|
228
|
+
enabled: false,
|
|
229
|
+
// Callback to update the annotation or perform other action when the
|
|
230
|
+
// interpolation is complete.
|
|
231
|
+
onInterpolationComplete: null,
|
|
232
|
+
},
|
|
211
233
|
calculateStats: false,
|
|
212
234
|
getTextLines: defaultGetTextLines,
|
|
213
235
|
statsCalculator: BasicStatsCalculator,
|
|
@@ -916,7 +938,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
|
|
|
916
938
|
function defaultGetTextLines(data, targetId): string[] {
|
|
917
939
|
const cachedVolumeStats = data.cachedStats[targetId];
|
|
918
940
|
const { area, mean, stdDev, max, isEmptyArea, areaUnit, modalityUnit } =
|
|
919
|
-
cachedVolumeStats;
|
|
941
|
+
cachedVolumeStats || {};
|
|
920
942
|
|
|
921
943
|
const textLines: string[] = [];
|
|
922
944
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { utilities } from '@cornerstonejs/core';
|
|
2
1
|
import {
|
|
3
2
|
getEnabledElement,
|
|
4
3
|
eventTarget,
|
|
5
4
|
triggerEvent,
|
|
5
|
+
utilities,
|
|
6
6
|
} from '@cornerstonejs/core';
|
|
7
7
|
import type { Types } from '@cornerstonejs/core';
|
|
8
8
|
import { vec3 } from 'gl-matrix';
|
|
@@ -13,7 +13,12 @@ import {
|
|
|
13
13
|
drawLinkedTextBox as drawLinkedTextBoxSvg,
|
|
14
14
|
} from '../../drawingSvg';
|
|
15
15
|
import { state } from '../../store';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
Events,
|
|
18
|
+
MouseBindings,
|
|
19
|
+
KeyboardBindings,
|
|
20
|
+
ChangeTypes,
|
|
21
|
+
} from '../../enums';
|
|
17
22
|
import { resetElementCursor } from '../../cursors/elementCursor';
|
|
18
23
|
import {
|
|
19
24
|
Annotation,
|
|
@@ -36,16 +41,14 @@ import { getViewportIdsWithToolToRender } from '../../utilities/viewportFilters'
|
|
|
36
41
|
import { getTextBoxCoordsCanvas } from '../../utilities/drawing';
|
|
37
42
|
|
|
38
43
|
import { SplineROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
|
|
39
|
-
import {
|
|
40
|
-
AnnotationCompletedEventDetail,
|
|
41
|
-
AnnotationModifiedEventDetail,
|
|
42
|
-
} from '../../types/EventTypes';
|
|
44
|
+
import { AnnotationModifiedEventDetail } from '../../types/EventTypes';
|
|
43
45
|
import { ISpline } from '../../types/ISpline';
|
|
44
46
|
import { CardinalSpline } from './splines/CardinalSpline';
|
|
45
47
|
import { LinearSpline } from './splines/LinearSpline';
|
|
46
48
|
import { CatmullRomSpline } from './splines/CatmullRomSpline';
|
|
47
49
|
import { BSpline } from './splines/BSpline';
|
|
48
50
|
import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
|
|
51
|
+
import reverseIfAntiClockwise from '../../utilities/contours/reverseIfAntiClockwise';
|
|
49
52
|
|
|
50
53
|
const SPLINE_MIN_POINTS = 3;
|
|
51
54
|
const SPLINE_CLICK_CLOSE_CURVE_DIST = 10;
|
|
@@ -90,6 +93,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
90
93
|
} | null;
|
|
91
94
|
isDrawing: boolean;
|
|
92
95
|
isHandleOutsideImage = false;
|
|
96
|
+
fireChangeOnUpdate: ChangeTypes = null;
|
|
93
97
|
|
|
94
98
|
constructor(
|
|
95
99
|
toolProps: PublicToolProps = {},
|
|
@@ -295,6 +299,7 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
295
299
|
|
|
296
300
|
const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
|
|
297
301
|
const { data } = annotation;
|
|
302
|
+
annotation.autoGenerated = false;
|
|
298
303
|
|
|
299
304
|
data.handles.activeHandleIndex = null;
|
|
300
305
|
|
|
@@ -305,6 +310,16 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
305
310
|
const enabledElement = getEnabledElement(element);
|
|
306
311
|
const { renderingEngine } = enabledElement;
|
|
307
312
|
|
|
313
|
+
// Decide whether there's at least one point is outside image
|
|
314
|
+
const image = this.getTargetIdImage(
|
|
315
|
+
this.getTargetId(enabledElement.viewport),
|
|
316
|
+
enabledElement.renderingEngine
|
|
317
|
+
);
|
|
318
|
+
const { imageData, dimensions } = image;
|
|
319
|
+
this.isHandleOutsideImage = data.handles.points
|
|
320
|
+
.map((p) => utilities.transformWorldToIndex(imageData, p))
|
|
321
|
+
.some((index) => !utilities.indexWithinDimensions(index, dimensions));
|
|
322
|
+
|
|
308
323
|
if (
|
|
309
324
|
this.isHandleOutsideImage &&
|
|
310
325
|
this.configuration.preventHandleOutsideImage
|
|
@@ -312,17 +327,11 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
312
327
|
removeAnnotation(annotation.annotationUID);
|
|
313
328
|
}
|
|
314
329
|
|
|
330
|
+
this.fireChangeOnUpdate ||= newAnnotation
|
|
331
|
+
? ChangeTypes.Completed
|
|
332
|
+
: ChangeTypes.HandlesUpdated;
|
|
315
333
|
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIdsToRender);
|
|
316
334
|
|
|
317
|
-
if (newAnnotation) {
|
|
318
|
-
const eventType = Events.ANNOTATION_COMPLETED;
|
|
319
|
-
const eventDetail: AnnotationCompletedEventDetail = {
|
|
320
|
-
annotation,
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
triggerEvent(eventTarget, eventType, eventDetail);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
335
|
this.editData = null;
|
|
327
336
|
this.isDrawing = false;
|
|
328
337
|
};
|
|
@@ -505,15 +514,20 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
505
514
|
*/
|
|
506
515
|
triggerAnnotationModified = (
|
|
507
516
|
annotation: SplineROIAnnotation,
|
|
508
|
-
enabledElement: Types.IEnabledElement
|
|
517
|
+
enabledElement: Types.IEnabledElement,
|
|
518
|
+
changeType = ChangeTypes.StatsUpdated
|
|
509
519
|
): void => {
|
|
510
520
|
const { viewportId, renderingEngineId } = enabledElement;
|
|
511
|
-
const eventType =
|
|
521
|
+
const eventType =
|
|
522
|
+
changeType === ChangeTypes.Completed
|
|
523
|
+
? Events.ANNOTATION_COMPLETED
|
|
524
|
+
: Events.ANNOTATION_MODIFIED;
|
|
512
525
|
|
|
513
526
|
const eventDetail: AnnotationModifiedEventDetail = {
|
|
514
527
|
annotation,
|
|
515
528
|
viewportId,
|
|
516
529
|
renderingEngineId,
|
|
530
|
+
changeType,
|
|
517
531
|
};
|
|
518
532
|
|
|
519
533
|
triggerEvent(eventTarget, eventType, eventDetail);
|
|
@@ -615,12 +629,12 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
615
629
|
const splineType = annotation.data.spline.type;
|
|
616
630
|
const splineConfig = this._getSplineConfig(splineType);
|
|
617
631
|
const spline = this._updateSplineInstance(element, annotation);
|
|
618
|
-
const splinePolylineCanvas =
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
632
|
+
const splinePolylineCanvas = reverseIfAntiClockwise(
|
|
633
|
+
spline.getPolylinePoints()
|
|
634
|
+
);
|
|
635
|
+
const splinePolylineWorld = splinePolylineCanvas.map((point2) =>
|
|
636
|
+
viewport.canvasToWorld(point2)
|
|
637
|
+
);
|
|
624
638
|
|
|
625
639
|
data.contour.polyline = splinePolylineWorld;
|
|
626
640
|
|
|
@@ -720,29 +734,73 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
720
734
|
annotationStyle.textbox
|
|
721
735
|
);
|
|
722
736
|
|
|
737
|
+
if (this.fireChangeOnUpdate) {
|
|
738
|
+
this.triggerAnnotationModified(
|
|
739
|
+
annotation,
|
|
740
|
+
enabledElement,
|
|
741
|
+
this.fireChangeOnUpdate
|
|
742
|
+
);
|
|
743
|
+
this.fireChangeOnUpdate = null;
|
|
744
|
+
}
|
|
745
|
+
|
|
723
746
|
annotation.invalidated = false;
|
|
724
747
|
return true;
|
|
725
748
|
}
|
|
726
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Creates new interpolated handles for the spline control given the
|
|
752
|
+
* polyline data. This allows creating the spline from polyline data
|
|
753
|
+
* directly.
|
|
754
|
+
*/
|
|
755
|
+
protected createInterpolatedSplineControl(annotation) {
|
|
756
|
+
if (annotation.data.handles.points?.length) {
|
|
757
|
+
// The interpolation itself created the handles
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
const { polyline } = annotation.data.contour;
|
|
761
|
+
if (!polyline || !polyline.length) {
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
annotation.data.handles.points = [];
|
|
765
|
+
const { points } = annotation.data.handles;
|
|
766
|
+
const increment = Math.max(10, Math.floor(polyline.length / 20));
|
|
767
|
+
for (let i = 0; i < polyline.length - increment; i += increment) {
|
|
768
|
+
points.push(polyline[i]);
|
|
769
|
+
}
|
|
770
|
+
points.push(polyline[polyline.length - 1]);
|
|
771
|
+
}
|
|
772
|
+
|
|
727
773
|
protected createAnnotation(evt: EventTypes.InteractionEventType): Annotation {
|
|
728
774
|
const contourAnnotation = super.createAnnotation(evt);
|
|
729
775
|
const { world: worldPos } = evt.detail.currentPoints;
|
|
730
776
|
const { type: splineType } = this.configuration.spline;
|
|
731
777
|
const splineConfig = this._getSplineConfig(splineType);
|
|
732
778
|
const spline = new splineConfig.Class();
|
|
779
|
+
const createSpline = () => ({
|
|
780
|
+
type: splineConfig.type,
|
|
781
|
+
instance: spline,
|
|
782
|
+
resolution: splineConfig.resolution,
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
// Add an action to create a new spline data on creating an interpolated
|
|
786
|
+
// instance.
|
|
787
|
+
let postInterpolateAction;
|
|
788
|
+
if (this.configuration.interpolation.enabled) {
|
|
789
|
+
postInterpolateAction = (annotation) => {
|
|
790
|
+
annotation.data.spline ||= createSpline();
|
|
791
|
+
this.createInterpolatedSplineControl(annotation);
|
|
792
|
+
};
|
|
793
|
+
}
|
|
733
794
|
|
|
734
795
|
return <SplineROIAnnotation>utilities.deepMerge(contourAnnotation, {
|
|
735
796
|
data: {
|
|
736
797
|
handles: {
|
|
737
798
|
points: [[...worldPos]],
|
|
738
799
|
},
|
|
739
|
-
spline:
|
|
740
|
-
type: splineConfig.type,
|
|
741
|
-
instance: spline,
|
|
742
|
-
resolution: splineConfig.resolution,
|
|
743
|
-
},
|
|
800
|
+
spline: createSpline(),
|
|
744
801
|
cachedStats: {},
|
|
745
802
|
},
|
|
803
|
+
postInterpolateAction,
|
|
746
804
|
});
|
|
747
805
|
}
|
|
748
806
|
|
|
@@ -1013,7 +1071,11 @@ class SplineROITool extends ContourSegmentationBaseTool {
|
|
|
1013
1071
|
};
|
|
1014
1072
|
}
|
|
1015
1073
|
|
|
1016
|
-
this.triggerAnnotationModified(
|
|
1074
|
+
this.triggerAnnotationModified(
|
|
1075
|
+
annotation,
|
|
1076
|
+
enabledElement,
|
|
1077
|
+
ChangeTypes.StatsUpdated
|
|
1078
|
+
);
|
|
1017
1079
|
|
|
1018
1080
|
return cachedStats;
|
|
1019
1081
|
};
|