@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,84 @@
|
|
|
1
|
+
import { BaseTool, AnnotationTool } from './base';
|
|
2
|
+
import PanTool from './PanTool';
|
|
3
|
+
import TrackballRotateTool from './TrackballRotateTool';
|
|
4
|
+
import WindowLevelTool from './WindowLevelTool';
|
|
5
|
+
import StackScrollTool from './StackScrollTool';
|
|
6
|
+
import PlanarRotateTool from './PlanarRotateTool';
|
|
7
|
+
import StackScrollMouseWheelTool from './StackScrollToolMouseWheelTool';
|
|
8
|
+
import ZoomTool from './ZoomTool';
|
|
9
|
+
import VolumeRotateMouseWheelTool from './VolumeRotateMouseWheelTool';
|
|
10
|
+
import MIPJumpToClickTool from './MIPJumpToClickTool';
|
|
11
|
+
import CrosshairsTool from './CrosshairsTool';
|
|
12
|
+
import MagnifyTool from './MagnifyTool';
|
|
13
|
+
import ReferenceLinesTool from './ReferenceLinesTool';
|
|
14
|
+
//
|
|
15
|
+
import BidirectionalTool from './annotation/BidirectionalTool';
|
|
16
|
+
import LengthTool from './annotation/LengthTool';
|
|
17
|
+
import ProbeTool from './annotation/ProbeTool';
|
|
18
|
+
import DragProbeTool from './annotation/DragProbeTool';
|
|
19
|
+
import RectangleROITool from './annotation/RectangleROITool';
|
|
20
|
+
import EllipticalROITool from './annotation/EllipticalROITool';
|
|
21
|
+
import CircleROITool from './annotation/CircleROITool';
|
|
22
|
+
import PlanarFreehandROITool from './annotation/PlanarFreehandROITool';
|
|
23
|
+
import ArrowAnnotateTool from './annotation/ArrowAnnotateTool';
|
|
24
|
+
import AngleTool from './annotation/AngleTool';
|
|
25
|
+
import CobbAngleTool from './annotation/CobbAngleTool';
|
|
26
|
+
import ReferenceCursors from './ReferenceCursors';
|
|
27
|
+
import ReferenceLines from './ReferenceLinesTool';
|
|
28
|
+
import ScaleOverlayTool from './ScaleOverlayTool';
|
|
29
|
+
|
|
30
|
+
// Segmentation DisplayTool
|
|
31
|
+
import SegmentationDisplayTool from './displayTools/SegmentationDisplayTool';
|
|
32
|
+
|
|
33
|
+
// Segmentation Tools
|
|
34
|
+
import RectangleScissorsTool from './segmentation/RectangleScissorsTool';
|
|
35
|
+
import CircleScissorsTool from './segmentation/CircleScissorsTool';
|
|
36
|
+
import SphereScissorsTool from './segmentation/SphereScissorsTool';
|
|
37
|
+
import RectangleROIThresholdTool from './segmentation/RectangleROIThresholdTool';
|
|
38
|
+
import RectangleROIStartEndThresholdTool from './segmentation/RectangleROIStartEndThresholdTool';
|
|
39
|
+
import BrushTool from './segmentation/BrushTool';
|
|
40
|
+
import PaintFillTool from './segmentation/PaintFillTool';
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
// ~~ BASE
|
|
44
|
+
BaseTool,
|
|
45
|
+
AnnotationTool,
|
|
46
|
+
// Manipulation Tools
|
|
47
|
+
PanTool,
|
|
48
|
+
TrackballRotateTool,
|
|
49
|
+
DragProbeTool,
|
|
50
|
+
WindowLevelTool,
|
|
51
|
+
StackScrollTool,
|
|
52
|
+
PlanarRotateTool,
|
|
53
|
+
StackScrollMouseWheelTool,
|
|
54
|
+
ZoomTool,
|
|
55
|
+
VolumeRotateMouseWheelTool,
|
|
56
|
+
MIPJumpToClickTool,
|
|
57
|
+
// Annotation Tools
|
|
58
|
+
CrosshairsTool,
|
|
59
|
+
ReferenceLinesTool,
|
|
60
|
+
BidirectionalTool,
|
|
61
|
+
LengthTool,
|
|
62
|
+
ProbeTool,
|
|
63
|
+
RectangleROITool,
|
|
64
|
+
EllipticalROITool,
|
|
65
|
+
CircleROITool,
|
|
66
|
+
PlanarFreehandROITool,
|
|
67
|
+
ArrowAnnotateTool,
|
|
68
|
+
AngleTool,
|
|
69
|
+
CobbAngleTool,
|
|
70
|
+
ReferenceCursors,
|
|
71
|
+
// Segmentations Display
|
|
72
|
+
SegmentationDisplayTool,
|
|
73
|
+
// Segmentations Tools
|
|
74
|
+
RectangleScissorsTool,
|
|
75
|
+
CircleScissorsTool,
|
|
76
|
+
SphereScissorsTool,
|
|
77
|
+
RectangleROIThresholdTool,
|
|
78
|
+
RectangleROIStartEndThresholdTool,
|
|
79
|
+
BrushTool,
|
|
80
|
+
MagnifyTool,
|
|
81
|
+
ReferenceLines,
|
|
82
|
+
PaintFillTool,
|
|
83
|
+
ScaleOverlayTool,
|
|
84
|
+
};
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { cache, getEnabledElement, StackViewport } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
import type { Types } from '@cornerstonejs/core';
|
|
4
|
+
import type {
|
|
5
|
+
PublicToolProps,
|
|
6
|
+
ToolProps,
|
|
7
|
+
EventTypes,
|
|
8
|
+
SVGDrawingHelper,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
import { BaseTool } from '../base';
|
|
11
|
+
import { fillInsideSphere } from './strategies/fillSphere';
|
|
12
|
+
import { eraseInsideSphere } from './strategies/eraseSphere';
|
|
13
|
+
import {
|
|
14
|
+
thresholdInsideCircle,
|
|
15
|
+
fillInsideCircle,
|
|
16
|
+
} from './strategies/fillCircle';
|
|
17
|
+
import { eraseInsideCircle } from './strategies/eraseCircle';
|
|
18
|
+
import { Events, ToolModes } from '../../enums';
|
|
19
|
+
import { drawCircle as drawCircleSvg } from '../../drawingSvg';
|
|
20
|
+
import {
|
|
21
|
+
resetElementCursor,
|
|
22
|
+
hideElementCursor,
|
|
23
|
+
} from '../../cursors/elementCursor';
|
|
24
|
+
|
|
25
|
+
import triggerAnnotationRenderForViewportUIDs from '../../utilities/triggerAnnotationRenderForViewportIds';
|
|
26
|
+
import {
|
|
27
|
+
config as segmentationConfig,
|
|
28
|
+
segmentLocking,
|
|
29
|
+
segmentIndex as segmentIndexController,
|
|
30
|
+
state as segmentationState,
|
|
31
|
+
activeSegmentation,
|
|
32
|
+
} from '../../stateManagement/segmentation';
|
|
33
|
+
import { LabelmapSegmentationData } from '../../types/LabelmapTypes';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
class BrushTool extends BaseTool {
|
|
39
|
+
static toolName;
|
|
40
|
+
private _editData: {
|
|
41
|
+
segmentation: Types.IImageVolume;
|
|
42
|
+
imageVolume: Types.IImageVolume; //
|
|
43
|
+
segmentsLocked: number[]; //
|
|
44
|
+
} | null;
|
|
45
|
+
private _hoverData?: {
|
|
46
|
+
brushCursor: any;
|
|
47
|
+
segmentationId: string;
|
|
48
|
+
segmentIndex: number;
|
|
49
|
+
segmentationRepresentationUID: string;
|
|
50
|
+
segmentColor: [number, number, number, number];
|
|
51
|
+
viewportIdsToRender: string[];
|
|
52
|
+
centerCanvas?: Array<number>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
constructor(
|
|
56
|
+
toolProps: PublicToolProps = {},
|
|
57
|
+
defaultToolProps: ToolProps = {
|
|
58
|
+
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
59
|
+
configuration: {
|
|
60
|
+
strategies: {
|
|
61
|
+
FILL_INSIDE_CIRCLE: fillInsideCircle,
|
|
62
|
+
THRESHOLD_INSIDE_CIRCLE: thresholdInsideCircle,
|
|
63
|
+
ERASE_INSIDE_CIRCLE: eraseInsideCircle,
|
|
64
|
+
FILL_INSIDE_SPHERE: fillInsideSphere,
|
|
65
|
+
ERASE_INSIDE_SPHERE: eraseInsideSphere,
|
|
66
|
+
},
|
|
67
|
+
strategySpecificConfiguration: {
|
|
68
|
+
THRESHOLD_INSIDE_CIRCLE: {
|
|
69
|
+
threshold: [-150, -70], // E.g. CT Fat // Only used during threshold strategies.
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
defaultStrategy: 'FILL_INSIDE_CIRCLE',
|
|
73
|
+
activeStrategy: 'FILL_INSIDE_CIRCLE',
|
|
74
|
+
brushSize: 25,
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
) {
|
|
78
|
+
super(toolProps, defaultToolProps);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
onSetToolPassive = () => {
|
|
82
|
+
this.disableCursor();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
onSetToolEnabled = () => {
|
|
86
|
+
this.disableCursor();
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
onSetToolDisabled = () => {
|
|
90
|
+
this.disableCursor();
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
private disableCursor() {
|
|
94
|
+
this._hoverData = undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
preMouseDownCallback = (
|
|
98
|
+
evt: EventTypes.MouseDownActivateEventType
|
|
99
|
+
): boolean => {
|
|
100
|
+
const eventData = evt.detail;
|
|
101
|
+
const { element } = eventData;
|
|
102
|
+
|
|
103
|
+
const enabledElement = getEnabledElement(element);
|
|
104
|
+
const { viewport, renderingEngine } = enabledElement;
|
|
105
|
+
|
|
106
|
+
if (viewport instanceof StackViewport) {
|
|
107
|
+
throw new Error('Not implemented yet');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const toolGroupId = this.toolGroupId;
|
|
111
|
+
|
|
112
|
+
const activeSegmentationRepresentation =
|
|
113
|
+
activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
|
|
114
|
+
if (!activeSegmentationRepresentation) {
|
|
115
|
+
throw new Error(
|
|
116
|
+
'No active segmentation detected, create one before using the brush tool'
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const { segmentationId, type } = activeSegmentationRepresentation;
|
|
121
|
+
const segmentsLocked = segmentLocking.getLockedSegments(segmentationId);
|
|
122
|
+
|
|
123
|
+
const { representationData } =
|
|
124
|
+
segmentationState.getSegmentation(segmentationId);
|
|
125
|
+
|
|
126
|
+
// Todo: are we going to support contour editing with this tool?
|
|
127
|
+
const { volumeId } = representationData[type] as LabelmapSegmentationData;
|
|
128
|
+
const segmentation = cache.getVolume(volumeId);
|
|
129
|
+
|
|
130
|
+
const actors = viewport.getActors();
|
|
131
|
+
|
|
132
|
+
// Note: For tools that need the source data. Assumed to use
|
|
133
|
+
// First volume actor for now.
|
|
134
|
+
const firstVolumeActorUID = actors[0].uid;
|
|
135
|
+
const imageVolume = cache.getVolume(firstVolumeActorUID);
|
|
136
|
+
|
|
137
|
+
const viewportIdsToRender = [viewport.id];
|
|
138
|
+
|
|
139
|
+
this._editData = {
|
|
140
|
+
segmentation,
|
|
141
|
+
imageVolume,
|
|
142
|
+
segmentsLocked,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
this._activateDraw(element);
|
|
146
|
+
|
|
147
|
+
hideElementCursor(element);
|
|
148
|
+
|
|
149
|
+
evt.preventDefault();
|
|
150
|
+
|
|
151
|
+
triggerAnnotationRenderForViewportUIDs(
|
|
152
|
+
renderingEngine,
|
|
153
|
+
viewportIdsToRender
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return true;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
mouseMoveCallback = (evt: EventTypes.InteractionEventType): void => {
|
|
160
|
+
if (this.mode === ToolModes.Active) {
|
|
161
|
+
this.updateCursor(evt);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
private updateCursor(evt: EventTypes.InteractionEventType) {
|
|
166
|
+
const eventData = evt.detail;
|
|
167
|
+
const { element } = eventData;
|
|
168
|
+
const { currentPoints } = eventData;
|
|
169
|
+
const centerCanvas = currentPoints.canvas;
|
|
170
|
+
const enabledElement = getEnabledElement(element);
|
|
171
|
+
const { renderingEngine, viewport } = enabledElement;
|
|
172
|
+
|
|
173
|
+
const camera = viewport.getCamera();
|
|
174
|
+
const { viewPlaneNormal, viewUp } = camera;
|
|
175
|
+
|
|
176
|
+
const toolGroupId = this.toolGroupId;
|
|
177
|
+
|
|
178
|
+
const activeSegmentationRepresentation =
|
|
179
|
+
activeSegmentation.getActiveSegmentationRepresentation(toolGroupId);
|
|
180
|
+
if (!activeSegmentationRepresentation) {
|
|
181
|
+
console.warn(
|
|
182
|
+
'No active segmentation detected, create one before using the brush tool'
|
|
183
|
+
);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const { segmentationRepresentationUID, segmentationId } =
|
|
188
|
+
activeSegmentationRepresentation;
|
|
189
|
+
const segmentIndex =
|
|
190
|
+
segmentIndexController.getActiveSegmentIndex(segmentationId);
|
|
191
|
+
|
|
192
|
+
const segmentColor = segmentationConfig.color.getColorForSegmentIndex(
|
|
193
|
+
toolGroupId,
|
|
194
|
+
segmentationRepresentationUID,
|
|
195
|
+
segmentIndex
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const viewportIdsToRender = [viewport.id];
|
|
199
|
+
|
|
200
|
+
// Center of circle in canvas Coordinates
|
|
201
|
+
|
|
202
|
+
const brushCursor = {
|
|
203
|
+
metadata: {
|
|
204
|
+
viewPlaneNormal: <Types.Point3>[...viewPlaneNormal],
|
|
205
|
+
viewUp: <Types.Point3>[...viewUp],
|
|
206
|
+
FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
|
|
207
|
+
referencedImageId: '',
|
|
208
|
+
toolName: this.getToolName(),
|
|
209
|
+
segmentColor,
|
|
210
|
+
},
|
|
211
|
+
data: {},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
this._hoverData = {
|
|
215
|
+
brushCursor,
|
|
216
|
+
centerCanvas,
|
|
217
|
+
segmentIndex,
|
|
218
|
+
segmentationId,
|
|
219
|
+
segmentationRepresentationUID,
|
|
220
|
+
segmentColor,
|
|
221
|
+
viewportIdsToRender,
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
this._calculateCursor(element, centerCanvas);
|
|
225
|
+
|
|
226
|
+
triggerAnnotationRenderForViewportUIDs(
|
|
227
|
+
renderingEngine,
|
|
228
|
+
viewportIdsToRender
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private _dragCallback = (evt: EventTypes.InteractionEventType): void => {
|
|
233
|
+
const eventData = evt.detail;
|
|
234
|
+
const { element } = eventData;
|
|
235
|
+
const enabledElement = getEnabledElement(element);
|
|
236
|
+
const { renderingEngine } = enabledElement;
|
|
237
|
+
|
|
238
|
+
const { imageVolume, segmentation, segmentsLocked } = this._editData;
|
|
239
|
+
|
|
240
|
+
this.updateCursor(evt);
|
|
241
|
+
|
|
242
|
+
const {
|
|
243
|
+
segmentIndex,
|
|
244
|
+
segmentationId,
|
|
245
|
+
segmentationRepresentationUID,
|
|
246
|
+
brushCursor,
|
|
247
|
+
viewportIdsToRender,
|
|
248
|
+
} = this._hoverData;
|
|
249
|
+
|
|
250
|
+
const { data } = brushCursor;
|
|
251
|
+
const { viewPlaneNormal, viewUp } = brushCursor.metadata;
|
|
252
|
+
|
|
253
|
+
triggerAnnotationRenderForViewportUIDs(
|
|
254
|
+
renderingEngine,
|
|
255
|
+
viewportIdsToRender
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
const operationData = {
|
|
259
|
+
points: data.handles.points,
|
|
260
|
+
volume: segmentation, // todo: just pass the segmentationId instead
|
|
261
|
+
imageVolume,
|
|
262
|
+
segmentIndex,
|
|
263
|
+
segmentsLocked,
|
|
264
|
+
viewPlaneNormal,
|
|
265
|
+
toolGroupId: this.toolGroupId,
|
|
266
|
+
segmentationId,
|
|
267
|
+
segmentationRepresentationUID,
|
|
268
|
+
viewUp,
|
|
269
|
+
strategySpecificConfiguration:
|
|
270
|
+
this.configuration.strategySpecificConfiguration,
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
this.applyActiveStrategy(enabledElement, operationData);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
private _calculateCursor(element, centerCanvas) {
|
|
277
|
+
const enabledElement = getEnabledElement(element);
|
|
278
|
+
const { viewport } = enabledElement;
|
|
279
|
+
const { canvasToWorld } = viewport;
|
|
280
|
+
const { brushSize } = this.configuration;
|
|
281
|
+
// Center of circle in canvas Coordinates
|
|
282
|
+
|
|
283
|
+
const radius = brushSize;
|
|
284
|
+
|
|
285
|
+
const bottomCanvas: Types.Point2 = [
|
|
286
|
+
centerCanvas[0],
|
|
287
|
+
centerCanvas[1] + radius,
|
|
288
|
+
];
|
|
289
|
+
const topCanvas: Types.Point2 = [centerCanvas[0], centerCanvas[1] - radius];
|
|
290
|
+
const leftCanvas: Types.Point2 = [
|
|
291
|
+
centerCanvas[0] - radius,
|
|
292
|
+
centerCanvas[1],
|
|
293
|
+
];
|
|
294
|
+
const rightCanvas: Types.Point2 = [
|
|
295
|
+
centerCanvas[0] + radius,
|
|
296
|
+
centerCanvas[1],
|
|
297
|
+
];
|
|
298
|
+
|
|
299
|
+
const { brushCursor } = this._hoverData;
|
|
300
|
+
const { data } = brushCursor;
|
|
301
|
+
|
|
302
|
+
if (data.handles === undefined) {
|
|
303
|
+
data.handles = {};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
data.handles.points = [
|
|
307
|
+
canvasToWorld(bottomCanvas),
|
|
308
|
+
canvasToWorld(topCanvas),
|
|
309
|
+
canvasToWorld(leftCanvas),
|
|
310
|
+
canvasToWorld(rightCanvas),
|
|
311
|
+
];
|
|
312
|
+
|
|
313
|
+
data.invalidated = false;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
private _endCallback = (evt: EventTypes.InteractionEventType): void => {
|
|
317
|
+
const eventData = evt.detail;
|
|
318
|
+
const { element } = eventData;
|
|
319
|
+
|
|
320
|
+
const { imageVolume, segmentation, segmentsLocked } = this._editData;
|
|
321
|
+
const {
|
|
322
|
+
segmentIndex,
|
|
323
|
+
segmentationId,
|
|
324
|
+
segmentationRepresentationUID,
|
|
325
|
+
brushCursor,
|
|
326
|
+
} = this._hoverData;
|
|
327
|
+
|
|
328
|
+
const { data } = brushCursor;
|
|
329
|
+
const { viewPlaneNormal, viewUp } = brushCursor.metadata;
|
|
330
|
+
|
|
331
|
+
this._deactivateDraw(element);
|
|
332
|
+
|
|
333
|
+
resetElementCursor(element);
|
|
334
|
+
|
|
335
|
+
const enabledElement = getEnabledElement(element);
|
|
336
|
+
const { viewport } = enabledElement;
|
|
337
|
+
|
|
338
|
+
this._editData = null;
|
|
339
|
+
this.updateCursor(evt);
|
|
340
|
+
|
|
341
|
+
if (viewport instanceof StackViewport) {
|
|
342
|
+
throw new Error('Not implemented yet');
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const operationData = {
|
|
346
|
+
points: data.handles.points,
|
|
347
|
+
volume: segmentation,
|
|
348
|
+
imageVolume,
|
|
349
|
+
segmentIndex,
|
|
350
|
+
segmentsLocked,
|
|
351
|
+
viewPlaneNormal,
|
|
352
|
+
toolGroupId: this.toolGroupId,
|
|
353
|
+
segmentationId,
|
|
354
|
+
segmentationRepresentationUID,
|
|
355
|
+
viewUp,
|
|
356
|
+
strategySpecificConfiguration:
|
|
357
|
+
this.configuration.strategySpecificConfiguration,
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
this.applyActiveStrategy(enabledElement, operationData);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Add event handlers for the modify event loop, and prevent default event propagation.
|
|
365
|
+
*/
|
|
366
|
+
private _activateDraw = (element: HTMLDivElement): void => {
|
|
367
|
+
element.addEventListener(
|
|
368
|
+
Events.MOUSE_UP,
|
|
369
|
+
this._endCallback as EventListener
|
|
370
|
+
);
|
|
371
|
+
element.addEventListener(
|
|
372
|
+
Events.MOUSE_DRAG,
|
|
373
|
+
this._dragCallback as EventListener
|
|
374
|
+
);
|
|
375
|
+
element.addEventListener(
|
|
376
|
+
Events.MOUSE_CLICK,
|
|
377
|
+
this._endCallback as EventListener
|
|
378
|
+
);
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Add event handlers for the modify event loop, and prevent default event prapogation.
|
|
383
|
+
*/
|
|
384
|
+
private _deactivateDraw = (element: HTMLDivElement): void => {
|
|
385
|
+
element.removeEventListener(
|
|
386
|
+
Events.MOUSE_UP,
|
|
387
|
+
this._endCallback as EventListener
|
|
388
|
+
);
|
|
389
|
+
element.removeEventListener(
|
|
390
|
+
Events.MOUSE_DRAG,
|
|
391
|
+
this._dragCallback as EventListener
|
|
392
|
+
);
|
|
393
|
+
element.removeEventListener(
|
|
394
|
+
Events.MOUSE_CLICK,
|
|
395
|
+
this._endCallback as EventListener
|
|
396
|
+
);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
public invalidateBrushCursor() {
|
|
400
|
+
if (this._hoverData !== undefined) {
|
|
401
|
+
const { data } = this._hoverData.brushCursor;
|
|
402
|
+
|
|
403
|
+
data.invalidated = true;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
renderAnnotation(
|
|
408
|
+
enabledElement: Types.IEnabledElement,
|
|
409
|
+
svgDrawingHelper: SVGDrawingHelper
|
|
410
|
+
): void {
|
|
411
|
+
if (!this._hoverData) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const { viewport } = enabledElement;
|
|
416
|
+
|
|
417
|
+
const viewportIdsToRender = this._hoverData.viewportIdsToRender;
|
|
418
|
+
|
|
419
|
+
if (!viewportIdsToRender.includes(viewport.id)) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const brushCursor = this._hoverData.brushCursor;
|
|
424
|
+
|
|
425
|
+
if (brushCursor.data.invalidated === true) {
|
|
426
|
+
const { centerCanvas } = this._hoverData;
|
|
427
|
+
const { element } = viewport;
|
|
428
|
+
|
|
429
|
+
// This can be set true when changing the brush size programmatically
|
|
430
|
+
// whilst the cursor is being rendered.
|
|
431
|
+
this._calculateCursor(element, centerCanvas);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const toolMetadata = brushCursor.metadata;
|
|
435
|
+
const annotationUID = toolMetadata.brushCursorUID;
|
|
436
|
+
|
|
437
|
+
const data = brushCursor.data;
|
|
438
|
+
const { points } = data.handles;
|
|
439
|
+
const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
|
|
440
|
+
|
|
441
|
+
const bottom = canvasCoordinates[0];
|
|
442
|
+
const top = canvasCoordinates[1];
|
|
443
|
+
|
|
444
|
+
const center = [
|
|
445
|
+
Math.floor((bottom[0] + top[0]) / 2),
|
|
446
|
+
Math.floor((bottom[1] + top[1]) / 2),
|
|
447
|
+
];
|
|
448
|
+
|
|
449
|
+
const radius = Math.abs(bottom[1] - Math.floor((bottom[1] + top[1]) / 2));
|
|
450
|
+
|
|
451
|
+
const color = `rgb(${toolMetadata.segmentColor.slice(0, 3)})`;
|
|
452
|
+
|
|
453
|
+
// If rendering engine has been destroyed while rendering
|
|
454
|
+
if (!viewport.getRenderingEngine()) {
|
|
455
|
+
console.warn('Rendering Engine has been destroyed');
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
const circleUID = '0';
|
|
460
|
+
drawCircleSvg(
|
|
461
|
+
svgDrawingHelper,
|
|
462
|
+
annotationUID,
|
|
463
|
+
circleUID,
|
|
464
|
+
center as Types.Point2,
|
|
465
|
+
radius,
|
|
466
|
+
{
|
|
467
|
+
color,
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
BrushTool.toolName = 'Brush';
|
|
474
|
+
export default BrushTool;
|