@cornerstonejs/tools 5.0.0-beta.1 → 5.0.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/esm/config.d.ts +4 -0
- package/dist/esm/drawingSvg/drawPath.d.ts +3 -0
- package/dist/esm/drawingSvg/drawPath.js +4 -1
- package/dist/esm/eventListeners/keyboard/keyDownListener.js +2 -2
- package/dist/esm/eventListeners/mouse/getMouseEventPoints.d.ts +1 -1
- package/dist/esm/eventListeners/mouse/getMouseEventPoints.js +19 -1
- package/dist/esm/eventListeners/mouse/mouseDoubleClickListener.js +8 -1
- package/dist/esm/eventListeners/mouse/mouseDownListener.js +37 -5
- package/dist/esm/eventListeners/mouse/mouseMoveListener.js +3 -0
- package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +60 -92
- package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +49 -21
- package/dist/esm/eventListeners/segmentation/labelmap/performStackLabelmapUpdate.js +7 -13
- package/dist/esm/eventListeners/segmentation/labelmap/performVolumeLabelmapUpdate.js +44 -18
- package/dist/esm/eventListeners/touch/getTouchEventPoints.js +27 -4
- package/dist/esm/eventListeners/touch/touchStartListener.js +27 -9
- package/dist/esm/eventListeners/wheel/wheelListener.js +5 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/init.js +2 -0
- package/dist/esm/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.js +10 -4
- package/dist/esm/stateManagement/segmentation/SegmentationRenderingEngine.js +23 -20
- package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.d.ts +12 -0
- package/dist/esm/stateManagement/segmentation/SegmentationRepresentationDisplayRegistry.js +7 -0
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -10
- package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +28 -149
- package/dist/esm/stateManagement/segmentation/addColorLUT.js +7 -1
- package/dist/esm/stateManagement/segmentation/getCurrentLabelmapImageIdForViewport.js +16 -1
- package/dist/esm/stateManagement/segmentation/helpers/clearSegmentValue.js +9 -7
- package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.d.ts +1 -1
- package/dist/esm/stateManagement/segmentation/helpers/getSegmentationActor.js +3 -2
- package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.d.ts +5 -0
- package/dist/esm/stateManagement/segmentation/helpers/getViewportLabelmapRenderMode.js +58 -0
- package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.d.ts +52 -0
- package/dist/esm/stateManagement/segmentation/helpers/labelmapImageMapperSupport.js +246 -0
- package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.d.ts +1 -0
- package/dist/esm/stateManagement/segmentation/helpers/labelmapSegmentationState.js +1 -0
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +12 -1
- package/dist/esm/stateManagement/segmentation/internalAddSegmentationRepresentation.js +3 -3
- package/dist/esm/stateManagement/segmentation/labelmapModel/index.d.ts +9 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/index.js +7 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.d.ts +54 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapEditTransaction.js +224 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.d.ts +6 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageIdMapping.js +39 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.d.ts +23 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapImageReferenceResolver.js +269 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.d.ts +15 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLayerStore.js +160 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.d.ts +4 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapLegacyAdapter.js +42 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.d.ts +11 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/labelmapSegmentBindings.js +73 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.d.ts +17 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.js +75 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.d.ts +5 -0
- package/dist/esm/stateManagement/segmentation/labelmapModel/privateLabelmap.js +106 -0
- package/dist/esm/stateManagement/segmentation/models/SegmentModel.d.ts +11 -0
- package/dist/esm/stateManagement/segmentation/models/SegmentModel.js +19 -0
- package/dist/esm/stateManagement/segmentation/models/SegmentationModel.d.ts +12 -0
- package/dist/esm/stateManagement/segmentation/models/SegmentationModel.js +23 -0
- package/dist/esm/stateManagement/segmentation/removeSegmentationRepresentations.js +6 -10
- package/dist/esm/stateManagement/segmentation/segmentIndex.js +24 -0
- package/dist/esm/stateManagement/segmentation/segmentationEventManager.js +2 -9
- package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +2 -1
- package/dist/esm/stateManagement/segmentation/segmentationState.js +4 -1
- package/dist/esm/store/SynchronizerManager/Synchronizer.d.ts +3 -1
- package/dist/esm/store/state.js +2 -1
- package/dist/esm/synchronizers/callbacks/imageSliceSyncCallback.js +12 -3
- package/dist/esm/synchronizers/callbacks/presentationViewSyncCallback.js +5 -2
- package/dist/esm/synchronizers/callbacks/zoomPanSyncCallback.js +51 -3
- package/dist/esm/synchronizers/synchronizers/createPresentationViewSynchronizer.d.ts +1 -1
- package/dist/esm/tools/AdvancedMagnifyTool.js +4 -1
- package/dist/esm/tools/CrosshairsTool.d.ts +4 -0
- package/dist/esm/tools/CrosshairsTool.js +95 -41
- package/dist/esm/tools/MagnifyTool.js +3 -1
- package/dist/esm/tools/OrientationControllerTool.d.ts +45 -0
- package/dist/esm/tools/OrientationControllerTool.js +454 -0
- package/dist/esm/tools/OrientationMarkerTool.js +4 -4
- package/dist/esm/tools/PanTool.js +26 -3
- package/dist/esm/tools/PlanarRotateTool.js +19 -4
- package/dist/esm/tools/ReferenceCursors.js +7 -1
- package/dist/esm/tools/SculptorTool/CircleSculptCursor.js +1 -1
- package/dist/esm/tools/TrackballRotateTool.js +3 -2
- package/dist/esm/tools/VolumeCroppingControlTool.d.ts +10 -35
- package/dist/esm/tools/VolumeCroppingControlTool.js +179 -699
- package/dist/esm/tools/VolumeCroppingTool.d.ts +34 -32
- package/dist/esm/tools/VolumeCroppingTool.js +813 -532
- package/dist/esm/tools/WindowLevelTool.d.ts +2 -1
- package/dist/esm/tools/WindowLevelTool.js +48 -4
- package/dist/esm/tools/ZoomTool.d.ts +8 -0
- package/dist/esm/tools/ZoomTool.js +92 -11
- package/dist/esm/tools/annotation/AngleTool.js +38 -32
- package/dist/esm/tools/annotation/ArrowAnnotateTool.js +30 -28
- package/dist/esm/tools/annotation/BidirectionalTool.js +51 -49
- package/dist/esm/tools/annotation/CircleROITool.d.ts +1 -0
- package/dist/esm/tools/annotation/CircleROITool.js +89 -51
- package/dist/esm/tools/annotation/CobbAngleTool.js +1 -1
- package/dist/esm/tools/annotation/DragProbeTool.js +1 -1
- package/dist/esm/tools/annotation/ETDRSGridTool.js +1 -1
- package/dist/esm/tools/annotation/EllipticalROITool.js +46 -39
- package/dist/esm/tools/annotation/HeightTool.js +1 -1
- package/dist/esm/tools/annotation/KeyImageTool.js +11 -11
- package/dist/esm/tools/annotation/LabelTool.js +37 -35
- package/dist/esm/tools/annotation/LengthTool.js +35 -33
- package/dist/esm/tools/annotation/LivewireContourSegmentationTool.js +6 -4
- package/dist/esm/tools/annotation/LivewireContourTool.js +4 -8
- package/dist/esm/tools/annotation/PlanarFreehandContourSegmentationTool.js +6 -4
- package/dist/esm/tools/annotation/PlanarFreehandROITool.js +3 -4
- package/dist/esm/tools/annotation/ProbeTool.js +66 -56
- package/dist/esm/tools/annotation/RectangleROITool.js +48 -37
- package/dist/esm/tools/annotation/RegionSegmentPlusTool.js +1 -1
- package/dist/esm/tools/annotation/RegionSegmentTool.js +1 -1
- package/dist/esm/tools/annotation/SplineContourSegmentationTool.js +1 -1
- package/dist/esm/tools/annotation/SplineROITool.js +60 -56
- package/dist/esm/tools/annotation/UltrasoundDirectionalTool.js +1 -1
- package/dist/esm/tools/annotation/UltrasoundPleuraBLineTool/UltrasoundPleuraBLineTool.js +57 -55
- package/dist/esm/tools/annotation/VideoRedactionTool.js +1 -1
- package/dist/esm/tools/base/AnnotationDisplayTool.js +9 -6
- package/dist/esm/tools/base/AnnotationTool.js +2 -1
- package/dist/esm/tools/base/BaseTool.js +16 -10
- package/dist/esm/tools/base/ContourSegmentationBaseTool.js +1 -1
- package/dist/esm/tools/base/GrowCutBaseTool.js +2 -2
- package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.d.ts +2 -4
- package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +15 -85
- package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.d.ts +5 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapActorStyle.js +191 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.d.ts +4 -3
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +48 -209
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.d.ts +3 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/createLabelmapRenderPlan.js +51 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.d.ts +4 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/index.js +3 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.d.ts +14 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/legacyVolumePlan.js +143 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.d.ts +40 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/planarGenericVolumeLabelmap.js +79 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.d.ts +3 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/removeLabelmapRepresentationFromViewport.js +18 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.d.ts +9 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/resolveLabelmapRenderPlan.js +56 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.d.ts +11 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/stackImagePlan.js +35 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.d.ts +48 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/types.js +0 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.d.ts +13 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan/volumeSliceImageMapperPlan.js +34 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.d.ts +2 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRenderPlan.js +1 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.d.ts +8 -0
- package/dist/esm/tools/displayTools/Labelmap/labelmapRepresentationUID.js +18 -0
- package/dist/esm/tools/displayTools/Labelmap/removeLabelmapFromElement.js +2 -2
- package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.d.ts +3 -0
- package/dist/esm/tools/displayTools/Labelmap/removeLabelmapRepresentationData.js +16 -0
- package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.d.ts +2 -0
- package/dist/esm/tools/displayTools/Labelmap/syncStackLabelmapActors.js +135 -0
- package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.d.ts +16 -0
- package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapImageMapper.js +267 -0
- package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.d.ts +27 -0
- package/dist/esm/tools/displayTools/Labelmap/volumeLabelmapSliceData.js +185 -0
- package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.d.ts +1 -0
- package/dist/esm/tools/displayTools/registerBuiltInSegmentationRepresentationDisplays.js +16 -0
- package/dist/esm/tools/index.d.ts +2 -1
- package/dist/esm/tools/index.js +2 -1
- package/dist/esm/tools/segmentation/BrushTool.d.ts +9 -2
- package/dist/esm/tools/segmentation/BrushTool.js +123 -26
- package/dist/esm/tools/segmentation/CircleScissorsTool.js +19 -36
- package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +2 -3
- package/dist/esm/tools/segmentation/LabelmapBaseTool.js +77 -46
- package/dist/esm/tools/segmentation/LabelmapEditWithContour.js +3 -3
- package/dist/esm/tools/segmentation/PaintFillTool.js +11 -4
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.d.ts +2 -0
- package/dist/esm/tools/segmentation/RectangleROIStartEndThresholdTool.js +16 -8
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js +13 -6
- package/dist/esm/tools/segmentation/SegmentBidirectionalTool.js +63 -61
- package/dist/esm/tools/segmentation/SegmentSelectTool.js +4 -4
- package/dist/esm/tools/segmentation/SphereScissorsTool.js +11 -31
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +7 -0
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +47 -24
- package/dist/esm/tools/segmentation/strategies/compositions/circularCursor.js +49 -21
- package/dist/esm/tools/segmentation/strategies/compositions/determineSegmentIndex.js +2 -2
- package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +5 -1
- package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.js +2 -2
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js +2 -2
- package/dist/esm/tools/segmentation/strategies/compositions/setValue.js +14 -6
- package/dist/esm/tools/segmentation/strategies/fillCircle.d.ts +3 -1
- package/dist/esm/tools/segmentation/strategies/fillCircle.js +38 -31
- package/dist/esm/tools/segmentation/strategies/fillSphere.js +11 -3
- package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.d.ts +4 -0
- package/dist/esm/tools/segmentation/strategies/utils/crossLayerErase.js +23 -0
- package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +1 -1
- package/dist/esm/tools/segmentation/strategies/utils/handleUseSegmentCenterIndex.js +12 -11
- package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.d.ts +4 -0
- package/dist/esm/tools/segmentation/strategies/utils/labelmapOverlap.js +41 -0
- package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.d.ts +3 -0
- package/dist/esm/tools/segmentation/strategies/utils/overwritePolicy.js +31 -0
- package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.d.ts +3 -0
- package/dist/esm/tools/segmentation/strategies/utils/segmentSeparation.js +38 -0
- package/dist/esm/tools/segmentation/utils/LazyBrushEditController.d.ts +19 -0
- package/dist/esm/tools/segmentation/utils/LazyBrushEditController.js +55 -0
- package/dist/esm/tools/segmentation/utils/lazyBrushPreview.d.ts +3 -0
- package/dist/esm/tools/segmentation/utils/lazyBrushPreview.js +34 -0
- package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.d.ts +3 -0
- package/dist/esm/tools/segmentation/utils/shouldUseLazyLabelmapEditing.js +42 -0
- package/dist/esm/types/ISynchronizerEventHandler.d.ts +2 -1
- package/dist/esm/types/LabelmapToolOperationData.d.ts +5 -0
- package/dist/esm/types/LabelmapTypes.d.ts +29 -6
- package/dist/esm/types/SegmentationStateTypes.d.ts +6 -0
- package/dist/esm/utilities/calibrateImageSpacing.js +17 -2
- package/dist/esm/utilities/contours/AnnotationToPointData.js +1 -1
- package/dist/esm/utilities/draw3D/addLine3DBetweenPoints.d.ts +7 -0
- package/dist/esm/utilities/draw3D/addLine3DBetweenPoints.js +34 -0
- package/dist/esm/utilities/draw3D/calculateAdaptiveSphereRadius.d.ts +6 -0
- package/dist/esm/utilities/draw3D/calculateAdaptiveSphereRadius.js +7 -0
- package/dist/esm/utilities/draw3D/index.d.ts +2 -0
- package/dist/esm/utilities/draw3D/index.js +2 -0
- package/dist/esm/utilities/drawing/getTextBoxCoordsCanvas.js +22 -14
- package/dist/esm/utilities/getCenterAndRadiusInCanvas.d.ts +6 -0
- package/dist/esm/utilities/getCenterAndRadiusInCanvas.js +26 -0
- package/dist/esm/utilities/getEllipseWorldCoordinates.d.ts +2 -0
- package/dist/esm/utilities/getEllipseWorldCoordinates.js +26 -0
- package/dist/esm/utilities/getSphereBoundsInfo.js +5 -1
- package/dist/esm/utilities/getViewportICamera.d.ts +4 -0
- package/dist/esm/utilities/getViewportICamera.js +23 -0
- package/dist/esm/utilities/getViewportsForAnnotation.js +5 -1
- package/dist/esm/utilities/index.d.ts +2 -1
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/interactionDragCoordinator.d.ts +5 -0
- package/dist/esm/utilities/interactionDragCoordinator.js +16 -0
- package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +9 -7
- package/dist/esm/utilities/pointInSurroundingSphereCallback.js +8 -1
- package/dist/esm/utilities/segmentation/InterpolationManager/InterpolationManager.js +121 -118
- package/dist/esm/utilities/segmentation/SegmentStatsCalculator.js +5 -4
- package/dist/esm/utilities/segmentation/VolumetricCalculator.js +1 -1
- package/dist/esm/utilities/segmentation/createLabelmapVolumeForViewport.js +1 -1
- package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentation.js +1 -1
- package/dist/esm/utilities/segmentation/getReferenceVolumeForSegmentationVolume.js +11 -2
- package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.js +36 -17
- package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.js +42 -25
- package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +3 -30
- package/dist/esm/utilities/segmentation/index.d.ts +2 -1
- package/dist/esm/utilities/segmentation/index.js +2 -1
- package/dist/esm/utilities/segmentation/utilsForWorker.js +6 -2
- package/dist/esm/utilities/segmentation/validateLabelmap.js +1 -1
- package/dist/esm/utilities/stackPrefetch/stackPrefetch.js +0 -1
- package/dist/esm/utilities/touch/index.js +3 -2
- package/dist/esm/utilities/viewportCapabilities.d.ts +16 -0
- package/dist/esm/utilities/viewportCapabilities.js +18 -0
- package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.d.ts +1 -1
- package/dist/esm/utilities/viewportFilters/filterViewportsWithParallelNormals.js +12 -4
- package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.d.ts +1 -1
- package/dist/esm/utilities/viewportFilters/filterViewportsWithSameOrientation.js +11 -4
- package/dist/esm/utilities/viewportFilters/getViewportIdsWithToolToRender.js +1 -1
- package/dist/esm/utilities/viewportPresentation.d.ts +3 -0
- package/dist/esm/utilities/viewportPresentation.js +26 -0
- package/dist/esm/utilities/volumeCropping/computePlanePlaneIntersection.d.ts +6 -0
- package/dist/esm/utilities/volumeCropping/computePlanePlaneIntersection.js +37 -0
- package/dist/esm/utilities/volumeCropping/constants.d.ts +31 -0
- package/dist/esm/utilities/volumeCropping/constants.js +31 -0
- package/dist/esm/utilities/volumeCropping/copyClippingPlanes.d.ts +2 -0
- package/dist/esm/utilities/volumeCropping/copyClippingPlanes.js +6 -0
- package/dist/esm/utilities/volumeCropping/extractVolumeDirectionVectors.d.ts +9 -0
- package/dist/esm/utilities/volumeCropping/extractVolumeDirectionVectors.js +9 -0
- package/dist/esm/utilities/volumeCropping/findLineBoundsIntersection.d.ts +5 -0
- package/dist/esm/utilities/volumeCropping/findLineBoundsIntersection.js +50 -0
- package/dist/esm/utilities/volumeCropping/getColorKeyForPlaneIndex.d.ts +1 -0
- package/dist/esm/utilities/volumeCropping/getColorKeyForPlaneIndex.js +13 -0
- package/dist/esm/utilities/volumeCropping/getOrientationFromNormal.d.ts +2 -0
- package/dist/esm/utilities/volumeCropping/getOrientationFromNormal.js +19 -0
- package/dist/esm/utilities/volumeCropping/index.d.ts +9 -0
- package/dist/esm/utilities/volumeCropping/index.js +9 -0
- package/dist/esm/utilities/volumeCropping/parseCornerKey.d.ts +8 -0
- package/dist/esm/utilities/volumeCropping/parseCornerKey.js +11 -0
- package/dist/esm/utilities/volumeCropping/types.d.ts +5 -0
- package/dist/esm/utilities/volumeCropping/types.js +0 -0
- package/dist/esm/utilities/vtkjs/AnnotatedRhombicuboctahedronActor/index.d.ts +31 -0
- package/dist/esm/utilities/vtkjs/AnnotatedRhombicuboctahedronActor/index.js +391 -0
- package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.d.ts +69 -0
- package/dist/esm/utilities/vtkjs/OrientationControllerWidget/index.js +804 -0
- package/dist/esm/utilities/vtkjs/RhombicuboctahedronSource/index.d.ts +7 -0
- package/dist/esm/utilities/vtkjs/RhombicuboctahedronSource/index.js +144 -0
- package/dist/esm/utilities/vtkjs/index.d.ts +3 -0
- package/dist/esm/utilities/vtkjs/index.js +3 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +10 -9
package/dist/esm/tools/index.js
CHANGED
|
@@ -55,9 +55,10 @@ import CircleROIStartEndThresholdTool from './segmentation/CircleROIStartEndThre
|
|
|
55
55
|
import BrushTool from './segmentation/BrushTool';
|
|
56
56
|
import PaintFillTool from './segmentation/PaintFillTool';
|
|
57
57
|
import OrientationMarkerTool from './OrientationMarkerTool';
|
|
58
|
+
import OrientationControllerTool from './OrientationControllerTool';
|
|
58
59
|
import SegmentSelectTool from './segmentation/SegmentSelectTool';
|
|
59
60
|
import SegmentBidirectionalTool from './segmentation/SegmentBidirectionalTool';
|
|
60
61
|
import * as strategies from './segmentation/strategies';
|
|
61
62
|
import SegmentLabelTool from './segmentation/SegmentLabelTool';
|
|
62
63
|
import LabelMapEditWithContourTool from './segmentation/LabelmapEditWithContour';
|
|
63
|
-
export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, SegmentLabelTool, LabelMapEditWithContourTool, strategies, };
|
|
64
|
+
export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, VolumeCroppingTool, VolumeCroppingControlTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LabelTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, ETDRSGridTool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, UltrasoundPleuraBLineTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OrientationControllerTool, SculptorTool, SegmentSelectTool, VolumeRotateTool, RegionSegmentTool, RegionSegmentPlusTool, WholeBodySegmentTool, LabelmapBaseTool, SegmentBidirectionalTool, SegmentLabelTool, LabelMapEditWithContourTool, strategies, };
|
|
@@ -4,11 +4,18 @@ import LabelmapBaseTool from './LabelmapBaseTool';
|
|
|
4
4
|
declare class BrushTool extends LabelmapBaseTool {
|
|
5
5
|
static toolName: any;
|
|
6
6
|
private _lastDragInfo;
|
|
7
|
+
private _lazyEdit;
|
|
7
8
|
constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
|
|
8
|
-
onSetToolPassive: (
|
|
9
|
+
onSetToolPassive: (_evt: any) => void;
|
|
9
10
|
onSetToolEnabled: () => void;
|
|
10
|
-
onSetToolDisabled: (
|
|
11
|
+
onSetToolDisabled: (_evt: any) => void;
|
|
11
12
|
private disableCursor;
|
|
13
|
+
private _isLazyLabelmapEditingEnabled;
|
|
14
|
+
private _resetLazyEditState;
|
|
15
|
+
private _clearPendingLazyPreviewCleanup;
|
|
16
|
+
private _refreshCursor;
|
|
17
|
+
private _scheduleLazyPreviewCleanup;
|
|
18
|
+
private _captureLazyPreviewCircle;
|
|
12
19
|
preMouseDownCallback: (evt: EventTypes.MouseDownActivateEventType) => boolean;
|
|
13
20
|
mouseMoveCallback: (evt: EventTypes.InteractionEventType) => void;
|
|
14
21
|
previewCallback: () => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEnabledElement, eventTarget } from '@cornerstonejs/core';
|
|
1
|
+
import { getEnabledElement, eventTarget, Enums } from '@cornerstonejs/core';
|
|
2
2
|
import { vec3, vec2 } from 'gl-matrix';
|
|
3
3
|
import { Events, ToolModes, StrategyCallbacks } from '../../enums';
|
|
4
4
|
import { fillInsideSphere, thresholdInsideSphere, thresholdInsideSphereIsland, } from './strategies/fillSphere';
|
|
@@ -9,6 +9,9 @@ import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCur
|
|
|
9
9
|
import triggerAnnotationRenderForViewportUIDs from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
10
10
|
import LabelmapBaseTool from './LabelmapBaseTool';
|
|
11
11
|
import { getStrategyData } from './strategies/utils/getStrategyData';
|
|
12
|
+
import LazyBrushEditController from './utils/LazyBrushEditController';
|
|
13
|
+
import { shouldUseLazyLabelmapEditing } from './utils/shouldUseLazyLabelmapEditing';
|
|
14
|
+
import { getActiveSegmentation } from '../../stateManagement/segmentation/getActiveSegmentation';
|
|
12
15
|
class BrushTool extends LabelmapBaseTool {
|
|
13
16
|
constructor(toolProps = {}, defaultToolProps = {
|
|
14
17
|
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
@@ -80,13 +83,14 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
80
83
|
}) {
|
|
81
84
|
super(toolProps, defaultToolProps);
|
|
82
85
|
this._lastDragInfo = null;
|
|
83
|
-
this.
|
|
86
|
+
this._lazyEdit = new LazyBrushEditController();
|
|
87
|
+
this.onSetToolPassive = (_evt) => {
|
|
84
88
|
this.disableCursor();
|
|
85
89
|
};
|
|
86
90
|
this.onSetToolEnabled = () => {
|
|
87
91
|
this.disableCursor();
|
|
88
92
|
};
|
|
89
|
-
this.onSetToolDisabled = (
|
|
93
|
+
this.onSetToolDisabled = (_evt) => {
|
|
90
94
|
this.disableCursor();
|
|
91
95
|
};
|
|
92
96
|
this.preMouseDownCallback = (evt) => {
|
|
@@ -94,6 +98,18 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
94
98
|
const { element, currentPoints } = eventData;
|
|
95
99
|
const enabledElement = getEnabledElement(element);
|
|
96
100
|
const { viewport } = enabledElement;
|
|
101
|
+
const activeSegmentation = getActiveSegmentation(viewport.id);
|
|
102
|
+
if (!activeSegmentation) {
|
|
103
|
+
const event = new CustomEvent(Enums.Events.ERROR_EVENT, {
|
|
104
|
+
detail: {
|
|
105
|
+
type: 'Segmentation',
|
|
106
|
+
message: 'No active segmentation detected, create a segmentation representation before using the brush tool',
|
|
107
|
+
},
|
|
108
|
+
cancelable: true,
|
|
109
|
+
});
|
|
110
|
+
eventTarget.dispatchEvent(event);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
97
113
|
this._editData = this.createEditData(element);
|
|
98
114
|
this._activateDraw(element);
|
|
99
115
|
hideElementCursor(element);
|
|
@@ -109,8 +125,14 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
109
125
|
canvas: canvasPoint,
|
|
110
126
|
world: vec3.clone(worldPoint),
|
|
111
127
|
};
|
|
112
|
-
|
|
113
|
-
|
|
128
|
+
this._hoverData = this.createHoverData(element, canvasPoint);
|
|
129
|
+
this._calculateCursor(element, canvasPoint);
|
|
130
|
+
this._resetLazyEditState();
|
|
131
|
+
if (this._isLazyLabelmapEditingEnabled(this._hoverData.viewport)) {
|
|
132
|
+
this._lazyEdit.appendStrokePoint(worldPoint);
|
|
133
|
+
this._captureLazyPreviewCircle();
|
|
134
|
+
}
|
|
135
|
+
triggerAnnotationRenderForViewportUIDs(this._hoverData.viewportIdsToRender);
|
|
114
136
|
const operationData = this.getOperationData(element);
|
|
115
137
|
if (!operationData) {
|
|
116
138
|
return false;
|
|
@@ -164,6 +186,9 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
164
186
|
}
|
|
165
187
|
this._previewData.timer = null;
|
|
166
188
|
const operationData = this.getOperationData(this._previewData.element);
|
|
189
|
+
if (!operationData) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
167
192
|
const enabledElement = getEnabledElement(this._previewData.element);
|
|
168
193
|
if (!enabledElement) {
|
|
169
194
|
return;
|
|
@@ -191,6 +216,9 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
191
216
|
const enabledElement = getEnabledElement(element);
|
|
192
217
|
const { viewport } = enabledElement;
|
|
193
218
|
this.updateCursor(evt);
|
|
219
|
+
if (!this._hoverData) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
194
222
|
const { viewportIdsToRender } = this._hoverData;
|
|
195
223
|
triggerAnnotationRenderForViewportUIDs(viewportIdsToRender);
|
|
196
224
|
const delta = vec2.distance(currentPoints.canvas, this._previewData.startPoint);
|
|
@@ -221,16 +249,26 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
221
249
|
currentCanvas[1],
|
|
222
250
|
]);
|
|
223
251
|
this._hoverData = this.createHoverData(element, currentCanvas);
|
|
224
|
-
this.
|
|
225
|
-
const operationData = this.getOperationData(element);
|
|
226
|
-
if (!operationData) {
|
|
252
|
+
if (!this._hoverData) {
|
|
227
253
|
return;
|
|
228
254
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
255
|
+
this._calculateCursor(element, currentCanvas);
|
|
256
|
+
if (this._isLazyLabelmapEditingEnabled(this._hoverData.viewport)) {
|
|
257
|
+
this._lazyEdit.appendStrokePoint(currentWorld);
|
|
258
|
+
this._captureLazyPreviewCircle();
|
|
259
|
+
this._previewData.preview = null;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
const operationData = this.getOperationData(element);
|
|
263
|
+
if (!operationData) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
operationData.strokePointsWorld = [
|
|
267
|
+
vec3.clone(this._lastDragInfo.world),
|
|
268
|
+
vec3.clone(currentWorld),
|
|
269
|
+
];
|
|
270
|
+
this._previewData.preview = this.applyActiveStrategy(enabledElement, operationData);
|
|
271
|
+
}
|
|
234
272
|
const currentCanvasClone = vec2.clone(currentCanvas);
|
|
235
273
|
this._lastDragInfo = {
|
|
236
274
|
canvas: currentCanvasClone,
|
|
@@ -249,15 +287,29 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
249
287
|
if (!operationData) {
|
|
250
288
|
return;
|
|
251
289
|
}
|
|
252
|
-
|
|
290
|
+
const isLazyLabelmapEditing = this._isLazyLabelmapEditingEnabled(this._hoverData?.viewport);
|
|
291
|
+
if (isLazyLabelmapEditing && this._previewData.isDrag) {
|
|
292
|
+
operationData.strokePointsWorld = this._lazyEdit
|
|
293
|
+
.getStrokePointsWorld()
|
|
294
|
+
.map((point) => vec3.clone(point));
|
|
295
|
+
this.applyActiveStrategy(enabledElement, operationData);
|
|
296
|
+
}
|
|
297
|
+
else if (!this._previewData.preview && !this._previewData.isDrag) {
|
|
253
298
|
this.applyActiveStrategy(enabledElement, operationData);
|
|
254
299
|
}
|
|
255
300
|
this.doneEditMemo();
|
|
256
301
|
this._deactivateDraw(element);
|
|
257
302
|
resetElementCursor(element);
|
|
258
|
-
this.updateCursor(evt);
|
|
259
303
|
this._editData = null;
|
|
260
304
|
this._lastDragInfo = null;
|
|
305
|
+
if (isLazyLabelmapEditing && this._previewData.isDrag) {
|
|
306
|
+
this._scheduleLazyPreviewCleanup(element, evt.detail.currentPoints.canvas, enabledElement.viewport.id, operationData.segmentationId);
|
|
307
|
+
triggerAnnotationRenderForViewportUIDs(this._hoverData.viewportIdsToRender);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
this._resetLazyEditState();
|
|
311
|
+
this.updateCursor(evt);
|
|
312
|
+
}
|
|
261
313
|
this.applyActiveStrategyCallback(enabledElement, operationData, StrategyCallbacks.OnInteractionEnd);
|
|
262
314
|
if (!this._previewData.isDrag) {
|
|
263
315
|
this.acceptPreview(element);
|
|
@@ -275,32 +327,69 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
275
327
|
};
|
|
276
328
|
}
|
|
277
329
|
disableCursor() {
|
|
330
|
+
this._clearPendingLazyPreviewCleanup();
|
|
278
331
|
this._hoverData = undefined;
|
|
332
|
+
this._resetLazyEditState();
|
|
279
333
|
this.rejectPreview();
|
|
280
334
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
335
|
+
_isLazyLabelmapEditingEnabled(viewport) {
|
|
336
|
+
return shouldUseLazyLabelmapEditing(viewport ?? this._hoverData?.viewport);
|
|
337
|
+
}
|
|
338
|
+
_resetLazyEditState() {
|
|
339
|
+
this._lazyEdit.reset();
|
|
340
|
+
}
|
|
341
|
+
_clearPendingLazyPreviewCleanup() {
|
|
342
|
+
this._lazyEdit.clearPendingCleanup();
|
|
343
|
+
}
|
|
344
|
+
_refreshCursor(element, centerCanvas) {
|
|
286
345
|
this._hoverData = this.createHoverData(element, centerCanvas);
|
|
287
|
-
this._calculateCursor(element, centerCanvas);
|
|
288
346
|
if (!this._hoverData) {
|
|
289
347
|
return;
|
|
290
348
|
}
|
|
349
|
+
this._calculateCursor(element, centerCanvas);
|
|
291
350
|
BrushTool.activeCursorTool = this;
|
|
292
351
|
triggerAnnotationRenderForViewportUIDs(this._hoverData.viewportIdsToRender);
|
|
293
352
|
}
|
|
294
|
-
|
|
353
|
+
_scheduleLazyPreviewCleanup(element, centerCanvas, viewportId, segmentationId) {
|
|
354
|
+
this._lazyEdit.scheduleCleanup({
|
|
355
|
+
element,
|
|
356
|
+
centerCanvas,
|
|
357
|
+
viewportId,
|
|
358
|
+
segmentationId,
|
|
359
|
+
refreshCursor: this._refreshCursor.bind(this),
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
_captureLazyPreviewCircle() {
|
|
363
|
+
if (!this._isLazyLabelmapEditingEnabled() || !this._hoverData) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
this._lazyEdit.capturePreviewCircle(this._hoverData);
|
|
367
|
+
}
|
|
368
|
+
updateCursor(evt) {
|
|
369
|
+
const eventData = evt.detail;
|
|
370
|
+
const { element } = eventData;
|
|
371
|
+
const { currentPoints } = eventData;
|
|
372
|
+
const centerCanvas = currentPoints.canvas;
|
|
373
|
+
this._refreshCursor(element, centerCanvas);
|
|
374
|
+
}
|
|
375
|
+
_calculateCursor(element, _centerCanvas) {
|
|
295
376
|
const enabledElement = getEnabledElement(element);
|
|
296
|
-
|
|
377
|
+
const operationData = this.getOperationData(element);
|
|
378
|
+
if (!enabledElement || !operationData) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
this.applyActiveStrategyCallback(enabledElement, operationData, StrategyCallbacks.CalculateCursorGeometry);
|
|
297
382
|
}
|
|
298
383
|
getStatistics(element, segmentIndices) {
|
|
299
384
|
if (!element) {
|
|
300
385
|
return;
|
|
301
386
|
}
|
|
302
387
|
const enabledElement = getEnabledElement(element);
|
|
303
|
-
const
|
|
388
|
+
const operationData = this.getOperationData(element);
|
|
389
|
+
if (!enabledElement || !operationData) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const stats = this.applyActiveStrategyCallback(enabledElement, operationData, StrategyCallbacks.GetStatistics, segmentIndices);
|
|
304
393
|
return stats;
|
|
305
394
|
}
|
|
306
395
|
rejectPreview(element = this._previewData.element) {
|
|
@@ -312,7 +401,11 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
312
401
|
if (!enabledElement) {
|
|
313
402
|
return;
|
|
314
403
|
}
|
|
315
|
-
|
|
404
|
+
const operationData = this.getOperationData(element);
|
|
405
|
+
if (!operationData) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
this.applyActiveStrategyCallback(enabledElement, operationData, StrategyCallbacks.RejectPreview);
|
|
316
409
|
this._previewData.preview = null;
|
|
317
410
|
this._previewData.isDrag = false;
|
|
318
411
|
}
|
|
@@ -327,7 +420,11 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
327
420
|
return;
|
|
328
421
|
}
|
|
329
422
|
const enabledElement = getEnabledElement(element);
|
|
330
|
-
|
|
423
|
+
const operationData = this.getOperationData(element);
|
|
424
|
+
if (!enabledElement || !operationData) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
this._previewData.preview = this.applyActiveStrategyCallback(enabledElement, operationData, StrategyCallbacks.Interpolate, config.configuration);
|
|
331
428
|
this._previewData.isDrag = true;
|
|
332
429
|
}
|
|
333
430
|
invalidateBrushCursor() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseVolumeViewport,
|
|
1
|
+
import { BaseVolumeViewport, getEnabledElement } from '@cornerstonejs/core';
|
|
2
2
|
import { BaseTool } from '../base';
|
|
3
3
|
import { fillInsideCircle } from './strategies/fillCircle';
|
|
4
4
|
import { eraseInsideCircle } from './strategies/eraseCircle';
|
|
@@ -8,7 +8,11 @@ import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCur
|
|
|
8
8
|
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
9
9
|
import { segmentLocking, activeSegmentation, segmentIndex as segmentIndexController, config as segmentationConfig, } from '../../stateManagement/segmentation';
|
|
10
10
|
import { getCurrentLabelmapImageIdForViewport, getSegmentation, } from '../../stateManagement/segmentation/segmentationState';
|
|
11
|
+
import getViewportLabelmapRenderMode from '../../stateManagement/segmentation/helpers/getViewportLabelmapRenderMode';
|
|
11
12
|
import LabelmapBaseTool from './LabelmapBaseTool';
|
|
13
|
+
import { getOrCreateLabelmapVolume, resolveLabelmapForSegment, } from '../../stateManagement/segmentation/helpers/labelmapSegmentationState';
|
|
14
|
+
import getEllipseWorldCoordinates from '../../utilities/getEllipseWorldCoordinates';
|
|
15
|
+
import getCenterAndRadiusInCanvas from '../../utilities/getCenterAndRadiusInCanvas';
|
|
12
16
|
class CircleScissorsTool extends LabelmapBaseTool {
|
|
13
17
|
constructor(toolProps = {}, defaultToolProps = {
|
|
14
18
|
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
@@ -90,13 +94,18 @@ class CircleScissorsTool extends LabelmapBaseTool {
|
|
|
90
94
|
referencedVolumeId: null,
|
|
91
95
|
imageId: null,
|
|
92
96
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
const viewportRenderMode = getViewportLabelmapRenderMode(viewport);
|
|
98
|
+
if (viewportRenderMode === 'volume' ||
|
|
99
|
+
viewport instanceof BaseVolumeViewport) {
|
|
100
|
+
const layer = resolveLabelmapForSegment(getSegmentation(segmentationId), segmentIndex);
|
|
101
|
+
const segmentation = layer ? getOrCreateLabelmapVolume(layer) : undefined;
|
|
102
|
+
if (!segmentation) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
96
105
|
this.editData = {
|
|
97
106
|
...this.editData,
|
|
98
|
-
volumeId,
|
|
99
|
-
referencedVolumeId: segmentation.referencedVolumeId,
|
|
107
|
+
volumeId: segmentation.volumeId,
|
|
108
|
+
referencedVolumeId: layer?.referencedVolumeId ?? segmentation.referencedVolumeId,
|
|
100
109
|
};
|
|
101
110
|
}
|
|
102
111
|
else {
|
|
@@ -123,28 +132,9 @@ class CircleScissorsTool extends LabelmapBaseTool {
|
|
|
123
132
|
const { canvasToWorld } = viewport;
|
|
124
133
|
const { annotation, viewportIdsToRender, centerCanvas } = this.editData;
|
|
125
134
|
const { data } = annotation;
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
const bottomCanvas = [
|
|
130
|
-
centerCanvas[0],
|
|
131
|
-
centerCanvas[1] + radius,
|
|
132
|
-
];
|
|
133
|
-
const topCanvas = [centerCanvas[0], centerCanvas[1] - radius];
|
|
134
|
-
const leftCanvas = [
|
|
135
|
-
centerCanvas[0] - radius,
|
|
136
|
-
centerCanvas[1],
|
|
137
|
-
];
|
|
138
|
-
const rightCanvas = [
|
|
139
|
-
centerCanvas[0] + radius,
|
|
140
|
-
centerCanvas[1],
|
|
141
|
-
];
|
|
142
|
-
data.handles.points = [
|
|
143
|
-
canvasToWorld(bottomCanvas),
|
|
144
|
-
canvasToWorld(topCanvas),
|
|
145
|
-
canvasToWorld(leftCanvas),
|
|
146
|
-
canvasToWorld(rightCanvas),
|
|
147
|
-
];
|
|
135
|
+
const centerWorld = canvasToWorld(centerCanvas);
|
|
136
|
+
const currentWorld = canvasToWorld(currentCanvasPoints);
|
|
137
|
+
data.handles.points = getEllipseWorldCoordinates([centerWorld, currentWorld], viewport);
|
|
148
138
|
annotation.invalidated = true;
|
|
149
139
|
this.editData.hasMoved = true;
|
|
150
140
|
triggerAnnotationRenderForViewportIds(viewportIdsToRender);
|
|
@@ -207,14 +197,7 @@ class CircleScissorsTool extends LabelmapBaseTool {
|
|
|
207
197
|
const annotationUID = annotation.annotationUID;
|
|
208
198
|
const data = annotation.data;
|
|
209
199
|
const { points } = data.handles;
|
|
210
|
-
const
|
|
211
|
-
const bottom = canvasCoordinates[0];
|
|
212
|
-
const top = canvasCoordinates[1];
|
|
213
|
-
const center = [
|
|
214
|
-
Math.floor((bottom[0] + top[0]) / 2),
|
|
215
|
-
Math.floor((bottom[1] + top[1]) / 2),
|
|
216
|
-
];
|
|
217
|
-
const radius = Math.abs(bottom[1] - Math.floor((bottom[1] + top[1]) / 2));
|
|
200
|
+
const { center, radius } = getCenterAndRadiusInCanvas(points, viewport);
|
|
218
201
|
const color = `rgb(${toolMetadata.segmentColor.slice(0, 3)})`;
|
|
219
202
|
if (!viewport.getRenderingEngine()) {
|
|
220
203
|
console.warn('Rendering Engine has been destroyed');
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { StackViewport } from '@cornerstonejs/core';
|
|
2
1
|
import type { Types } from '@cornerstonejs/core';
|
|
3
2
|
import { BaseTool } from '../base';
|
|
4
3
|
import type vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
@@ -92,7 +91,7 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
92
91
|
};
|
|
93
92
|
centerCanvas: any;
|
|
94
93
|
segmentIndex: number;
|
|
95
|
-
viewport:
|
|
94
|
+
viewport: Types.IStackViewport | import("@cornerstonejs/core").VolumeViewport;
|
|
96
95
|
segmentationId: string;
|
|
97
96
|
segmentColor: Types.Color;
|
|
98
97
|
viewportIdsToRender: string[];
|
|
@@ -102,7 +101,7 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
102
101
|
segmentationId: string;
|
|
103
102
|
segmentColor: Types.Color;
|
|
104
103
|
};
|
|
105
|
-
protected getOperationData(element?: any): ModifiedLabelmapToolOperationData;
|
|
104
|
+
protected getOperationData(element?: any): ModifiedLabelmapToolOperationData | undefined;
|
|
106
105
|
addPreview(element?: HTMLDivElement, options?: {
|
|
107
106
|
acceptReject: boolean;
|
|
108
107
|
}): any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEnabledElement, cache, utilities as csUtils, Enums, eventTarget, BaseVolumeViewport,
|
|
1
|
+
import { getEnabledElement, cache, utilities as csUtils, Enums, eventTarget, BaseVolumeViewport, } from '@cornerstonejs/core';
|
|
2
2
|
import { BaseTool } from '../base';
|
|
3
3
|
import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
|
|
4
4
|
import { getActiveSegmentation } from '../../stateManagement/segmentation/getActiveSegmentation';
|
|
@@ -14,15 +14,10 @@ import { filterAnnotationsForDisplay } from '../../utilities/planar';
|
|
|
14
14
|
import { isPointInsidePolyline3D } from '../../utilities/math/polyline';
|
|
15
15
|
import { triggerSegmentationDataModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
|
|
16
16
|
import { fillInsideCircle } from './strategies';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
timerStart: 0,
|
|
22
|
-
timer: null,
|
|
23
|
-
startPoint: [NaN, NaN],
|
|
24
|
-
isDrag: false,
|
|
25
|
-
}; }
|
|
17
|
+
import getViewportLabelmapRenderMode from '../../stateManagement/segmentation/helpers/getViewportLabelmapRenderMode';
|
|
18
|
+
import { getOrCreateLabelmapVolume, resolveLabelmapForSegment, } from '../../stateManagement/segmentation/helpers/labelmapSegmentationState';
|
|
19
|
+
import getViewportICamera from '../../utilities/getViewportICamera';
|
|
20
|
+
class LabelmapBaseTool extends BaseTool {
|
|
26
21
|
constructor(toolProps, defaultToolProps) {
|
|
27
22
|
super(toolProps, defaultToolProps);
|
|
28
23
|
this.memoMap = new Map();
|
|
@@ -44,6 +39,9 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
44
39
|
const memoData = this.acceptedMemoIds.get(id);
|
|
45
40
|
const element = memoData?.element;
|
|
46
41
|
const operationData = this.getOperationData(element);
|
|
42
|
+
if (!operationData) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
47
45
|
operationData.segmentIndex = memoData?.segmentIndex;
|
|
48
46
|
if (element) {
|
|
49
47
|
this.applyActiveStrategyCallback(getEnabledElement(element), operationData, StrategyCallbacks.AcceptPreview);
|
|
@@ -86,14 +84,6 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
86
84
|
const { viewport } = enabledElement;
|
|
87
85
|
const activeSegmentation = getActiveSegmentation(viewport.id);
|
|
88
86
|
if (!activeSegmentation) {
|
|
89
|
-
const event = new CustomEvent(Enums.Events.ERROR_EVENT, {
|
|
90
|
-
detail: {
|
|
91
|
-
type: 'Segmentation',
|
|
92
|
-
message: 'No active segmentation detected, create a segmentation representation before using the brush tool',
|
|
93
|
-
},
|
|
94
|
-
cancelable: true,
|
|
95
|
-
});
|
|
96
|
-
eventTarget.dispatchEvent(event);
|
|
97
87
|
return null;
|
|
98
88
|
}
|
|
99
89
|
const { segmentationId } = activeSegmentation;
|
|
@@ -108,40 +98,37 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
108
98
|
return editData;
|
|
109
99
|
}
|
|
110
100
|
getEditData({ viewport, representationData, segmentsLocked, segmentationId, }) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
const viewportRenderMode = getViewportLabelmapRenderMode(viewport);
|
|
102
|
+
const activeSegmentIndex = getActiveSegmentIndex(segmentationId);
|
|
103
|
+
const segmentation = getSegmentation(segmentationId);
|
|
104
|
+
const layerForEdit = activeSegmentIndex
|
|
105
|
+
? resolveLabelmapForSegment(segmentation, activeSegmentIndex)
|
|
106
|
+
: undefined;
|
|
107
|
+
if (viewportRenderMode === 'volume' ||
|
|
108
|
+
viewport instanceof BaseVolumeViewport) {
|
|
109
|
+
const segmentationVolume = layerForEdit
|
|
110
|
+
? getOrCreateLabelmapVolume(layerForEdit)
|
|
111
|
+
: undefined;
|
|
112
|
+
const volumeId = layerForEdit?.volumeId ?? segmentationVolume?.volumeId;
|
|
113
|
+
if (!segmentationVolume || !volumeId) {
|
|
117
114
|
return;
|
|
118
115
|
}
|
|
119
116
|
const actors = viewport.getActors();
|
|
120
|
-
const isStackViewport = viewport instanceof StackViewport;
|
|
121
|
-
if (isStackViewport) {
|
|
122
|
-
const event = new CustomEvent(Enums.Events.ERROR_EVENT, {
|
|
123
|
-
detail: {
|
|
124
|
-
type: 'Segmentation',
|
|
125
|
-
message: 'Cannot perform brush operation on the selected viewport',
|
|
126
|
-
},
|
|
127
|
-
cancelable: true,
|
|
128
|
-
});
|
|
129
|
-
eventTarget.dispatchEvent(event);
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
117
|
const volumes = actors
|
|
133
118
|
.filter((actorEntry) => actorEntry.referencedId)
|
|
134
|
-
.map((actorEntry) => cache.getVolume(actorEntry.referencedId))
|
|
135
|
-
|
|
119
|
+
.map((actorEntry) => cache.getVolume(actorEntry.referencedId))
|
|
120
|
+
.filter((volume) => !!volume);
|
|
136
121
|
const referencedVolumeIdToThreshold = volumes.find((volume) => csUtils.isEqual(volume.dimensions, segmentationVolume.dimensions))?.volumeId || volumes[0]?.volumeId;
|
|
137
122
|
return {
|
|
138
123
|
volumeId,
|
|
139
124
|
referencedVolumeId: this.configuration.threshold?.volumeId ??
|
|
125
|
+
layerForEdit?.referencedVolumeId ??
|
|
126
|
+
segmentationVolume.referencedVolumeId ??
|
|
140
127
|
referencedVolumeIdToThreshold,
|
|
141
128
|
segmentsLocked,
|
|
142
129
|
};
|
|
143
130
|
}
|
|
144
|
-
|
|
131
|
+
if (viewportRenderMode === 'image') {
|
|
145
132
|
const segmentationImageId = getCurrentLabelmapImageIdForViewport(viewport.id, segmentationId);
|
|
146
133
|
if (!segmentationImageId) {
|
|
147
134
|
return;
|
|
@@ -151,14 +138,30 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
151
138
|
segmentsLocked,
|
|
152
139
|
};
|
|
153
140
|
}
|
|
141
|
+
const event = new CustomEvent(Enums.Events.ERROR_EVENT, {
|
|
142
|
+
detail: {
|
|
143
|
+
type: 'Segmentation',
|
|
144
|
+
message: 'Cannot perform brush operation on the selected viewport',
|
|
145
|
+
},
|
|
146
|
+
cancelable: true,
|
|
147
|
+
});
|
|
148
|
+
eventTarget.dispatchEvent(event);
|
|
149
|
+
return null;
|
|
154
150
|
}
|
|
155
151
|
createHoverData(element, centerCanvas) {
|
|
156
152
|
const enabledElement = getEnabledElement(element);
|
|
157
153
|
const { viewport } = enabledElement;
|
|
158
|
-
const camera = viewport
|
|
154
|
+
const camera = getViewportICamera(viewport);
|
|
159
155
|
const { viewPlaneNormal, viewUp } = camera;
|
|
156
|
+
if (!viewPlaneNormal || !viewUp) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
160
159
|
const viewportIdsToRender = [viewport.id];
|
|
161
|
-
const
|
|
160
|
+
const activeSegmentationData = this.getActiveSegmentationData(viewport);
|
|
161
|
+
if (!activeSegmentationData) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const { segmentIndex, segmentationId, segmentColor } = activeSegmentationData;
|
|
162
165
|
const brushCursor = {
|
|
163
166
|
metadata: {
|
|
164
167
|
viewPlaneNormal: [...viewPlaneNormal],
|
|
@@ -200,11 +203,19 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
200
203
|
}
|
|
201
204
|
getOperationData(element) {
|
|
202
205
|
const editData = this._editData || this.createEditData(element);
|
|
203
|
-
const
|
|
206
|
+
const hoverData = this._hoverData || this.createHoverData(element);
|
|
207
|
+
if (!editData || !hoverData) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const { segmentIndex, segmentationId, brushCursor } = hoverData;
|
|
204
211
|
const { data, metadata = {} } = brushCursor || {};
|
|
205
212
|
const { viewPlaneNormal, viewUp } = metadata;
|
|
213
|
+
const points = data?.editPoints || data?.handles?.points;
|
|
206
214
|
const configColor = this.configuration.preview?.previewColors?.[segmentIndex];
|
|
207
|
-
const { viewport } = getEnabledElement(element);
|
|
215
|
+
const { viewport } = getEnabledElement(element) || {};
|
|
216
|
+
if (!viewport || !segmentIndex || !segmentationId) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
208
219
|
const segmentColor = getSegmentIndexColor(viewport.id, segmentationId, segmentIndex);
|
|
209
220
|
if (!configColor && !segmentColor) {
|
|
210
221
|
return;
|
|
@@ -216,7 +227,7 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
216
227
|
}
|
|
217
228
|
const operationData = {
|
|
218
229
|
...editData,
|
|
219
|
-
points
|
|
230
|
+
points,
|
|
220
231
|
segmentIndex,
|
|
221
232
|
viewPlaneNormal,
|
|
222
233
|
previewOnHover: !this._previewData.isDrag,
|
|
@@ -243,7 +254,11 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
243
254
|
this.rejectPreview(element);
|
|
244
255
|
}
|
|
245
256
|
const enabledElement = getEnabledElement(element);
|
|
246
|
-
const
|
|
257
|
+
const operationData = this.getOperationData(element);
|
|
258
|
+
if (!enabledElement || !operationData) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const results = this.applyActiveStrategyCallback(enabledElement, operationData, StrategyCallbacks.AddPreview);
|
|
247
262
|
_previewData.isDrag = true;
|
|
248
263
|
if (results?.modified) {
|
|
249
264
|
_previewData.preview = results;
|
|
@@ -257,7 +272,11 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
257
272
|
}
|
|
258
273
|
this.doneEditMemo();
|
|
259
274
|
const enabledElement = getEnabledElement(element);
|
|
260
|
-
|
|
275
|
+
const operationData = this.getOperationData(element);
|
|
276
|
+
if (!enabledElement || !operationData) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
this.applyActiveStrategyCallback(enabledElement, operationData, StrategyCallbacks.RejectPreview);
|
|
261
280
|
this._previewData.preview = null;
|
|
262
281
|
this._previewData.isDrag = false;
|
|
263
282
|
}
|
|
@@ -266,6 +285,9 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
266
285
|
return;
|
|
267
286
|
}
|
|
268
287
|
const operationData = this.getOperationData(element);
|
|
288
|
+
if (!operationData) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
269
291
|
if (this.memo && this.memo.id) {
|
|
270
292
|
this.acceptedMemoIds.set(this.memo.id, {
|
|
271
293
|
element,
|
|
@@ -365,6 +387,15 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
365
387
|
triggerSegmentationDataModified(segmentationId, slices);
|
|
366
388
|
}
|
|
367
389
|
}
|
|
390
|
+
LabelmapBaseTool.previewData = {
|
|
391
|
+
preview: null,
|
|
392
|
+
element: null,
|
|
393
|
+
timerStart: 0,
|
|
394
|
+
timer: null,
|
|
395
|
+
startPoint: [NaN, NaN],
|
|
396
|
+
isDrag: false,
|
|
397
|
+
};
|
|
398
|
+
export default LabelmapBaseTool;
|
|
368
399
|
function lightenColor(r, g, b, a, factor = 0.4) {
|
|
369
400
|
return [
|
|
370
401
|
Math.round(r + (255 - r) * factor),
|
|
@@ -5,9 +5,6 @@ import BrushTool from './BrushTool';
|
|
|
5
5
|
import * as segmentation from '../../stateManagement/segmentation';
|
|
6
6
|
import { getSegmentationRepresentationsBySegmentationId } from '../../stateManagement/segmentation/getSegmentationRepresentation';
|
|
7
7
|
class LabelMapEditWithContourTool extends PlanarFreehandContourSegmentationTool {
|
|
8
|
-
static { this.toolName = 'LabelMapEditWithContour'; }
|
|
9
|
-
static { this.annotationsToViewportMap = new Map(); }
|
|
10
|
-
static { this.viewportIdsChecked = []; }
|
|
11
8
|
constructor(toolProps = {}) {
|
|
12
9
|
const initialProps = utilities.deepMerge({
|
|
13
10
|
configuration: {
|
|
@@ -119,4 +116,7 @@ class LabelMapEditWithContourTool extends PlanarFreehandContourSegmentationTool
|
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
118
|
}
|
|
119
|
+
LabelMapEditWithContourTool.toolName = 'LabelMapEditWithContour';
|
|
120
|
+
LabelMapEditWithContourTool.annotationsToViewportMap = new Map();
|
|
121
|
+
LabelMapEditWithContourTool.viewportIdsChecked = [];
|
|
122
122
|
export default LabelMapEditWithContourTool;
|