@cornerstonejs/tools 1.50.3 → 1.51.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/eventListeners/annotations/annotationCompletedListener.d.ts +2 -0
- package/dist/cjs/eventListeners/annotations/annotationCompletedListener.js +35 -0
- package/dist/cjs/eventListeners/annotations/annotationCompletedListener.js.map +1 -0
- package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts +2 -0
- package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +174 -0
- package/dist/cjs/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -0
- package/dist/cjs/eventListeners/annotations/contourSegmentation/index.d.ts +1 -0
- package/dist/cjs/eventListeners/annotations/contourSegmentation/index.js +9 -0
- package/dist/cjs/eventListeners/annotations/contourSegmentation/index.js.map +1 -0
- package/dist/cjs/eventListeners/annotations/index.d.ts +2 -1
- package/dist/cjs/eventListeners/annotations/index.js +3 -1
- package/dist/cjs/eventListeners/annotations/index.js.map +1 -1
- package/dist/cjs/eventListeners/index.d.ts +2 -2
- package/dist/cjs/eventListeners/index.js +2 -1
- package/dist/cjs/eventListeners/index.js.map +1 -1
- package/dist/cjs/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.d.ts +3 -0
- package/dist/cjs/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +89 -0
- package/dist/cjs/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js.map +1 -0
- package/dist/cjs/eventListeners/segmentation/segmentationDataModifiedEventListener.js +5 -53
- package/dist/cjs/eventListeners/segmentation/segmentationDataModifiedEventListener.js.map +1 -1
- package/dist/cjs/init.js +2 -0
- package/dist/cjs/init.js.map +1 -1
- package/dist/cjs/stateManagement/annotation/helpers/state.d.ts +3 -1
- package/dist/cjs/stateManagement/annotation/helpers/state.js +21 -1
- package/dist/cjs/stateManagement/annotation/helpers/state.js.map +1 -1
- package/dist/cjs/store/ToolGroupManager/ToolGroup.d.ts +1 -0
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js +3 -0
- package/dist/cjs/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/cjs/store/addTool.d.ts +1 -0
- package/dist/cjs/store/addTool.js +6 -1
- package/dist/cjs/store/addTool.js.map +1 -1
- package/dist/cjs/store/index.d.ts +2 -2
- package/dist/cjs/store/index.js +2 -1
- package/dist/cjs/store/index.js.map +1 -1
- package/dist/cjs/store/removeEnabledElement.js +1 -2
- package/dist/cjs/store/removeEnabledElement.js.map +1 -1
- package/dist/cjs/tools/AdvancedMagnifyTool.js +3 -10
- package/dist/cjs/tools/AdvancedMagnifyTool.js.map +1 -1
- package/dist/cjs/tools/annotation/AngleTool.js +5 -18
- package/dist/cjs/tools/annotation/AngleTool.js.map +1 -1
- package/dist/cjs/tools/annotation/ArrowAnnotateTool.js +9 -28
- package/dist/cjs/tools/annotation/ArrowAnnotateTool.js.map +1 -1
- package/dist/cjs/tools/annotation/BidirectionalTool.js +7 -22
- package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/cjs/tools/annotation/CircleROITool.js +7 -22
- package/dist/cjs/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/CobbAngleTool.js +5 -18
- package/dist/cjs/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/cjs/tools/annotation/EllipticalROITool.js +7 -22
- package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/KeyImageTool.js +5 -12
- package/dist/cjs/tools/annotation/KeyImageTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LengthTool.js +5 -18
- package/dist/cjs/tools/annotation/LengthTool.js.map +1 -1
- package/dist/cjs/tools/annotation/LivewireContourTool.d.ts +4 -1
- package/dist/cjs/tools/annotation/LivewireContourTool.js +30 -22
- package/dist/cjs/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +2 -1
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js +11 -0
- package/dist/cjs/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -1
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.d.ts +2 -10
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js +6 -22
- package/dist/cjs/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/ProbeTool.js +8 -23
- package/dist/cjs/tools/annotation/ProbeTool.js.map +1 -1
- package/dist/cjs/tools/annotation/RectangleROITool.js +8 -22
- package/dist/cjs/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/SplineROITool.d.ts +8 -9
- package/dist/cjs/tools/annotation/SplineROITool.js +27 -10
- package/dist/cjs/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js +5 -18
- package/dist/cjs/tools/annotation/UltrasoundDirectionalTool.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +7 -6
- package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js +8 -5
- package/dist/cjs/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/editLoopCommon.js +8 -8
- package/dist/cjs/tools/annotation/planarFreehandROITool/editLoopCommon.js.map +1 -1
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +6 -5
- package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/cjs/tools/base/ContourBaseTool.d.ts +2 -8
- package/dist/cjs/tools/base/ContourBaseTool.js.map +1 -1
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.d.ts +3 -2
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js +13 -1
- package/dist/cjs/tools/base/ContourSegmentationBaseTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js +3 -9
- package/dist/cjs/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
- package/dist/cjs/tools/segmentation/RectangleROIThresholdTool.js +3 -9
- package/dist/cjs/tools/segmentation/RectangleROIThresholdTool.js.map +1 -1
- package/dist/cjs/types/AnnotationRenderContext.d.ts +11 -0
- package/dist/cjs/types/AnnotationRenderContext.js +3 -0
- package/dist/cjs/types/AnnotationRenderContext.js.map +1 -0
- package/dist/cjs/types/IToolGroup.d.ts +2 -1
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/utilities/contourSegmentation/areSameSegment.d.ts +2 -0
- package/dist/cjs/utilities/contourSegmentation/areSameSegment.js +12 -0
- package/dist/cjs/utilities/contourSegmentation/areSameSegment.js.map +1 -0
- package/dist/cjs/utilities/contourSegmentation/index.d.ts +2 -0
- package/dist/cjs/utilities/contourSegmentation/index.js +11 -0
- package/dist/cjs/utilities/contourSegmentation/index.js.map +1 -0
- package/dist/cjs/utilities/contourSegmentation/isContourSegmentationAnnotation.d.ts +3 -0
- package/dist/cjs/utilities/contourSegmentation/isContourSegmentationAnnotation.js +8 -0
- package/dist/cjs/utilities/contourSegmentation/isContourSegmentationAnnotation.js.map +1 -0
- package/dist/cjs/utilities/contours/areCoplanarContours.d.ts +2 -0
- package/dist/cjs/utilities/contours/areCoplanarContours.js +19 -0
- package/dist/cjs/utilities/contours/areCoplanarContours.js.map +1 -0
- package/dist/cjs/utilities/contours/index.d.ts +2 -1
- package/dist/cjs/utilities/contours/index.js +3 -1
- package/dist/cjs/utilities/contours/index.js.map +1 -1
- package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js +3 -22
- package/dist/cjs/utilities/contours/reverseIfAntiClockwise.js.map +1 -1
- package/dist/cjs/utilities/math/aabb/index.d.ts +1 -0
- package/dist/cjs/utilities/math/aabb/index.js +3 -1
- package/dist/cjs/utilities/math/aabb/index.js.map +1 -1
- package/dist/cjs/utilities/math/aabb/intersectAABB.d.ts +2 -0
- package/dist/cjs/utilities/math/aabb/intersectAABB.js +10 -0
- package/dist/cjs/utilities/math/aabb/intersectAABB.js.map +1 -0
- package/dist/cjs/utilities/math/point/distanceToPointSquared.js +4 -1
- package/dist/cjs/utilities/math/point/distanceToPointSquared.js.map +1 -1
- package/dist/cjs/utilities/math/polyline/areLineSegmentsIntersecting.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/areLineSegmentsIntersecting.js +59 -0
- package/dist/cjs/utilities/math/polyline/areLineSegmentsIntersecting.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/combinePolyline.d.ts +4 -0
- package/dist/cjs/utilities/math/polyline/combinePolyline.js +213 -0
- package/dist/cjs/utilities/math/polyline/combinePolyline.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/containsPoint.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/containsPoint.js +36 -0
- package/dist/cjs/utilities/math/polyline/containsPoint.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getAABB.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getAABB.js +18 -0
- package/dist/cjs/utilities/math/polyline/getAABB.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getArea.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/{calculateAreaOfPoints.js → getArea.js} +3 -3
- package/dist/cjs/utilities/math/polyline/getArea.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getClosestLineSegmentIntersection.d.ts +5 -0
- package/dist/cjs/utilities/math/polyline/getClosestLineSegmentIntersection.js +51 -0
- package/dist/cjs/utilities/math/polyline/getClosestLineSegmentIntersection.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.js +28 -0
- package/dist/cjs/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.js +20 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsIndexes.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsIndexes.js +22 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentIntersectionsIndexes.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentsIntersection.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentsIntersection.js +21 -0
- package/dist/cjs/utilities/math/polyline/getLineSegmentsIntersection.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getNormal2.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getNormal2.js +12 -0
- package/dist/cjs/utilities/math/polyline/getNormal2.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getNormal3.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getNormal3.js +29 -0
- package/dist/cjs/utilities/math/polyline/getNormal3.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/getSignedArea.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/getSignedArea.js +20 -0
- package/dist/cjs/utilities/math/polyline/getSignedArea.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/index.d.ts +14 -3
- package/dist/cjs/utilities/math/polyline/index.js +28 -6
- package/dist/cjs/utilities/math/polyline/index.js.map +1 -1
- package/dist/cjs/utilities/math/polyline/intersectPolyline.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/intersectPolyline.js +20 -0
- package/dist/cjs/utilities/math/polyline/intersectPolyline.js.map +1 -0
- package/dist/cjs/utilities/math/polyline/isClosed.d.ts +2 -0
- package/dist/cjs/utilities/math/polyline/isClosed.js +39 -0
- package/dist/cjs/utilities/math/polyline/isClosed.js.map +1 -0
- package/dist/esm/eventListeners/annotations/annotationCompletedListener.js +9 -0
- package/dist/esm/eventListeners/annotations/annotationCompletedListener.js.map +1 -0
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js +153 -0
- package/dist/esm/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.js.map +1 -0
- package/dist/esm/eventListeners/annotations/contourSegmentation/index.js +2 -0
- package/dist/esm/eventListeners/annotations/contourSegmentation/index.js.map +1 -0
- package/dist/esm/eventListeners/annotations/index.js +2 -1
- package/dist/esm/eventListeners/annotations/index.js.map +1 -1
- package/dist/esm/eventListeners/index.js +2 -2
- package/dist/esm/eventListeners/index.js.map +1 -1
- package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +61 -0
- package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js.map +1 -0
- package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js +5 -53
- package/dist/esm/eventListeners/segmentation/segmentationDataModifiedEventListener.js.map +1 -1
- package/dist/esm/init.js +3 -1
- package/dist/esm/init.js.map +1 -1
- package/dist/esm/stateManagement/annotation/helpers/state.js +19 -1
- package/dist/esm/stateManagement/annotation/helpers/state.js.map +1 -1
- package/dist/esm/store/ToolGroupManager/ToolGroup.js +3 -0
- package/dist/esm/store/ToolGroupManager/ToolGroup.js.map +1 -1
- package/dist/esm/store/addTool.js +4 -0
- package/dist/esm/store/addTool.js.map +1 -1
- package/dist/esm/store/index.js +2 -2
- package/dist/esm/store/index.js.map +1 -1
- package/dist/esm/store/removeEnabledElement.js +1 -2
- package/dist/esm/store/removeEnabledElement.js.map +1 -1
- package/dist/esm/tools/AdvancedMagnifyTool.js +4 -11
- package/dist/esm/tools/AdvancedMagnifyTool.js.map +1 -1
- package/dist/esm/tools/annotation/AngleTool.js +6 -19
- package/dist/esm/tools/annotation/AngleTool.js.map +1 -1
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js +10 -29
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js.map +1 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +8 -23
- package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/esm/tools/annotation/CircleROITool.js +8 -23
- package/dist/esm/tools/annotation/CircleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/CobbAngleTool.js +6 -19
- package/dist/esm/tools/annotation/CobbAngleTool.js.map +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +8 -23
- package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
- package/dist/esm/tools/annotation/KeyImageTool.js +6 -13
- package/dist/esm/tools/annotation/KeyImageTool.js.map +1 -1
- package/dist/esm/tools/annotation/LengthTool.js +6 -19
- package/dist/esm/tools/annotation/LengthTool.js.map +1 -1
- package/dist/esm/tools/annotation/LivewireContourTool.js +31 -23
- package/dist/esm/tools/annotation/LivewireContourTool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +11 -0
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js.map +1 -1
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +7 -23
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js.map +1 -1
- package/dist/esm/tools/annotation/ProbeTool.js +9 -24
- package/dist/esm/tools/annotation/ProbeTool.js.map +1 -1
- package/dist/esm/tools/annotation/RectangleROITool.js +9 -23
- package/dist/esm/tools/annotation/RectangleROITool.js.map +1 -1
- package/dist/esm/tools/annotation/SplineROITool.js +26 -9
- package/dist/esm/tools/annotation/SplineROITool.js.map +1 -1
- package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +6 -19
- package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +7 -6
- package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js +8 -5
- package/dist/esm/tools/annotation/planarFreehandROITool/drawLoop.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/editLoopCommon.js +8 -8
- package/dist/esm/tools/annotation/planarFreehandROITool/editLoopCommon.js.map +1 -1
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +6 -5
- package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
- package/dist/esm/tools/base/ContourBaseTool.js.map +1 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +13 -1
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js.map +1 -1
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +4 -10
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js.map +1 -1
- package/dist/esm/tools/segmentation/RectangleROIThresholdTool.js +4 -10
- package/dist/esm/tools/segmentation/RectangleROIThresholdTool.js.map +1 -1
- package/dist/esm/types/AnnotationRenderContext.js +2 -0
- package/dist/esm/types/AnnotationRenderContext.js.map +1 -0
- package/dist/esm/utilities/contourSegmentation/areSameSegment.js +9 -0
- package/dist/esm/utilities/contourSegmentation/areSameSegment.js.map +1 -0
- package/dist/esm/utilities/contourSegmentation/index.js +3 -0
- package/dist/esm/utilities/contourSegmentation/index.js.map +1 -0
- package/dist/esm/utilities/contourSegmentation/isContourSegmentationAnnotation.js +4 -0
- package/dist/esm/utilities/contourSegmentation/isContourSegmentationAnnotation.js.map +1 -0
- package/dist/esm/utilities/contours/areCoplanarContours.js +16 -0
- package/dist/esm/utilities/contours/areCoplanarContours.js.map +1 -0
- package/dist/esm/utilities/contours/index.js +2 -1
- package/dist/esm/utilities/contours/index.js.map +1 -1
- package/dist/esm/utilities/contours/reverseIfAntiClockwise.js +3 -22
- package/dist/esm/utilities/contours/reverseIfAntiClockwise.js.map +1 -1
- package/dist/esm/utilities/math/aabb/index.js +1 -0
- package/dist/esm/utilities/math/aabb/index.js.map +1 -1
- package/dist/esm/utilities/math/aabb/intersectAABB.js +7 -0
- package/dist/esm/utilities/math/aabb/intersectAABB.js.map +1 -0
- package/dist/esm/utilities/math/point/distanceToPointSquared.js +4 -1
- package/dist/esm/utilities/math/point/distanceToPointSquared.js.map +1 -1
- package/dist/esm/utilities/math/polyline/areLineSegmentsIntersecting.js +56 -0
- package/dist/esm/utilities/math/polyline/areLineSegmentsIntersecting.js.map +1 -0
- package/dist/esm/utilities/math/polyline/combinePolyline.js +187 -0
- package/dist/esm/utilities/math/polyline/combinePolyline.js.map +1 -0
- package/dist/esm/utilities/math/polyline/containsPoint.js +30 -0
- package/dist/esm/utilities/math/polyline/containsPoint.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getAABB.js +15 -0
- package/dist/esm/utilities/math/polyline/getAABB.js.map +1 -0
- package/dist/esm/utilities/math/polyline/{calculateAreaOfPoints.js → getArea.js} +2 -2
- package/dist/esm/utilities/math/polyline/getArea.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getClosestLineSegmentIntersection.js +45 -0
- package/dist/esm/utilities/math/polyline/getClosestLineSegmentIntersection.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.js +22 -0
- package/dist/esm/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.js +14 -0
- package/dist/esm/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getLineSegmentIntersectionsIndexes.js +16 -0
- package/dist/esm/utilities/math/polyline/getLineSegmentIntersectionsIndexes.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getLineSegmentsIntersection.js +18 -0
- package/dist/esm/utilities/math/polyline/getLineSegmentsIntersection.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getNormal2.js +6 -0
- package/dist/esm/utilities/math/polyline/getNormal2.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getNormal3.js +26 -0
- package/dist/esm/utilities/math/polyline/getNormal3.js.map +1 -0
- package/dist/esm/utilities/math/polyline/getSignedArea.js +17 -0
- package/dist/esm/utilities/math/polyline/getSignedArea.js.map +1 -0
- package/dist/esm/utilities/math/polyline/index.js +14 -3
- package/dist/esm/utilities/math/polyline/index.js.map +1 -1
- package/dist/esm/utilities/math/polyline/intersectPolyline.js +14 -0
- package/dist/esm/utilities/math/polyline/intersectPolyline.js.map +1 -0
- package/dist/esm/utilities/math/polyline/isClosed.js +13 -0
- package/dist/esm/utilities/math/polyline/isClosed.js.map +1 -0
- package/dist/types/eventListeners/annotations/annotationCompletedListener.d.ts +3 -0
- package/dist/types/eventListeners/annotations/annotationCompletedListener.d.ts.map +1 -0
- package/dist/types/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts +3 -0
- package/dist/types/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.d.ts.map +1 -0
- package/dist/types/eventListeners/annotations/contourSegmentation/index.d.ts +2 -0
- package/dist/types/eventListeners/annotations/contourSegmentation/index.d.ts.map +1 -0
- package/dist/types/eventListeners/annotations/index.d.ts +2 -1
- package/dist/types/eventListeners/annotations/index.d.ts.map +1 -1
- package/dist/types/eventListeners/index.d.ts +2 -2
- package/dist/types/eventListeners/index.d.ts.map +1 -1
- package/dist/types/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.d.ts +4 -0
- package/dist/types/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.d.ts.map +1 -0
- package/dist/types/eventListeners/segmentation/segmentationDataModifiedEventListener.d.ts.map +1 -1
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/stateManagement/annotation/helpers/state.d.ts +3 -1
- package/dist/types/stateManagement/annotation/helpers/state.d.ts.map +1 -1
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts +1 -0
- package/dist/types/store/ToolGroupManager/ToolGroup.d.ts.map +1 -1
- package/dist/types/store/addTool.d.ts +1 -0
- package/dist/types/store/addTool.d.ts.map +1 -1
- package/dist/types/store/index.d.ts +2 -2
- package/dist/types/store/index.d.ts.map +1 -1
- package/dist/types/store/removeEnabledElement.d.ts.map +1 -1
- package/dist/types/tools/AdvancedMagnifyTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/AngleTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/ArrowAnnotateTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/BidirectionalTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/CircleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/CobbAngleTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/EllipticalROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/KeyImageTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LengthTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/LivewireContourTool.d.ts +4 -1
- package/dist/types/tools/annotation/LivewireContourTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts +2 -1
- package/dist/types/tools/annotation/PlanarFreehandContourSegmentationTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts +2 -10
- package/dist/types/tools/annotation/PlanarFreehandROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/ProbeTool.d.ts.map +1 -1
- package/dist/types/tools/annotation/RectangleROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/SplineROITool.d.ts +8 -9
- package/dist/types/tools/annotation/SplineROITool.d.ts.map +1 -1
- package/dist/types/tools/annotation/UltrasoundDirectionalTool.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/editLoopCommon.d.ts.map +1 -1
- package/dist/types/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts.map +1 -1
- package/dist/types/tools/base/ContourBaseTool.d.ts +2 -8
- package/dist/types/tools/base/ContourBaseTool.d.ts.map +1 -1
- package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts +3 -2
- package/dist/types/tools/base/ContourSegmentationBaseTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts.map +1 -1
- package/dist/types/tools/segmentation/RectangleROIThresholdTool.d.ts.map +1 -1
- package/dist/types/types/AnnotationRenderContext.d.ts +12 -0
- package/dist/types/types/AnnotationRenderContext.d.ts.map +1 -0
- package/dist/types/types/IToolGroup.d.ts +2 -1
- package/dist/types/types/IToolGroup.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/contourSegmentation/areSameSegment.d.ts +3 -0
- package/dist/types/utilities/contourSegmentation/areSameSegment.d.ts.map +1 -0
- package/dist/types/utilities/contourSegmentation/index.d.ts +3 -0
- package/dist/types/utilities/contourSegmentation/index.d.ts.map +1 -0
- package/dist/types/utilities/contourSegmentation/isContourSegmentationAnnotation.d.ts +4 -0
- package/dist/types/utilities/contourSegmentation/isContourSegmentationAnnotation.d.ts.map +1 -0
- package/dist/types/utilities/contours/areCoplanarContours.d.ts +3 -0
- package/dist/types/utilities/contours/areCoplanarContours.d.ts.map +1 -0
- package/dist/types/utilities/contours/index.d.ts +2 -1
- package/dist/types/utilities/contours/index.d.ts.map +1 -1
- package/dist/types/utilities/contours/reverseIfAntiClockwise.d.ts.map +1 -1
- package/dist/types/utilities/math/aabb/index.d.ts +1 -0
- package/dist/types/utilities/math/aabb/index.d.ts.map +1 -1
- package/dist/types/utilities/math/aabb/intersectAABB.d.ts +3 -0
- package/dist/types/utilities/math/aabb/intersectAABB.d.ts.map +1 -0
- package/dist/types/utilities/math/point/distanceToPointSquared.d.ts.map +1 -1
- package/dist/types/utilities/math/polyline/areLineSegmentsIntersecting.d.ts +3 -0
- package/dist/types/utilities/math/polyline/areLineSegmentsIntersecting.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/combinePolyline.d.ts +5 -0
- package/dist/types/utilities/math/polyline/combinePolyline.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/containsPoint.d.ts +3 -0
- package/dist/types/utilities/math/polyline/containsPoint.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getAABB.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getAABB.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getArea.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getArea.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getClosestLineSegmentIntersection.d.ts +6 -0
- package/dist/types/utilities/math/polyline/getClosestLineSegmentIntersection.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getLineSegmentIntersectionsIndexes.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getLineSegmentIntersectionsIndexes.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getLineSegmentsIntersection.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getLineSegmentsIntersection.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getNormal2.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getNormal2.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getNormal3.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getNormal3.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/getSignedArea.d.ts +3 -0
- package/dist/types/utilities/math/polyline/getSignedArea.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/index.d.ts +14 -3
- package/dist/types/utilities/math/polyline/index.d.ts.map +1 -1
- package/dist/types/utilities/math/polyline/intersectPolyline.d.ts +3 -0
- package/dist/types/utilities/math/polyline/intersectPolyline.d.ts.map +1 -0
- package/dist/types/utilities/math/polyline/isClosed.d.ts +3 -0
- package/dist/types/utilities/math/polyline/isClosed.d.ts.map +1 -0
- package/dist/umd/index.js +1 -2
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/eventListeners/annotations/annotationCompletedListener.ts +13 -0
- package/src/eventListeners/annotations/contourSegmentation/contourSegmentationCompleted.ts +273 -0
- package/src/eventListeners/annotations/contourSegmentation/index.ts +1 -0
- package/src/eventListeners/annotations/index.ts +6 -1
- package/src/eventListeners/index.ts +2 -0
- package/src/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.ts +117 -0
- package/src/eventListeners/segmentation/segmentationDataModifiedEventListener.ts +5 -99
- package/src/init.ts +12 -1
- package/src/stateManagement/annotation/helpers/state.ts +42 -2
- package/src/store/ToolGroupManager/ToolGroup.ts +10 -0
- package/src/store/addTool.ts +11 -0
- package/src/store/index.ts +2 -1
- package/src/store/removeEnabledElement.ts +2 -1
- package/src/tools/AdvancedMagnifyTool.ts +4 -21
- package/src/tools/annotation/AngleTool.ts +8 -32
- package/src/tools/annotation/ArrowAnnotateTool.ts +12 -45
- package/src/tools/annotation/BidirectionalTool.ts +11 -39
- package/src/tools/annotation/CircleROITool.ts +10 -34
- package/src/tools/annotation/CobbAngleTool.ts +9 -32
- package/src/tools/annotation/EllipticalROITool.ts +10 -34
- package/src/tools/annotation/KeyImageTool.ts +9 -23
- package/src/tools/annotation/LengthTool.ts +9 -33
- package/src/tools/annotation/LivewireContourTool.ts +58 -33
- package/src/tools/annotation/PlanarFreehandContourSegmentationTool.ts +22 -1
- package/src/tools/annotation/PlanarFreehandROITool.ts +10 -53
- package/src/tools/annotation/ProbeTool.ts +11 -36
- package/src/tools/annotation/RectangleROITool.ts +11 -33
- package/src/tools/annotation/SplineROITool.ts +53 -24
- package/src/tools/annotation/UltrasoundDirectionalTool.ts +8 -29
- package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +9 -11
- package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +8 -5
- package/src/tools/annotation/planarFreehandROITool/editLoopCommon.ts +9 -8
- package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +7 -6
- package/src/tools/base/ContourBaseTool.ts +5 -8
- package/src/tools/base/ContourSegmentationBaseTool.ts +29 -6
- package/src/tools/segmentation/RectangleROIStartEndThresholdTool.ts +3 -13
- package/src/tools/segmentation/RectangleROIThresholdTool.ts +3 -14
- package/src/types/AnnotationRenderContext.ts +13 -0
- package/src/types/IToolGroup.ts +3 -1
- package/src/types/index.ts +3 -0
- package/src/utilities/contourSegmentation/areSameSegment.ts +24 -0
- package/src/utilities/contourSegmentation/index.ts +2 -0
- package/src/utilities/contourSegmentation/isContourSegmentationAnnotation.ts +8 -0
- package/src/utilities/contours/areCoplanarContours.ts +39 -0
- package/src/utilities/contours/index.ts +2 -0
- package/src/utilities/contours/reverseIfAntiClockwise.ts +6 -25
- package/src/utilities/math/aabb/index.ts +1 -0
- package/src/utilities/math/aabb/intersectAABB.ts +19 -0
- package/src/utilities/math/point/distanceToPointSquared.ts +6 -1
- package/src/utilities/math/polyline/areLineSegmentsIntersecting.ts +118 -0
- package/src/utilities/math/polyline/combinePolyline.ts +350 -0
- package/src/utilities/math/polyline/containsPoint.ts +63 -0
- package/src/utilities/math/polyline/getAABB.ts +20 -0
- package/src/utilities/math/polyline/{calculateAreaOfPoints.ts → getArea.ts} +1 -1
- package/src/utilities/math/polyline/getClosestLineSegmentIntersection.ts +72 -0
- package/src/utilities/math/polyline/getFirstLineSegmentIntersectionIndexes.ts +42 -0
- package/src/utilities/math/polyline/getLineSegmentIntersectionsCoordinates.ts +30 -0
- package/src/utilities/math/polyline/getLineSegmentIntersectionsIndexes.ts +35 -0
- package/src/utilities/math/polyline/getLineSegmentsIntersection.ts +47 -0
- package/src/utilities/math/polyline/getNormal2.ts +17 -0
- package/src/utilities/math/polyline/getNormal3.ts +53 -0
- package/src/utilities/math/polyline/getSignedArea.ts +47 -0
- package/src/utilities/math/polyline/index.ts +27 -8
- package/src/utilities/math/polyline/intersectPolyline.ts +34 -0
- package/src/utilities/math/polyline/isClosed.ts +26 -0
- package/dist/cjs/utilities/math/polyline/calculateAreaOfPoints.d.ts +0 -2
- package/dist/cjs/utilities/math/polyline/calculateAreaOfPoints.js.map +0 -1
- package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.d.ts +0 -9
- package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.js +0 -160
- package/dist/cjs/utilities/math/polyline/getIntersectionWithPolyline.js.map +0 -1
- package/dist/cjs/utilities/math/polyline/pointInPolyline.d.ts +0 -2
- package/dist/cjs/utilities/math/polyline/pointInPolyline.js +0 -15
- package/dist/cjs/utilities/math/polyline/pointInPolyline.js.map +0 -1
- package/dist/esm/utilities/math/polyline/calculateAreaOfPoints.js.map +0 -1
- package/dist/esm/utilities/math/polyline/getIntersectionWithPolyline.js +0 -154
- package/dist/esm/utilities/math/polyline/getIntersectionWithPolyline.js.map +0 -1
- package/dist/esm/utilities/math/polyline/pointInPolyline.js +0 -12
- package/dist/esm/utilities/math/polyline/pointInPolyline.js.map +0 -1
- package/dist/types/utilities/math/polyline/calculateAreaOfPoints.d.ts +0 -3
- package/dist/types/utilities/math/polyline/calculateAreaOfPoints.d.ts.map +0 -1
- package/dist/types/utilities/math/polyline/getIntersectionWithPolyline.d.ts +0 -10
- package/dist/types/utilities/math/polyline/getIntersectionWithPolyline.d.ts.map +0 -1
- package/dist/types/utilities/math/polyline/pointInPolyline.d.ts +0 -3
- package/dist/types/utilities/math/polyline/pointInPolyline.d.ts.map +0 -1
- package/dist/umd/index.js.LICENSE.txt +0 -6
- package/src/utilities/math/polyline/getIntersectionWithPolyline.ts +0 -275
- package/src/utilities/math/polyline/pointInPolyline.ts +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.51.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.51.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": "a4ca4dde651d17e658a4aec5a4e3ec1b274dc580"
|
|
57
57
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AnnotationCompletedEventType } from '../../types/EventTypes';
|
|
2
|
+
import * as contourSegUtils from '../../utilities/contourSegmentation';
|
|
3
|
+
import { contourSegmentationCompleted } from './contourSegmentation';
|
|
4
|
+
|
|
5
|
+
export default function annotationCompletedListener(
|
|
6
|
+
evt: AnnotationCompletedEventType
|
|
7
|
+
) {
|
|
8
|
+
const annotation = evt.detail.annotation;
|
|
9
|
+
|
|
10
|
+
if (contourSegUtils.isContourSegmentationAnnotation(annotation)) {
|
|
11
|
+
contourSegmentationCompleted(evt);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEnabledElement,
|
|
3
|
+
utilities as csUtils,
|
|
4
|
+
Types,
|
|
5
|
+
} from '@cornerstonejs/core';
|
|
6
|
+
import { ContourSegmentationAnnotation } from '../../../types/ContourSegmentationAnnotation';
|
|
7
|
+
import {
|
|
8
|
+
getViewportForAnnotation,
|
|
9
|
+
math,
|
|
10
|
+
triggerAnnotationRenderForViewportIds,
|
|
11
|
+
} from '../../../utilities';
|
|
12
|
+
import { getViewportIdsWithToolToRender } from '../../../utilities/viewportFilters';
|
|
13
|
+
import {
|
|
14
|
+
getAnnotations,
|
|
15
|
+
addAnnotation,
|
|
16
|
+
removeAnnotation,
|
|
17
|
+
} from '../../../stateManagement/annotation/annotationState';
|
|
18
|
+
import { AnnotationCompletedEventType } from '../../../types/EventTypes';
|
|
19
|
+
import * as contourUtils from '../../../utilities/contours';
|
|
20
|
+
import * as contourSegUtils from '../../../utilities/contourSegmentation';
|
|
21
|
+
import { ToolGroupManager, hasTool as cstHasTool } from '../../../store';
|
|
22
|
+
import { PlanarFreehandContourSegmentationTool } from '../../../tools';
|
|
23
|
+
|
|
24
|
+
const DEFAULT_CONTOUR_SEG_TOOLNAME = 'PlanarFreehandContourSegmentationTool';
|
|
25
|
+
|
|
26
|
+
export default function contourSegmentationCompletedListener(
|
|
27
|
+
evt: AnnotationCompletedEventType
|
|
28
|
+
) {
|
|
29
|
+
const sourceAnnotation = evt.detail
|
|
30
|
+
.annotation as ContourSegmentationAnnotation;
|
|
31
|
+
|
|
32
|
+
if (!contourSegUtils.isContourSegmentationAnnotation(sourceAnnotation)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const viewport = getViewportForAnnotation(sourceAnnotation);
|
|
37
|
+
const contourSegmentationAnnotations =
|
|
38
|
+
getValidContourSegmentationAnnotations(sourceAnnotation);
|
|
39
|
+
|
|
40
|
+
if (!contourSegmentationAnnotations.length) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const sourcePolyline = convertContourPolylineToCanvasSpace(
|
|
45
|
+
sourceAnnotation.data.contour.polyline,
|
|
46
|
+
viewport
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const targetAnnotationInfo = findIntersectingContour(
|
|
50
|
+
viewport,
|
|
51
|
+
sourcePolyline,
|
|
52
|
+
contourSegmentationAnnotations
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (!targetAnnotationInfo) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!isFreehandContourSegToolRegistered(viewport)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { targetAnnotation, targetPolyline } = targetAnnotationInfo;
|
|
64
|
+
|
|
65
|
+
processContours(
|
|
66
|
+
viewport,
|
|
67
|
+
sourceAnnotation,
|
|
68
|
+
sourcePolyline,
|
|
69
|
+
targetAnnotation,
|
|
70
|
+
targetPolyline
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isFreehandContourSegToolRegistered(viewport: Types.IViewport) {
|
|
75
|
+
const { toolName } = PlanarFreehandContourSegmentationTool;
|
|
76
|
+
|
|
77
|
+
if (!cstHasTool(PlanarFreehandContourSegmentationTool)) {
|
|
78
|
+
console.warn(`${toolName} is not registered in cornerstone`);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(
|
|
83
|
+
viewport.id,
|
|
84
|
+
viewport.renderingEngineId
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
if (!toolGroup.hasTool(toolName)) {
|
|
88
|
+
console.warn(`Tool ${toolName} not added to ${toolGroup.id} toolGroup`);
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!toolGroup.getToolOptions(toolName)) {
|
|
93
|
+
console.warn(`Tool ${toolName} must be in active/passive state`);
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function convertContourPolylineToCanvasSpace(
|
|
101
|
+
polyline: Types.Point3[],
|
|
102
|
+
viewport: Types.IViewport
|
|
103
|
+
): Types.Point2[] {
|
|
104
|
+
const numPoints = polyline.length;
|
|
105
|
+
const projectedPolyline = new Array(numPoints);
|
|
106
|
+
|
|
107
|
+
for (let i = 0; i < numPoints; i++) {
|
|
108
|
+
projectedPolyline[i] = viewport.worldToCanvas(polyline[i]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return projectedPolyline;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function convertPolylineToWorldSpace(
|
|
115
|
+
polyline: Types.Point2[],
|
|
116
|
+
viewport: Types.IViewport
|
|
117
|
+
): Types.Point3[] {
|
|
118
|
+
const numPoints = polyline.length;
|
|
119
|
+
const projectedPolyline = new Array(numPoints);
|
|
120
|
+
|
|
121
|
+
for (let i = 0; i < numPoints; i++) {
|
|
122
|
+
projectedPolyline[i] = viewport.canvasToWorld(polyline[i]);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return projectedPolyline;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function getValidContourSegmentationAnnotations(
|
|
129
|
+
sourceAnnotation: ContourSegmentationAnnotation
|
|
130
|
+
): ContourSegmentationAnnotation[] {
|
|
131
|
+
const { annotationUID: sourceAnnotationUID } = sourceAnnotation;
|
|
132
|
+
const { FrameOfReferenceUID } = sourceAnnotation.metadata;
|
|
133
|
+
|
|
134
|
+
// Get all annotations and filter all contour segmentations locally
|
|
135
|
+
const toolName = undefined;
|
|
136
|
+
const annotationsGroups = getAnnotations(toolName, FrameOfReferenceUID);
|
|
137
|
+
const toolNames = Object.keys(annotationsGroups);
|
|
138
|
+
|
|
139
|
+
return toolNames.reduce((validAnnotations, toolName) => {
|
|
140
|
+
const toolAnnotations = annotationsGroups[toolName].filter(
|
|
141
|
+
(targetAnnotation) =>
|
|
142
|
+
targetAnnotation.annotationUID &&
|
|
143
|
+
targetAnnotation.annotationUID !== sourceAnnotationUID &&
|
|
144
|
+
contourSegUtils.isContourSegmentationAnnotation(targetAnnotation) &&
|
|
145
|
+
contourSegUtils.areSameSegment(targetAnnotation, sourceAnnotation) &&
|
|
146
|
+
contourUtils.areCoplanarContours(targetAnnotation, sourceAnnotation)
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
return validAnnotations.concat(toolAnnotations);
|
|
150
|
+
}, []);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function findIntersectingContour(
|
|
154
|
+
viewport: Types.IViewport,
|
|
155
|
+
sourcePolyline: Types.Point2[],
|
|
156
|
+
contourSegmentationAnnotations: ContourSegmentationAnnotation[]
|
|
157
|
+
): {
|
|
158
|
+
targetAnnotation: ContourSegmentationAnnotation;
|
|
159
|
+
targetPolyline: Types.Point2[];
|
|
160
|
+
} {
|
|
161
|
+
const sourceAABB = math.polyline.getAABB(sourcePolyline);
|
|
162
|
+
|
|
163
|
+
for (let i = 0; i < contourSegmentationAnnotations.length; i++) {
|
|
164
|
+
const targetAnnotation = contourSegmentationAnnotations[i];
|
|
165
|
+
const targetPolyline = convertContourPolylineToCanvasSpace(
|
|
166
|
+
targetAnnotation.data.contour.polyline,
|
|
167
|
+
viewport
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
const targetAABB = math.polyline.getAABB(targetPolyline);
|
|
171
|
+
const polylinesIntersect =
|
|
172
|
+
math.aabb.intersectAABB(sourceAABB, targetAABB) &&
|
|
173
|
+
math.polyline.intersectPolyline(sourcePolyline, targetPolyline);
|
|
174
|
+
|
|
175
|
+
if (polylinesIntersect) {
|
|
176
|
+
return { targetAnnotation, targetPolyline };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function processContours(
|
|
182
|
+
viewport: Types.IViewport,
|
|
183
|
+
sourceAnnotation: ContourSegmentationAnnotation,
|
|
184
|
+
sourcePolyline: Types.Point2[],
|
|
185
|
+
targetAnnotation: ContourSegmentationAnnotation,
|
|
186
|
+
targetPolyline: Types.Point2[]
|
|
187
|
+
) {
|
|
188
|
+
const sourceStartPoint = sourcePolyline[0];
|
|
189
|
+
const mergePolylines = math.polyline.containsPoint(
|
|
190
|
+
targetPolyline,
|
|
191
|
+
sourceStartPoint
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const newPolylines = [];
|
|
195
|
+
|
|
196
|
+
if (mergePolylines) {
|
|
197
|
+
const mergedPolyline = math.polyline.mergePolylines(
|
|
198
|
+
targetPolyline,
|
|
199
|
+
sourcePolyline
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
newPolylines.push(mergedPolyline);
|
|
203
|
+
} else {
|
|
204
|
+
const subtractedPolylines = math.polyline.subtractPolylines(
|
|
205
|
+
targetPolyline,
|
|
206
|
+
sourcePolyline
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
subtractedPolylines.forEach((newPolyline) =>
|
|
210
|
+
newPolylines.push(newPolyline)
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
removeAnnotation(sourceAnnotation.annotationUID);
|
|
215
|
+
removeAnnotation(targetAnnotation.annotationUID);
|
|
216
|
+
|
|
217
|
+
const { element } = viewport;
|
|
218
|
+
const enabledElement = getEnabledElement(element);
|
|
219
|
+
const { renderingEngine } = enabledElement;
|
|
220
|
+
const { metadata, data } = targetAnnotation;
|
|
221
|
+
const { handles, segmentation } = data;
|
|
222
|
+
const { textBox } = handles;
|
|
223
|
+
|
|
224
|
+
for (let i = 0; i < newPolylines.length; i++) {
|
|
225
|
+
const polyline = convertPolylineToWorldSpace(newPolylines[i], viewport);
|
|
226
|
+
const startPoint = polyline[0];
|
|
227
|
+
const endPoint = polyline[polyline.length - 1];
|
|
228
|
+
const newAnnotation = {
|
|
229
|
+
metadata: {
|
|
230
|
+
...metadata,
|
|
231
|
+
toolName: DEFAULT_CONTOUR_SEG_TOOLNAME,
|
|
232
|
+
},
|
|
233
|
+
data: {
|
|
234
|
+
cachedStats: {},
|
|
235
|
+
handles: {
|
|
236
|
+
points: [startPoint, endPoint],
|
|
237
|
+
textBox: textBox ? { ...textBox } : undefined,
|
|
238
|
+
},
|
|
239
|
+
contour: {
|
|
240
|
+
polyline,
|
|
241
|
+
closed: true,
|
|
242
|
+
},
|
|
243
|
+
segmentation: {
|
|
244
|
+
...segmentation,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
annotationUID: csUtils.uuidv4() as string,
|
|
248
|
+
highlighted: true,
|
|
249
|
+
invalidated: true,
|
|
250
|
+
isLocked: false,
|
|
251
|
+
isVisible: undefined,
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
addAnnotation(newAnnotation, element);
|
|
255
|
+
|
|
256
|
+
// Updating a Spline contours, for example, should also update freehand contours
|
|
257
|
+
const updatedTtoolNames = new Set([
|
|
258
|
+
DEFAULT_CONTOUR_SEG_TOOLNAME,
|
|
259
|
+
targetAnnotation.metadata.toolName,
|
|
260
|
+
]);
|
|
261
|
+
|
|
262
|
+
for (const toolName of updatedTtoolNames.values()) {
|
|
263
|
+
const viewportIdsToRender = getViewportIdsWithToolToRender(
|
|
264
|
+
element,
|
|
265
|
+
toolName
|
|
266
|
+
);
|
|
267
|
+
triggerAnnotationRenderForViewportIds(
|
|
268
|
+
renderingEngine,
|
|
269
|
+
viewportIdsToRender
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as contourSegmentationCompleted } from './contourSegmentationCompleted';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import annotationCompletedListener from './annotationCompletedListener';
|
|
1
2
|
import annotationSelectionListener from './annotationSelectionListener';
|
|
2
3
|
import annotationModifiedListener from './annotationModifiedListener';
|
|
3
4
|
|
|
4
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
annotationCompletedListener,
|
|
7
|
+
annotationSelectionListener,
|
|
8
|
+
annotationModifiedListener,
|
|
9
|
+
};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
imageChangeEventListener,
|
|
11
11
|
} from './segmentation';
|
|
12
12
|
import {
|
|
13
|
+
annotationCompletedListener,
|
|
13
14
|
annotationSelectionListener,
|
|
14
15
|
annotationModifiedListener,
|
|
15
16
|
} from './annotations';
|
|
@@ -25,6 +26,7 @@ export {
|
|
|
25
26
|
segmentationRepresentationRemovedEventListener,
|
|
26
27
|
segmentationDataModifiedEventListener,
|
|
27
28
|
imageChangeEventListener,
|
|
29
|
+
annotationCompletedListener,
|
|
28
30
|
annotationSelectionListener,
|
|
29
31
|
annotationModifiedListener,
|
|
30
32
|
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cache,
|
|
3
|
+
getEnabledElementByIds,
|
|
4
|
+
utilities as csUtils,
|
|
5
|
+
} from '@cornerstonejs/core';
|
|
6
|
+
|
|
7
|
+
import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
|
|
8
|
+
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
9
|
+
import { SegmentationDataModifiedEventType } from '../../../types/EventTypes';
|
|
10
|
+
import {
|
|
11
|
+
LabelmapSegmentationDataStack,
|
|
12
|
+
LabelmapSegmentationDataVolume,
|
|
13
|
+
} from '../../../types/LabelmapTypes';
|
|
14
|
+
import { isVolumeSegmentation } from '../../../tools/segmentation/strategies/utils/stackVolumeCheck';
|
|
15
|
+
import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
16
|
+
|
|
17
|
+
/** A callback function that is called when the segmentation data is modified which
|
|
18
|
+
* often is as a result of tool interactions e.g., scissors, eraser, etc.
|
|
19
|
+
*/
|
|
20
|
+
const onLabelmapSegmentationDataModified = function (
|
|
21
|
+
evt: SegmentationDataModifiedEventType
|
|
22
|
+
): void {
|
|
23
|
+
const { segmentationId, modifiedSlicesToUse } = evt.detail;
|
|
24
|
+
|
|
25
|
+
const { representationData, type } =
|
|
26
|
+
SegmentationState.getSegmentation(segmentationId);
|
|
27
|
+
|
|
28
|
+
const toolGroupIds =
|
|
29
|
+
SegmentationState.getToolGroupIdsWithSegmentation(segmentationId);
|
|
30
|
+
|
|
31
|
+
if (type !== SegmentationRepresentations.Labelmap) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`onLabelmapSegmentationDataModifiedListener: representationType ${type} not supported yet`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isVolumeSegmentation(representationData[type])) {
|
|
38
|
+
// get the volume from cache, we need the openGLTexture to be updated to GPU
|
|
39
|
+
const segmentationVolume = cache.getVolume(
|
|
40
|
+
(representationData[type] as LabelmapSegmentationDataVolume).volumeId
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (!segmentationVolume) {
|
|
44
|
+
console.warn('segmentation not found in cache');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { imageData, vtkOpenGLTexture } = segmentationVolume;
|
|
49
|
+
|
|
50
|
+
// Update the texture for the volume in the GPU
|
|
51
|
+
let slicesToUpdate;
|
|
52
|
+
if (modifiedSlicesToUse && Array.isArray(modifiedSlicesToUse)) {
|
|
53
|
+
slicesToUpdate = modifiedSlicesToUse;
|
|
54
|
+
} else {
|
|
55
|
+
const numSlices = imageData.getDimensions()[2];
|
|
56
|
+
slicesToUpdate = [...Array(numSlices).keys()];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
slicesToUpdate.forEach((i) => {
|
|
60
|
+
vtkOpenGLTexture.setUpdatedFrame(i);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Trigger modified on the imageData to update the image
|
|
64
|
+
imageData.modified();
|
|
65
|
+
} else {
|
|
66
|
+
toolGroupIds.forEach((toolGroupId) => {
|
|
67
|
+
const toolGroupSegmentationRepresentations =
|
|
68
|
+
SegmentationState.getSegmentationRepresentations(toolGroupId);
|
|
69
|
+
|
|
70
|
+
const toolGroup = getToolGroup(toolGroupId);
|
|
71
|
+
const viewportsInfo = toolGroup.getViewportsInfo();
|
|
72
|
+
|
|
73
|
+
toolGroupSegmentationRepresentations.forEach((representation) => {
|
|
74
|
+
if (representation.segmentationId !== segmentationId) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
viewportsInfo.forEach(({ viewportId, renderingEngineId }) => {
|
|
79
|
+
const viewport = getEnabledElementByIds(
|
|
80
|
+
viewportId,
|
|
81
|
+
renderingEngineId
|
|
82
|
+
).viewport;
|
|
83
|
+
|
|
84
|
+
const actorEntry = viewport.getActor(
|
|
85
|
+
representation.segmentationRepresentationUID
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (!actorEntry) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const currentImageId = viewport.getCurrentImageId();
|
|
93
|
+
|
|
94
|
+
const segImageData = actorEntry.actor.getMapper().getInputData();
|
|
95
|
+
|
|
96
|
+
const { imageIdReferenceMap } = representationData[
|
|
97
|
+
type
|
|
98
|
+
] as LabelmapSegmentationDataStack;
|
|
99
|
+
|
|
100
|
+
const currentSegmentationImageId =
|
|
101
|
+
imageIdReferenceMap.get(currentImageId);
|
|
102
|
+
|
|
103
|
+
const segmentationImage = cache.getImage(currentSegmentationImageId);
|
|
104
|
+
segImageData.modified();
|
|
105
|
+
|
|
106
|
+
// update the cache with the new image data
|
|
107
|
+
csUtils.updateVTKImageDataWithCornerstoneImage(
|
|
108
|
+
segImageData,
|
|
109
|
+
segmentationImage
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default onLabelmapSegmentationDataModified;
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cache,
|
|
3
|
-
getEnabledElementByIds,
|
|
4
|
-
utilities as csUtils,
|
|
5
|
-
} from '@cornerstonejs/core';
|
|
6
|
-
|
|
7
1
|
import triggerSegmentationRender from '../../utilities/segmentation/triggerSegmentationRender';
|
|
8
2
|
import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
|
|
9
3
|
import * as SegmentationState from '../../stateManagement/segmentation/segmentationState';
|
|
10
4
|
import { SegmentationDataModifiedEventType } from '../../types/EventTypes';
|
|
11
|
-
import
|
|
12
|
-
LabelmapSegmentationDataStack,
|
|
13
|
-
LabelmapSegmentationDataVolume,
|
|
14
|
-
} from '../../types/LabelmapTypes';
|
|
15
|
-
import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
|
|
16
|
-
import { getToolGroup } from '../../store/ToolGroupManager';
|
|
5
|
+
import onLabelmapSegmentationDataModified from './labelmap/onLabelmapSegmentationDataModified';
|
|
17
6
|
|
|
18
7
|
/** A callback function that is called when the segmentation data is modified which
|
|
19
8
|
* often is as a result of tool interactions e.g., scissors, eraser, etc.
|
|
@@ -21,97 +10,14 @@ import { getToolGroup } from '../../store/ToolGroupManager';
|
|
|
21
10
|
const onSegmentationDataModified = function (
|
|
22
11
|
evt: SegmentationDataModifiedEventType
|
|
23
12
|
): void {
|
|
24
|
-
const { segmentationId
|
|
25
|
-
|
|
26
|
-
const { representationData, type } =
|
|
27
|
-
SegmentationState.getSegmentation(segmentationId);
|
|
13
|
+
const { segmentationId } = evt.detail;
|
|
14
|
+
const { type } = SegmentationState.getSegmentation(segmentationId);
|
|
28
15
|
|
|
29
16
|
const toolGroupIds =
|
|
30
17
|
SegmentationState.getToolGroupIdsWithSegmentation(segmentationId);
|
|
31
18
|
|
|
32
|
-
if (type
|
|
33
|
-
|
|
34
|
-
`onSegmentationDataModified: representationType ${type} not supported yet`
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (isVolumeSegmentation(representationData[type])) {
|
|
39
|
-
// get the volume from cache, we need the openGLTexture to be updated to GPU
|
|
40
|
-
const segmentationVolume = cache.getVolume(
|
|
41
|
-
(representationData[type] as LabelmapSegmentationDataVolume).volumeId
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
if (!segmentationVolume) {
|
|
45
|
-
console.warn('segmentation not found in cache');
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const { imageData, vtkOpenGLTexture } = segmentationVolume;
|
|
50
|
-
|
|
51
|
-
// Update the texture for the volume in the GPU
|
|
52
|
-
let slicesToUpdate;
|
|
53
|
-
if (modifiedSlicesToUse && Array.isArray(modifiedSlicesToUse)) {
|
|
54
|
-
slicesToUpdate = modifiedSlicesToUse;
|
|
55
|
-
} else {
|
|
56
|
-
const numSlices = imageData.getDimensions()[2];
|
|
57
|
-
slicesToUpdate = [...Array(numSlices).keys()];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
slicesToUpdate.forEach((i) => {
|
|
61
|
-
vtkOpenGLTexture.setUpdatedFrame(i);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Trigger modified on the imageData to update the image
|
|
65
|
-
imageData.modified();
|
|
66
|
-
} else {
|
|
67
|
-
toolGroupIds.forEach((toolGroupId) => {
|
|
68
|
-
const toolGroupSegmentationRepresentations =
|
|
69
|
-
SegmentationState.getSegmentationRepresentations(toolGroupId);
|
|
70
|
-
|
|
71
|
-
const toolGroup = getToolGroup(toolGroupId);
|
|
72
|
-
const viewportsInfo = toolGroup.getViewportsInfo();
|
|
73
|
-
|
|
74
|
-
toolGroupSegmentationRepresentations.forEach((representation) => {
|
|
75
|
-
if (representation.segmentationId !== segmentationId) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
viewportsInfo.forEach(({ viewportId, renderingEngineId }) => {
|
|
80
|
-
const viewport = getEnabledElementByIds(
|
|
81
|
-
viewportId,
|
|
82
|
-
renderingEngineId
|
|
83
|
-
).viewport;
|
|
84
|
-
|
|
85
|
-
const actorEntry = viewport.getActor(
|
|
86
|
-
representation.segmentationRepresentationUID
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
if (!actorEntry) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const currentImageId = viewport.getCurrentImageId();
|
|
94
|
-
|
|
95
|
-
const segImageData = actorEntry.actor.getMapper().getInputData();
|
|
96
|
-
|
|
97
|
-
const { imageIdReferenceMap } = representationData[
|
|
98
|
-
type
|
|
99
|
-
] as LabelmapSegmentationDataStack;
|
|
100
|
-
|
|
101
|
-
const currentSegmentationImageId =
|
|
102
|
-
imageIdReferenceMap.get(currentImageId);
|
|
103
|
-
|
|
104
|
-
const segmentationImage = cache.getImage(currentSegmentationImageId);
|
|
105
|
-
segImageData.modified();
|
|
106
|
-
|
|
107
|
-
// update the cache with the new image data
|
|
108
|
-
csUtils.updateVTKImageDataWithCornerstoneImage(
|
|
109
|
-
segImageData,
|
|
110
|
-
segmentationImage
|
|
111
|
-
);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
});
|
|
19
|
+
if (type === SegmentationRepresentations.Labelmap) {
|
|
20
|
+
onLabelmapSegmentationDataModified(evt);
|
|
115
21
|
}
|
|
116
22
|
|
|
117
23
|
toolGroupIds.forEach((toolGroupId) => {
|
package/src/init.ts
CHANGED
|
@@ -5,12 +5,13 @@ import { Events as TOOLS_EVENTS } from './enums';
|
|
|
5
5
|
import { addEnabledElement, removeEnabledElement } from './store';
|
|
6
6
|
import { resetCornerstoneToolsState } from './store/state';
|
|
7
7
|
import {
|
|
8
|
+
annotationCompletedListener,
|
|
8
9
|
annotationSelectionListener,
|
|
10
|
+
annotationModifiedListener,
|
|
9
11
|
segmentationDataModifiedEventListener,
|
|
10
12
|
segmentationRepresentationModifiedEventListener,
|
|
11
13
|
segmentationRepresentationRemovedEventListener,
|
|
12
14
|
segmentationModifiedListener,
|
|
13
|
-
annotationModifiedListener,
|
|
14
15
|
} from './eventListeners';
|
|
15
16
|
import { annotationInterpolationEventDispatcher } from './eventDispatchers';
|
|
16
17
|
|
|
@@ -103,6 +104,11 @@ function _addCornerstoneToolsEventListeners() {
|
|
|
103
104
|
/**
|
|
104
105
|
* Annotation
|
|
105
106
|
*/
|
|
107
|
+
eventTarget.addEventListener(
|
|
108
|
+
TOOLS_EVENTS.ANNOTATION_COMPLETED,
|
|
109
|
+
annotationCompletedListener
|
|
110
|
+
);
|
|
111
|
+
|
|
106
112
|
eventTarget.addEventListener(
|
|
107
113
|
TOOLS_EVENTS.ANNOTATION_MODIFIED,
|
|
108
114
|
annotationModifiedListener
|
|
@@ -148,6 +154,11 @@ function _removeCornerstoneToolsEventListeners() {
|
|
|
148
154
|
/**
|
|
149
155
|
* Annotation
|
|
150
156
|
*/
|
|
157
|
+
eventTarget.removeEventListener(
|
|
158
|
+
TOOLS_EVENTS.ANNOTATION_COMPLETED,
|
|
159
|
+
annotationCompletedListener
|
|
160
|
+
);
|
|
161
|
+
|
|
151
162
|
eventTarget.removeEventListener(
|
|
152
163
|
TOOLS_EVENTS.ANNOTATION_MODIFIED,
|
|
153
164
|
annotationModifiedListener
|
|
@@ -7,7 +7,11 @@ import {
|
|
|
7
7
|
import { Events } from '../../../enums';
|
|
8
8
|
import { Annotation } from '../../../types/AnnotationTypes';
|
|
9
9
|
import { getToolGroupsWithToolName } from '../../../store/ToolGroupManager';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
AnnotationAddedEventDetail,
|
|
12
|
+
AnnotationModifiedEventDetail,
|
|
13
|
+
AnnotationCompletedEventDetail,
|
|
14
|
+
} from '../../../types/EventTypes';
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* It triggers an event for the element when an annotation is added
|
|
@@ -76,4 +80,40 @@ function triggerAnnotationAddedForFOR(annotation: Annotation) {
|
|
|
76
80
|
});
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Triggers an annotation modified event.
|
|
85
|
+
*/
|
|
86
|
+
function triggerAnnotationModified(
|
|
87
|
+
annotation: Annotation,
|
|
88
|
+
element: HTMLDivElement
|
|
89
|
+
): void {
|
|
90
|
+
const enabledElement = getEnabledElement(element);
|
|
91
|
+
const { viewportId, renderingEngineId } = enabledElement;
|
|
92
|
+
const eventType = Events.ANNOTATION_MODIFIED;
|
|
93
|
+
const eventDetail: AnnotationModifiedEventDetail = {
|
|
94
|
+
annotation,
|
|
95
|
+
viewportId,
|
|
96
|
+
renderingEngineId,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
triggerEvent(eventTarget, eventType, eventDetail);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Triggers an annotation completed event.
|
|
104
|
+
*/
|
|
105
|
+
function triggerAnnotationCompleted(annotation: Annotation): void {
|
|
106
|
+
const eventType = Events.ANNOTATION_COMPLETED;
|
|
107
|
+
const eventDetail: AnnotationCompletedEventDetail = {
|
|
108
|
+
annotation,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
triggerEvent(eventTarget, eventType, eventDetail);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
triggerAnnotationAddedForElement,
|
|
116
|
+
triggerAnnotationAddedForFOR,
|
|
117
|
+
triggerAnnotationModified,
|
|
118
|
+
triggerAnnotationCompleted,
|
|
119
|
+
};
|
|
@@ -87,6 +87,16 @@ export default class ToolGroup implements IToolGroup {
|
|
|
87
87
|
|
|
88
88
|
return toolInstance;
|
|
89
89
|
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Check if a tool is already added to the tool group
|
|
93
|
+
* @param toolName - Tool name
|
|
94
|
+
* @returns True if the tool is already added or false otherwise
|
|
95
|
+
*/
|
|
96
|
+
hasTool(toolName: string): boolean {
|
|
97
|
+
return !!this._toolInstances[toolName];
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
/**
|
|
91
101
|
* Add a tool to the tool group with the given tool name and tool configuration.
|
|
92
102
|
* Note that adding a tool to a tool group will not automatically set the tool
|