@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,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The events for cornerstoneTools3D Tools. Native Mouse and Keyboard events are
|
|
3
|
+
* captured, normalized, and re-triggered with a `CORNERSTONE_TOOLS` prefix. This
|
|
4
|
+
* allows us to handle events consistently across different browsers.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
enum Events {
|
|
8
|
+
///////////////////////////////////////
|
|
9
|
+
// Annotations
|
|
10
|
+
///////////////////////////////////////
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Triggers on the eventTarget when a new annotation is added to the state.
|
|
14
|
+
*
|
|
15
|
+
* Make use of {@link EventTypes.AnnotationAddedEventType | Annotation Added Event Type }
|
|
16
|
+
* for typing your event listeners for this annotation added event, and see what event
|
|
17
|
+
* detail is included in {@link EventTypes.AnnotationAddedEventDetail | Annotation Added Event Detail}.
|
|
18
|
+
*/
|
|
19
|
+
ANNOTATION_ADDED = 'CORNERSTONE_TOOLS_ANNOTATION_ADDED',
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Triggers on the eventTarget when a new annotation is completed its drawing
|
|
23
|
+
* Make use of {@link EventTypes.AnnotationCompletedEventType | Annotation Completed Event Type }
|
|
24
|
+
* for typing your event listeners for this annotation completed event, and see what event
|
|
25
|
+
* detail is included in {@link EventTypes.AnnotationCompletedEventDetail | Annotation Completed Event Detail}.
|
|
26
|
+
*/
|
|
27
|
+
ANNOTATION_COMPLETED = 'CORNERSTONE_TOOLS_ANNOTATION_COMPLETED',
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Triggers on the eventTarget when an annotation is modified (e.g. a handle is modified).
|
|
31
|
+
* Make use of {@link EventTypes.AnnotationModifiedEventType | Annotation Modified Event Type}
|
|
32
|
+
* for typing your event listeners for this annotation modified event, and see what
|
|
33
|
+
* event detail is included in {@link EventTypes.AnnotationModifiedEventDetail | Annotation Modified Event Detail}.
|
|
34
|
+
*/
|
|
35
|
+
ANNOTATION_MODIFIED = 'CORNERSTONE_TOOLS_ANNOTATION_MODIFIED',
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Triggers on the eventTarget when an annotation is removed from the annotations manager.
|
|
39
|
+
* Make use of {@link EventTypes.AnnotationRemovedEventType | Annotation Removed Event Type}
|
|
40
|
+
* for typing your event listeners for this annotation removed event, and see what
|
|
41
|
+
* event detail is included in {@link EventTypes.AnnotationRemovedEventDetail | Annotation Removed Event Detail}.
|
|
42
|
+
*/
|
|
43
|
+
ANNOTATION_REMOVED = 'CORNERSTONE_TOOLS_ANNOTATION_REMOVED',
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Triggers on the eventTarget when an annotation selection status is changed.
|
|
47
|
+
* Make use of {@link EventTypes.AnnotationSelectionChangeEventType | Annotation Selection Change Event Type}
|
|
48
|
+
* for typing your event listeners for this annotation selection change event, and see what
|
|
49
|
+
* event detail is included in {@link EventTypes.AnnotationSelectionChangeEventDetail | Annotation Selection Change Event Detail}.
|
|
50
|
+
*/
|
|
51
|
+
ANNOTATION_SELECTION_CHANGE = 'CORNERSTONE_TOOLS_ANNOTATION_SELECTION_CHANGE',
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Triggers on the eventTarget when an annotation locked status is changed.
|
|
55
|
+
* Make use of {@link EventTypes.AnnotationLockChangeEventType | Annotation Lock Change Event Type}
|
|
56
|
+
* for typing your event listeners for this annotation lock change event, and see what
|
|
57
|
+
* event detail is included in {@link EventTypes.AnnotationLockChangeEventDetail | Annotation Lock Change Event Detail}.
|
|
58
|
+
*/
|
|
59
|
+
ANNOTATION_LOCK_CHANGE = 'CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE',
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Triggers on the eventTarget when an annotation visible status is changed.
|
|
63
|
+
* Make use of {@link EventTypes.AnnotationVisibilityChangeEventType | Annotation Visible Change Event Type}
|
|
64
|
+
* for typing your event listeners for this annotation Hide change event, and see what
|
|
65
|
+
* event detail is included in {@link EventTypes.AnnotationVisibilityChangeEventDetail | Annotation Visible Change Event Detail}.
|
|
66
|
+
*/
|
|
67
|
+
ANNOTATION_VISIBILITY_CHANGE = 'CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE',
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Triggers on the eventTarget when an annotation is rendered.
|
|
71
|
+
* Make use of {@link EventTypes.AnnotationRenderedEventType | Annotation Rendered Event Type}
|
|
72
|
+
* for typing your event listeners for this annotation rendered event, and see what
|
|
73
|
+
* event detail is included in {@link EventTypes.AnnotationRenderedEventDetail | Annotation Rendered Event Detail}.
|
|
74
|
+
*/
|
|
75
|
+
ANNOTATION_RENDERED = 'CORNERSTONE_TOOLS_ANNOTATION_RENDERED',
|
|
76
|
+
|
|
77
|
+
///////////////////////////////////////
|
|
78
|
+
// Segmentations Events
|
|
79
|
+
///////////////////////////////////////
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Triggers on the eventTarget when a Segmentation is updated in the state manager.
|
|
83
|
+
* Make use of {@link EventTypes.SegmentationModifiedEventType | Segmentation Modified Event Type}
|
|
84
|
+
* for typing your event listeners for this segmentation modified event, and see what
|
|
85
|
+
* event detail is included in {@link EventTypes.SegmentationModifiedEventDetail | Segmentation Modified Event Detail}.
|
|
86
|
+
*/
|
|
87
|
+
SEGMENTATION_MODIFIED = 'CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED',
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Triggers on the eventTarget when a Segmentation is rendered by the Segmentation Rendering Engine.
|
|
91
|
+
* Make use of {@link EventTypes.SegmentationRenderedEventType | Segmentation Rendered Event Type}
|
|
92
|
+
* for typing your event listeners for this segmentation rendered event, and see what
|
|
93
|
+
* event detail is included in {@link EventTypes.SegmentationRenderedEventDetail | Segmentation Rendered Event Detail}.
|
|
94
|
+
*/
|
|
95
|
+
SEGMENTATION_RENDERED = 'CORNERSTONE_TOOLS_SEGMENTATION_RENDERED',
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Triggers on the eventTarget when a Segmentation representation of a toolGroup is modified in the state manager.
|
|
99
|
+
* Make use of {@link EventTypes.SegmentationRepresentationModifiedEventType | Segmentation Representation Modified Event Type}
|
|
100
|
+
* for typing your event listeners for this segmentation representation modified event, and see what
|
|
101
|
+
* event detail is included in {@link EventTypes.SegmentationRepresentationModifiedEventDetail | Segmentation Representation Modified Event Detail}.
|
|
102
|
+
*/
|
|
103
|
+
SEGMENTATION_REPRESENTATION_MODIFIED = 'CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED',
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Triggers on the eventTarget when a Segmentation is removed from the state manager.
|
|
107
|
+
* Make use of {@link EventTypes.SegmentationRemovedEventType | Segmentation Removed Event Type}
|
|
108
|
+
* for typing your event listeners for this segmentation removed event, and see what
|
|
109
|
+
* event detail is included in {@link EventTypes.SegmentationRemovedEventDetail | Segmentation Removed Event Detail}.
|
|
110
|
+
*/
|
|
111
|
+
SEGMENTATION_REMOVED = 'CORNERSTONE_TOOLS_SEGMENTATION_REMOVED',
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Triggers on the eventTarget when a Segmentation representation of a toolGroup is removed in the state manager.
|
|
115
|
+
* Make use of {@link EventTypes.SegmentationRepresentationRemovedEventType | Segmentation Representation Removed Event Type}
|
|
116
|
+
* for typing your event listeners for this segmentation representation removed event, and see what
|
|
117
|
+
* event detail is included in {@link EventTypes.SegmentationRepresentationRemovedEventDetail | Segmentation Representation Removed Event Detail}.
|
|
118
|
+
*/
|
|
119
|
+
SEGMENTATION_REPRESENTATION_REMOVED = 'CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED',
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Triggers on the eventTarget when a Segmentation data is modified (e.g., by brush tool).
|
|
123
|
+
* Make use of {@link EventTypes.SegmentationDataModifiedEventType | Segmentation Data Modified Event Type}
|
|
124
|
+
* for typing your event listeners for this segmentation data modified event, and see what
|
|
125
|
+
* event detail is included in {@link EventTypes.SegmentationDataModifiedEventDetail | Segmentation Data Modified Event Detail}.
|
|
126
|
+
*/
|
|
127
|
+
SEGMENTATION_DATA_MODIFIED = 'CORNERSTONE_TOOLS_SEGMENTATION_DATA_MODIFIED',
|
|
128
|
+
|
|
129
|
+
///////////////////////////////////////
|
|
130
|
+
// Keyboard Events
|
|
131
|
+
///////////////////////////////////////
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Triggers on the eventTarget when a key on the keyboard is pressed.
|
|
135
|
+
* Make use of {@link EventTypes.KeyDownEventType | Key Down Event Type}
|
|
136
|
+
* for typing your event listeners for this key down event, and see what
|
|
137
|
+
* event detail is included in {@link EventTypes.KeyDownEventDetail | Key Down Event Detail}.
|
|
138
|
+
*/
|
|
139
|
+
KEY_DOWN = 'CORNERSTONE_TOOLS_KEY_DOWN',
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Triggers on the eventTarget when a key on the keyboard is released.
|
|
143
|
+
* Make use of {@link EventTypes.KeyUpEventType | Key Up Event Type}
|
|
144
|
+
* for typing your event listeners for this key up event, and see what
|
|
145
|
+
* event detail is included in {@link EventTypes.KeyUpEventDetail | Key Up Event Detail}.
|
|
146
|
+
*/
|
|
147
|
+
KEY_UP = 'CORNERSTONE_TOOLS_KEY_UP',
|
|
148
|
+
|
|
149
|
+
///////////////////////////////////////
|
|
150
|
+
// Mouse Events
|
|
151
|
+
///////////////////////////////////////
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Triggers on the eventTarget when the mouse is pressed down, it is CornerstoneTools normalized event.
|
|
155
|
+
* Make use of {@link EventTypes.MouseDownEventType | Mouse Down Event Type}
|
|
156
|
+
* for typing your event listeners for this mouse down event, and see what
|
|
157
|
+
* event detail is included in {@link EventTypes.MouseDownEventDetail | Mouse Down Event Detail}.
|
|
158
|
+
*/
|
|
159
|
+
MOUSE_DOWN = 'CORNERSTONE_TOOLS_MOUSE_DOWN',
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Triggers on the eventTarget when the mouse is released, it is CornerstoneTools normalized event.
|
|
163
|
+
* Make use of {@link EventTypes.MouseUpEventType | Mouse Up Event Type}
|
|
164
|
+
* for typing your event listeners for this mouse up event, and see what
|
|
165
|
+
* event detail is included in {@link EventTypes.MouseUpEventDetail | Mouse Up Event Detail}.
|
|
166
|
+
*/
|
|
167
|
+
MOUSE_UP = 'CORNERSTONE_TOOLS_MOUSE_UP',
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Triggers on the eventTarget when a handled `MOUSE_DOWN` event does not `stopPropagation`. The hook
|
|
171
|
+
* we use to create new annotation for mouse events.
|
|
172
|
+
* Make use of {@link EventTypes.MouseDownActivateEventType | Mouse Down Activate Event Type}
|
|
173
|
+
* for typing your event listeners for this mouse down activate event, and see what
|
|
174
|
+
* event detail is included in {@link EventTypes.MouseDownActivateEventDetail | Mouse Down Activate Event Detail}.
|
|
175
|
+
*/
|
|
176
|
+
MOUSE_DOWN_ACTIVATE = 'CORNERSTONE_TOOLS_MOUSE_DOWN_ACTIVATE',
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Triggers on the event target when mouse is dragging an annotation or textBox.
|
|
180
|
+
* Make use of {@link EventTypes.MouseDragEventType | Mouse Drag Event Type}
|
|
181
|
+
* for typing your event listeners for this mouse drag event, and see what
|
|
182
|
+
* event detail is included in {@link EventTypes.MouseDragEventDetail | Mouse Drag Event Detail}.
|
|
183
|
+
*/
|
|
184
|
+
MOUSE_DRAG = 'CORNERSTONE_TOOLS_MOUSE_DRAG',
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Triggers on the eventTarget, when the mouse is moved, it is CornerstoneTools normalized event.
|
|
188
|
+
* It can be just a mouse move or when double click is performed and annotation
|
|
189
|
+
* drawing can be performed with just mouse move.
|
|
190
|
+
* Make use of {@link EventTypes.MouseMoveEventType | Mouse Move Event Type}
|
|
191
|
+
* for typing your event listeners for this mouse move event, and see what
|
|
192
|
+
* event detail is included in {@link EventTypes.MouseMoveEventDetail | Mouse Move Event Detail}.
|
|
193
|
+
*/
|
|
194
|
+
MOUSE_MOVE = 'CORNERSTONE_TOOLS_MOUSE_MOVE',
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Triggers on the eventTarget when a mouse click is detected. It is CornerstoneTools normalized event.
|
|
198
|
+
* Make use of {@link EventTypes.MouseClickEventType | Mouse Click Event Type}
|
|
199
|
+
* for typing your event listeners for this mouse click event, and see what
|
|
200
|
+
* event detail is included in {@link EventTypes.MouseClickEventDetail | Mouse Click Event Detail}.
|
|
201
|
+
*/
|
|
202
|
+
MOUSE_CLICK = 'CORNERSTONE_TOOLS_MOUSE_CLICK',
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Triggers on the eventTarget when a mouse double click is detected. It is CornerstoneTools normalized event.
|
|
206
|
+
* Make use of {@link EventTypes.MouseDoubleClickEventType | Mouse Double Click Event Type}
|
|
207
|
+
* for typing your event listeners for this mouse double click event, and see what
|
|
208
|
+
* event detail is included in {@link EventTypes.MouseDoubleClickEventDetail | Mouse Double Click Event Detail}.
|
|
209
|
+
*/
|
|
210
|
+
MOUSE_DOUBLE_CLICK = 'CORNERSTONE_TOOLS_MOUSE_DOUBLE_CLICK',
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Triggers on the eventTarget when a mouse wheel event is detected. It is CornerstoneTools normalized event.
|
|
214
|
+
* Make use of {@link EventTypes.MouseWheelEventType | Mouse Wheel Event Type}
|
|
215
|
+
* for typing your event listeners for this mouse wheel event, and see what
|
|
216
|
+
* event detail is included in {@link EventTypes.MouseWheelEventDetail | Mouse Wheel Event Detail}.
|
|
217
|
+
*/
|
|
218
|
+
MOUSE_WHEEL = 'CORNERSTONE_TOOLS_MOUSE_WHEEL',
|
|
219
|
+
|
|
220
|
+
// Todo: not being fired as of now
|
|
221
|
+
// ANNOTATION_COMPLETED = 'CORNERSTONE_TOOLS_ANNOTATION_COMPLETED',
|
|
222
|
+
// Todo: not implemented yet
|
|
223
|
+
// KEY_PRESS = 'CORNERSTONE_TOOLS_KEY_PRESS',
|
|
224
|
+
|
|
225
|
+
//////////////////////
|
|
226
|
+
// Touch Events //
|
|
227
|
+
//////////////////////
|
|
228
|
+
// The event flow looks like the following
|
|
229
|
+
// Touch Start -> (optional) Touch Press -> Touch Drag -> (optional) Touch Swipe -> Touch End
|
|
230
|
+
// Touch Tap
|
|
231
|
+
// mousedown
|
|
232
|
+
// mousedown, Touch Start, and Tap are mutually exclusive events
|
|
233
|
+
TOUCH_START = 'CORNERSTONE_TOOLS_TOUCH_START',
|
|
234
|
+
TOUCH_START_ACTIVATE = 'CORNERSTONE_TOOLS_TOUCH_START_ACTIVATE',
|
|
235
|
+
TOUCH_PRESS = 'CORNERSTONE_TOOLS_TOUCH_PRESS',
|
|
236
|
+
TOUCH_DRAG = 'CORNERSTONE_TOOLS_TOUCH_DRAG',
|
|
237
|
+
TOUCH_END = 'CORNERSTONE_TOOLS_TOUCH_END',
|
|
238
|
+
TOUCH_TAP = 'CORNERSTONE_TOOLS_TAP',
|
|
239
|
+
TOUCH_SWIPE = 'CORNERSTONE_TOOLS_SWIPE',
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export default Events;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segmentations on viewports can be visualized in different ways. This enum
|
|
3
|
+
* defines the different ways of visualizing segmentations. Currently, only
|
|
4
|
+
* labelmap is supported.
|
|
5
|
+
*/
|
|
6
|
+
enum SegmentationRepresentations {
|
|
7
|
+
Labelmap = 'LABELMAP',
|
|
8
|
+
Contour = 'CONTOUR',
|
|
9
|
+
// Todo: add more representations
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default SegmentationRepresentations;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mouse This enum enumerates the different buttons returned by `.buttons` on the mouse event.
|
|
3
|
+
* These values are used when setting a tool active in a tool group.
|
|
4
|
+
*
|
|
5
|
+
* See also: https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
6
|
+
*/
|
|
7
|
+
enum MouseBindings {
|
|
8
|
+
/** usually the left button */
|
|
9
|
+
Primary = 1,
|
|
10
|
+
/** usually the right button */
|
|
11
|
+
Secondary = 2,
|
|
12
|
+
Primary_And_Secondary = 3,
|
|
13
|
+
/** usually mouse wheel button */
|
|
14
|
+
Auxiliary = 4,
|
|
15
|
+
Primary_And_Auxiliary = 5,
|
|
16
|
+
Secondary_And_Auxiliary = 6,
|
|
17
|
+
Primary_And_Secondary_And_Auxiliary = 7,
|
|
18
|
+
/** usually "Browser Back" button */
|
|
19
|
+
Fourth_Button = 8,
|
|
20
|
+
/** usually "Browser Forward" button */
|
|
21
|
+
Fifth_Button = 16,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
enum KeyboardBindings {
|
|
25
|
+
Shift = 16,
|
|
26
|
+
Ctrl = 17,
|
|
27
|
+
Alt = 18,
|
|
28
|
+
Meta = 91,
|
|
29
|
+
ShiftCtrl = 1617,
|
|
30
|
+
ShiftAlt = 1618,
|
|
31
|
+
ShiftMeta = 1691,
|
|
32
|
+
CtrlAlt = 1718,
|
|
33
|
+
CtrlMeta = 1791,
|
|
34
|
+
AltMeta = 1891,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { MouseBindings, KeyboardBindings };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolModes - This enum defines the 4 tool states which are available.
|
|
3
|
+
*/
|
|
4
|
+
enum ToolModes {
|
|
5
|
+
/**
|
|
6
|
+
* Active:
|
|
7
|
+
* - Can be actively used by mouse/touch events mapped to its `ToolBinding`s.
|
|
8
|
+
* - Can add data if an annotation tool.
|
|
9
|
+
* - Can be passively interacted by grabbing a tool or its handles.
|
|
10
|
+
* - Renders data if the tool has a `renderAnnotation` method.
|
|
11
|
+
*/
|
|
12
|
+
Active = 'Active',
|
|
13
|
+
/**
|
|
14
|
+
* Passive:
|
|
15
|
+
* - Can be passively interacted by grabbing a tool or its handles.
|
|
16
|
+
* - Renders data if the tool has a `renderAnnotation` method.
|
|
17
|
+
*/
|
|
18
|
+
Passive = 'Passive',
|
|
19
|
+
/**
|
|
20
|
+
* Enabled:
|
|
21
|
+
* - Renders data if the tool has a `renderAnnotation` method.
|
|
22
|
+
*/
|
|
23
|
+
Enabled = 'Enabled',
|
|
24
|
+
/**
|
|
25
|
+
* Disabled:
|
|
26
|
+
* - Annotation does not render.
|
|
27
|
+
*/
|
|
28
|
+
Disabled = 'Disabled',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default ToolModes;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MouseBindings, KeyboardBindings } from './ToolBindings';
|
|
2
|
+
import ToolModes from './ToolModes';
|
|
3
|
+
import AnnotationStyleStates from './AnnotationStyleStates';
|
|
4
|
+
import Events from './Events';
|
|
5
|
+
import SegmentationRepresentations from './SegmentationRepresentations';
|
|
6
|
+
import { Swipe } from './Touch';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
MouseBindings,
|
|
10
|
+
KeyboardBindings,
|
|
11
|
+
ToolModes,
|
|
12
|
+
AnnotationStyleStates,
|
|
13
|
+
Events,
|
|
14
|
+
SegmentationRepresentations,
|
|
15
|
+
Swipe,
|
|
16
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { eventTarget, getRenderingEngine } from '@cornerstonejs/core';
|
|
2
|
+
import Events from '../enums/Events';
|
|
3
|
+
import triggerAnnotationRenderForViewportIds from '../utilities/triggerAnnotationRenderForViewportIds';
|
|
4
|
+
import { AnnotationModifiedEventType } from '../types/EventTypes';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is a callback function that is called when an annotation is modified.
|
|
8
|
+
* Since we are throttling the cachedStats calculation for annotation tools,
|
|
9
|
+
* we need to trigger a final render for the annotation. so that the annotation
|
|
10
|
+
* textBox is updated.
|
|
11
|
+
* Todo: This will trigger all the annotation tools to re-render, although DOM
|
|
12
|
+
* will update those that have changed, but more efficient would be to only
|
|
13
|
+
* update the changed annotation.
|
|
14
|
+
* Todo: A better way is to extract the textBox render logic from the renderAnnotation
|
|
15
|
+
* of all tools and just trigger a render for that (instead of the entire annotation., even if
|
|
16
|
+
* no svg update happens since the attributes for handles are the same)
|
|
17
|
+
*/
|
|
18
|
+
const onAnnotationModified = function (evt: AnnotationModifiedEventType) {
|
|
19
|
+
const { viewportId, renderingEngineId } = evt.detail;
|
|
20
|
+
const renderingEngine = getRenderingEngine(renderingEngineId);
|
|
21
|
+
triggerAnnotationRenderForViewportIds(renderingEngine, [viewportId]);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const enable = function () {
|
|
25
|
+
eventTarget.addEventListener(
|
|
26
|
+
Events.ANNOTATION_MODIFIED,
|
|
27
|
+
onAnnotationModified
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const disable = function () {
|
|
32
|
+
eventTarget.removeEventListener(
|
|
33
|
+
Events.ANNOTATION_MODIFIED,
|
|
34
|
+
onAnnotationModified
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
enable,
|
|
40
|
+
disable,
|
|
41
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Enums, Types } from '@cornerstonejs/core';
|
|
2
|
+
import { ToolModes } from '../enums';
|
|
3
|
+
import getToolsWithModesForMouseEvent from './shared/getToolsWithModesForMouseEvent';
|
|
4
|
+
|
|
5
|
+
const { Active, Passive, Enabled } = ToolModes;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* When the camera is modified, check what tools need to react to this.
|
|
9
|
+
*
|
|
10
|
+
* - First we get all tools which are active, passive or enabled on the element.
|
|
11
|
+
* - If any of these tools have a `onCameraModified` method, we call it.
|
|
12
|
+
*
|
|
13
|
+
* @param evt - The normalized camera modified event.
|
|
14
|
+
*/
|
|
15
|
+
const onCameraModified = function (evt: Types.EventTypes.CameraModifiedEvent) {
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const enabledTools = getToolsWithModesForMouseEvent(evt, [
|
|
18
|
+
Active,
|
|
19
|
+
Passive,
|
|
20
|
+
Enabled,
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
enabledTools.forEach((tool) => {
|
|
24
|
+
if (tool.onCameraModified) {
|
|
25
|
+
tool.onCameraModified(evt);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const enable = function (element) {
|
|
31
|
+
element.addEventListener(Enums.Events.CAMERA_MODIFIED, onCameraModified);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const disable = function (element) {
|
|
35
|
+
element.removeEventListener(Enums.Events.CAMERA_MODIFIED, onCameraModified);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
enable,
|
|
40
|
+
disable,
|
|
41
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Enums, Types } from '@cornerstonejs/core';
|
|
2
|
+
import triggerAnnotationRender from '../utilities/triggerAnnotationRender';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* When the image is rendered, check what tools can be rendered for this element.
|
|
6
|
+
*
|
|
7
|
+
* - First we get all tools which are active, passive or enabled on the element.
|
|
8
|
+
* - If any of these tools have a `renderAnnotation` method, then we render them.
|
|
9
|
+
* - Note that these tools don't necessarily have to be instances of `AnnotationTool`,
|
|
10
|
+
* Any tool may register a `renderAnnotation` method (e.g. a tool that displays an overlay).
|
|
11
|
+
*
|
|
12
|
+
* @param evt - The normalized IMAGE_RENDERED event.
|
|
13
|
+
*/
|
|
14
|
+
const onImageRendered = function (evt: Types.EventTypes.ImageRenderedEvent) {
|
|
15
|
+
// TODO: should we do this on camera modified instead of image rendered?
|
|
16
|
+
// e.g. no need to re-render annotations if only the VOI has changed
|
|
17
|
+
triggerAnnotationRender(evt.detail.element);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const enable = function (element: HTMLDivElement): void {
|
|
21
|
+
element.addEventListener(
|
|
22
|
+
Enums.Events.IMAGE_RENDERED,
|
|
23
|
+
onImageRendered as EventListener
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const disable = function (element: HTMLDivElement): void {
|
|
28
|
+
element.removeEventListener(
|
|
29
|
+
Enums.Events.IMAGE_RENDERED,
|
|
30
|
+
onImageRendered as EventListener
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
enable,
|
|
36
|
+
disable,
|
|
37
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Enums, Types } from '@cornerstonejs/core';
|
|
2
|
+
import { ToolModes } from '../enums';
|
|
3
|
+
import getToolsWithModesForMouseEvent from './shared/getToolsWithModesForMouseEvent';
|
|
4
|
+
|
|
5
|
+
const { Active, Passive, Enabled } = ToolModes;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* When image spacing is calibrated modify the annotations for all of its tools
|
|
9
|
+
* to consider the new calibration info.
|
|
10
|
+
*
|
|
11
|
+
* - First we get all tools which are active, passive or enabled on the element.
|
|
12
|
+
* - If any of these tools have a `onImageSpacingCalibrated` method, we call it.
|
|
13
|
+
*
|
|
14
|
+
* @param evt - The normalized image calibration event.
|
|
15
|
+
*/
|
|
16
|
+
const onImageSpacingCalibrated = function (
|
|
17
|
+
evt: Types.EventTypes.ImageSpacingCalibratedEvent
|
|
18
|
+
) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const enabledTools = getToolsWithModesForMouseEvent(evt, [
|
|
21
|
+
Active,
|
|
22
|
+
Passive,
|
|
23
|
+
Enabled,
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
enabledTools.forEach((tool) => {
|
|
27
|
+
if (tool.onImageSpacingCalibrated) {
|
|
28
|
+
tool.onImageSpacingCalibrated(evt);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const enable = function (element: HTMLDivElement) {
|
|
34
|
+
element.addEventListener(
|
|
35
|
+
Enums.Events.IMAGE_SPACING_CALIBRATED,
|
|
36
|
+
onImageSpacingCalibrated as EventListener
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const disable = function (element: HTMLDivElement) {
|
|
41
|
+
element.removeEventListener(
|
|
42
|
+
Enums.Events.IMAGE_SPACING_CALIBRATED,
|
|
43
|
+
onImageSpacingCalibrated as EventListener
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
enable,
|
|
49
|
+
disable,
|
|
50
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import imageRenderedEventDispatcher from './imageRenderedEventDispatcher';
|
|
2
|
+
import mouseToolEventDispatcher from './mouseToolEventDispatcher';
|
|
3
|
+
import keyboardToolEventDispatcher from './keyboardToolEventDispatcher';
|
|
4
|
+
import cameraModifiedEventDispatcher from './cameraModifiedEventDispatcher';
|
|
5
|
+
import imageSpacingCalibratedEventDispatcher from './imageSpacingCalibratedEventDispatcher';
|
|
6
|
+
import touchToolEventDispatcher from './touchToolEventDispatcher';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
imageRenderedEventDispatcher,
|
|
10
|
+
mouseToolEventDispatcher,
|
|
11
|
+
keyboardToolEventDispatcher,
|
|
12
|
+
cameraModifiedEventDispatcher,
|
|
13
|
+
imageSpacingCalibratedEventDispatcher,
|
|
14
|
+
touchToolEventDispatcher,
|
|
15
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ToolGroupManager } from '../../store';
|
|
2
|
+
import getActiveToolForKeyboardEvent from '../shared/getActiveToolForKeyboardEvent';
|
|
3
|
+
import { KeyDownEventType } from '../../types/EventTypes';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* KeyDown event listener to handle viewport cursor icon changes
|
|
7
|
+
*
|
|
8
|
+
* @param evt - The KeyboardEvent
|
|
9
|
+
*/
|
|
10
|
+
export default function keyDown(evt: KeyDownEventType): void {
|
|
11
|
+
// get the active tool given the key and mouse button
|
|
12
|
+
const activeTool = getActiveToolForKeyboardEvent(evt);
|
|
13
|
+
|
|
14
|
+
if (!activeTool) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const { renderingEngineId, viewportId } = evt.detail;
|
|
19
|
+
|
|
20
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(
|
|
21
|
+
viewportId,
|
|
22
|
+
renderingEngineId
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const toolName = activeTool.getToolName();
|
|
26
|
+
if (Object.keys(toolGroup.toolOptions).includes(toolName)) {
|
|
27
|
+
toolGroup.setViewportsCursorByToolName(toolName);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { resetModifierKey } from '../../eventListeners/keyboard/keyDownListener';
|
|
2
|
+
import { ToolGroupManager } from '../../store';
|
|
3
|
+
import getActiveToolForKeyboardEvent from '../shared/getActiveToolForKeyboardEvent';
|
|
4
|
+
import { KeyDownEventType } from '../../types/EventTypes';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* KeyDown event listener to handle viewport cursor icon changes
|
|
8
|
+
*
|
|
9
|
+
* @param evt - The KeyboardEvent
|
|
10
|
+
*/
|
|
11
|
+
export default function keyUp(evt: KeyDownEventType): void {
|
|
12
|
+
// get the active tool for the primary mouse button
|
|
13
|
+
const activeTool = getActiveToolForKeyboardEvent(evt);
|
|
14
|
+
|
|
15
|
+
if (!activeTool) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { renderingEngineId, viewportId } = evt.detail;
|
|
20
|
+
|
|
21
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(
|
|
22
|
+
viewportId,
|
|
23
|
+
renderingEngineId
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Reset the modifier key
|
|
27
|
+
resetModifierKey();
|
|
28
|
+
|
|
29
|
+
const toolName = activeTool.getToolName();
|
|
30
|
+
if (Object.keys(toolGroup.toolOptions).includes(toolName)) {
|
|
31
|
+
toolGroup.setViewportsCursorByToolName(toolName);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Events from '../enums/Events';
|
|
2
|
+
import { keyDown, keyUp } from './keyboardEventHandlers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Enable Key down and key up listeners
|
|
6
|
+
*
|
|
7
|
+
* @param element - The HTML element to attach the event listeners to.
|
|
8
|
+
*/
|
|
9
|
+
const enable = function (element: HTMLDivElement) {
|
|
10
|
+
element.addEventListener(Events.KEY_DOWN, keyDown as EventListener);
|
|
11
|
+
element.addEventListener(Events.KEY_UP, keyUp as EventListener);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Disable Key down and key up listeners
|
|
16
|
+
* @param element - The HTML element to attach the event listeners to.
|
|
17
|
+
*/
|
|
18
|
+
const disable = function (element: HTMLDivElement) {
|
|
19
|
+
element.removeEventListener(Events.KEY_DOWN, keyDown as EventListener);
|
|
20
|
+
element.removeEventListener(Events.KEY_UP, keyUp as EventListener);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const keyboardToolEventDispatcher = {
|
|
24
|
+
enable,
|
|
25
|
+
disable,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default keyboardToolEventDispatcher;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import mouseClick from './mouseClick';
|
|
2
|
+
import mouseDoubleClick from './mouseDoubleClick';
|
|
3
|
+
import mouseDown from './mouseDown';
|
|
4
|
+
import mouseDownActivate from './mouseDownActivate';
|
|
5
|
+
import mouseDrag from './mouseDrag';
|
|
6
|
+
import mouseMove from './mouseMove';
|
|
7
|
+
import mouseUp from './mouseUp';
|
|
8
|
+
import mouseWheel from './mouseWheel';
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
mouseClick,
|
|
12
|
+
mouseDown,
|
|
13
|
+
mouseDownActivate,
|
|
14
|
+
mouseDoubleClick,
|
|
15
|
+
mouseDrag,
|
|
16
|
+
mouseMove,
|
|
17
|
+
mouseUp,
|
|
18
|
+
mouseWheel,
|
|
19
|
+
};
|