@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,252 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cache,
|
|
3
|
+
Enums,
|
|
4
|
+
getEnabledElementByIds,
|
|
5
|
+
Types,
|
|
6
|
+
utilities as csUtils,
|
|
7
|
+
} from '@cornerstonejs/core';
|
|
8
|
+
|
|
9
|
+
import Representations from '../../../enums/SegmentationRepresentations';
|
|
10
|
+
import * as SegmentationConfig from '../../../stateManagement/segmentation/config/segmentationConfig';
|
|
11
|
+
import * as SegmentationState from '../../../stateManagement/segmentation/segmentationState';
|
|
12
|
+
import { getToolGroup } from '../../../store/ToolGroupManager';
|
|
13
|
+
import {
|
|
14
|
+
RepresentationPublicInput,
|
|
15
|
+
SegmentationRepresentationConfig,
|
|
16
|
+
ToolGroupSpecificRepresentation,
|
|
17
|
+
} from '../../../types/SegmentationStateTypes';
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
addContourSetToElement,
|
|
21
|
+
addContourToElement,
|
|
22
|
+
} from './addContourToElement';
|
|
23
|
+
import { default as removeContourFromElement } from './removeContourFromElement';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* It adds a new segmentation representation to the segmentation state
|
|
27
|
+
* @param toolGroupId - The id of the toolGroup that the segmentation
|
|
28
|
+
* belongs to
|
|
29
|
+
* @param representationInput - RepresentationPublicInput
|
|
30
|
+
* @param toolGroupSpecificConfig - The configuration that is specific to the toolGroup.
|
|
31
|
+
* @returns The segmentationRepresentationUID
|
|
32
|
+
*/
|
|
33
|
+
async function addSegmentationRepresentation(
|
|
34
|
+
toolGroupId: string,
|
|
35
|
+
representationInput: RepresentationPublicInput,
|
|
36
|
+
toolGroupSpecificConfig?: SegmentationRepresentationConfig
|
|
37
|
+
): Promise<string> {
|
|
38
|
+
const { segmentationId } = representationInput;
|
|
39
|
+
const segmentationRepresentationUID = csUtils.uuidv4();
|
|
40
|
+
// Todo: make these configurable during representation input by user
|
|
41
|
+
const segmentsHidden = new Set() as Set<number>;
|
|
42
|
+
const visibility = true;
|
|
43
|
+
const colorLUTIndex = 0;
|
|
44
|
+
const active = true;
|
|
45
|
+
const toolGroupSpecificRepresentation: ToolGroupSpecificRepresentation = {
|
|
46
|
+
segmentationId,
|
|
47
|
+
segmentationRepresentationUID,
|
|
48
|
+
type: Representations.Contour,
|
|
49
|
+
segmentsHidden,
|
|
50
|
+
colorLUTIndex,
|
|
51
|
+
active,
|
|
52
|
+
segmentationRepresentationSpecificConfig: {},
|
|
53
|
+
segmentSpecificConfig: {},
|
|
54
|
+
config: {},
|
|
55
|
+
};
|
|
56
|
+
// Update the toolGroup specific configuration
|
|
57
|
+
if (toolGroupSpecificConfig) {
|
|
58
|
+
// Since setting configuration on toolGroup will trigger a segmentationRepresentation
|
|
59
|
+
// update event, we don't want to trigger the event twice, so we suppress
|
|
60
|
+
// the first one
|
|
61
|
+
const currentToolGroupConfig =
|
|
62
|
+
SegmentationConfig.getToolGroupSpecificConfig(toolGroupId);
|
|
63
|
+
const mergedConfig = csUtils.deepMerge(
|
|
64
|
+
currentToolGroupConfig,
|
|
65
|
+
toolGroupSpecificConfig
|
|
66
|
+
);
|
|
67
|
+
SegmentationConfig.setToolGroupSpecificConfig(toolGroupId, {
|
|
68
|
+
renderInactiveSegmentations:
|
|
69
|
+
mergedConfig.renderInactiveSegmentations || true,
|
|
70
|
+
representations: {
|
|
71
|
+
...mergedConfig.representations,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
SegmentationState.addSegmentationRepresentation(
|
|
76
|
+
toolGroupId,
|
|
77
|
+
toolGroupSpecificRepresentation
|
|
78
|
+
);
|
|
79
|
+
return segmentationRepresentationUID;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* It removes a segmentation representation from the tool group's viewports and
|
|
84
|
+
* from the segmentation state
|
|
85
|
+
* @param toolGroupId - The toolGroupId of the toolGroup that the
|
|
86
|
+
* segmentationRepresentation belongs to.
|
|
87
|
+
* @param segmentationRepresentationUID - This is the unique identifier
|
|
88
|
+
* for the segmentation representation.
|
|
89
|
+
* @param renderImmediate - If true, the viewport will be rendered
|
|
90
|
+
* immediately after the segmentation representation is removed.
|
|
91
|
+
*/
|
|
92
|
+
function removeSegmentationRepresentation(
|
|
93
|
+
toolGroupId: string,
|
|
94
|
+
segmentationRepresentationUID: string,
|
|
95
|
+
renderImmediate = false
|
|
96
|
+
): void {
|
|
97
|
+
_removeContourFromToolGroupViewports(
|
|
98
|
+
toolGroupId,
|
|
99
|
+
segmentationRepresentationUID
|
|
100
|
+
);
|
|
101
|
+
SegmentationState.removeSegmentationRepresentation(
|
|
102
|
+
toolGroupId,
|
|
103
|
+
segmentationRepresentationUID
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (renderImmediate) {
|
|
107
|
+
const viewportsInfo = getToolGroup(toolGroupId).getViewportsInfo();
|
|
108
|
+
viewportsInfo.forEach(({ viewportId, renderingEngineId }) => {
|
|
109
|
+
const enabledElement = getEnabledElementByIds(
|
|
110
|
+
viewportId,
|
|
111
|
+
renderingEngineId
|
|
112
|
+
);
|
|
113
|
+
enabledElement.viewport.render();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* It renders the contour sets for the given segmentation
|
|
120
|
+
* @param viewport - The viewport object
|
|
121
|
+
* @param representation - ToolGroupSpecificRepresentation
|
|
122
|
+
* @param toolGroupConfig - This is the configuration object for the tool group
|
|
123
|
+
*/
|
|
124
|
+
async function render(
|
|
125
|
+
viewport: Types.IVolumeViewport,
|
|
126
|
+
representation: ToolGroupSpecificRepresentation,
|
|
127
|
+
toolGroupConfig: SegmentationRepresentationConfig
|
|
128
|
+
): Promise<void> {
|
|
129
|
+
const {
|
|
130
|
+
colorLUTIndex,
|
|
131
|
+
active,
|
|
132
|
+
segmentationId,
|
|
133
|
+
segmentationRepresentationUID,
|
|
134
|
+
segmentsHidden,
|
|
135
|
+
} = representation;
|
|
136
|
+
|
|
137
|
+
const segmentation = SegmentationState.getSegmentation(segmentationId);
|
|
138
|
+
const contourData = segmentation.representationData[Representations.Contour];
|
|
139
|
+
const { geometryIds } = contourData;
|
|
140
|
+
|
|
141
|
+
if (!geometryIds?.length) {
|
|
142
|
+
console.warn(
|
|
143
|
+
`No contours found for segmentationId ${segmentationId}. Skipping render.`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
_renderContourSets(viewport, geometryIds, segmentationRepresentationUID);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function _renderContourSets(
|
|
151
|
+
viewport,
|
|
152
|
+
geometryIds,
|
|
153
|
+
segmentationRepresentationUID
|
|
154
|
+
) {
|
|
155
|
+
geometryIds.forEach((geometryId) => {
|
|
156
|
+
const geometry = cache.getGeometry(geometryId);
|
|
157
|
+
if (!geometry) {
|
|
158
|
+
throw new Error(`No contours found for geometryId ${geometryId}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (geometry.type !== Enums.GeometryType.CONTOUR) {
|
|
162
|
+
// Todo: later we can support converting other geometries to contours
|
|
163
|
+
throw new Error(
|
|
164
|
+
`Geometry type ${geometry.type} not supported for rendering.`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!geometry.data) {
|
|
169
|
+
console.warn(
|
|
170
|
+
`No contours found for geometryId ${geometryId}. Skipping render.`
|
|
171
|
+
);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const contourSet = geometry.data;
|
|
176
|
+
|
|
177
|
+
_renderContourSet(viewport, contourSet, segmentationRepresentationUID);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function _renderContourSet(
|
|
182
|
+
viewport: Types.IVolumeViewport,
|
|
183
|
+
contourSet: Types.IContourSet,
|
|
184
|
+
segmentationRepresentationUID: string,
|
|
185
|
+
separated = false
|
|
186
|
+
): void {
|
|
187
|
+
if (separated) {
|
|
188
|
+
contourSet.getContours().forEach((contour: Types.IContour, index) => {
|
|
189
|
+
const contourUID = `${segmentationRepresentationUID}_${contourSet.id}_${index}}`;
|
|
190
|
+
_renderContour(viewport, contour, contourUID);
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
const contourUID = `${segmentationRepresentationUID}_${contourSet.id}`;
|
|
194
|
+
const actorUID = contourUID;
|
|
195
|
+
const actorEntry = viewport.getActor(actorUID);
|
|
196
|
+
|
|
197
|
+
if (!actorEntry) {
|
|
198
|
+
addContourSetToElement(viewport.element, contourSet, actorUID);
|
|
199
|
+
} else {
|
|
200
|
+
throw new Error('Not implemented yet. (Update contour)');
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
viewport.resetCamera();
|
|
205
|
+
viewport.render();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function _renderContour(
|
|
209
|
+
viewport: Types.IVolumeViewport,
|
|
210
|
+
contour: Types.IContour,
|
|
211
|
+
contourUID: string
|
|
212
|
+
): void {
|
|
213
|
+
const actorUID = contourUID;
|
|
214
|
+
const actorEntry = viewport.getActor(actorUID);
|
|
215
|
+
|
|
216
|
+
if (!actorEntry) {
|
|
217
|
+
addContourToElement(viewport.element, contour, actorUID);
|
|
218
|
+
} else {
|
|
219
|
+
throw new Error('Not implemented yet. (Update contour)');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function _removeContourFromToolGroupViewports(
|
|
224
|
+
toolGroupId: string,
|
|
225
|
+
segmentationRepresentationUID: string
|
|
226
|
+
): void {
|
|
227
|
+
const toolGroup = getToolGroup(toolGroupId);
|
|
228
|
+
|
|
229
|
+
if (toolGroup === undefined) {
|
|
230
|
+
throw new Error(`ToolGroup with ToolGroupId ${toolGroupId} does not exist`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const { viewportsInfo } = toolGroup;
|
|
234
|
+
|
|
235
|
+
for (const viewportInfo of viewportsInfo) {
|
|
236
|
+
const { viewportId, renderingEngineId } = viewportInfo;
|
|
237
|
+
const enabledElement = getEnabledElementByIds(
|
|
238
|
+
viewportId,
|
|
239
|
+
renderingEngineId
|
|
240
|
+
);
|
|
241
|
+
removeContourFromElement(
|
|
242
|
+
enabledElement.viewport.element,
|
|
243
|
+
segmentationRepresentationUID
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export default {
|
|
249
|
+
render,
|
|
250
|
+
addSegmentationRepresentation,
|
|
251
|
+
removeSegmentationRepresentation,
|
|
252
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getEnabledElement } from '@cornerstonejs/core';
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Remove the contour representation from the viewport's HTML Element.
|
|
6
|
+
* NOTE: This function should not be called directly.
|
|
7
|
+
*
|
|
8
|
+
* @param element - The element that the segmentation is being added to.
|
|
9
|
+
* @param segmentationRepresentationUID - The UID of the contour representation to remove.
|
|
10
|
+
* @param removeFromCache - boolean
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
function removeContourFromElement(
|
|
15
|
+
element: HTMLDivElement,
|
|
16
|
+
segmentationRepresentationUID: string,
|
|
17
|
+
removeFromCache = false // Todo
|
|
18
|
+
): void {
|
|
19
|
+
const enabledElement = getEnabledElement(element);
|
|
20
|
+
const { viewport } = enabledElement;
|
|
21
|
+
|
|
22
|
+
const actorEntries = (viewport as Types.IVolumeViewport).getActors();
|
|
23
|
+
|
|
24
|
+
// remove actors whose id has the same prefix as the segmentationRepresentationUID
|
|
25
|
+
const actorUIDsToRemove = actorEntries
|
|
26
|
+
.map(({ uid }) =>
|
|
27
|
+
uid.startsWith(segmentationRepresentationUID) ? uid : undefined
|
|
28
|
+
)
|
|
29
|
+
.filter(Boolean);
|
|
30
|
+
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
viewport.removeActors(actorUIDsToRemove);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default removeContourFromElement;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEnabledElement,
|
|
3
|
+
addVolumesToViewports,
|
|
4
|
+
Types,
|
|
5
|
+
Enums,
|
|
6
|
+
} from '@cornerstonejs/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* It adds a labelmap segmentation representation of the viewport's HTML Element.
|
|
10
|
+
* NOTE: This function should not be called directly.
|
|
11
|
+
*
|
|
12
|
+
* @param element - The element that will be rendered.
|
|
13
|
+
* @param volumeId - The volume id of the labelmap.
|
|
14
|
+
* @param segmentationRepresentationUID - The segmentation representation UID.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
async function addLabelmapToElement(
|
|
19
|
+
element: HTMLDivElement,
|
|
20
|
+
volumeId: string,
|
|
21
|
+
segmentationRepresentationUID: string
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
const enabledElement = getEnabledElement(element);
|
|
24
|
+
const { renderingEngine, viewport } = enabledElement;
|
|
25
|
+
const { id: viewportId } = viewport;
|
|
26
|
+
|
|
27
|
+
// Default to true since we are setting a new segmentation, however,
|
|
28
|
+
// in the event listener, we will make other segmentations visible/invisible
|
|
29
|
+
// based on the config
|
|
30
|
+
const visibility = true;
|
|
31
|
+
const immediateRender = false;
|
|
32
|
+
const suppressEvents = true;
|
|
33
|
+
|
|
34
|
+
// Todo: Right now we use MIP blend mode for the labelmap, since the
|
|
35
|
+
// composite blend mode has a non linear behavior regarding fill and line
|
|
36
|
+
// opacity. This should be changed to a custom labelmap blendMode which does
|
|
37
|
+
// what composite does, but with a linear behavior.
|
|
38
|
+
const volumeInputs: Types.IVolumeInput[] = [
|
|
39
|
+
{
|
|
40
|
+
volumeId,
|
|
41
|
+
actorUID: segmentationRepresentationUID,
|
|
42
|
+
visibility,
|
|
43
|
+
blendMode: Enums.BlendModes.MAXIMUM_INTENSITY_BLEND,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
// Add labelmap volumes to the viewports to be be rendered, but not force the render
|
|
48
|
+
await addVolumesToViewports(
|
|
49
|
+
renderingEngine,
|
|
50
|
+
volumeInputs,
|
|
51
|
+
[viewportId],
|
|
52
|
+
immediateRender,
|
|
53
|
+
suppressEvents
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default addLabelmapToElement;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LabelmapConfig } from '../../../types/LabelmapTypes';
|
|
2
|
+
|
|
3
|
+
const defaultLabelmapConfig: LabelmapConfig = {
|
|
4
|
+
renderOutline: true,
|
|
5
|
+
outlineWidthActive: 3,
|
|
6
|
+
outlineWidthInactive: 2,
|
|
7
|
+
renderFill: true,
|
|
8
|
+
renderFillInactive: true,
|
|
9
|
+
fillAlpha: 0.7,
|
|
10
|
+
fillAlphaInactive: 0.65,
|
|
11
|
+
outlineOpacity: 1,
|
|
12
|
+
outlineOpacityInactive: 0.85,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function getDefaultLabelmapConfig(): LabelmapConfig {
|
|
16
|
+
return defaultLabelmapConfig;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Checks if the labelmap config is valid, which means
|
|
20
|
+
// if all the required fields are present and have the correct type
|
|
21
|
+
function isValidLabelmapConfig(config): boolean {
|
|
22
|
+
return (
|
|
23
|
+
config &&
|
|
24
|
+
typeof config.renderOutline === 'boolean' &&
|
|
25
|
+
typeof config.outlineWidthActive === 'number' &&
|
|
26
|
+
typeof config.outlineWidthInactive === 'number' &&
|
|
27
|
+
typeof config.renderFill === 'boolean' &&
|
|
28
|
+
typeof config.renderFillInactive === 'boolean' &&
|
|
29
|
+
typeof config.fillAlpha === 'number' &&
|
|
30
|
+
typeof config.fillAlphaInactive === 'number' &&
|
|
31
|
+
typeof config.outlineOpacity === 'number' &&
|
|
32
|
+
typeof config.outlineOpacityInactive === 'number'
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default getDefaultLabelmapConfig;
|
|
37
|
+
export { isValidLabelmapConfig };
|