@cornerstonejs/tools 0.56.1 → 0.56.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tools/CrosshairsTool.d.ts +1 -0
- package/dist/cjs/tools/CrosshairsTool.js +4 -1
- package/dist/cjs/tools/CrosshairsTool.js.map +1 -1
- package/dist/esm/tools/CrosshairsTool.d.ts +1 -0
- package/dist/esm/tools/CrosshairsTool.js +4 -1
- package/dist/esm/tools/CrosshairsTool.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +5 -4
- package/src/constants/COLOR_LUT.ts +262 -0
- package/src/constants/index.ts +3 -0
- package/src/cursors/ImageMouseCursor.ts +39 -0
- package/src/cursors/MouseCursor.ts +114 -0
- package/src/cursors/SVGCursorDescriptor.ts +462 -0
- package/src/cursors/SVGMouseCursor.ts +145 -0
- package/src/cursors/elementCursor.ts +69 -0
- package/src/cursors/index.ts +24 -0
- package/src/cursors/setCursorForElement.ts +33 -0
- package/src/drawingSvg/_getHash.ts +9 -0
- package/src/drawingSvg/_setAttributesIfNecessary.ts +13 -0
- package/src/drawingSvg/_setNewAttributesIfValid.ts +10 -0
- package/src/drawingSvg/clearByToolType.ts +26 -0
- package/src/drawingSvg/draw.ts +16 -0
- package/src/drawingSvg/drawArrow.ts +82 -0
- package/src/drawingSvg/drawCircle.ts +62 -0
- package/src/drawingSvg/drawEllipse.ts +71 -0
- package/src/drawingSvg/drawHandles.ts +87 -0
- package/src/drawingSvg/drawLine.ts +70 -0
- package/src/drawingSvg/drawLink.ts +76 -0
- package/src/drawingSvg/drawLinkedTextBox.ts +64 -0
- package/src/drawingSvg/drawPolyline.ts +80 -0
- package/src/drawingSvg/drawRect.ts +70 -0
- package/src/drawingSvg/drawTextBox.ts +213 -0
- package/src/drawingSvg/getSvgDrawingHelper.ts +98 -0
- package/src/drawingSvg/index.ts +23 -0
- package/src/enums/AnnotationStyleStates.ts +22 -0
- package/src/enums/Events.ts +242 -0
- package/src/enums/SegmentationRepresentations.ts +12 -0
- package/src/enums/ToolBindings.ts +37 -0
- package/src/enums/ToolModes.ts +31 -0
- package/src/enums/Touch.ts +8 -0
- package/src/enums/index.js +16 -0
- package/src/eventDispatchers/annotationModifiedEventDispatcher.ts +41 -0
- package/src/eventDispatchers/cameraModifiedEventDispatcher.ts +41 -0
- package/src/eventDispatchers/imageRenderedEventDispatcher.ts +37 -0
- package/src/eventDispatchers/imageSpacingCalibratedEventDispatcher.ts +50 -0
- package/src/eventDispatchers/index.js +15 -0
- package/src/eventDispatchers/keyboardEventHandlers/index.js +4 -0
- package/src/eventDispatchers/keyboardEventHandlers/keyDown.ts +29 -0
- package/src/eventDispatchers/keyboardEventHandlers/keyUp.ts +33 -0
- package/src/eventDispatchers/keyboardToolEventDispatcher.ts +28 -0
- package/src/eventDispatchers/mouseEventHandlers/index.js +19 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseClick.ts +13 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseDoubleClick.ts +13 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseDown.ts +196 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseDownActivate.ts +35 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseDrag.ts +25 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseMove.ts +70 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseUp.ts +9 -0
- package/src/eventDispatchers/mouseEventHandlers/mouseWheel.ts +13 -0
- package/src/eventDispatchers/mouseToolEventDispatcher.ts +64 -0
- package/src/eventDispatchers/shared/customCallbackHandler.ts +73 -0
- package/src/eventDispatchers/shared/getActiveToolForKeyboardEvent.ts +58 -0
- package/src/eventDispatchers/shared/getActiveToolForMouseEvent.ts +61 -0
- package/src/eventDispatchers/shared/getActiveToolForTouchEvent.ts +64 -0
- package/src/eventDispatchers/shared/getMouseModifier.ts +30 -0
- package/src/eventDispatchers/shared/getToolsWithModesForMouseEvent.ts +56 -0
- package/src/eventDispatchers/shared/getToolsWithModesForTouchEvent.ts +54 -0
- package/src/eventDispatchers/touchEventHandlers/index.js +15 -0
- package/src/eventDispatchers/touchEventHandlers/touchDrag.ts +23 -0
- package/src/eventDispatchers/touchEventHandlers/touchEnd.ts +9 -0
- package/src/eventDispatchers/touchEventHandlers/touchPress.ts +13 -0
- package/src/eventDispatchers/touchEventHandlers/touchStart.ts +174 -0
- package/src/eventDispatchers/touchEventHandlers/touchStartActivate.ts +36 -0
- package/src/eventDispatchers/touchEventHandlers/touchTap.ts +9 -0
- package/src/eventDispatchers/touchToolEventDispatcher.ts +51 -0
- package/src/eventListeners/annotations/annotationModifiedListener.ts +22 -0
- package/src/eventListeners/annotations/annotationSelectionListener.ts +29 -0
- package/src/eventListeners/annotations/index.ts +4 -0
- package/src/eventListeners/index.ts +28 -0
- package/src/eventListeners/keyboard/index.ts +16 -0
- package/src/eventListeners/keyboard/keyDownListener.ts +99 -0
- package/src/eventListeners/mouse/getMouseEventPoints.ts +66 -0
- package/src/eventListeners/mouse/index.ts +55 -0
- package/src/eventListeners/mouse/mouseDoubleClickListener.ts +55 -0
- package/src/eventListeners/mouse/mouseDownListener.ts +519 -0
- package/src/eventListeners/mouse/mouseMoveListener.ts +33 -0
- package/src/eventListeners/segmentation/index.ts +11 -0
- package/src/eventListeners/segmentation/segmentationDataModifiedEventListener.ts +61 -0
- package/src/eventListeners/segmentation/segmentationModifiedEventListener.ts +32 -0
- package/src/eventListeners/segmentation/segmentationRepresentationModifiedEventListener.ts +15 -0
- package/src/eventListeners/segmentation/segmentationRepresentationRemovedEventListener.ts +16 -0
- package/src/eventListeners/touch/getTouchEventPoints.ts +75 -0
- package/src/eventListeners/touch/index.ts +37 -0
- package/src/eventListeners/touch/preventGhostClick.js +72 -0
- package/src/eventListeners/touch/touchStartListener.ts +499 -0
- package/src/eventListeners/wheel/index.ts +27 -0
- package/src/eventListeners/wheel/normalizeWheel.ts +69 -0
- package/src/eventListeners/wheel/wheelListener.ts +51 -0
- package/src/index.ts +133 -0
- package/src/init.ts +187 -0
- package/src/stateManagement/annotation/FrameOfReferenceSpecificAnnotationManager.ts +399 -0
- package/src/stateManagement/annotation/annotationLocking.ts +178 -0
- package/src/stateManagement/annotation/annotationSelection.ts +163 -0
- package/src/stateManagement/annotation/annotationState.ts +180 -0
- package/src/stateManagement/annotation/annotationVisibility.ts +156 -0
- package/src/stateManagement/annotation/config/ToolStyle.ts +265 -0
- package/src/stateManagement/annotation/config/getFont.ts +36 -0
- package/src/stateManagement/annotation/config/getState.ts +26 -0
- package/src/stateManagement/annotation/config/helpers.ts +55 -0
- package/src/stateManagement/annotation/config/index.ts +5 -0
- package/src/stateManagement/annotation/helpers/state.ts +83 -0
- package/src/stateManagement/annotation/index.ts +15 -0
- package/src/stateManagement/index.js +40 -0
- package/src/stateManagement/segmentation/SegmentationStateManager.ts +491 -0
- package/src/stateManagement/segmentation/activeSegmentation.ts +60 -0
- package/src/stateManagement/segmentation/addSegmentationRepresentations.ts +77 -0
- package/src/stateManagement/segmentation/addSegmentations.ts +27 -0
- package/src/stateManagement/segmentation/config/index.ts +29 -0
- package/src/stateManagement/segmentation/config/segmentationColor.ts +132 -0
- package/src/stateManagement/segmentation/config/segmentationConfig.ts +195 -0
- package/src/stateManagement/segmentation/config/segmentationVisibility.ts +171 -0
- package/src/stateManagement/segmentation/helpers/index.ts +3 -0
- package/src/stateManagement/segmentation/helpers/normalizeSegmentationInput.ts +35 -0
- package/src/stateManagement/segmentation/helpers/validateSegmentationInput.ts +41 -0
- package/src/stateManagement/segmentation/index.ts +22 -0
- package/src/stateManagement/segmentation/removeSegmentationsFromToolGroup.ts +85 -0
- package/src/stateManagement/segmentation/segmentIndex.ts +38 -0
- package/src/stateManagement/segmentation/segmentLocking.ts +72 -0
- package/src/stateManagement/segmentation/segmentationState.ts +429 -0
- package/src/stateManagement/segmentation/triggerSegmentationEvents.ts +157 -0
- package/src/store/SynchronizerManager/Synchronizer.ts +344 -0
- package/src/store/SynchronizerManager/createSynchronizer.ts +41 -0
- package/src/store/SynchronizerManager/destroy.ts +14 -0
- package/src/store/SynchronizerManager/destroySynchronizer.ts +25 -0
- package/src/store/SynchronizerManager/getAllSynchronizers.ts +12 -0
- package/src/store/SynchronizerManager/getSynchronizer.ts +13 -0
- package/src/store/SynchronizerManager/getSynchronizersForViewport.ts +44 -0
- package/src/store/SynchronizerManager/index.js +15 -0
- package/src/store/ToolGroupManager/ToolGroup.ts +679 -0
- package/src/store/ToolGroupManager/createToolGroup.ts +33 -0
- package/src/store/ToolGroupManager/destroy.ts +24 -0
- package/src/store/ToolGroupManager/destroyToolGroup.ts +26 -0
- package/src/store/ToolGroupManager/getAllToolGroups.ts +12 -0
- package/src/store/ToolGroupManager/getToolGroup.ts +14 -0
- package/src/store/ToolGroupManager/getToolGroupForViewport.ts +44 -0
- package/src/store/ToolGroupManager/getToolGroupsWithToolName.ts +33 -0
- package/src/store/ToolGroupManager/index.ts +17 -0
- package/src/store/addEnabledElement.ts +137 -0
- package/src/store/addTool.ts +56 -0
- package/src/store/cancelActiveManipulations.ts +30 -0
- package/src/store/filterMoveableAnnotationTools.ts +61 -0
- package/src/store/filterToolsWithAnnotationsForElement.ts +51 -0
- package/src/store/filterToolsWithMoveableHandles.ts +51 -0
- package/src/store/index.ts +29 -0
- package/src/store/removeEnabledElement.ts +132 -0
- package/src/store/state.ts +57 -0
- package/src/store/svgNodeCache.ts +7 -0
- package/src/synchronizers/callbacks/areViewportsCoplanar .ts +12 -0
- package/src/synchronizers/callbacks/cameraSyncCallback.ts +33 -0
- package/src/synchronizers/callbacks/stackImageSyncCallback.ts +157 -0
- package/src/synchronizers/callbacks/voiSyncCallback.ts +51 -0
- package/src/synchronizers/callbacks/zoomPanSyncCallback.ts +43 -0
- package/src/synchronizers/index.ts +11 -0
- package/src/synchronizers/synchronizers/createCameraPositionSynchronizer.ts +25 -0
- package/src/synchronizers/synchronizers/createStackImageSynchronizer.ts +25 -0
- package/src/synchronizers/synchronizers/createVOISynchronizer.ts +24 -0
- package/src/synchronizers/synchronizers/createZoomPanSynchronizer.ts +25 -0
- package/src/synchronizers/synchronizers/index.ts +11 -0
- package/src/tools/CrosshairsTool.ts +2693 -0
- package/src/tools/MIPJumpToClickTool.ts +99 -0
- package/src/tools/MagnifyTool.ts +319 -0
- package/src/tools/PanTool.ts +58 -0
- package/src/tools/PlanarRotateTool.ts +77 -0
- package/src/tools/ReferenceCursors.ts +466 -0
- package/src/tools/ReferenceLinesTool.ts +279 -0
- package/src/tools/ScaleOverlayTool.ts +685 -0
- package/src/tools/StackScrollTool.ts +97 -0
- package/src/tools/StackScrollToolMouseWheelTool.ts +58 -0
- package/src/tools/TrackballRotateTool.ts +141 -0
- package/src/tools/VolumeRotateMouseWheelTool.ts +86 -0
- package/src/tools/WindowLevelTool.ts +260 -0
- package/src/tools/ZoomTool.ts +293 -0
- package/src/tools/annotation/AngleTool.ts +835 -0
- package/src/tools/annotation/ArrowAnnotateTool.ts +820 -0
- package/src/tools/annotation/BidirectionalTool.ts +1350 -0
- package/src/tools/annotation/CircleROITool.ts +1070 -0
- package/src/tools/annotation/CobbAngleTool.ts +815 -0
- package/src/tools/annotation/DragProbeTool.ts +213 -0
- package/src/tools/annotation/EllipticalROITool.ts +1223 -0
- package/src/tools/annotation/LengthTool.ts +861 -0
- package/src/tools/annotation/PlanarFreehandROITool.ts +636 -0
- package/src/tools/annotation/ProbeTool.ts +681 -0
- package/src/tools/annotation/RectangleROITool.ts +1028 -0
- package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +488 -0
- package/src/tools/annotation/planarFreehandROITool/drawLoop.ts +462 -0
- package/src/tools/annotation/planarFreehandROITool/editLoopCommon.ts +331 -0
- package/src/tools/annotation/planarFreehandROITool/findOpenUShapedContourVectorToPeak.ts +74 -0
- package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +612 -0
- package/src/tools/annotation/planarFreehandROITool/openContourEndEditLoop.ts +74 -0
- package/src/tools/annotation/planarFreehandROITool/renderMethods.ts +407 -0
- package/src/tools/base/AnnotationDisplayTool.ts +228 -0
- package/src/tools/base/AnnotationTool.ts +307 -0
- package/src/tools/base/BaseTool.ts +215 -0
- package/src/tools/base/index.ts +4 -0
- package/src/tools/displayTools/Contour/addContourToElement.ts +135 -0
- package/src/tools/displayTools/Contour/contourDisplay.ts +252 -0
- package/src/tools/displayTools/Contour/index.ts +3 -0
- package/src/tools/displayTools/Contour/removeContourFromElement.ts +35 -0
- package/src/tools/displayTools/Labelmap/addLabelmapToElement.ts +57 -0
- package/src/tools/displayTools/Labelmap/index.ts +4 -0
- package/src/tools/displayTools/Labelmap/labelmapConfig.ts +37 -0
- package/src/tools/displayTools/Labelmap/labelmapDisplay.ts +461 -0
- package/src/tools/displayTools/Labelmap/removeLabelmapFromElement.ts +27 -0
- package/src/tools/displayTools/Labelmap/validateRepresentationData.ts +30 -0
- package/src/tools/displayTools/SegmentationDisplayTool.ts +198 -0
- package/src/tools/index.ts +84 -0
- package/src/tools/segmentation/BrushTool.ts +474 -0
- package/src/tools/segmentation/CircleScissorsTool.ts +365 -0
- package/src/tools/segmentation/PaintFillTool.ts +370 -0
- package/src/tools/segmentation/RectangleROIStartEndThresholdTool.ts +471 -0
- package/src/tools/segmentation/RectangleROIThresholdTool.ts +281 -0
- package/src/tools/segmentation/RectangleScissorsTool.ts +382 -0
- package/src/tools/segmentation/SphereScissorsTool.ts +368 -0
- package/src/tools/segmentation/strategies/eraseCircle.ts +30 -0
- package/src/tools/segmentation/strategies/eraseRectangle.ts +81 -0
- package/src/tools/segmentation/strategies/eraseSphere.ts +27 -0
- package/src/tools/segmentation/strategies/fillCircle.ts +185 -0
- package/src/tools/segmentation/strategies/fillRectangle.ts +110 -0
- package/src/tools/segmentation/strategies/fillSphere.ts +88 -0
- package/src/tools/segmentation/strategies/index.ts +9 -0
- package/src/types/AnnotationGroupSelector.ts +7 -0
- package/src/types/AnnotationStyle.ts +42 -0
- package/src/types/AnnotationTypes.ts +109 -0
- package/src/types/BoundsIJK.ts +5 -0
- package/src/types/CINETypes.ts +32 -0
- package/src/types/ContourTypes.ts +26 -0
- package/src/types/CursorTypes.ts +12 -0
- package/src/types/EventTypes.ts +657 -0
- package/src/types/FloodFillTypes.ts +19 -0
- package/src/types/IAnnotationManager.ts +89 -0
- package/src/types/IDistance.ts +16 -0
- package/src/types/IPoints.ts +18 -0
- package/src/types/ISetToolModeOptions.ts +29 -0
- package/src/types/ISynchronizerEventHandler.ts +11 -0
- package/src/types/IToolClassReference.ts +5 -0
- package/src/types/IToolGroup.ts +72 -0
- package/src/types/ITouchPoints.ts +14 -0
- package/src/types/InteractionTypes.ts +6 -0
- package/src/types/InternalToolTypes.ts +19 -0
- package/src/types/JumpToSliceOptions.ts +7 -0
- package/src/types/LabelmapTypes.ts +41 -0
- package/src/types/PlanarBoundingBox.ts +8 -0
- package/src/types/SVGDrawingHelper.ts +10 -0
- package/src/types/ScrollOptions.ts +9 -0
- package/src/types/SegmentationStateTypes.ts +248 -0
- package/src/types/ToolHandle.ts +26 -0
- package/src/types/ToolProps.ts +16 -0
- package/src/types/ToolSpecificAnnotationTypes.ts +311 -0
- package/src/types/index.ts +115 -0
- package/src/utilities/boundingBox/extend2DBoundingBoxInViewAxis.ts +29 -0
- package/src/utilities/boundingBox/getBoundingBoxAroundShape.ts +57 -0
- package/src/utilities/boundingBox/index.ts +4 -0
- package/src/utilities/calibrateImageSpacing.ts +46 -0
- package/src/utilities/cine/events.ts +9 -0
- package/src/utilities/cine/index.ts +5 -0
- package/src/utilities/cine/playClip.ts +435 -0
- package/src/utilities/cine/state.ts +18 -0
- package/src/utilities/clip.js +30 -0
- package/src/utilities/debounce.js +217 -0
- package/src/utilities/drawing/getTextBoxCoordsCanvas.ts +45 -0
- package/src/utilities/drawing/index.ts +3 -0
- package/src/utilities/dynamicVolume/getDataInTime.ts +110 -0
- package/src/utilities/dynamicVolume/index.ts +2 -0
- package/src/utilities/getAnnotationNearPoint.ts +130 -0
- package/src/utilities/getModalityUnit.ts +11 -0
- package/src/utilities/getToolsWithModesForElement.ts +52 -0
- package/src/utilities/index.ts +68 -0
- package/src/utilities/isObject.js +29 -0
- package/src/utilities/math/angle/angleBetweenLines.ts +29 -0
- package/src/utilities/math/circle/_types.ts +6 -0
- package/src/utilities/math/circle/getCanvasCircleCorners.ts +23 -0
- package/src/utilities/math/circle/getCanvasCircleRadius.ts +16 -0
- package/src/utilities/math/circle/index.ts +4 -0
- package/src/utilities/math/ellipse/getCanvasEllipseCorners.ts +26 -0
- package/src/utilities/math/ellipse/index.ts +4 -0
- package/src/utilities/math/ellipse/pointInEllipse.ts +38 -0
- package/src/utilities/math/ellipse/pointInEllipsoidWithConstraint.ts +35 -0
- package/src/utilities/math/index.ts +8 -0
- package/src/utilities/math/line/distanceToPoint.ts +24 -0
- package/src/utilities/math/line/distanceToPointSquared.ts +44 -0
- package/src/utilities/math/line/index.ts +5 -0
- package/src/utilities/math/line/intersectLine.ts +92 -0
- package/src/utilities/math/midPoint.ts +24 -0
- package/src/utilities/math/point/distanceToPoint.ts +22 -0
- package/src/utilities/math/point/index.ts +3 -0
- package/src/utilities/math/polyline/addCanvasPointsToArray.ts +62 -0
- package/src/utilities/math/polyline/calculateAreaOfPoints.ts +23 -0
- package/src/utilities/math/polyline/getIntersectionWithPolyline.ts +182 -0
- package/src/utilities/math/polyline/getSubPixelSpacingAndXYDirections.ts +99 -0
- package/src/utilities/math/polyline/index.ts +19 -0
- package/src/utilities/math/polyline/planarFreehandROIInternalTypes.ts +36 -0
- package/src/utilities/math/polyline/pointCanProjectOnLine.ts +57 -0
- package/src/utilities/math/polyline/pointsAreWithinCloseContourProximity.ts +15 -0
- package/src/utilities/math/rectangle/distanceToPoint.ts +82 -0
- package/src/utilities/math/rectangle/index.ts +3 -0
- package/src/utilities/math/sphere/index.ts +3 -0
- package/src/utilities/math/sphere/pointInSphere.ts +31 -0
- package/src/utilities/math/vec2/findClosestPoint.ts +40 -0
- package/src/utilities/math/vec2/index.ts +4 -0
- package/src/utilities/math/vec2/liangBarksyClip.ts +84 -0
- package/src/utilities/orientation/getOrientationStringLPS.ts +52 -0
- package/src/utilities/orientation/index.ts +4 -0
- package/src/utilities/orientation/invertOrientationStringLPS.ts +21 -0
- package/src/utilities/planar/filterAnnotationsForDisplay.ts +68 -0
- package/src/utilities/planar/filterAnnotationsWithinSlice.ts +85 -0
- package/src/utilities/planar/getPointInLineOfSightWithCriteria.ts +104 -0
- package/src/utilities/planar/getWorldWidthAndHeightFromCorners.ts +51 -0
- package/src/utilities/planar/getWorldWidthAndHeightFromTwoPoints.ts +51 -0
- package/src/utilities/planar/index.ts +18 -0
- package/src/utilities/planarFreehandROITool/index.ts +7 -0
- package/src/utilities/planarFreehandROITool/interpolateAnnotation.ts +87 -0
- package/src/utilities/planarFreehandROITool/interpolatePoints.ts +214 -0
- package/src/utilities/planarFreehandROITool/interpolation/algorithms/bspline.ts +55 -0
- package/src/utilities/planarFreehandROITool/interpolation/interpolateSegmentPoints.ts +90 -0
- package/src/utilities/pointInShapeCallback.ts +138 -0
- package/src/utilities/pointInSurroundingSphereCallback.ts +188 -0
- package/src/utilities/rectangleROITool/getBoundsIJKFromRectangleAnnotations.ts +76 -0
- package/src/utilities/rectangleROITool/index.ts +3 -0
- package/src/utilities/scroll.ts +62 -0
- package/src/utilities/segmentation/brushSizeForToolGroup.ts +72 -0
- package/src/utilities/segmentation/brushThresholdForToolGroup.ts +65 -0
- package/src/utilities/segmentation/createLabelmapVolumeForViewport.ts +74 -0
- package/src/utilities/segmentation/createMergedLabelmapForIndex.ts +65 -0
- package/src/utilities/segmentation/floodFill.ts +194 -0
- package/src/utilities/segmentation/getDefaultRepresentationConfig.ts +20 -0
- package/src/utilities/segmentation/index.ts +33 -0
- package/src/utilities/segmentation/isValidRepresentationConfig.ts +22 -0
- package/src/utilities/segmentation/rectangleROIThresholdVolumeByRange.ts +91 -0
- package/src/utilities/segmentation/thresholdSegmentationByRange.ts +129 -0
- package/src/utilities/segmentation/thresholdVolumeByRange.ts +150 -0
- package/src/utilities/segmentation/triggerSegmentationRender.ts +206 -0
- package/src/utilities/segmentation/utilities.ts +116 -0
- package/src/utilities/stackPrefetch/index.ts +8 -0
- package/src/utilities/stackPrefetch/stackPrefetch.ts +405 -0
- package/src/utilities/stackPrefetch/state.ts +17 -0
- package/src/utilities/throttle.js +69 -0
- package/src/utilities/touch/index.ts +246 -0
- package/src/utilities/triggerAnnotationRender.ts +237 -0
- package/src/utilities/triggerAnnotationRenderForViewportIds.ts +18 -0
- package/src/utilities/viewport/index.ts +5 -0
- package/src/utilities/viewport/isViewportPreScaled.ts +24 -0
- package/src/utilities/viewport/jumpToSlice.ts +73 -0
- package/src/utilities/viewport/jumpToWorld.ts +58 -0
- package/src/utilities/viewportFilters/filterViewportsWithFrameOfReferenceUID.ts +28 -0
- package/src/utilities/viewportFilters/filterViewportsWithParallelNormals.ts +26 -0
- package/src/utilities/viewportFilters/filterViewportsWithSameOrientation.ts +15 -0
- package/src/utilities/viewportFilters/filterViewportsWithToolEnabled.ts +72 -0
- package/src/utilities/viewportFilters/getViewportIdsWithToolToRender.ts +45 -0
- package/src/utilities/viewportFilters/index.ts +11 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getSegmentation } from './segmentationState';
|
|
2
|
+
import { triggerSegmentationModified } from './triggerSegmentationEvents';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Set the active segment index for a segmentation Id. It fires a global state
|
|
6
|
+
* modified event.
|
|
7
|
+
*
|
|
8
|
+
* @triggers SEGMENTATION_MODIFIED
|
|
9
|
+
* @param segmentationId - The id of the segmentation that the segment belongs to.
|
|
10
|
+
* @param segmentIndex - The index of the segment to be activated.
|
|
11
|
+
*/
|
|
12
|
+
function setActiveSegmentIndex(
|
|
13
|
+
segmentationId: string,
|
|
14
|
+
segmentIndex: number
|
|
15
|
+
): void {
|
|
16
|
+
const segmentation = getSegmentation(segmentationId);
|
|
17
|
+
|
|
18
|
+
if (segmentation?.activeSegmentIndex !== segmentIndex) {
|
|
19
|
+
segmentation.activeSegmentIndex = segmentIndex;
|
|
20
|
+
|
|
21
|
+
triggerSegmentationModified(segmentationId);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get the active segment index for a segmentation in the global state
|
|
27
|
+
* @param segmentationId - The id of the segmentation to get the active segment index from.
|
|
28
|
+
* @returns The active segment index for the given segmentation.
|
|
29
|
+
*/
|
|
30
|
+
function getActiveSegmentIndex(segmentationId: string): number | undefined {
|
|
31
|
+
const segmentation = getSegmentation(segmentationId);
|
|
32
|
+
|
|
33
|
+
if (segmentation) {
|
|
34
|
+
return segmentation.activeSegmentIndex;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { getActiveSegmentIndex, setActiveSegmentIndex };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getActiveSegmentationRepresentation } from './activeSegmentation';
|
|
2
|
+
|
|
3
|
+
import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
|
|
4
|
+
import { triggerSegmentationModified } from './triggerSegmentationEvents';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get the locked status for a segment index in a segmentation
|
|
8
|
+
* @param segmentationId - The id of the segmentation that the segment
|
|
9
|
+
* belongs to.
|
|
10
|
+
* @param segmentIndex - The index of the segment
|
|
11
|
+
* @returns A boolean value indicating whether the segment is locked or not.
|
|
12
|
+
*/
|
|
13
|
+
function isSegmentIndexLocked(
|
|
14
|
+
segmentationId: string,
|
|
15
|
+
segmentIndex: number
|
|
16
|
+
): boolean {
|
|
17
|
+
const segmentation = getSegmentation(segmentationId);
|
|
18
|
+
|
|
19
|
+
if (!segmentation) {
|
|
20
|
+
throw new Error(`No segmentation state found for ${segmentationId}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { segmentsLocked } = segmentation;
|
|
24
|
+
return segmentsLocked.has(segmentIndex);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Set the locked status of a segment index in a segmentation
|
|
29
|
+
* @param segmentationId - The id of the segmentation whose segment
|
|
30
|
+
* index is being modified.
|
|
31
|
+
* @param segmentIndex - The index of the segment to lock/unlock.
|
|
32
|
+
*/
|
|
33
|
+
function setSegmentIndexLocked(
|
|
34
|
+
segmentationId: string,
|
|
35
|
+
segmentIndex: number,
|
|
36
|
+
locked = true
|
|
37
|
+
): void {
|
|
38
|
+
const segmentation = getSegmentation(segmentationId);
|
|
39
|
+
|
|
40
|
+
if (!segmentation) {
|
|
41
|
+
throw new Error(`No segmentation state found for ${segmentationId}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { segmentsLocked } = segmentation;
|
|
45
|
+
|
|
46
|
+
if (locked) {
|
|
47
|
+
segmentsLocked.add(segmentIndex);
|
|
48
|
+
} else {
|
|
49
|
+
segmentsLocked.delete(segmentIndex);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
triggerSegmentationModified(segmentationId);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get the locked segments for a segmentation
|
|
57
|
+
* @param segmentationId - The id of the segmentation to get locked
|
|
58
|
+
* segments for.
|
|
59
|
+
* @returns An array of locked segment indices.
|
|
60
|
+
*/
|
|
61
|
+
function getLockedSegments(segmentationId: string): number[] | [] {
|
|
62
|
+
const segmentation = getSegmentation(segmentationId);
|
|
63
|
+
|
|
64
|
+
if (!segmentation) {
|
|
65
|
+
throw new Error(`No segmentation state found for ${segmentationId}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const { segmentsLocked } = segmentation;
|
|
69
|
+
return Array.from(segmentsLocked);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { isSegmentIndexLocked, setSegmentIndexLocked, getLockedSegments };
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
2
|
+
import {
|
|
3
|
+
triggerSegmentationRepresentationModified,
|
|
4
|
+
triggerSegmentationModified,
|
|
5
|
+
triggerSegmentationRepresentationRemoved,
|
|
6
|
+
triggerSegmentationRemoved,
|
|
7
|
+
} from './triggerSegmentationEvents';
|
|
8
|
+
import type {
|
|
9
|
+
ColorLUT,
|
|
10
|
+
RepresentationConfig,
|
|
11
|
+
Segmentation,
|
|
12
|
+
SegmentationPublicInput,
|
|
13
|
+
SegmentationRepresentationConfig,
|
|
14
|
+
SegmentSpecificRepresentationConfig,
|
|
15
|
+
ToolGroupSpecificRepresentation,
|
|
16
|
+
ToolGroupSpecificRepresentations,
|
|
17
|
+
} from '../../types/SegmentationStateTypes';
|
|
18
|
+
|
|
19
|
+
import normalizeSegmentationInput from './helpers/normalizeSegmentationInput';
|
|
20
|
+
import getDefaultLabelmapConfig from '../../tools/displayTools/Labelmap/labelmapConfig';
|
|
21
|
+
import { SegmentationRepresentations } from '../../enums';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* It returns the defaultSegmentationStateManager.
|
|
25
|
+
*/
|
|
26
|
+
function getDefaultSegmentationStateManager() {
|
|
27
|
+
return defaultSegmentationStateManager;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*************************
|
|
31
|
+
*
|
|
32
|
+
* Segmentation State
|
|
33
|
+
*
|
|
34
|
+
**************************/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get the segmentation for the given segmentationId
|
|
38
|
+
* @param segmentationId - The Id of the segmentation
|
|
39
|
+
* @returns A GlobalSegmentationData object
|
|
40
|
+
*/
|
|
41
|
+
function getSegmentation(segmentationId: string): Segmentation | undefined {
|
|
42
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
43
|
+
return segmentationStateManager.getSegmentation(segmentationId);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Get the segmentations inside the state
|
|
48
|
+
* @returns Segmentation array
|
|
49
|
+
*/
|
|
50
|
+
function getSegmentations(): Segmentation[] | [] {
|
|
51
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
52
|
+
const state = segmentationStateManager.getState();
|
|
53
|
+
|
|
54
|
+
return state.segmentations;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* It takes a segmentation input and adds it to the segmentation state manager
|
|
59
|
+
* @param segmentationInput - The segmentation to add.
|
|
60
|
+
* @param suppressEvents - If true, the event will not be triggered.
|
|
61
|
+
*/
|
|
62
|
+
function addSegmentation(
|
|
63
|
+
segmentationInput: SegmentationPublicInput,
|
|
64
|
+
suppressEvents?: boolean
|
|
65
|
+
): void {
|
|
66
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
67
|
+
|
|
68
|
+
const segmentation = normalizeSegmentationInput(segmentationInput);
|
|
69
|
+
|
|
70
|
+
segmentationStateManager.addSegmentation(segmentation);
|
|
71
|
+
|
|
72
|
+
if (!suppressEvents) {
|
|
73
|
+
triggerSegmentationModified(segmentation.segmentationId);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get the segmentation state for a tool group. It will return an array of
|
|
79
|
+
* segmentation representation objects.
|
|
80
|
+
* @param toolGroupId - The unique identifier of the tool group.
|
|
81
|
+
* @returns An array of segmentation representation objects.
|
|
82
|
+
*/
|
|
83
|
+
function getSegmentationRepresentations(
|
|
84
|
+
toolGroupId: string
|
|
85
|
+
): ToolGroupSpecificRepresentations | [] {
|
|
86
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
87
|
+
return segmentationStateManager.getSegmentationRepresentations(toolGroupId);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the tool group IDs that have a segmentation representation with the given
|
|
92
|
+
* segmentationId
|
|
93
|
+
* @param segmentationId - The id of the segmentation
|
|
94
|
+
* @returns An array of tool group IDs.
|
|
95
|
+
*/
|
|
96
|
+
function getToolGroupIdsWithSegmentation(segmentationId: string): string[] {
|
|
97
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
98
|
+
const state = segmentationStateManager.getState();
|
|
99
|
+
const toolGroupIds = Object.keys(state.toolGroups);
|
|
100
|
+
|
|
101
|
+
const foundToolGroupIds = [];
|
|
102
|
+
toolGroupIds.forEach((toolGroupId) => {
|
|
103
|
+
const toolGroupSegmentationRepresentations =
|
|
104
|
+
segmentationStateManager.getSegmentationRepresentations(toolGroupId);
|
|
105
|
+
|
|
106
|
+
toolGroupSegmentationRepresentations.forEach((representation) => {
|
|
107
|
+
if (representation.segmentationId === segmentationId) {
|
|
108
|
+
foundToolGroupIds.push(toolGroupId);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return foundToolGroupIds;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Get the segmentation representations config for a given tool group
|
|
118
|
+
* @param toolGroupId - The Id of the tool group that the segmentation
|
|
119
|
+
* config belongs to.
|
|
120
|
+
* @returns A SegmentationConfig object.
|
|
121
|
+
*/
|
|
122
|
+
function getToolGroupSpecificConfig(
|
|
123
|
+
toolGroupId: string
|
|
124
|
+
): SegmentationRepresentationConfig {
|
|
125
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
126
|
+
return segmentationStateManager.getToolGroupSpecificConfig(toolGroupId);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Set the segmentation representation config for the provided toolGroup. ToolGroup specific
|
|
131
|
+
* configuration overwrites the global configuration for each representation.
|
|
132
|
+
* It fires SEGMENTATION_REPRESENTATION_MODIFIED event if not suppressed.
|
|
133
|
+
*
|
|
134
|
+
* @triggers SEGMENTATION_REPRESENTATION_MODIFIED
|
|
135
|
+
* @param toolGroupId - The Id of the tool group that the segmentation
|
|
136
|
+
* config is being set for.
|
|
137
|
+
* @param config - The new configuration for the tool group.
|
|
138
|
+
* @param suppressEvents - If true, the event will not be triggered.
|
|
139
|
+
*/
|
|
140
|
+
function setToolGroupSpecificConfig(
|
|
141
|
+
toolGroupId: string,
|
|
142
|
+
config: SegmentationRepresentationConfig,
|
|
143
|
+
suppressEvents?: boolean
|
|
144
|
+
): void {
|
|
145
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
146
|
+
segmentationStateManager.setSegmentationRepresentationConfig(
|
|
147
|
+
toolGroupId,
|
|
148
|
+
config
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (!suppressEvents) {
|
|
152
|
+
triggerSegmentationRepresentationModified(toolGroupId);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* It sets the segmentation representation specific config for all the segments
|
|
158
|
+
* inside the segmentation.
|
|
159
|
+
* @param segmentationRepresentationUID - The unique identifier of the segmentation representation.
|
|
160
|
+
* @param config - The new configuration for the segmentation representation it is an object with keys of
|
|
161
|
+
* different representation types, and values of the configuration for each representation type.
|
|
162
|
+
*/
|
|
163
|
+
function setSegmentationRepresentationSpecificConfig(
|
|
164
|
+
toolGroupId: string,
|
|
165
|
+
segmentationRepresentationUID: string,
|
|
166
|
+
config: RepresentationConfig,
|
|
167
|
+
suppressEvents = false
|
|
168
|
+
): void {
|
|
169
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
170
|
+
segmentationStateManager.setSegmentationRepresentationSpecificConfig(
|
|
171
|
+
toolGroupId,
|
|
172
|
+
segmentationRepresentationUID,
|
|
173
|
+
config
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
if (!suppressEvents) {
|
|
177
|
+
triggerSegmentationRepresentationModified(
|
|
178
|
+
toolGroupId,
|
|
179
|
+
segmentationRepresentationUID
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* It returns the segmentation representation specific config which is the same for all the segments
|
|
186
|
+
* @param segmentationRepresentationUID - The unique identifier of the segmentation representation.
|
|
187
|
+
* @returns - The segmentation representation specific config.
|
|
188
|
+
*/
|
|
189
|
+
function getSegmentationRepresentationSpecificConfig(
|
|
190
|
+
toolGroupId: string,
|
|
191
|
+
segmentationRepresentationUID: string
|
|
192
|
+
): RepresentationConfig {
|
|
193
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
194
|
+
return segmentationStateManager.getSegmentationRepresentationSpecificConfig(
|
|
195
|
+
toolGroupId,
|
|
196
|
+
segmentationRepresentationUID
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function getSegmentSpecificRepresentationConfig(
|
|
201
|
+
toolGroupId: string,
|
|
202
|
+
segmentationRepresentationUID: string,
|
|
203
|
+
segmentIndex: number
|
|
204
|
+
): RepresentationConfig {
|
|
205
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
206
|
+
return segmentationStateManager.getSegmentSpecificConfig(
|
|
207
|
+
toolGroupId,
|
|
208
|
+
segmentationRepresentationUID,
|
|
209
|
+
segmentIndex
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function setSegmentSpecificRepresentationConfig(
|
|
214
|
+
toolGroupId: string,
|
|
215
|
+
segmentationRepresentationUID: string,
|
|
216
|
+
config: SegmentSpecificRepresentationConfig,
|
|
217
|
+
suppressEvents = false
|
|
218
|
+
): void {
|
|
219
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
220
|
+
segmentationStateManager.setSegmentSpecificConfig(
|
|
221
|
+
toolGroupId,
|
|
222
|
+
segmentationRepresentationUID,
|
|
223
|
+
config
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
// Todo: this can be even more performant if we create a new event for
|
|
227
|
+
// triggering a specific segment config change.
|
|
228
|
+
if (!suppressEvents) {
|
|
229
|
+
triggerSegmentationRepresentationModified(
|
|
230
|
+
toolGroupId,
|
|
231
|
+
segmentationRepresentationUID
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Add the given segmentation representation data to the given tool group state. It fires
|
|
238
|
+
* SEGMENTATION_REPRESENTATION_MODIFIED event if not suppressed.
|
|
239
|
+
*
|
|
240
|
+
* @triggers SEGMENTATION_REPRESENTATION_MODIFIED
|
|
241
|
+
*
|
|
242
|
+
* @param toolGroupId - The Id of the tool group that the segmentation representation is for.
|
|
243
|
+
* @param segmentationData - The data to add to the segmentation state.
|
|
244
|
+
* @param suppressEvents - boolean
|
|
245
|
+
*/
|
|
246
|
+
function addSegmentationRepresentation(
|
|
247
|
+
toolGroupId: string,
|
|
248
|
+
segmentationRepresentation: ToolGroupSpecificRepresentation,
|
|
249
|
+
suppressEvents?: boolean
|
|
250
|
+
): void {
|
|
251
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
252
|
+
segmentationStateManager.addSegmentationRepresentation(
|
|
253
|
+
toolGroupId,
|
|
254
|
+
segmentationRepresentation
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
if (!suppressEvents) {
|
|
258
|
+
triggerSegmentationRepresentationModified(
|
|
259
|
+
toolGroupId,
|
|
260
|
+
segmentationRepresentation.segmentationRepresentationUID
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* It returns the global segmentation config. Note that the toolGroup-specific
|
|
267
|
+
* configuration has higher priority than the global configuration and overwrites
|
|
268
|
+
* the global configuration for each representation.
|
|
269
|
+
* @returns The global segmentation configuration for all segmentations.
|
|
270
|
+
*/
|
|
271
|
+
function getGlobalConfig(): SegmentationRepresentationConfig {
|
|
272
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
273
|
+
return segmentationStateManager.getGlobalConfig();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Set the global segmentation configuration. It fires SEGMENTATION_MODIFIED
|
|
278
|
+
* event if not suppressed.
|
|
279
|
+
*
|
|
280
|
+
* @triggers SEGMENTATION_MODIFIED
|
|
281
|
+
* @param config - The new global segmentation config.
|
|
282
|
+
* @param suppressEvents - If true, the `segmentationGlobalStateModified` event will not be triggered.
|
|
283
|
+
*/
|
|
284
|
+
function setGlobalConfig(
|
|
285
|
+
config: SegmentationRepresentationConfig,
|
|
286
|
+
suppressEvents?: boolean
|
|
287
|
+
): void {
|
|
288
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
289
|
+
segmentationStateManager.setGlobalConfig(config);
|
|
290
|
+
|
|
291
|
+
if (!suppressEvents) {
|
|
292
|
+
triggerSegmentationModified();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Get the segmentation data object for a given tool group and
|
|
298
|
+
* segmentation data UID. It searches all the toolGroup specific segmentation
|
|
299
|
+
* data objects and returns the first one that matches the UID.
|
|
300
|
+
* @param toolGroupId - The Id of the tool group that the segmentation
|
|
301
|
+
* data belongs to.
|
|
302
|
+
* @param segmentationRepresentationUID - The uid of the segmentation representation
|
|
303
|
+
* @returns Segmentation Data object.
|
|
304
|
+
*/
|
|
305
|
+
function getSegmentationRepresentationByUID(
|
|
306
|
+
toolGroupId: string,
|
|
307
|
+
segmentationRepresentationUID: string
|
|
308
|
+
): ToolGroupSpecificRepresentation | undefined {
|
|
309
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
310
|
+
return segmentationStateManager.getSegmentationRepresentationByUID(
|
|
311
|
+
toolGroupId,
|
|
312
|
+
segmentationRepresentationUID
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* It removes the segmentation from the segmentation state manager
|
|
318
|
+
*
|
|
319
|
+
* @triggers SEGMENTATION_REMOVED
|
|
320
|
+
*
|
|
321
|
+
* @param segmentationId - The id of the segmentation
|
|
322
|
+
*/
|
|
323
|
+
function removeSegmentation(segmentationId: string): void {
|
|
324
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
325
|
+
segmentationStateManager.removeSegmentation(segmentationId);
|
|
326
|
+
triggerSegmentationRemoved(segmentationId);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Remove a segmentation representation from the segmentation state manager for a toolGroup.
|
|
331
|
+
* It fires SEGMENTATION_REPRESENTATION_MODIFIED event.
|
|
332
|
+
*
|
|
333
|
+
* @triggers SEGMENTATION_REPRESENTATION_REMOVED
|
|
334
|
+
*
|
|
335
|
+
* @param toolGroupId - The Id of the tool group that the segmentation
|
|
336
|
+
* data belongs to.
|
|
337
|
+
* @param segmentationRepresentationUID - The uid of the segmentation representation to remove.
|
|
338
|
+
* remove.
|
|
339
|
+
* @param - immediate - If true, the viewports will be updated immediately.
|
|
340
|
+
*/
|
|
341
|
+
function removeSegmentationRepresentation(
|
|
342
|
+
toolGroupId: string,
|
|
343
|
+
segmentationRepresentationUID: string
|
|
344
|
+
): void {
|
|
345
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
346
|
+
segmentationStateManager.removeSegmentationRepresentation(
|
|
347
|
+
toolGroupId,
|
|
348
|
+
segmentationRepresentationUID
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
triggerSegmentationRepresentationRemoved(
|
|
352
|
+
toolGroupId,
|
|
353
|
+
segmentationRepresentationUID
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Add a color LUT to the segmentation state manager
|
|
359
|
+
* @param colorLUT - The color LUT array to add.
|
|
360
|
+
* @param index - The index of the color LUT to add.
|
|
361
|
+
*/
|
|
362
|
+
function removeColorLUT(colorLUTIndex: number): void {
|
|
363
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
364
|
+
segmentationStateManager.removeColorLUT(colorLUTIndex);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Get the color lut for a given index
|
|
369
|
+
* @param index - The index of the color lut to retrieve.
|
|
370
|
+
* @returns A ColorLUT array.
|
|
371
|
+
*/
|
|
372
|
+
function getColorLUT(index: number): ColorLUT | undefined {
|
|
373
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
374
|
+
return segmentationStateManager.getColorLUT(index);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Add a color LUT to the segmentation state manager
|
|
379
|
+
* @param colorLUT - The color LUT array to add.
|
|
380
|
+
* @param index - The index of the color LUT to add.
|
|
381
|
+
*/
|
|
382
|
+
function addColorLUT(colorLUT: ColorLUT, index: number): void {
|
|
383
|
+
const segmentationStateManager = getDefaultSegmentationStateManager();
|
|
384
|
+
segmentationStateManager.addColorLUT(colorLUT, index);
|
|
385
|
+
// Todo: trigger event color LUT added
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Initialize the default configuration
|
|
389
|
+
// Note: when we get other representations, we should set their default representations too.
|
|
390
|
+
const defaultLabelmapConfig = getDefaultLabelmapConfig();
|
|
391
|
+
|
|
392
|
+
const newGlobalConfig: SegmentationRepresentationConfig = {
|
|
393
|
+
renderInactiveSegmentations: true,
|
|
394
|
+
representations: {
|
|
395
|
+
[SegmentationRepresentations.Labelmap]: defaultLabelmapConfig,
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
setGlobalConfig(newGlobalConfig, true);
|
|
400
|
+
|
|
401
|
+
export {
|
|
402
|
+
// state manager
|
|
403
|
+
getDefaultSegmentationStateManager,
|
|
404
|
+
// Segmentation
|
|
405
|
+
getSegmentation,
|
|
406
|
+
getSegmentations,
|
|
407
|
+
addSegmentation,
|
|
408
|
+
removeSegmentation,
|
|
409
|
+
// ToolGroup specific Segmentation Representation
|
|
410
|
+
getSegmentationRepresentations,
|
|
411
|
+
addSegmentationRepresentation,
|
|
412
|
+
removeSegmentationRepresentation,
|
|
413
|
+
// config
|
|
414
|
+
getToolGroupSpecificConfig,
|
|
415
|
+
setToolGroupSpecificConfig,
|
|
416
|
+
getGlobalConfig,
|
|
417
|
+
setGlobalConfig,
|
|
418
|
+
getSegmentationRepresentationSpecificConfig,
|
|
419
|
+
setSegmentationRepresentationSpecificConfig,
|
|
420
|
+
getSegmentSpecificRepresentationConfig,
|
|
421
|
+
setSegmentSpecificRepresentationConfig,
|
|
422
|
+
// helpers s
|
|
423
|
+
getToolGroupIdsWithSegmentation,
|
|
424
|
+
getSegmentationRepresentationByUID,
|
|
425
|
+
// color
|
|
426
|
+
addColorLUT,
|
|
427
|
+
getColorLUT,
|
|
428
|
+
removeColorLUT,
|
|
429
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { triggerEvent, eventTarget } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
import { Events } from '../../enums';
|
|
4
|
+
import {
|
|
5
|
+
getSegmentationRepresentations,
|
|
6
|
+
getSegmentations,
|
|
7
|
+
} from '../../stateManagement/segmentation/segmentationState';
|
|
8
|
+
import {
|
|
9
|
+
SegmentationRepresentationModifiedEventDetail,
|
|
10
|
+
SegmentationDataModifiedEventDetail,
|
|
11
|
+
SegmentationModifiedEventDetail,
|
|
12
|
+
SegmentationRepresentationRemovedEventDetail,
|
|
13
|
+
SegmentationRemovedEventDetail,
|
|
14
|
+
} from '../../types/EventTypes';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Trigger an event that a segmentation is removed
|
|
18
|
+
* @param segmentationId - The Id of segmentation
|
|
19
|
+
*/
|
|
20
|
+
function triggerSegmentationRemoved(segmentationId: string): void {
|
|
21
|
+
const eventDetail: SegmentationRemovedEventDetail = {
|
|
22
|
+
segmentationId,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
triggerEvent(eventTarget, Events.SEGMENTATION_REMOVED, eventDetail);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Trigger an event that a segmentation representation was removed
|
|
30
|
+
* @param toolGroupId - The id of the tool group that the segmentation
|
|
31
|
+
* representation was removed from.
|
|
32
|
+
* @param segmentationRepresentationUID - The UID of the segmentation
|
|
33
|
+
* representation that was removed.
|
|
34
|
+
*/
|
|
35
|
+
function triggerSegmentationRepresentationRemoved(
|
|
36
|
+
toolGroupId: string,
|
|
37
|
+
segmentationRepresentationUID: string
|
|
38
|
+
): void {
|
|
39
|
+
const eventDetail: SegmentationRepresentationRemovedEventDetail = {
|
|
40
|
+
toolGroupId,
|
|
41
|
+
segmentationRepresentationUID,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
triggerEvent(
|
|
45
|
+
eventTarget,
|
|
46
|
+
Events.SEGMENTATION_REPRESENTATION_REMOVED,
|
|
47
|
+
eventDetail
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Trigger an event on the eventTarget that the segmentation representation for
|
|
53
|
+
* toolGroupId has been updated
|
|
54
|
+
* @param toolGroupId - The Id of the toolGroup
|
|
55
|
+
*/
|
|
56
|
+
function triggerSegmentationRepresentationModified(
|
|
57
|
+
toolGroupId: string,
|
|
58
|
+
segmentationRepresentationUID?: string
|
|
59
|
+
): void {
|
|
60
|
+
const eventDetail: SegmentationRepresentationModifiedEventDetail = {
|
|
61
|
+
toolGroupId,
|
|
62
|
+
segmentationRepresentationUID,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (segmentationRepresentationUID) {
|
|
66
|
+
triggerEvent(
|
|
67
|
+
eventTarget,
|
|
68
|
+
Events.SEGMENTATION_REPRESENTATION_MODIFIED,
|
|
69
|
+
eventDetail
|
|
70
|
+
);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// If no segmentationRepresentationUID is provided, then we need to trigger
|
|
75
|
+
// the event for all segmentation representations in the toolGroup
|
|
76
|
+
|
|
77
|
+
// Get all segmentation representations in the toolGroup
|
|
78
|
+
const segmentationRepresentations =
|
|
79
|
+
getSegmentationRepresentations(toolGroupId) || [];
|
|
80
|
+
|
|
81
|
+
segmentationRepresentations.forEach((segmentationRepresentation) => {
|
|
82
|
+
const { segmentationRepresentationUID } = segmentationRepresentation;
|
|
83
|
+
const eventDetail: SegmentationRepresentationModifiedEventDetail = {
|
|
84
|
+
toolGroupId,
|
|
85
|
+
segmentationRepresentationUID,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
triggerEvent(
|
|
89
|
+
eventTarget,
|
|
90
|
+
Events.SEGMENTATION_REPRESENTATION_MODIFIED,
|
|
91
|
+
eventDetail
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Triggers segmentation global state updated event, notifying all toolGroups
|
|
98
|
+
* that the global state has been updated, If a segmentationId is provided
|
|
99
|
+
* the event will only be triggered for that segmentation, otherwise it will
|
|
100
|
+
* be triggered for all segmentations.
|
|
101
|
+
*
|
|
102
|
+
* @param segmentationId - The id of the segmentation that has been updated
|
|
103
|
+
*/
|
|
104
|
+
function triggerSegmentationModified(segmentationId?: string): void {
|
|
105
|
+
let segmentationIds;
|
|
106
|
+
|
|
107
|
+
if (segmentationId) {
|
|
108
|
+
segmentationIds = [segmentationId];
|
|
109
|
+
} else {
|
|
110
|
+
// get all toolGroups
|
|
111
|
+
segmentationIds = getSegmentations().map(
|
|
112
|
+
({ segmentationId }) => segmentationId
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 1. Trigger an event notifying all listeners about the segmentationId
|
|
117
|
+
// that has been updated.
|
|
118
|
+
segmentationIds.forEach((segmentationId) => {
|
|
119
|
+
const eventDetail: SegmentationModifiedEventDetail = {
|
|
120
|
+
segmentationId,
|
|
121
|
+
};
|
|
122
|
+
triggerEvent(eventTarget, Events.SEGMENTATION_MODIFIED, eventDetail);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Todo: I don't think we need the following lines of code
|
|
126
|
+
// // 2. Notify all viewports that render the segmentationId in order to update the
|
|
127
|
+
// // rendering based on the new global state.
|
|
128
|
+
// toolGroupIds.forEach((toolGroupId) => {
|
|
129
|
+
// triggerSegmentationRepresentationModified(toolGroupId)
|
|
130
|
+
// })
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Trigger an event that a segmentation data has been modified
|
|
135
|
+
* @param segmentationId - The Id of segmentation
|
|
136
|
+
*/
|
|
137
|
+
function triggerSegmentationDataModified(
|
|
138
|
+
segmentationId: string,
|
|
139
|
+
modifiedSlicesToUse?: number[]
|
|
140
|
+
): void {
|
|
141
|
+
const eventDetail: SegmentationDataModifiedEventDetail = {
|
|
142
|
+
segmentationId,
|
|
143
|
+
modifiedSlicesToUse,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
triggerEvent(eventTarget, Events.SEGMENTATION_DATA_MODIFIED, eventDetail);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export {
|
|
150
|
+
// ToolGroup Specific
|
|
151
|
+
triggerSegmentationRepresentationModified,
|
|
152
|
+
triggerSegmentationRepresentationRemoved,
|
|
153
|
+
// Global
|
|
154
|
+
triggerSegmentationDataModified,
|
|
155
|
+
triggerSegmentationModified,
|
|
156
|
+
triggerSegmentationRemoved,
|
|
157
|
+
};
|