@cornerstonejs/tools 0.56.2 → 0.56.4
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/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,64 @@
|
|
|
1
|
+
import { ToolGroupManager } from '../../store';
|
|
2
|
+
import { MouseBindings, ToolModes } from '../../enums';
|
|
3
|
+
import { EventTypes } from '../../types';
|
|
4
|
+
import getMouseModifier from './getMouseModifier';
|
|
5
|
+
|
|
6
|
+
const { Active } = ToolModes;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Iterate tool group tools until we find a tool that has a "ToolBinding"
|
|
10
|
+
* that matches our TouchEvent's `buttons`. It's possible there will be no match
|
|
11
|
+
* (no active tool for that touch button combination).
|
|
12
|
+
*
|
|
13
|
+
* @param evt - The event dispatcher touch event.
|
|
14
|
+
*
|
|
15
|
+
* @returns tool
|
|
16
|
+
*/
|
|
17
|
+
export default function getActiveToolForTouchEvent(
|
|
18
|
+
evt: EventTypes.NormalizedTouchEventType
|
|
19
|
+
) {
|
|
20
|
+
// Todo: we should refactor this to use getToolsWithModesForTouchEvent instead
|
|
21
|
+
const { renderingEngineId, viewportId } = evt.detail;
|
|
22
|
+
const touchEvent = evt.detail.event;
|
|
23
|
+
|
|
24
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(
|
|
25
|
+
viewportId,
|
|
26
|
+
renderingEngineId
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
if (!toolGroup) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const toolGroupToolNames = Object.keys(toolGroup.toolOptions);
|
|
34
|
+
|
|
35
|
+
const numTouchPoints = Object.keys(touchEvent.touches).length;
|
|
36
|
+
|
|
37
|
+
// If any keyboard modifier key is also pressed
|
|
38
|
+
const modifierKey = getMouseModifier(touchEvent);
|
|
39
|
+
|
|
40
|
+
for (let j = 0; j < toolGroupToolNames.length; j++) {
|
|
41
|
+
const toolName = toolGroupToolNames[j];
|
|
42
|
+
const toolOptions = toolGroup.toolOptions[toolName];
|
|
43
|
+
|
|
44
|
+
const correctBinding =
|
|
45
|
+
toolOptions.bindings.length &&
|
|
46
|
+
/**
|
|
47
|
+
* TODO: setActiveTool treats MouseBindings.Primary in a special way
|
|
48
|
+
* which is analgous to numTouchPoints === 1 as the primary interaction
|
|
49
|
+
* for touch based applications. The ToolGroup set active and get active
|
|
50
|
+
* logic should be updated to account for numTouchPoints === 1
|
|
51
|
+
*/
|
|
52
|
+
toolOptions.bindings.some(
|
|
53
|
+
(binding) =>
|
|
54
|
+
(binding.numTouchPoints === numTouchPoints ||
|
|
55
|
+
(numTouchPoints === 1 &&
|
|
56
|
+
binding.mouseButton === MouseBindings.Primary)) &&
|
|
57
|
+
binding.modifierKey === modifierKey
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if (toolOptions.mode === Active && correctBinding) {
|
|
61
|
+
return toolGroup.getToolInstance(toolName);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { KeyboardBindings as kb } from '../../enums';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gets the mouse modifier key from a mouse event.
|
|
5
|
+
* Supports Shift, Ctrl, Alt, in singly and in combinations of 2
|
|
6
|
+
* Supports Meta singly.
|
|
7
|
+
*/
|
|
8
|
+
const getMouseModifierKey = (evt) => {
|
|
9
|
+
// The logic is a hard coded key mapping
|
|
10
|
+
if (evt.shiftKey) {
|
|
11
|
+
if (evt.ctrlKey) return kb.ShiftCtrl;
|
|
12
|
+
if (evt.altKey) return kb.ShiftAlt;
|
|
13
|
+
if (evt.metaKey) return kb.ShiftMeta;
|
|
14
|
+
return kb.Shift;
|
|
15
|
+
}
|
|
16
|
+
if (evt.ctrlKey) {
|
|
17
|
+
if (evt.altKey) return kb.CtrlAlt;
|
|
18
|
+
if (evt.metaKey) return kb.CtrlMeta;
|
|
19
|
+
return kb.Ctrl;
|
|
20
|
+
}
|
|
21
|
+
if (evt.altKey) {
|
|
22
|
+
return (evt.metaKey && kb.AltMeta) || kb.Alt;
|
|
23
|
+
}
|
|
24
|
+
if (evt.metaKey) {
|
|
25
|
+
kb.Meta;
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default getMouseModifierKey;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ToolGroupManager } from '../../store';
|
|
2
|
+
import { ToolModes } from '../../enums';
|
|
3
|
+
import { EventTypes } from '../../types';
|
|
4
|
+
|
|
5
|
+
type ModesFilter = Array<ToolModes>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Given the normalized mouse event and a filter of modes,
|
|
9
|
+
* find all the tools on the element that are in one of the specified modes.
|
|
10
|
+
* If the evtButton is specified, only tools with a matching binding will be returned.
|
|
11
|
+
* @param evt - The normalized mouseDown event.
|
|
12
|
+
* @param modesFilter - An array of entries from the `ToolModes` enum.
|
|
13
|
+
*/
|
|
14
|
+
export default function getToolsWithModesForMouseEvent(
|
|
15
|
+
evt: EventTypes.MouseMoveEventType,
|
|
16
|
+
modesFilter: ModesFilter,
|
|
17
|
+
evtButton?: any
|
|
18
|
+
) {
|
|
19
|
+
const { renderingEngineId, viewportId } = evt.detail;
|
|
20
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(
|
|
21
|
+
viewportId,
|
|
22
|
+
renderingEngineId
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (!toolGroup) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const enabledTools = [];
|
|
30
|
+
|
|
31
|
+
const toolGroupToolNames = Object.keys(toolGroup.toolOptions);
|
|
32
|
+
|
|
33
|
+
for (let j = 0; j < toolGroupToolNames.length; j++) {
|
|
34
|
+
const toolName = toolGroupToolNames[j];
|
|
35
|
+
const tool = toolGroup.toolOptions[toolName];
|
|
36
|
+
|
|
37
|
+
// tool has binding that matches the mouse button - we match those with
|
|
38
|
+
// any modifier keys too since they can be passively interacted with
|
|
39
|
+
const correctBinding =
|
|
40
|
+
evtButton != null && // not null or undefined
|
|
41
|
+
tool.bindings.length &&
|
|
42
|
+
tool.bindings.some((binding) => binding.mouseButton === evtButton);
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
modesFilter.includes(tool.mode) &&
|
|
46
|
+
// Should not filter by event's button
|
|
47
|
+
// or should, and the tool binding includes the event's button
|
|
48
|
+
(!evtButton || correctBinding)
|
|
49
|
+
) {
|
|
50
|
+
const toolInstance = toolGroup.getToolInstance(toolName);
|
|
51
|
+
enabledTools.push(toolInstance);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return enabledTools;
|
|
56
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ToolGroupManager } from '../../store';
|
|
2
|
+
import { ToolModes } from '../../enums';
|
|
3
|
+
import { EventTypes } from '../../types';
|
|
4
|
+
|
|
5
|
+
type ModesFilter = Array<ToolModes>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Given the normalized touch event and a filter of modes,
|
|
9
|
+
* find all the tools on the element that are in one of the specified modes.
|
|
10
|
+
* If the evtButton is specified, only tools with a matching binding will be returned.
|
|
11
|
+
* @param evt - The normalized touchStart event.
|
|
12
|
+
* @param modesFilter - An array of entries from the `ToolModes` enum.
|
|
13
|
+
*/
|
|
14
|
+
export default function getToolsWithModesForTouchEvent(
|
|
15
|
+
evt: EventTypes.NormalizedTouchEventType,
|
|
16
|
+
modesFilter: ModesFilter,
|
|
17
|
+
numTouchPoints?: number
|
|
18
|
+
) {
|
|
19
|
+
const { renderingEngineId, viewportId } = evt.detail;
|
|
20
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(
|
|
21
|
+
viewportId,
|
|
22
|
+
renderingEngineId
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (!toolGroup) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const enabledTools = [];
|
|
30
|
+
|
|
31
|
+
const toolGroupToolNames = Object.keys(toolGroup.toolOptions);
|
|
32
|
+
|
|
33
|
+
for (let j = 0; j < toolGroupToolNames.length; j++) {
|
|
34
|
+
const toolName = toolGroupToolNames[j];
|
|
35
|
+
const tool = toolGroup.toolOptions[toolName];
|
|
36
|
+
|
|
37
|
+
const correctBinding =
|
|
38
|
+
numTouchPoints != null &&
|
|
39
|
+
tool.bindings.length &&
|
|
40
|
+
tool.bindings.some(
|
|
41
|
+
(binding) => binding.numTouchPoints === numTouchPoints
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
modesFilter.includes(tool.mode) &&
|
|
46
|
+
(!numTouchPoints || correctBinding)
|
|
47
|
+
) {
|
|
48
|
+
const toolInstance = toolGroup.getToolInstance(toolName);
|
|
49
|
+
enabledTools.push(toolInstance);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return enabledTools;
|
|
54
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import touchStart from './touchStart';
|
|
2
|
+
import touchStartActivate from './touchStartActivate';
|
|
3
|
+
import touchDrag from './touchDrag';
|
|
4
|
+
import touchEnd from './touchEnd';
|
|
5
|
+
import touchTap from './touchTap';
|
|
6
|
+
import touchPress from './touchPress';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
touchStart,
|
|
10
|
+
touchStartActivate,
|
|
11
|
+
touchDrag,
|
|
12
|
+
touchEnd,
|
|
13
|
+
touchTap,
|
|
14
|
+
touchPress,
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import getActiveToolForTouchEvent from '../shared/getActiveToolForTouchEvent';
|
|
2
|
+
import { state } from '../../store';
|
|
3
|
+
import { TouchDragEventType } from '../../types/EventTypes';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* touchDrag - Event handler for touchDrag events. Uses `customCallbackHandler` to fire
|
|
7
|
+
* the `touchDragCallback` function on active tools.
|
|
8
|
+
*/
|
|
9
|
+
export default function touchDrag(evt: TouchDragEventType) {
|
|
10
|
+
if (state.isInteractingWithTool) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const activeTool = getActiveToolForTouchEvent(evt);
|
|
15
|
+
|
|
16
|
+
const noFoundToolOrDoesNotHaveTouchDragCallback =
|
|
17
|
+
!activeTool || typeof activeTool.touchDragCallback !== 'function';
|
|
18
|
+
if (noFoundToolOrDoesNotHaveTouchDragCallback) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
activeTool.touchDragCallback(evt);
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import customCallbackHandler from '../shared/customCallbackHandler';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* touchEnd - Event handler for touchEnd events. Uses `customCallbackHandler` to fire
|
|
5
|
+
* the `touchEndCallback` function on active tools.
|
|
6
|
+
*/
|
|
7
|
+
const touchEnd = customCallbackHandler.bind(null, 'Touch', 'touchEndCallback');
|
|
8
|
+
|
|
9
|
+
export default touchEnd;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import customCallbackHandler from '../shared/customCallbackHandler';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* touchPress - Event handler for touch press events. Uses `customCallbackHandler` to fire
|
|
5
|
+
* the `touchPressCallback` function on active tools.
|
|
6
|
+
*/
|
|
7
|
+
const touchPress = customCallbackHandler.bind(
|
|
8
|
+
null,
|
|
9
|
+
'Touch',
|
|
10
|
+
'touchPressCallback'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default touchPress;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { state } from '../../store';
|
|
2
|
+
import { ToolModes } from '../../enums';
|
|
3
|
+
import { EventTypes } from '../../types';
|
|
4
|
+
import {
|
|
5
|
+
ToolAnnotationPair,
|
|
6
|
+
ToolsWithMoveableHandles,
|
|
7
|
+
} from '../../types/InternalToolTypes';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
setAnnotationSelected,
|
|
11
|
+
isAnnotationSelected,
|
|
12
|
+
} from '../../stateManagement/annotation/annotationSelection';
|
|
13
|
+
|
|
14
|
+
import { isAnnotationLocked } from '../../stateManagement/annotation/annotationLocking';
|
|
15
|
+
import { isAnnotationVisible } from '../../stateManagement/annotation/annotationVisibility';
|
|
16
|
+
|
|
17
|
+
// Util
|
|
18
|
+
import filterToolsWithMoveableHandles from '../../store/filterToolsWithMoveableHandles';
|
|
19
|
+
import filterToolsWithAnnotationsForElement from '../../store/filterToolsWithAnnotationsForElement';
|
|
20
|
+
import filterMoveableAnnotationTools from '../../store/filterMoveableAnnotationTools';
|
|
21
|
+
import getActiveToolForTouchEvent from '../shared/getActiveToolForTouchEvent';
|
|
22
|
+
import getToolsWithModesForTouchEvent from '../shared/getToolsWithModesForTouchEvent';
|
|
23
|
+
|
|
24
|
+
const { Active, Passive } = ToolModes;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* touchStart - Event handler for touchStart events. Uses `customCallbackHandler` to fire
|
|
28
|
+
* the `touchStartCallback` function on active tools.
|
|
29
|
+
*/
|
|
30
|
+
export default function touchStart(evt: EventTypes.TouchStartEventType) {
|
|
31
|
+
if (state.isInteractingWithTool) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const activeTool = getActiveToolForTouchEvent(evt);
|
|
35
|
+
|
|
36
|
+
// Check for preTouchStartCallbacks,
|
|
37
|
+
// If the tool claims it consumed the event, prevent further checks.
|
|
38
|
+
if (activeTool && typeof activeTool.preTouchStartCallback === 'function') {
|
|
39
|
+
const consumedEvent = activeTool.preTouchStartCallback(evt);
|
|
40
|
+
|
|
41
|
+
if (consumedEvent) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const isPrimaryClick = Object.keys(evt.detail.event.touches).length === 1;
|
|
47
|
+
const activeToolsWithEventBinding = getToolsWithModesForTouchEvent(
|
|
48
|
+
evt,
|
|
49
|
+
[Active],
|
|
50
|
+
Object.keys(evt.detail.event.touches).length
|
|
51
|
+
);
|
|
52
|
+
const passiveToolsIfEventWasPrimaryTouchButton = isPrimaryClick
|
|
53
|
+
? getToolsWithModesForTouchEvent(evt, [Passive])
|
|
54
|
+
: undefined;
|
|
55
|
+
const applicableTools = [
|
|
56
|
+
...(activeToolsWithEventBinding || []),
|
|
57
|
+
...(passiveToolsIfEventWasPrimaryTouchButton || []),
|
|
58
|
+
activeTool,
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const eventDetail = evt.detail;
|
|
62
|
+
const { element } = eventDetail;
|
|
63
|
+
|
|
64
|
+
// Filter tools with annotations for this element
|
|
65
|
+
const annotationToolsWithAnnotations = filterToolsWithAnnotationsForElement(
|
|
66
|
+
element,
|
|
67
|
+
applicableTools
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const canvasCoords = eventDetail.currentPoints.canvas;
|
|
71
|
+
|
|
72
|
+
// For the canvas coordinates, find all tools that might respond to this touch start
|
|
73
|
+
// on their handles. This filter will call getHandleNearImagePoint for each tool
|
|
74
|
+
// instance (each annotation)
|
|
75
|
+
const annotationToolsWithMoveableHandles = filterToolsWithMoveableHandles(
|
|
76
|
+
element,
|
|
77
|
+
annotationToolsWithAnnotations,
|
|
78
|
+
canvasCoords,
|
|
79
|
+
'touch'
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const isMultiSelect = false;
|
|
83
|
+
|
|
84
|
+
// If there are annotation tools whose handle is near the touch, select the first one
|
|
85
|
+
// that isn't locked. If there's only one annotation tool, select it.
|
|
86
|
+
if (annotationToolsWithMoveableHandles.length > 0) {
|
|
87
|
+
const { tool, annotation, handle } = getAnnotationForSelection(
|
|
88
|
+
annotationToolsWithMoveableHandles
|
|
89
|
+
) as ToolsWithMoveableHandles;
|
|
90
|
+
|
|
91
|
+
toggleAnnotationSelection(annotation.annotationUID, isMultiSelect);
|
|
92
|
+
tool.handleSelectedCallback(evt, annotation, handle, 'Touch');
|
|
93
|
+
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// If there were no annotation tools whose handle was near the touch, try to check
|
|
98
|
+
// if any of the annotation tools are interactable (e.g. moving an entire length annotation)
|
|
99
|
+
const moveableAnnotationTools = filterMoveableAnnotationTools(
|
|
100
|
+
element,
|
|
101
|
+
annotationToolsWithAnnotations,
|
|
102
|
+
canvasCoords,
|
|
103
|
+
'touch'
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
// If there are annotation tools that are interactable, select the first one
|
|
107
|
+
// that isn't locked. If there's only one annotation tool, select it.
|
|
108
|
+
if (moveableAnnotationTools.length > 0) {
|
|
109
|
+
const { tool, annotation } = getAnnotationForSelection(
|
|
110
|
+
moveableAnnotationTools
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
toggleAnnotationSelection(annotation.annotationUID, isMultiSelect);
|
|
114
|
+
tool.toolSelectedCallback(evt, annotation, 'Touch');
|
|
115
|
+
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Run the postTouchStartCallback for the active tool if it exists
|
|
120
|
+
if (activeTool && typeof activeTool.postTouchStartCallback === 'function') {
|
|
121
|
+
const consumedEvent = activeTool.postTouchStartCallback(evt);
|
|
122
|
+
|
|
123
|
+
if (consumedEvent) {
|
|
124
|
+
// If the tool claims it consumed the event, prevent further checks.
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Don't stop propagation so that touchStartActivate can handle the event
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* If there are multiple annotation tools, return the first one that isn't locked neither hidden.
|
|
134
|
+
* If there's only one annotation tool, return it
|
|
135
|
+
* @param annotationTools - An array of tools and annotation.
|
|
136
|
+
* @returns The candidate for selection
|
|
137
|
+
*/
|
|
138
|
+
function getAnnotationForSelection(
|
|
139
|
+
toolsWithMovableHandles: ToolAnnotationPair[]
|
|
140
|
+
): ToolAnnotationPair {
|
|
141
|
+
return (
|
|
142
|
+
(toolsWithMovableHandles.length > 1 &&
|
|
143
|
+
toolsWithMovableHandles.find(
|
|
144
|
+
(item) =>
|
|
145
|
+
!isAnnotationLocked(item.annotation) &&
|
|
146
|
+
isAnnotationVisible(item.annotation.annotationUID)
|
|
147
|
+
)) ||
|
|
148
|
+
toolsWithMovableHandles[0]
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* If the annotation is selected, deselect it. If it's not selected, select it
|
|
154
|
+
* @param annotationUID - The AnnotationUID that we
|
|
155
|
+
* want to toggle the selection of.
|
|
156
|
+
* @param isMultiSelect - If true, the annotation. will be deselected if it is
|
|
157
|
+
* already selected, or deselected if it is selected.
|
|
158
|
+
*/
|
|
159
|
+
function toggleAnnotationSelection(
|
|
160
|
+
annotationUID: string,
|
|
161
|
+
isMultiSelect = false
|
|
162
|
+
): void {
|
|
163
|
+
if (isMultiSelect) {
|
|
164
|
+
if (isAnnotationSelected(annotationUID)) {
|
|
165
|
+
setAnnotationSelected(annotationUID, false);
|
|
166
|
+
} else {
|
|
167
|
+
const preserveSelected = true;
|
|
168
|
+
setAnnotationSelected(annotationUID, true, preserveSelected);
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
const preserveSelected = false;
|
|
172
|
+
setAnnotationSelected(annotationUID, true, preserveSelected);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { state } from '../../store';
|
|
2
|
+
import { EventTypes } from '../../types';
|
|
3
|
+
import { setAnnotationSelected } from '../../stateManagement/annotation/annotationSelection';
|
|
4
|
+
|
|
5
|
+
import getActiveToolForTouchEvent from '../shared/getActiveToolForTouchEvent';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* If the `touchStart` handler does not consume an event,
|
|
9
|
+
* activate the creation loop of the active tool, if one is found for the
|
|
10
|
+
* touch button pressed.
|
|
11
|
+
*
|
|
12
|
+
* @param evt - The normalized touchStart event.
|
|
13
|
+
*/
|
|
14
|
+
export default function touchStartActivate(
|
|
15
|
+
evt: EventTypes.TouchStartActivateEventType
|
|
16
|
+
) {
|
|
17
|
+
// If a tool has locked the current state it is dealing with an interaction within its own eventLoop.
|
|
18
|
+
if (state.isInteractingWithTool) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const activeTool = getActiveToolForTouchEvent(evt);
|
|
23
|
+
|
|
24
|
+
if (!activeTool) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (state.isMultiPartToolActive) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (activeTool.addNewAnnotation) {
|
|
33
|
+
const annotation = activeTool.addNewAnnotation(evt, 'touch');
|
|
34
|
+
setAnnotationSelected(annotation.annotationUID);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import customCallbackHandler from '../shared/customCallbackHandler';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* touchTap - Event handler for touch tap events. Uses `customCallbackHandler` to fire
|
|
5
|
+
* the `touchTapCallback` function on active tools.
|
|
6
|
+
*/
|
|
7
|
+
const touchTap = customCallbackHandler.bind(null, 'Touch', 'touchTapCallback');
|
|
8
|
+
|
|
9
|
+
export default touchTap;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Events from '../enums/Events';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
touchStart,
|
|
5
|
+
touchStartActivate,
|
|
6
|
+
touchDrag,
|
|
7
|
+
touchEnd,
|
|
8
|
+
touchTap,
|
|
9
|
+
touchPress,
|
|
10
|
+
} from './touchEventHandlers';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Enable these listeners are emitted in order, and can be cancelled/prevented from bubbling
|
|
14
|
+
* by any previous event.
|
|
15
|
+
*
|
|
16
|
+
* @param element - The element to add the event listeners to.
|
|
17
|
+
*/
|
|
18
|
+
const enable = function (element: HTMLDivElement): void {
|
|
19
|
+
element.addEventListener(Events.TOUCH_START, touchStart as EventListener);
|
|
20
|
+
element.addEventListener(
|
|
21
|
+
Events.TOUCH_START_ACTIVATE,
|
|
22
|
+
touchStartActivate as EventListener
|
|
23
|
+
);
|
|
24
|
+
element.addEventListener(Events.TOUCH_DRAG, touchDrag as EventListener);
|
|
25
|
+
element.addEventListener(Events.TOUCH_END, touchEnd as EventListener);
|
|
26
|
+
element.addEventListener(Events.TOUCH_TAP, touchTap as EventListener);
|
|
27
|
+
element.addEventListener(Events.TOUCH_PRESS, touchPress as EventListener);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Disable and Remove the MouseToolEventDispatcher handlers from the element.
|
|
32
|
+
*
|
|
33
|
+
* @param element - HTMLDivElement
|
|
34
|
+
*/
|
|
35
|
+
const disable = function (element: HTMLDivElement) {
|
|
36
|
+
element.removeEventListener(Events.TOUCH_START, touchStart as EventListener);
|
|
37
|
+
element.removeEventListener(
|
|
38
|
+
Events.TOUCH_START_ACTIVATE,
|
|
39
|
+
touchStartActivate as EventListener
|
|
40
|
+
);
|
|
41
|
+
element.removeEventListener(Events.TOUCH_DRAG, touchDrag as EventListener);
|
|
42
|
+
element.removeEventListener(Events.TOUCH_END, touchEnd as EventListener);
|
|
43
|
+
element.removeEventListener(Events.TOUCH_PRESS, touchPress as EventListener);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const touchToolEventDispatcher = {
|
|
47
|
+
enable,
|
|
48
|
+
disable,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default touchToolEventDispatcher;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getRenderingEngine } from '@cornerstonejs/core';
|
|
2
|
+
import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This is a callback function that is called when an annotation is modified.
|
|
6
|
+
* Since we are throttling the cachedStats calculation for annotation tools,
|
|
7
|
+
* we need to trigger a final render for the annotation. so that the annotation
|
|
8
|
+
* textBox is updated.
|
|
9
|
+
* Todo: This will trigger all the annotation tools to re-render, although DOM
|
|
10
|
+
* will update those that have changed, but more efficient would be to only
|
|
11
|
+
* update the changed annotation.
|
|
12
|
+
* Todo: A better way is to extract the textBox render logic from the renderAnnotation
|
|
13
|
+
* of all tools and just trigger a render for that (instead of the entire annotation., even if
|
|
14
|
+
* no svg update happens since the attributes for handles are the same)
|
|
15
|
+
*/
|
|
16
|
+
function annotationModifiedListener(evt): void {
|
|
17
|
+
const { viewportId, renderingEngineId } = evt.detail;
|
|
18
|
+
const renderingEngine = getRenderingEngine(renderingEngineId);
|
|
19
|
+
triggerAnnotationRenderForViewportIds(renderingEngine, [viewportId]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default annotationModifiedListener;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getRenderingEngines } from '@cornerstonejs/core';
|
|
2
|
+
import { triggerAnnotationRenderForViewportIds } from '../../utilities';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* When an annotation is deselected, trigger an annotation render for all viewports.
|
|
6
|
+
* The reason for this is that, drawing an annotation in a different viewport
|
|
7
|
+
* should deselect all other annotations in other viewports. In order to achieve
|
|
8
|
+
* this, we need to trigger an annotation render for all viewports.
|
|
9
|
+
* Todo: Although this is inefficient, but since annotations are only rendered if necessary,
|
|
10
|
+
* it's probably not going to have a noticeable impact on performance.
|
|
11
|
+
* @param evt - The event object.
|
|
12
|
+
*/
|
|
13
|
+
function annotationSelectionListener(evt): void {
|
|
14
|
+
const deselectedAnnotation = evt.detail.removed;
|
|
15
|
+
|
|
16
|
+
if (!deselectedAnnotation.length) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const renderingEngines = getRenderingEngines();
|
|
21
|
+
|
|
22
|
+
renderingEngines.forEach((renderingEngine) => {
|
|
23
|
+
const viewports = renderingEngine.getViewports();
|
|
24
|
+
const viewportIds = viewports.map((vp) => vp.id);
|
|
25
|
+
triggerAnnotationRenderForViewportIds(renderingEngine, viewportIds);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default annotationSelectionListener;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import mouseEventListeners from './mouse';
|
|
2
|
+
import touchEventListeners from './touch';
|
|
3
|
+
import wheelEventListener from './wheel';
|
|
4
|
+
import keyEventListener from './keyboard';
|
|
5
|
+
import {
|
|
6
|
+
segmentationDataModifiedEventListener,
|
|
7
|
+
segmentationRepresentationModifiedEventListener,
|
|
8
|
+
segmentationRepresentationRemovedEventListener,
|
|
9
|
+
segmentationModifiedListener,
|
|
10
|
+
} from './segmentation';
|
|
11
|
+
import {
|
|
12
|
+
annotationSelectionListener,
|
|
13
|
+
annotationModifiedListener,
|
|
14
|
+
} from './annotations';
|
|
15
|
+
//import touchEventListeners from './touchEventListeners';
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
mouseEventListeners,
|
|
19
|
+
touchEventListeners,
|
|
20
|
+
wheelEventListener,
|
|
21
|
+
keyEventListener,
|
|
22
|
+
segmentationRepresentationModifiedEventListener,
|
|
23
|
+
segmentationModifiedListener,
|
|
24
|
+
segmentationRepresentationRemovedEventListener,
|
|
25
|
+
segmentationDataModifiedEventListener,
|
|
26
|
+
annotationSelectionListener,
|
|
27
|
+
annotationModifiedListener,
|
|
28
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import keyDownListener, { getModifierKey } from './keyDownListener';
|
|
2
|
+
|
|
3
|
+
function enable(element: HTMLDivElement): void {
|
|
4
|
+
disable(element);
|
|
5
|
+
element.addEventListener('keydown', keyDownListener);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function disable(element: HTMLDivElement): void {
|
|
9
|
+
element.removeEventListener('keydown', keyDownListener);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
enable,
|
|
14
|
+
disable,
|
|
15
|
+
getModifierKey,
|
|
16
|
+
};
|