@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,24 @@
|
|
|
1
|
+
// `BaseManager` or IManager interface for duplicate API between ToolGroup/Synchronizer?
|
|
2
|
+
import { state as csToolsState } from '../index';
|
|
3
|
+
import destroyToolGroup from './destroyToolGroup';
|
|
4
|
+
|
|
5
|
+
// ToolGroups function entirely by their "state" being queried and leveraged
|
|
6
|
+
// removing a ToolGroup from state is equivalent to killing it. Calling
|
|
7
|
+
// destroyToolGroup() to make sure the SegmentationDisplayTools
|
|
8
|
+
// have been removed from the toolGroup Viewports. //Todo: this makes more sense
|
|
9
|
+
// to be based on events, but we don't have any toolGroup created/removed events
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Destroy all tool groups
|
|
13
|
+
*/
|
|
14
|
+
function destroy(): void {
|
|
15
|
+
const toolGroups = [...csToolsState.toolGroups];
|
|
16
|
+
|
|
17
|
+
for (const toolGroup of toolGroups) {
|
|
18
|
+
destroyToolGroup(toolGroup.id);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
csToolsState.toolGroups = [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default destroy;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { state } from '../index';
|
|
2
|
+
import { removeSegmentationsFromToolGroup } from '../../stateManagement/segmentation';
|
|
3
|
+
import { segmentationRenderingEngine } from '../../utilities/segmentation/triggerSegmentationRender';
|
|
4
|
+
// ToolGroups function entirely by their "state" being queried and leveraged
|
|
5
|
+
// removing a ToolGroup from state is equivalent to killing it
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Given a tool group Id, destroy the toolGroup. It will also cleanup all segmentations
|
|
9
|
+
* associated with that tool group too
|
|
10
|
+
*
|
|
11
|
+
* @param toolGroupId - The Id of the tool group to be destroyed.
|
|
12
|
+
*/
|
|
13
|
+
function destroyToolGroup(toolGroupId: string): void {
|
|
14
|
+
const toolGroupIndex = state.toolGroups.findIndex(
|
|
15
|
+
(tg) => tg.id === toolGroupId
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (toolGroupIndex > -1) {
|
|
19
|
+
segmentationRenderingEngine.removeToolGroup(toolGroupId);
|
|
20
|
+
// Todo: this should not happen here)
|
|
21
|
+
removeSegmentationsFromToolGroup(toolGroupId);
|
|
22
|
+
state.toolGroups.splice(toolGroupIndex, 1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default destroyToolGroup;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { state } from '../index';
|
|
2
|
+
import { IToolGroup } from '../../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Return the array of tool groups
|
|
6
|
+
* @returns An array of tool groups.
|
|
7
|
+
*/
|
|
8
|
+
function getAllToolGroups(): Array<IToolGroup> {
|
|
9
|
+
return state.toolGroups;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default getAllToolGroups;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { state } from '../index';
|
|
2
|
+
import { IToolGroup } from '../../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Given a tool group Id, return the tool group
|
|
6
|
+
* @param toolGroupId - The Id of the tool group to be retrieved.
|
|
7
|
+
* @returns The tool group that has the same id as the tool group id that was
|
|
8
|
+
* passed in.
|
|
9
|
+
*/
|
|
10
|
+
function getToolGroup(toolGroupId: string): IToolGroup | undefined {
|
|
11
|
+
return state.toolGroups.find((s) => s.id === toolGroupId);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default getToolGroup;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { state } from '../index';
|
|
2
|
+
import { IToolGroup } from '../../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Given a rendering engine Id and a viewport Id, return the tool group that
|
|
6
|
+
* contains that rendering engine and viewport. Note: A viewport can only be
|
|
7
|
+
* associated with a single tool group. You cannot have a viewport that belongs
|
|
8
|
+
* to multiple tool groups. To achieve so, create a new viewport and a new toolGroup
|
|
9
|
+
* for it. This will not impact memory usage much as the volume textures are
|
|
10
|
+
* shared across all viewports rendering the same image.
|
|
11
|
+
*
|
|
12
|
+
* @param viewportId - The Id of the viewport that the tool is being
|
|
13
|
+
* added to.
|
|
14
|
+
* @param renderingEngineId - The Id of the rendering engine that the
|
|
15
|
+
* tool group is associated with.
|
|
16
|
+
* @returns A tool group.
|
|
17
|
+
*/
|
|
18
|
+
function getToolGroupForViewport(
|
|
19
|
+
viewportId: string,
|
|
20
|
+
renderingEngineId: string
|
|
21
|
+
): IToolGroup | undefined {
|
|
22
|
+
const toolGroupFilteredByIds = state.toolGroups.filter((tg) =>
|
|
23
|
+
tg.viewportsInfo.some(
|
|
24
|
+
(vp) =>
|
|
25
|
+
vp.renderingEngineId === renderingEngineId &&
|
|
26
|
+
(!vp.viewportId || vp.viewportId === viewportId)
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (!toolGroupFilteredByIds.length) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (toolGroupFilteredByIds.length > 1) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Multiple tool groups found for renderingEngineId: ${renderingEngineId} and viewportId: ${viewportId}. You should only
|
|
37
|
+
have one tool group per viewport in a renderingEngine.`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return toolGroupFilteredByIds[0];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default getToolGroupForViewport;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { state } from '../index';
|
|
2
|
+
import { IToolGroup } from '../../types';
|
|
3
|
+
import { ToolModes } from '../../enums';
|
|
4
|
+
|
|
5
|
+
const MODES = [ToolModes.Active, ToolModes.Passive, ToolModes.Enabled];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the toolGroups that has the given toolName as active, passive
|
|
9
|
+
* or enabled.
|
|
10
|
+
* @param toolName - The name of the tool
|
|
11
|
+
* @returns An array of tool groups.
|
|
12
|
+
*/
|
|
13
|
+
function getToolGroupsWithToolName(toolName: string): IToolGroup[] | [] {
|
|
14
|
+
return state.toolGroups.filter(({ toolOptions }) => {
|
|
15
|
+
const toolGroupToolNames = Object.keys(toolOptions);
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < toolGroupToolNames.length; i++) {
|
|
18
|
+
if (toolName !== toolGroupToolNames[i]) continue;
|
|
19
|
+
|
|
20
|
+
/* filter out tools that don't have options */
|
|
21
|
+
if (!toolOptions[toolName]) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (MODES.includes(toolOptions[toolName].mode)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default getToolGroupsWithToolName;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import createToolGroup from './createToolGroup';
|
|
2
|
+
import destroyToolGroup from './destroyToolGroup';
|
|
3
|
+
import destroy from './destroy';
|
|
4
|
+
import getToolGroup from './getToolGroup';
|
|
5
|
+
import getToolGroupForViewport from './getToolGroupForViewport';
|
|
6
|
+
import getAllToolGroups from './getAllToolGroups';
|
|
7
|
+
import getToolGroupsWithToolName from './getToolGroupsWithToolName';
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
createToolGroup,
|
|
11
|
+
destroy,
|
|
12
|
+
destroyToolGroup,
|
|
13
|
+
getToolGroup,
|
|
14
|
+
getToolGroupForViewport,
|
|
15
|
+
getAllToolGroups,
|
|
16
|
+
getToolGroupsWithToolName,
|
|
17
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Types } from '@cornerstonejs/core';
|
|
2
|
+
import {
|
|
3
|
+
mouseEventListeners,
|
|
4
|
+
wheelEventListener,
|
|
5
|
+
touchEventListeners,
|
|
6
|
+
keyEventListener,
|
|
7
|
+
} from '../eventListeners';
|
|
8
|
+
import {
|
|
9
|
+
imageRenderedEventDispatcher,
|
|
10
|
+
cameraModifiedEventDispatcher,
|
|
11
|
+
mouseToolEventDispatcher,
|
|
12
|
+
touchToolEventDispatcher,
|
|
13
|
+
keyboardToolEventDispatcher,
|
|
14
|
+
imageSpacingCalibratedEventDispatcher,
|
|
15
|
+
} from '../eventDispatchers';
|
|
16
|
+
import { state } from './state';
|
|
17
|
+
|
|
18
|
+
import { annotationRenderingEngine } from '../utilities/triggerAnnotationRender';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* When an element is "enabled", add event listeners and dispatchers to it
|
|
22
|
+
* so we can use interactions to affect tool behaviors
|
|
23
|
+
*
|
|
24
|
+
* @param evt - The ELEMENT_ENABLED event
|
|
25
|
+
*/
|
|
26
|
+
export default function addEnabledElement(
|
|
27
|
+
evt: Types.EventTypes.ElementEnabledEvent
|
|
28
|
+
): void {
|
|
29
|
+
const { element, viewportId } = evt.detail;
|
|
30
|
+
const svgLayer = _createSvgAnnotationLayer(viewportId);
|
|
31
|
+
|
|
32
|
+
// Reset/Create svgNodeCache for element
|
|
33
|
+
_setSvgNodeCache(element);
|
|
34
|
+
_appendChild(svgLayer, element);
|
|
35
|
+
|
|
36
|
+
// Add this element to the annotation rendering engine
|
|
37
|
+
annotationRenderingEngine.addViewportElement(viewportId, element);
|
|
38
|
+
|
|
39
|
+
// Listeners
|
|
40
|
+
mouseEventListeners.enable(element);
|
|
41
|
+
wheelEventListener.enable(element);
|
|
42
|
+
touchEventListeners.enable(element);
|
|
43
|
+
keyEventListener.enable(element);
|
|
44
|
+
|
|
45
|
+
// Dispatchers: renderer
|
|
46
|
+
imageRenderedEventDispatcher.enable(element);
|
|
47
|
+
cameraModifiedEventDispatcher.enable(element);
|
|
48
|
+
imageSpacingCalibratedEventDispatcher.enable(element);
|
|
49
|
+
// Dispatchers: interaction
|
|
50
|
+
mouseToolEventDispatcher.enable(element);
|
|
51
|
+
keyboardToolEventDispatcher.enable(element);
|
|
52
|
+
touchToolEventDispatcher.enable(element);
|
|
53
|
+
|
|
54
|
+
// labelmap
|
|
55
|
+
// State
|
|
56
|
+
state.enabledElements.push(element);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
function _createSvgAnnotationLayer(viewportId: string): SVGElement {
|
|
63
|
+
const svgns = 'http://www.w3.org/2000/svg';
|
|
64
|
+
const svgLayer = document.createElementNS(svgns, 'svg');
|
|
65
|
+
|
|
66
|
+
const svgLayerId = `svg-layer-${viewportId}`;
|
|
67
|
+
svgLayer.classList.add('svg-layer');
|
|
68
|
+
svgLayer.setAttribute('id', svgLayerId);
|
|
69
|
+
svgLayer.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
70
|
+
svgLayer.style.width = '100%';
|
|
71
|
+
svgLayer.style.height = '100%';
|
|
72
|
+
svgLayer.style.pointerEvents = 'none';
|
|
73
|
+
svgLayer.style.position = 'absolute';
|
|
74
|
+
// TODO: we should test this on high-res monitors
|
|
75
|
+
//svgLayer.style.textRendering = 'optimizeSpeed'
|
|
76
|
+
|
|
77
|
+
// Single dropshadow config for now
|
|
78
|
+
const defs = document.createElementNS(svgns, 'defs');
|
|
79
|
+
const filter = document.createElementNS(svgns, 'filter');
|
|
80
|
+
const feOffset = document.createElementNS(svgns, 'feOffset');
|
|
81
|
+
const feColorMatrix = document.createElementNS(svgns, 'feColorMatrix');
|
|
82
|
+
const feBlend = document.createElementNS(svgns, 'feBlend');
|
|
83
|
+
|
|
84
|
+
//
|
|
85
|
+
filter.setAttribute('id', `shadow-${svgLayerId}`);
|
|
86
|
+
filter.setAttribute('filterUnits', 'userSpaceOnUse');
|
|
87
|
+
|
|
88
|
+
//
|
|
89
|
+
feOffset.setAttribute('result', 'offOut');
|
|
90
|
+
feOffset.setAttribute('in', 'SourceGraphic');
|
|
91
|
+
feOffset.setAttribute('dx', '0.5');
|
|
92
|
+
feOffset.setAttribute('dy', '0.5');
|
|
93
|
+
|
|
94
|
+
//
|
|
95
|
+
feColorMatrix.setAttribute('result', 'matrixOut');
|
|
96
|
+
feColorMatrix.setAttribute('in', 'offOut');
|
|
97
|
+
feColorMatrix.setAttribute('in2', 'matrix');
|
|
98
|
+
feColorMatrix.setAttribute(
|
|
99
|
+
'values',
|
|
100
|
+
'0.2 0 0 0 0 0 0.2 0 0 0 0 0 0.2 0 0 0 0 0 1 0'
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
//
|
|
104
|
+
feBlend.setAttribute('in', 'SourceGraphic');
|
|
105
|
+
feBlend.setAttribute('in2', 'matrixOut');
|
|
106
|
+
feBlend.setAttribute('mode', 'normal');
|
|
107
|
+
|
|
108
|
+
filter.appendChild(feOffset);
|
|
109
|
+
filter.appendChild(feColorMatrix);
|
|
110
|
+
filter.appendChild(feBlend);
|
|
111
|
+
defs.appendChild(filter);
|
|
112
|
+
svgLayer.appendChild(defs);
|
|
113
|
+
|
|
114
|
+
return svgLayer;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function _setSvgNodeCache(element) {
|
|
118
|
+
const { viewportUid: viewportId, renderingEngineUid: renderingEngineId } =
|
|
119
|
+
element.dataset;
|
|
120
|
+
const elementHash = `${viewportId}:${renderingEngineId}`;
|
|
121
|
+
|
|
122
|
+
// Create or reset
|
|
123
|
+
// TODO: If... Reset, we should blow out any nodes in DOM
|
|
124
|
+
state.svgNodeCache[elementHash] = {};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* @param newNode
|
|
130
|
+
* @param referenceNode
|
|
131
|
+
*/
|
|
132
|
+
function _appendChild(
|
|
133
|
+
newNode: SVGElement,
|
|
134
|
+
referenceNode: HTMLDivElement
|
|
135
|
+
): void {
|
|
136
|
+
referenceNode.querySelector('div.viewport-element').appendChild(newNode);
|
|
137
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { state } from './state';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds the tool class to the cornerstoneTools to be used later. This function
|
|
5
|
+
* should be called before creating the toolGroups and adding tools and setting their mode.
|
|
6
|
+
* The flow is:
|
|
7
|
+
* - addTool(ToolClass) // where ToolClass is the tool constructor imported from CornerstoneTools or created by a 3rd party
|
|
8
|
+
* - createToolGroup(toolGroupId)
|
|
9
|
+
* - toolGroup.addTool(${toolName}) // NOT THE TOOL CLASS
|
|
10
|
+
* - toolGroup.setToolActive(${toolName})
|
|
11
|
+
*
|
|
12
|
+
* @param ToolClass - A tool calls to instantiate.
|
|
13
|
+
* @param toolOptions - The tool-specific configuration options for the tool.
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export function addTool(ToolClass): void {
|
|
17
|
+
// Check if tool exists and name is not undefined
|
|
18
|
+
const toolName = ToolClass.toolName;
|
|
19
|
+
const toolAlreadyAdded = state.tools[toolName] !== undefined;
|
|
20
|
+
|
|
21
|
+
if (!toolName) {
|
|
22
|
+
throw new Error(`No Tool Found for the ToolClass ${ToolClass.name}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (toolAlreadyAdded) {
|
|
26
|
+
throw new Error(`${toolName} has already been added globally`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Stores the toolNames and ToolClass to be instantiated in the toolGroup on toolGroup.addTool
|
|
30
|
+
state.tools[toolName] = {
|
|
31
|
+
toolClass: ToolClass,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Removes the tool class from the cornerstoneTools.
|
|
37
|
+
*
|
|
38
|
+
* @param ToolClass - A tool calls to instantiate.
|
|
39
|
+
*/
|
|
40
|
+
export function removeTool(ToolClass): void {
|
|
41
|
+
const toolName = ToolClass.toolName;
|
|
42
|
+
|
|
43
|
+
if (!toolName) {
|
|
44
|
+
throw new Error(`No tool found for: ${ToolClass.name}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!state.tools[toolName] !== undefined) {
|
|
48
|
+
delete state.tools[toolName];
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`${toolName} cannot be removed because it has not been added`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default addTool;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ToolModes } from '../enums';
|
|
2
|
+
import getToolsWithModesForElement from '../utilities/getToolsWithModesForElement';
|
|
3
|
+
import filterToolsWithAnnotationsForElement from './filterToolsWithAnnotationsForElement';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Cancel the current active manipulation that is being performed on the provided
|
|
7
|
+
* element. It filters all the active and passive tools for the enabledElement
|
|
8
|
+
* and calls cancel() method for all of them, and returns the tool that has executed its
|
|
9
|
+
* cancellation (returned its annotationUID), since tools that are not being manipulated will
|
|
10
|
+
* short circuit early. Note: not all tools currently implement a cancel method.
|
|
11
|
+
*
|
|
12
|
+
* @param element - canvas element
|
|
13
|
+
* @returns annotationUID that is cancelled
|
|
14
|
+
*/
|
|
15
|
+
export default function cancelActiveManipulations(
|
|
16
|
+
element: HTMLDivElement
|
|
17
|
+
): string | undefined {
|
|
18
|
+
const tools = getToolsWithModesForElement(element, [
|
|
19
|
+
ToolModes.Active,
|
|
20
|
+
ToolModes.Passive,
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const toolsWithData = filterToolsWithAnnotationsForElement(element, tools);
|
|
24
|
+
for (const { tool } of toolsWithData) {
|
|
25
|
+
const annotationUID = tool.cancel(element);
|
|
26
|
+
if (annotationUID) {
|
|
27
|
+
return annotationUID;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ToolAnnotationPair,
|
|
5
|
+
ToolAnnotationsPair,
|
|
6
|
+
} from '../types/InternalToolTypes';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Filters an array of tools with annotations, returning the first annotation
|
|
10
|
+
* for each tool that is moveable and at the mouse location. It results in
|
|
11
|
+
* one annotation per tool.
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* @param element - The HTML element
|
|
15
|
+
* @param ToolAndAnnotations - The input tool array.
|
|
16
|
+
* @param canvasCoords - The coordinates of the mouse position.
|
|
17
|
+
* @param interactionType - The type of interaction that is taking place.
|
|
18
|
+
* @returns The filtered array containing ToolAndAnnotation
|
|
19
|
+
*/
|
|
20
|
+
export default function filterMoveableAnnotationTools(
|
|
21
|
+
element: HTMLDivElement,
|
|
22
|
+
ToolAndAnnotations: ToolAnnotationsPair[],
|
|
23
|
+
canvasCoords: Types.Point2,
|
|
24
|
+
interactionType = 'mouse'
|
|
25
|
+
): ToolAnnotationPair[] {
|
|
26
|
+
const proximity = interactionType === 'touch' ? 36 : 6;
|
|
27
|
+
|
|
28
|
+
// TODO - This could get pretty expensive pretty quickly. We don't want to fetch the camera
|
|
29
|
+
// And do world to canvas on each coord.
|
|
30
|
+
|
|
31
|
+
// We want to produce a matrix from canvas to world for the viewport and just do a matrix operation on each handle.
|
|
32
|
+
// This could still be expensive for ROIs, but we probably shouldn't have "handles" for them anyway.
|
|
33
|
+
|
|
34
|
+
const moveableAnnotationTools = [];
|
|
35
|
+
|
|
36
|
+
ToolAndAnnotations.forEach(({ tool, annotations }) => {
|
|
37
|
+
for (const annotation of annotations) {
|
|
38
|
+
if (annotation.isLocked || !annotation.isVisible) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const near = tool.isPointNearTool(
|
|
43
|
+
element,
|
|
44
|
+
annotation,
|
|
45
|
+
canvasCoords,
|
|
46
|
+
proximity,
|
|
47
|
+
interactionType
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (near) {
|
|
51
|
+
moveableAnnotationTools.push({
|
|
52
|
+
tool,
|
|
53
|
+
annotation,
|
|
54
|
+
});
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return moveableAnnotationTools;
|
|
61
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getAnnotations } from '../stateManagement/annotation/annotationState';
|
|
2
|
+
import { ToolAnnotationsPair } from '../types/InternalToolTypes';
|
|
3
|
+
import type AnnotationTool from '../tools/base/AnnotationTool';
|
|
4
|
+
import BaseTool from '../tools/base/BaseTool';
|
|
5
|
+
import { getEnabledElement } from '@cornerstonejs/core';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Filters an array of tools, returning only tools which have annotation.
|
|
9
|
+
*
|
|
10
|
+
* @param element - The cornerstone3D enabled element.
|
|
11
|
+
* @param tools - The array of tools to check.
|
|
12
|
+
*
|
|
13
|
+
* @returns The array of tools with their found annotations.
|
|
14
|
+
*/
|
|
15
|
+
export default function filterToolsWithAnnotationsForElement(
|
|
16
|
+
element: HTMLDivElement,
|
|
17
|
+
tools: AnnotationTool[]
|
|
18
|
+
): ToolAnnotationsPair[] {
|
|
19
|
+
const result = [];
|
|
20
|
+
for (let i = 0; i < tools.length; i++) {
|
|
21
|
+
const tool = tools[i];
|
|
22
|
+
|
|
23
|
+
if (!tool) {
|
|
24
|
+
console.warn('undefined tool in filterToolsWithAnnotationsForElement');
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let annotations = getAnnotations(
|
|
29
|
+
(tool.constructor as typeof BaseTool).toolName,
|
|
30
|
+
element
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (!annotations?.length) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (typeof tool.filterInteractableAnnotationsForElement === 'function') {
|
|
38
|
+
// If the tool has a annotations filter (e.g. with in-plane-annotations-only filtering), use it.
|
|
39
|
+
annotations = tool.filterInteractableAnnotationsForElement(
|
|
40
|
+
element,
|
|
41
|
+
annotations
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (annotations.length > 0) {
|
|
46
|
+
result.push({ tool, annotations });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ToolAnnotationsPair,
|
|
5
|
+
ToolsWithMoveableHandles,
|
|
6
|
+
} from '../types/InternalToolTypes';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Filters an array of tools, returning only tools with moveable handles at the mouse location that are not locked
|
|
10
|
+
*
|
|
11
|
+
* @param element - The element
|
|
12
|
+
* @param ToolAndAnnotations - The input tool array.
|
|
13
|
+
* @param canvasCoords - The coordinates of the mouse position.
|
|
14
|
+
* @param interactionType - The type of interaction (e.g. 'mouse' or 'touch')
|
|
15
|
+
* @returns The filtered array.
|
|
16
|
+
*/
|
|
17
|
+
export default function filterToolsWithMoveableHandles(
|
|
18
|
+
element: HTMLDivElement,
|
|
19
|
+
ToolAndAnnotations: ToolAnnotationsPair[],
|
|
20
|
+
canvasCoords: Types.Point2,
|
|
21
|
+
interactionType = 'mouse'
|
|
22
|
+
): ToolsWithMoveableHandles[] {
|
|
23
|
+
const proximity = interactionType === 'touch' ? 36 : 6;
|
|
24
|
+
const toolsWithMoveableHandles = [];
|
|
25
|
+
|
|
26
|
+
ToolAndAnnotations.forEach(({ tool, annotations }) => {
|
|
27
|
+
for (const annotation of annotations) {
|
|
28
|
+
if (annotation.isLocked || !annotation.isVisible) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const handle = tool.getHandleNearImagePoint(
|
|
33
|
+
element,
|
|
34
|
+
annotation,
|
|
35
|
+
canvasCoords,
|
|
36
|
+
proximity
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (handle) {
|
|
40
|
+
toolsWithMoveableHandles.push({
|
|
41
|
+
tool,
|
|
42
|
+
annotation,
|
|
43
|
+
handle,
|
|
44
|
+
});
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return toolsWithMoveableHandles;
|
|
51
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { addTool, removeTool } from './addTool';
|
|
2
|
+
import addEnabledElement from './addEnabledElement';
|
|
3
|
+
import removeEnabledElement from './removeEnabledElement';
|
|
4
|
+
import cancelActiveManipulations from './cancelActiveManipulations';
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import Synchronizer from './SynchronizerManager/Synchronizer';
|
|
8
|
+
|
|
9
|
+
import svgNodeCache from './svgNodeCache';
|
|
10
|
+
import state from './state';
|
|
11
|
+
|
|
12
|
+
import * as ToolGroupManager from './ToolGroupManager';
|
|
13
|
+
import * as SynchronizerManager from './SynchronizerManager';
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
// Store
|
|
17
|
+
state,
|
|
18
|
+
addTool,
|
|
19
|
+
removeTool,
|
|
20
|
+
addEnabledElement,
|
|
21
|
+
removeEnabledElement,
|
|
22
|
+
cancelActiveManipulations,
|
|
23
|
+
svgNodeCache,
|
|
24
|
+
// Managers
|
|
25
|
+
ToolGroupManager,
|
|
26
|
+
SynchronizerManager,
|
|
27
|
+
// Classes
|
|
28
|
+
Synchronizer,
|
|
29
|
+
};
|