@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/stateManagement/segmentation/labelmapModel/normalizeLabelmapSegmentationData.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const SOURCE_REPRESENTATION_NAME = 'binaryLabelmap';
|
|
2
|
+
function getSegmentOrder(segmentation) {
|
|
3
|
+
if (segmentation.segmentOrder?.length) {
|
|
4
|
+
return [...segmentation.segmentOrder];
|
|
5
|
+
}
|
|
6
|
+
return Object.keys(segmentation.segments)
|
|
7
|
+
.map(Number)
|
|
8
|
+
.sort((a, b) => a - b);
|
|
9
|
+
}
|
|
10
|
+
function getPrimaryLabelmapId(segmentationId) {
|
|
11
|
+
return `${segmentationId}-storage-0`;
|
|
12
|
+
}
|
|
13
|
+
function getPrimaryLabelmapType(labelmapData) {
|
|
14
|
+
return labelmapData.volumeId ? 'volume' : 'stack';
|
|
15
|
+
}
|
|
16
|
+
function createPrimaryLabelmapLayer(segmentation, labelmapData, labelmapId = getPrimaryLabelmapId(segmentation.segmentationId)) {
|
|
17
|
+
const layer = {
|
|
18
|
+
labelmapId,
|
|
19
|
+
type: getPrimaryLabelmapType(labelmapData),
|
|
20
|
+
labelToSegmentIndex: {},
|
|
21
|
+
};
|
|
22
|
+
if (labelmapData.volumeId != null) {
|
|
23
|
+
layer.volumeId = labelmapData.volumeId;
|
|
24
|
+
}
|
|
25
|
+
if (labelmapData.referencedVolumeId != null) {
|
|
26
|
+
layer.referencedVolumeId = labelmapData.referencedVolumeId;
|
|
27
|
+
}
|
|
28
|
+
if (labelmapData.referencedImageIds != null) {
|
|
29
|
+
layer.referencedImageIds = labelmapData.referencedImageIds;
|
|
30
|
+
}
|
|
31
|
+
if (labelmapData.imageIds != null) {
|
|
32
|
+
layer.imageIds = labelmapData.imageIds;
|
|
33
|
+
}
|
|
34
|
+
return layer;
|
|
35
|
+
}
|
|
36
|
+
function resolvePrimaryLabelmapId(segmentation, labelmapData) {
|
|
37
|
+
const storedLabelmapId = labelmapData.primaryLabelmapId;
|
|
38
|
+
if (storedLabelmapId && labelmapData.labelmaps?.[storedLabelmapId]) {
|
|
39
|
+
return storedLabelmapId;
|
|
40
|
+
}
|
|
41
|
+
const fallbackLabelmapId = Object.keys(labelmapData.labelmaps ?? {})[0] ??
|
|
42
|
+
getPrimaryLabelmapId(segmentation.segmentationId);
|
|
43
|
+
labelmapData.primaryLabelmapId = fallbackLabelmapId;
|
|
44
|
+
return fallbackLabelmapId;
|
|
45
|
+
}
|
|
46
|
+
function ensureLabelmapState(segmentation) {
|
|
47
|
+
const labelmapData = segmentation.representationData.Labelmap;
|
|
48
|
+
if (!labelmapData) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
labelmapData.labelmaps ||= {};
|
|
52
|
+
const primaryLabelmapId = resolvePrimaryLabelmapId(segmentation, labelmapData);
|
|
53
|
+
labelmapData.labelmaps[primaryLabelmapId] ||= createPrimaryLabelmapLayer(segmentation, labelmapData, primaryLabelmapId);
|
|
54
|
+
labelmapData.segmentBindings ||= {};
|
|
55
|
+
labelmapData.sourceRepresentationName ||= SOURCE_REPRESENTATION_NAME;
|
|
56
|
+
getSegmentOrder(segmentation).forEach((segmentIndex) => {
|
|
57
|
+
labelmapData.segmentBindings[segmentIndex] ||= {
|
|
58
|
+
labelmapId: primaryLabelmapId,
|
|
59
|
+
labelValue: segmentIndex,
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
Object.values(labelmapData.labelmaps).forEach((layer) => {
|
|
63
|
+
layer.labelToSegmentIndex = {};
|
|
64
|
+
});
|
|
65
|
+
Object.entries(labelmapData.segmentBindings).forEach(([segmentIndex, binding]) => {
|
|
66
|
+
const layer = labelmapData.labelmaps[binding.labelmapId];
|
|
67
|
+
if (!layer) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
layer.labelToSegmentIndex ||= {};
|
|
71
|
+
layer.labelToSegmentIndex[binding.labelValue] = Number(segmentIndex);
|
|
72
|
+
});
|
|
73
|
+
return labelmapData;
|
|
74
|
+
}
|
|
75
|
+
export { SOURCE_REPRESENTATION_NAME, ensureLabelmapState, getPrimaryLabelmapId, getSegmentOrder, };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Segmentation } from '../../../types/SegmentationStateTypes';
|
|
2
|
+
import type { LabelmapLayer } from '../../../types/LabelmapTypes';
|
|
3
|
+
declare function createPrivateLabelmap(segmentation: Segmentation, sourceLabelmap: LabelmapLayer): LabelmapLayer;
|
|
4
|
+
declare function moveSegmentToPrivateLabelmap(segmentation: Segmentation, segmentIndex: number): LabelmapLayer | undefined;
|
|
5
|
+
export { createPrivateLabelmap, moveSegmentToPrivateLabelmap };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { cache, imageLoader, utilities as csUtils, volumeLoader, } from '@cornerstonejs/core';
|
|
2
|
+
import { getLabelmap, registerLabelmap } from './labelmapLayerStore';
|
|
3
|
+
import { getSegmentBinding, getSegmentsOnLabelmap, setSegmentBinding, } from './labelmapSegmentBindings';
|
|
4
|
+
import { syncLegacyLabelmapData } from './labelmapLegacyAdapter';
|
|
5
|
+
function createPrivateVolumeLabelmap(segmentation, sourceLabelmap) {
|
|
6
|
+
const sourceVolume = cache.getVolume(sourceLabelmap.volumeId);
|
|
7
|
+
const volumeId = `${segmentation.segmentationId}-storage-${csUtils.uuidv4()}`;
|
|
8
|
+
const referencedVolumeId = sourceLabelmap.referencedVolumeId ??
|
|
9
|
+
sourceVolume?.referencedVolumeId ??
|
|
10
|
+
sourceLabelmap.volumeId;
|
|
11
|
+
const volume = volumeLoader.createAndCacheDerivedLabelmapVolume(referencedVolumeId, {
|
|
12
|
+
volumeId,
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
labelmapId: volumeId,
|
|
16
|
+
type: 'volume',
|
|
17
|
+
volumeId,
|
|
18
|
+
imageIds: volume.imageIds,
|
|
19
|
+
referencedVolumeId,
|
|
20
|
+
referencedImageIds: sourceLabelmap.referencedImageIds ?? sourceVolume?.referencedImageIds,
|
|
21
|
+
labelToSegmentIndex: {},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function createPrivateStackLabelmap(segmentation, sourceLabelmap) {
|
|
25
|
+
const referencedImageIds = sourceLabelmap.referencedImageIds ?? sourceLabelmap.imageIds ?? [];
|
|
26
|
+
const sourceImageIds = sourceLabelmap.imageIds ?? [];
|
|
27
|
+
const sourceImage = sourceImageIds[0]
|
|
28
|
+
? cache.getImage(sourceImageIds[0])
|
|
29
|
+
: null;
|
|
30
|
+
const targetType = sourceImage?.voxelManager?.getConstructor?.().name ?? 'Uint8Array';
|
|
31
|
+
const images = imageLoader.createAndCacheDerivedImages(referencedImageIds, {
|
|
32
|
+
getDerivedImageId: (referencedImageId) => `${segmentation.segmentationId}-storage-${csUtils.uuidv4()}-${referencedImageId.slice(-12)}`,
|
|
33
|
+
targetBuffer: {
|
|
34
|
+
type: targetType,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
labelmapId: `${segmentation.segmentationId}-storage-${csUtils.uuidv4()}`,
|
|
39
|
+
type: 'stack',
|
|
40
|
+
imageIds: images.map((image) => image.imageId),
|
|
41
|
+
referencedVolumeId: sourceLabelmap.referencedVolumeId,
|
|
42
|
+
referencedImageIds,
|
|
43
|
+
labelToSegmentIndex: {},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function createPrivateLabelmap(segmentation, sourceLabelmap) {
|
|
47
|
+
if (sourceLabelmap.imageIds?.length ||
|
|
48
|
+
sourceLabelmap.referencedImageIds?.length) {
|
|
49
|
+
return createPrivateStackLabelmap(segmentation, sourceLabelmap);
|
|
50
|
+
}
|
|
51
|
+
if (sourceLabelmap.volumeId) {
|
|
52
|
+
return createPrivateVolumeLabelmap(segmentation, sourceLabelmap);
|
|
53
|
+
}
|
|
54
|
+
return createPrivateStackLabelmap(segmentation, sourceLabelmap);
|
|
55
|
+
}
|
|
56
|
+
function moveSegmentToPrivateLabelmap(segmentation, segmentIndex) {
|
|
57
|
+
const binding = getSegmentBinding(segmentation, segmentIndex);
|
|
58
|
+
if (!binding) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const sourceLabelmap = getLabelmap(segmentation, binding.labelmapId);
|
|
62
|
+
if (!sourceLabelmap) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (getSegmentsOnLabelmap(segmentation, sourceLabelmap.labelmapId).length <= 1) {
|
|
66
|
+
return sourceLabelmap;
|
|
67
|
+
}
|
|
68
|
+
const privateLabelmap = createPrivateLabelmap(segmentation, sourceLabelmap);
|
|
69
|
+
registerLabelmap(segmentation, privateLabelmap);
|
|
70
|
+
if (sourceLabelmap.volumeId && privateLabelmap.volumeId) {
|
|
71
|
+
const sourceVolume = cache.getVolume(sourceLabelmap.volumeId);
|
|
72
|
+
const targetVolume = cache.getVolume(privateLabelmap.volumeId);
|
|
73
|
+
sourceVolume.voxelManager.forEach(({ value, index }) => {
|
|
74
|
+
if (value !== binding.labelValue) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
targetVolume.voxelManager.setAtIndex(index, 1);
|
|
78
|
+
sourceVolume.voxelManager.setAtIndex(index, 0);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const sourceImageIds = sourceLabelmap.imageIds ?? [];
|
|
83
|
+
const targetImageIds = privateLabelmap.imageIds ?? [];
|
|
84
|
+
sourceImageIds.forEach((imageId, imageIndex) => {
|
|
85
|
+
const sourceImage = cache.getImage(imageId);
|
|
86
|
+
const targetImage = cache.getImage(targetImageIds[imageIndex]);
|
|
87
|
+
if (!sourceImage || !targetImage) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
sourceImage.voxelManager.forEach(({ value, index }) => {
|
|
91
|
+
if (value !== binding.labelValue) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
targetImage.voxelManager.setAtIndex(index, 1);
|
|
95
|
+
sourceImage.voxelManager.setAtIndex(index, 0);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
setSegmentBinding(segmentation, segmentIndex, {
|
|
100
|
+
labelmapId: privateLabelmap.labelmapId,
|
|
101
|
+
labelValue: 1,
|
|
102
|
+
});
|
|
103
|
+
syncLegacyLabelmapData(segmentation);
|
|
104
|
+
return privateLabelmap;
|
|
105
|
+
}
|
|
106
|
+
export { createPrivateLabelmap, moveSegmentToPrivateLabelmap };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Segment, Segmentation } from '../../../types/SegmentationStateTypes';
|
|
2
|
+
import type { SegmentLabelmapBindingState } from '../../../types/LabelmapTypes';
|
|
3
|
+
export default class SegmentModel {
|
|
4
|
+
private readonly segmentation;
|
|
5
|
+
private readonly state;
|
|
6
|
+
constructor(segmentation: Segmentation, state: Segment);
|
|
7
|
+
get segmentIndex(): number;
|
|
8
|
+
get label(): string;
|
|
9
|
+
get binding(): SegmentLabelmapBindingState | undefined;
|
|
10
|
+
toState(): Segment;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getSegmentBinding } from '../helpers/labelmapSegmentationState';
|
|
2
|
+
export default class SegmentModel {
|
|
3
|
+
constructor(segmentation, state) {
|
|
4
|
+
this.segmentation = segmentation;
|
|
5
|
+
this.state = state;
|
|
6
|
+
}
|
|
7
|
+
get segmentIndex() {
|
|
8
|
+
return this.state.segmentIndex;
|
|
9
|
+
}
|
|
10
|
+
get label() {
|
|
11
|
+
return this.state.label;
|
|
12
|
+
}
|
|
13
|
+
get binding() {
|
|
14
|
+
return getSegmentBinding(this.segmentation, this.state.segmentIndex);
|
|
15
|
+
}
|
|
16
|
+
toState() {
|
|
17
|
+
return this.state;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Segmentation } from '../../../types/SegmentationStateTypes';
|
|
2
|
+
import type { LabelmapLayer } from '../../../types/LabelmapTypes';
|
|
3
|
+
import SegmentModel from './SegmentModel';
|
|
4
|
+
export default class SegmentationModel {
|
|
5
|
+
private readonly state;
|
|
6
|
+
constructor(state: Segmentation);
|
|
7
|
+
get segmentationId(): string;
|
|
8
|
+
get segments(): SegmentModel[];
|
|
9
|
+
getLabelmaps(): LabelmapLayer[];
|
|
10
|
+
getBinding(segmentIndex: number): import("../../../types/LabelmapTypes").SegmentLabelmapBindingState;
|
|
11
|
+
toState(): Segmentation;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import SegmentModel from './SegmentModel';
|
|
2
|
+
import { ensureLabelmapState, getLabelmaps, getSegmentBinding, } from '../helpers/labelmapSegmentationState';
|
|
3
|
+
export default class SegmentationModel {
|
|
4
|
+
constructor(state) {
|
|
5
|
+
this.state = state;
|
|
6
|
+
ensureLabelmapState(state);
|
|
7
|
+
}
|
|
8
|
+
get segmentationId() {
|
|
9
|
+
return this.state.segmentationId;
|
|
10
|
+
}
|
|
11
|
+
get segments() {
|
|
12
|
+
return Object.values(this.state.segments).map((segment) => new SegmentModel(this.state, segment));
|
|
13
|
+
}
|
|
14
|
+
getLabelmaps() {
|
|
15
|
+
return getLabelmaps(this.state);
|
|
16
|
+
}
|
|
17
|
+
getBinding(segmentIndex) {
|
|
18
|
+
return getSegmentBinding(this.state, segmentIndex);
|
|
19
|
+
}
|
|
20
|
+
toState() {
|
|
21
|
+
return this.state;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
|
|
2
|
-
import labelmapDisplay from '../../tools/displayTools/Labelmap/labelmapDisplay';
|
|
3
|
-
import contourDisplay from '../../tools/displayTools/Contour/contourDisplay';
|
|
4
2
|
import { getSegmentationRepresentations } from './getSegmentationRepresentation';
|
|
5
3
|
import { getEnabledElementByViewportId } from '@cornerstonejs/core';
|
|
6
4
|
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
7
|
-
import { surfaceDisplay } from '../../tools/displayTools/Surface';
|
|
8
5
|
import { removeSegmentationListener } from './segmentationEventManager';
|
|
6
|
+
import { getSegmentationRepresentationDisplay } from './SegmentationRepresentationDisplayRegistry';
|
|
9
7
|
function removeSegmentationRepresentation(viewportId, specifier, immediate) {
|
|
10
8
|
return _removeSegmentationRepresentations(viewportId, specifier, immediate);
|
|
11
9
|
}
|
|
@@ -56,14 +54,12 @@ function _removeRepresentationObject(viewportId, segmentationId, type, immediate
|
|
|
56
54
|
type,
|
|
57
55
|
});
|
|
58
56
|
representations.forEach((representation) => {
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const display = getSegmentationRepresentationDisplay(representation.type);
|
|
58
|
+
if (display) {
|
|
59
|
+
display.removeRepresentation(viewportId, representation.segmentationId, immediate);
|
|
61
60
|
}
|
|
62
|
-
else
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
else if (representation.type === SegmentationRepresentations.Surface) {
|
|
66
|
-
surfaceDisplay.removeRepresentation(viewportId, representation.segmentationId, immediate);
|
|
61
|
+
else {
|
|
62
|
+
console.warn(`No display registered for segmentation representation type ${representation.type}.`);
|
|
67
63
|
}
|
|
68
64
|
removeSegmentationListener(representation.segmentationId, representation.type);
|
|
69
65
|
});
|
|
@@ -5,6 +5,7 @@ import { getViewportIdsWithSegmentation } from './getViewportIdsWithSegmentation
|
|
|
5
5
|
import { triggerSegmentationModified } from './triggerSegmentationEvents';
|
|
6
6
|
import { getActiveSegmentIndex } from './getActiveSegmentIndex';
|
|
7
7
|
import { getSegmentationRepresentations } from './getSegmentationRepresentation';
|
|
8
|
+
import { ensureLabelmapState, getSegmentBinding, getLabelmaps, setSegmentBinding, syncLegacyLabelmapData, } from './helpers/labelmapSegmentationState';
|
|
8
9
|
function setActiveSegmentIndex(segmentationId, segmentIndex) {
|
|
9
10
|
const segmentation = getSegmentation(segmentationId);
|
|
10
11
|
if (typeof segmentIndex === 'string') {
|
|
@@ -22,6 +23,29 @@ function setActiveSegmentIndex(segmentationId, segmentIndex) {
|
|
|
22
23
|
cachedStats: {},
|
|
23
24
|
active: false,
|
|
24
25
|
};
|
|
26
|
+
if (segmentation.representationData?.Labelmap) {
|
|
27
|
+
ensureLabelmapState(segmentation);
|
|
28
|
+
const primaryLayer = getLabelmaps(segmentation)[0];
|
|
29
|
+
if (primaryLayer) {
|
|
30
|
+
setSegmentBinding(segmentation, segmentIndex, {
|
|
31
|
+
labelmapId: primaryLayer.labelmapId,
|
|
32
|
+
labelValue: segmentIndex,
|
|
33
|
+
});
|
|
34
|
+
syncLegacyLabelmapData(segmentation);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (segmentation.representationData?.Labelmap &&
|
|
39
|
+
!getSegmentBinding(segmentation, segmentIndex)) {
|
|
40
|
+
ensureLabelmapState(segmentation);
|
|
41
|
+
const primaryLayer = getLabelmaps(segmentation)[0];
|
|
42
|
+
if (primaryLayer) {
|
|
43
|
+
setSegmentBinding(segmentation, segmentIndex, {
|
|
44
|
+
labelmapId: primaryLayer.labelmapId,
|
|
45
|
+
labelValue: segmentIndex,
|
|
46
|
+
});
|
|
47
|
+
syncLegacyLabelmapData(segmentation);
|
|
48
|
+
}
|
|
25
49
|
}
|
|
26
50
|
if (segmentation.segments[segmentIndex].active !== true) {
|
|
27
51
|
segmentation.segments[segmentIndex].active = true;
|
|
@@ -2,18 +2,11 @@ import { eventTarget } from '@cornerstonejs/core';
|
|
|
2
2
|
import { Events, SegmentationRepresentations } from '../../enums';
|
|
3
3
|
import { triggerSegmentationModified } from './triggerSegmentationEvents';
|
|
4
4
|
import debounce from '../../utilities/debounce';
|
|
5
|
-
import surfaceDisplay from '../../tools/displayTools/Surface/surfaceDisplay';
|
|
6
|
-
import contourDisplay from '../../tools/displayTools/Contour/contourDisplay';
|
|
7
|
-
import labelmapDisplay from '../../tools/displayTools/Labelmap/labelmapDisplay';
|
|
8
5
|
import { getSegmentation } from './getSegmentation';
|
|
9
|
-
|
|
10
|
-
[SegmentationRepresentations.Labelmap]: labelmapDisplay,
|
|
11
|
-
[SegmentationRepresentations.Contour]: contourDisplay,
|
|
12
|
-
[SegmentationRepresentations.Surface]: surfaceDisplay,
|
|
13
|
-
};
|
|
6
|
+
import { getSegmentationRepresentationDisplay } from './SegmentationRepresentationDisplayRegistry';
|
|
14
7
|
const segmentationListeners = new Map();
|
|
15
8
|
export function addDefaultSegmentationListener(viewport, segmentationId, representationType) {
|
|
16
|
-
const updateFunction =
|
|
9
|
+
const updateFunction = getSegmentationRepresentationDisplay(representationType)?.getUpdateFunction(viewport);
|
|
17
10
|
if (updateFunction) {
|
|
18
11
|
addSegmentationListener(segmentationId, representationType, updateFunction);
|
|
19
12
|
}
|
|
@@ -14,4 +14,5 @@ import { updateLabelmapSegmentationImageReferences } from './updateLabelmapSegme
|
|
|
14
14
|
import { getStackSegmentationImageIdsForViewport } from './getStackSegmentationImageIdsForViewport';
|
|
15
15
|
import { getSegmentationRepresentation, getSegmentationRepresentations, getSegmentationRepresentationsBySegmentationId } from './getSegmentationRepresentation';
|
|
16
16
|
declare function destroy(): void;
|
|
17
|
-
|
|
17
|
+
declare function getDefaultSegmentationStateManager(): import("./SegmentationStateManager").default;
|
|
18
|
+
export { getColorLUT, getCurrentLabelmapImageIdForViewport, getCurrentLabelmapImageIdsForViewport, getNextColorLUTIndex, getSegmentation, getSegmentations, getStackSegmentationImageIdsForViewport, getViewportIdsWithSegmentation, getSegmentationRepresentation, getSegmentationRepresentations, getViewportSegmentationRepresentations, removeColorLUT, getViewportSegmentations, removeSegmentation, removeLabelmapRepresentation, removeContourRepresentation, removeSurfaceRepresentation, removeSegmentationRepresentation, removeAllSegmentationRepresentations, removeAllSegmentations, addColorLUT, addSegmentations, updateLabelmapSegmentationImageReferences, getSegmentationRepresentationsBySegmentationId, destroy, getDefaultSegmentationStateManager, };
|
|
@@ -17,4 +17,7 @@ import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
|
17
17
|
function destroy() {
|
|
18
18
|
defaultSegmentationStateManager.resetState();
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
function getDefaultSegmentationStateManager() {
|
|
21
|
+
return defaultSegmentationStateManager;
|
|
22
|
+
}
|
|
23
|
+
export { getColorLUT, getCurrentLabelmapImageIdForViewport, getCurrentLabelmapImageIdsForViewport, getNextColorLUTIndex, getSegmentation, getSegmentations, getStackSegmentationImageIdsForViewport, getViewportIdsWithSegmentation, getSegmentationRepresentation, getSegmentationRepresentations, getViewportSegmentationRepresentations, removeColorLUT, getViewportSegmentations, removeSegmentation, removeLabelmapRepresentation, removeContourRepresentation, removeSurfaceRepresentation, removeSegmentationRepresentation, removeAllSegmentationRepresentations, removeAllSegmentations, addColorLUT, addSegmentations, updateLabelmapSegmentationImageReferences, getSegmentationRepresentationsBySegmentationId, destroy, getDefaultSegmentationStateManager, };
|
|
@@ -8,7 +8,9 @@ type auxiliaryEvent = {
|
|
|
8
8
|
export type SynchronizerOptions = {
|
|
9
9
|
auxiliaryEvents?: auxiliaryEvent[];
|
|
10
10
|
eventSource?: eventSource;
|
|
11
|
-
viewPresentation?: Types.
|
|
11
|
+
viewPresentation?: Types.ViewPresentationSelector;
|
|
12
|
+
syncInvertState?: boolean;
|
|
13
|
+
syncColormap?: boolean;
|
|
12
14
|
};
|
|
13
15
|
declare class Synchronizer {
|
|
14
16
|
private _enabled;
|
package/dist/esm/store/state.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { utilities } from '@cornerstonejs/core';
|
|
1
2
|
import svgNodeCache, { resetSvgNodeCache } from './svgNodeCache';
|
|
2
3
|
const defaultState = {
|
|
3
4
|
isInteractingWithTool: false,
|
|
@@ -22,7 +23,7 @@ let state = {
|
|
|
22
23
|
function resetCornerstoneToolsState() {
|
|
23
24
|
resetSvgNodeCache();
|
|
24
25
|
state = {
|
|
25
|
-
...
|
|
26
|
+
...utilities.deepClone({
|
|
26
27
|
...defaultState,
|
|
27
28
|
svgNodeCache: {},
|
|
28
29
|
}),
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { vec3, mat4 } from 'gl-matrix';
|
|
2
|
-
import { getRenderingEngine, metaData, utilities, VolumeViewport, } from '@cornerstonejs/core';
|
|
2
|
+
import { ActorRenderMode, getRenderingEngine, metaData, utilities, VolumeViewport, } from '@cornerstonejs/core';
|
|
3
3
|
import areViewportsCoplanar from './areViewportsCoplanar';
|
|
4
4
|
const getSpatialRegistration = (targetId, sourceId) => utilities.spatialRegistrationMetadataProvider.get('spatialRegistrationModule', targetId, sourceId);
|
|
5
|
+
function isVolumeSliceViewport(viewport) {
|
|
6
|
+
if (viewport instanceof VolumeViewport) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
const getDefaultActor = viewport.getDefaultActor;
|
|
10
|
+
const renderMode = getDefaultActor?.call(viewport)?.actorMapper?.renderMode;
|
|
11
|
+
return (renderMode === ActorRenderMode.CPU_VOLUME ||
|
|
12
|
+
renderMode === ActorRenderMode.VTK_VOLUME_SLICE);
|
|
13
|
+
}
|
|
5
14
|
export default async function imageSliceSyncCallback(synchronizerInstance, sourceViewport, targetViewport) {
|
|
6
15
|
const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
|
|
7
16
|
if (!renderingEngine) {
|
|
@@ -39,11 +48,11 @@ export default async function imageSliceSyncCallback(synchronizerInstance, sourc
|
|
|
39
48
|
const targetImagePositionPatientWithRegistrationMatrix = vec3.transformMat4(vec3.create(), sourceImagePositionPatient, registrationMatrixMat4);
|
|
40
49
|
const closestImageIdIndex2 = _getClosestImageIdIndex(targetImagePositionPatientWithRegistrationMatrix, targetImageIds);
|
|
41
50
|
let imageIndexToSet = closestImageIdIndex2.index;
|
|
42
|
-
if (tViewport
|
|
51
|
+
if (isVolumeSliceViewport(tViewport)) {
|
|
43
52
|
imageIndexToSet = targetImageIds.length - closestImageIdIndex2.index - 1;
|
|
44
53
|
}
|
|
45
54
|
if (closestImageIdIndex2.index !== -1 &&
|
|
46
|
-
tViewport.getCurrentImageIdIndex() !==
|
|
55
|
+
tViewport.getCurrentImageIdIndex() !== imageIndexToSet) {
|
|
47
56
|
await utilities.jumpToSlice(tViewport.element, {
|
|
48
57
|
imageIndex: imageIndexToSet,
|
|
49
58
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getRenderingEngine } from '@cornerstonejs/core';
|
|
2
|
+
import { applyViewportPresentation, getViewportPresentation, } from '../../utilities/viewportPresentation';
|
|
2
3
|
export default function presentationViewSyncCallback(_synchronizerInstance, sourceViewport, targetViewport, _sourceEvent, options) {
|
|
3
4
|
const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
|
|
4
5
|
if (!renderingEngine) {
|
|
@@ -6,7 +7,9 @@ export default function presentationViewSyncCallback(_synchronizerInstance, sour
|
|
|
6
7
|
}
|
|
7
8
|
const tViewport = renderingEngine.getViewport(targetViewport.viewportId);
|
|
8
9
|
const sViewport = renderingEngine.getViewport(sourceViewport.viewportId);
|
|
9
|
-
const presentationView = sViewport
|
|
10
|
-
tViewport
|
|
10
|
+
const presentationView = getViewportPresentation(sViewport, options);
|
|
11
|
+
if (!applyViewportPresentation(tViewport, presentationView)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
11
14
|
tViewport.render();
|
|
12
15
|
}
|
|
@@ -1,4 +1,43 @@
|
|
|
1
|
-
import { getRenderingEngine } from '@cornerstonejs/core';
|
|
1
|
+
import { getRenderingEngine, viewportHasPan, viewportHasZoom, viewportProjection, } from '@cornerstonejs/core';
|
|
2
|
+
const zoomPanProjectionSelector = {
|
|
3
|
+
pan: true,
|
|
4
|
+
zoom: true,
|
|
5
|
+
};
|
|
6
|
+
function viewportHasViewStateSetter(viewport) {
|
|
7
|
+
return (Boolean(viewport) &&
|
|
8
|
+
typeof viewport === 'object' &&
|
|
9
|
+
'setViewState' in viewport &&
|
|
10
|
+
typeof viewport.setViewState === 'function');
|
|
11
|
+
}
|
|
12
|
+
function syncProjectionZoomPan(sourceViewport, targetViewport, options) {
|
|
13
|
+
if (!viewportHasViewStateSetter(targetViewport)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const sourcePresentation = viewportProjection.getPresentation(sourceViewport, {
|
|
17
|
+
selector: zoomPanProjectionSelector,
|
|
18
|
+
});
|
|
19
|
+
if (!sourcePresentation) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const presentationPatch = {};
|
|
23
|
+
if (options?.syncZoom !== false &&
|
|
24
|
+
typeof sourcePresentation.zoom === 'number') {
|
|
25
|
+
presentationPatch.zoom = sourcePresentation.zoom;
|
|
26
|
+
}
|
|
27
|
+
if (options?.syncPan !== false && sourcePresentation.pan) {
|
|
28
|
+
presentationPatch.pan = sourcePresentation.pan;
|
|
29
|
+
}
|
|
30
|
+
if (presentationPatch.zoom === undefined &&
|
|
31
|
+
presentationPatch.pan === undefined) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const nextViewState = viewportProjection.withPresentation(targetViewport, presentationPatch);
|
|
35
|
+
if (!nextViewState) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
targetViewport.setViewState(nextViewState);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
2
41
|
export default function zoomPanSyncCallback(synchronizerInstance, sourceViewport, targetViewport) {
|
|
3
42
|
const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
|
|
4
43
|
if (!renderingEngine) {
|
|
@@ -7,11 +46,20 @@ export default function zoomPanSyncCallback(synchronizerInstance, sourceViewport
|
|
|
7
46
|
const options = synchronizerInstance.getOptions(targetViewport.viewportId);
|
|
8
47
|
const tViewport = renderingEngine.getViewport(targetViewport.viewportId);
|
|
9
48
|
const sViewport = renderingEngine.getViewport(sourceViewport.viewportId);
|
|
10
|
-
|
|
49
|
+
const syncedByProjection = syncProjectionZoomPan(sViewport, tViewport, options);
|
|
50
|
+
if (syncedByProjection) {
|
|
51
|
+
tViewport.render();
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (options?.syncZoom !== false &&
|
|
55
|
+
viewportHasZoom(sViewport) &&
|
|
56
|
+
viewportHasZoom(tViewport)) {
|
|
11
57
|
const srcZoom = sViewport.getZoom();
|
|
12
58
|
tViewport.setZoom(srcZoom);
|
|
13
59
|
}
|
|
14
|
-
if (options?.syncPan !== false
|
|
60
|
+
if (options?.syncPan !== false &&
|
|
61
|
+
viewportHasPan(sViewport) &&
|
|
62
|
+
viewportHasPan(tViewport)) {
|
|
15
63
|
const srcPan = sViewport.getPan();
|
|
16
64
|
tViewport.setPan(srcPan);
|
|
17
65
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Types } from '@cornerstonejs/core';
|
|
2
2
|
import type Synchronizer from '../../store/SynchronizerManager/Synchronizer';
|
|
3
|
-
export default function createPresentationViewSynchronizer(synchronizerName: string, options?: Types.
|
|
3
|
+
export default function createPresentationViewSynchronizer(synchronizerName: string, options?: Types.ViewPresentationSelector): Synchronizer;
|
|
@@ -27,7 +27,6 @@ var AdvancedMagnifyToolActions;
|
|
|
27
27
|
const ADVANCED_MAGNIFY_TOOL_NAME = 'AdvancedMagnify';
|
|
28
28
|
const PARALLEL_THRESHOLD = 1 - CONSTANTS.EPSILON;
|
|
29
29
|
class AdvancedMagnifyTool extends AnnotationTool {
|
|
30
|
-
static { this.Actions = AdvancedMagnifyToolActions; }
|
|
31
30
|
constructor(toolProps = {}, defaultToolProps = {
|
|
32
31
|
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
33
32
|
configuration: {
|
|
@@ -455,6 +454,7 @@ class AdvancedMagnifyTool extends AnnotationTool {
|
|
|
455
454
|
}
|
|
456
455
|
}
|
|
457
456
|
}
|
|
457
|
+
AdvancedMagnifyTool.Actions = AdvancedMagnifyToolActions;
|
|
458
458
|
class AdvancedMagnifyViewportManager {
|
|
459
459
|
constructor() {
|
|
460
460
|
this.createViewport = (annotation, viewportInfo) => {
|
|
@@ -902,6 +902,7 @@ class AdvancedMagnifyViewport {
|
|
|
902
902
|
_syncViewportsCameras(sourceViewport, magnifyViewport) {
|
|
903
903
|
const worldPos = sourceViewport.canvasToWorld(this.position);
|
|
904
904
|
const parallelScale = this._convertZoomFactorToParallelScale(sourceViewport, magnifyViewport, this.zoomFactor);
|
|
905
|
+
const { flipHorizontal, flipVertical } = sourceViewport.getCamera();
|
|
905
906
|
const { focalPoint, position, viewPlaneNormal } = magnifyViewport.getCamera();
|
|
906
907
|
const distance = Math.sqrt(Math.pow(focalPoint[0] - position[0], 2) +
|
|
907
908
|
Math.pow(focalPoint[1] - position[1], 2) +
|
|
@@ -920,6 +921,8 @@ class AdvancedMagnifyViewport {
|
|
|
920
921
|
parallelScale,
|
|
921
922
|
focalPoint: updatedFocalPoint,
|
|
922
923
|
position: updatedPosition,
|
|
924
|
+
flipHorizontal,
|
|
925
|
+
flipVertical,
|
|
923
926
|
});
|
|
924
927
|
}
|
|
925
928
|
_syncStackViewports(sourceViewport, magnifyViewport) {
|
|
@@ -16,6 +16,10 @@ export type CrosshairsAnnotation = Annotation & {
|
|
|
16
16
|
};
|
|
17
17
|
declare class CrosshairsTool extends AnnotationTool {
|
|
18
18
|
static toolName: any;
|
|
19
|
+
static minimalModeExamples: Map<string, {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
lineLengthInPx: number;
|
|
22
|
+
}>;
|
|
19
23
|
toolCenter: Types.Point3;
|
|
20
24
|
_getReferenceLineColor?: (viewportId: string) => string;
|
|
21
25
|
_getReferenceLineControllable?: (viewportId: string) => boolean;
|