@cornerstonejs/tools 0.56.2 → 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/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,132 @@
|
|
|
1
|
+
import { getEnabledElement, Types } from '@cornerstonejs/core';
|
|
2
|
+
import {
|
|
3
|
+
mouseEventListeners,
|
|
4
|
+
wheelEventListener,
|
|
5
|
+
touchEventListeners,
|
|
6
|
+
keyEventListener,
|
|
7
|
+
} from '../eventListeners';
|
|
8
|
+
import {
|
|
9
|
+
imageRenderedEventDispatcher,
|
|
10
|
+
cameraModifiedEventDispatcher,
|
|
11
|
+
mouseToolEventDispatcher,
|
|
12
|
+
keyboardToolEventDispatcher,
|
|
13
|
+
imageSpacingCalibratedEventDispatcher,
|
|
14
|
+
touchToolEventDispatcher,
|
|
15
|
+
} from '../eventDispatchers';
|
|
16
|
+
// ~~
|
|
17
|
+
|
|
18
|
+
import filterToolsWithAnnotationsForElement from './filterToolsWithAnnotationsForElement';
|
|
19
|
+
import { state } from './state';
|
|
20
|
+
import getToolsWithModesForElement from '../utilities/getToolsWithModesForElement';
|
|
21
|
+
import { ToolModes } from '../enums';
|
|
22
|
+
import { removeAnnotation } from '../stateManagement';
|
|
23
|
+
import getSynchronizersForViewport from './SynchronizerManager/getSynchronizersForViewport';
|
|
24
|
+
import getToolGroupForViewport from './ToolGroupManager/getToolGroupForViewport';
|
|
25
|
+
import { annotationRenderingEngine } from '../utilities/triggerAnnotationRender';
|
|
26
|
+
|
|
27
|
+
const VIEWPORT_ELEMENT = 'viewport-element';
|
|
28
|
+
|
|
29
|
+
function removeEnabledElement(
|
|
30
|
+
elementDisabledEvt: Types.EventTypes.ElementDisabledEvent
|
|
31
|
+
): void {
|
|
32
|
+
// Is DOM element
|
|
33
|
+
const { element, viewportId } = elementDisabledEvt.detail;
|
|
34
|
+
|
|
35
|
+
_resetSvgNodeCache(element);
|
|
36
|
+
_removeSvgNode(element);
|
|
37
|
+
|
|
38
|
+
// Remove this element from the annotation rendering engine
|
|
39
|
+
annotationRenderingEngine.removeViewportElement(viewportId, element);
|
|
40
|
+
|
|
41
|
+
// Listeners
|
|
42
|
+
mouseEventListeners.disable(element);
|
|
43
|
+
wheelEventListener.disable(element);
|
|
44
|
+
touchEventListeners.disable(element);
|
|
45
|
+
keyEventListener.disable(element);
|
|
46
|
+
// labelmap
|
|
47
|
+
|
|
48
|
+
// Dispatchers: renderer
|
|
49
|
+
imageRenderedEventDispatcher.disable(element);
|
|
50
|
+
cameraModifiedEventDispatcher.disable(element);
|
|
51
|
+
imageSpacingCalibratedEventDispatcher.disable(element);
|
|
52
|
+
// Dispatchers: interaction
|
|
53
|
+
mouseToolEventDispatcher.disable(element);
|
|
54
|
+
keyboardToolEventDispatcher.disable(element);
|
|
55
|
+
touchToolEventDispatcher.disable(element);
|
|
56
|
+
|
|
57
|
+
// State
|
|
58
|
+
// @TODO: We used to "disable" the tool before removal. Should we preserve the hook that would call on tools?
|
|
59
|
+
_removeViewportFromSynchronizers(element);
|
|
60
|
+
_removeViewportFromToolGroup(element);
|
|
61
|
+
|
|
62
|
+
// _removeAllToolsForElement(canvas)
|
|
63
|
+
_removeEnabledElement(element);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const _removeViewportFromSynchronizers = (element: HTMLDivElement) => {
|
|
67
|
+
const enabledElement = getEnabledElement(element);
|
|
68
|
+
|
|
69
|
+
const synchronizers = getSynchronizersForViewport(
|
|
70
|
+
enabledElement.viewportId,
|
|
71
|
+
enabledElement.renderingEngineId
|
|
72
|
+
);
|
|
73
|
+
synchronizers.forEach((sync) => {
|
|
74
|
+
sync.remove(enabledElement);
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const _removeViewportFromToolGroup = (element: HTMLDivElement) => {
|
|
79
|
+
const { renderingEngineId, viewportId } = getEnabledElement(element);
|
|
80
|
+
|
|
81
|
+
const toolGroup = getToolGroupForViewport(viewportId, renderingEngineId);
|
|
82
|
+
|
|
83
|
+
if (toolGroup) {
|
|
84
|
+
toolGroup.removeViewports(renderingEngineId, viewportId);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const _removeAllToolsForElement = function (element) {
|
|
89
|
+
const tools = getToolsWithModesForElement(element, [
|
|
90
|
+
ToolModes.Active,
|
|
91
|
+
ToolModes.Passive,
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
const toolsWithData = filterToolsWithAnnotationsForElement(element, tools);
|
|
95
|
+
toolsWithData.forEach(({ annotations }) => {
|
|
96
|
+
annotations.forEach((annotation) => {
|
|
97
|
+
removeAnnotation(annotation.annotationUID);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
function _resetSvgNodeCache(element: HTMLDivElement) {
|
|
103
|
+
const { viewportUid: viewportId, renderingEngineUid: renderingEngineId } =
|
|
104
|
+
element.dataset;
|
|
105
|
+
const elementHash = `${viewportId}:${renderingEngineId}`;
|
|
106
|
+
|
|
107
|
+
delete state.svgNodeCache[elementHash];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function _removeSvgNode(element: HTMLDivElement) {
|
|
111
|
+
const internalViewportNode = element.querySelector(`div.${VIEWPORT_ELEMENT}`);
|
|
112
|
+
const svgLayer = internalViewportNode.querySelector('svg');
|
|
113
|
+
if (svgLayer) {
|
|
114
|
+
internalViewportNode.removeChild(svgLayer);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @private
|
|
120
|
+
* @param enabledElement
|
|
121
|
+
*/
|
|
122
|
+
const _removeEnabledElement = function (element: HTMLDivElement) {
|
|
123
|
+
const foundElementIndex = state.enabledElements.findIndex(
|
|
124
|
+
(el) => el === element
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
if (foundElementIndex > -1) {
|
|
128
|
+
state.enabledElements.splice(foundElementIndex, 1);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default removeEnabledElement;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _cloneDeep from 'lodash.clonedeep';
|
|
2
|
+
|
|
3
|
+
import { IToolGroup, IToolClassReference } from '../types';
|
|
4
|
+
import Synchronizer from './SynchronizerManager/Synchronizer';
|
|
5
|
+
import svgNodeCache, { resetSvgNodeCache } from './svgNodeCache';
|
|
6
|
+
|
|
7
|
+
interface ICornerstoneTools3dState {
|
|
8
|
+
isInteractingWithTool: boolean;
|
|
9
|
+
isMultiPartToolActive: boolean;
|
|
10
|
+
tools: Record<
|
|
11
|
+
string,
|
|
12
|
+
{
|
|
13
|
+
toolClass: IToolClassReference;
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
16
|
+
toolGroups: Array<IToolGroup>;
|
|
17
|
+
synchronizers: Array<Synchronizer>;
|
|
18
|
+
svgNodeCache: Record<string, unknown>;
|
|
19
|
+
enabledElements: Array<unknown>;
|
|
20
|
+
handleRadius: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const defaultState: ICornerstoneTools3dState = {
|
|
24
|
+
isInteractingWithTool: false,
|
|
25
|
+
isMultiPartToolActive: false,
|
|
26
|
+
tools: {},
|
|
27
|
+
toolGroups: [],
|
|
28
|
+
synchronizers: [],
|
|
29
|
+
svgNodeCache: svgNodeCache,
|
|
30
|
+
// Should this be named... canvases?
|
|
31
|
+
enabledElements: [], // switch to Uids?
|
|
32
|
+
handleRadius: 6,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let state: ICornerstoneTools3dState = {
|
|
36
|
+
isInteractingWithTool: false,
|
|
37
|
+
isMultiPartToolActive: false,
|
|
38
|
+
tools: {},
|
|
39
|
+
toolGroups: [],
|
|
40
|
+
synchronizers: [],
|
|
41
|
+
svgNodeCache: svgNodeCache,
|
|
42
|
+
// Should this be named... canvases?
|
|
43
|
+
enabledElements: [], // switch to Uids?
|
|
44
|
+
handleRadius: 6,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function resetCornerstoneToolsState(): void {
|
|
48
|
+
resetSvgNodeCache();
|
|
49
|
+
state = _cloneDeep(defaultState);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
ICornerstoneTools3dState,
|
|
54
|
+
resetCornerstoneToolsState,
|
|
55
|
+
state,
|
|
56
|
+
state as default,
|
|
57
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix';
|
|
2
|
+
import { Types } from '@cornerstonejs/core';
|
|
3
|
+
|
|
4
|
+
export default function areViewportsCoplanar(
|
|
5
|
+
viewport1: Types.IStackViewport,
|
|
6
|
+
viewport2: Types.IStackViewport
|
|
7
|
+
): boolean {
|
|
8
|
+
const { viewPlaneNormal: viewPlaneNormal1 } = viewport1.getCamera();
|
|
9
|
+
const { viewPlaneNormal: viewPlaneNormal2 } = viewport2.getCamera();
|
|
10
|
+
const dotProducts = vec3.dot(viewPlaneNormal1, viewPlaneNormal2);
|
|
11
|
+
return Math.abs(dotProducts) > 0.9;
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getRenderingEngine, Types } from '@cornerstonejs/core';
|
|
2
|
+
import { Synchronizer } from '../../store';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Synchronizer callback to synchronize the camera by updating all camera
|
|
6
|
+
* values. See also zoomPanSyncCallback
|
|
7
|
+
*
|
|
8
|
+
* @param synchronizerInstance - The Instance of the Synchronizer
|
|
9
|
+
* @param sourceViewport - The list of IDs defining the source viewport.
|
|
10
|
+
* @param targetViewport - The list of IDs defining the target viewport, never
|
|
11
|
+
* the same as sourceViewport.
|
|
12
|
+
* @param cameraModifiedEvent - The CAMERA_MODIFIED event.
|
|
13
|
+
*/
|
|
14
|
+
export default function cameraSyncCallback(
|
|
15
|
+
synchronizerInstance: Synchronizer,
|
|
16
|
+
sourceViewport: Types.IViewportId,
|
|
17
|
+
targetViewport: Types.IViewportId,
|
|
18
|
+
cameraModifiedEvent: CustomEvent
|
|
19
|
+
): void {
|
|
20
|
+
const { camera } = cameraModifiedEvent.detail;
|
|
21
|
+
|
|
22
|
+
const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
|
|
23
|
+
if (!renderingEngine) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`No RenderingEngine for Id: ${targetViewport.renderingEngineId}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const tViewport = renderingEngine.getViewport(targetViewport.viewportId);
|
|
30
|
+
|
|
31
|
+
tViewport.setCamera(camera);
|
|
32
|
+
tViewport.render();
|
|
33
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix';
|
|
2
|
+
import {
|
|
3
|
+
getRenderingEngine,
|
|
4
|
+
Types,
|
|
5
|
+
metaData,
|
|
6
|
+
utilities,
|
|
7
|
+
} from '@cornerstonejs/core';
|
|
8
|
+
import { Synchronizer } from '../../store';
|
|
9
|
+
import { jumpToSlice } from '../../utilities';
|
|
10
|
+
import areViewportsCoplanar from './areViewportsCoplanar ';
|
|
11
|
+
/**
|
|
12
|
+
* Synchronizer callback to synchronize the source viewport image to the
|
|
13
|
+
* target viewports closest image in its stack. There are two scenarios
|
|
14
|
+
*
|
|
15
|
+
* 1) viewports are in the same frameOfReferenceUID then we can use the
|
|
16
|
+
* absolute imagePositionPatient for the source viewport's current image
|
|
17
|
+
* and set the target viewport's image to the closest image in its stack
|
|
18
|
+
* (which might have different slice thickness so cannot use slice number)
|
|
19
|
+
*
|
|
20
|
+
* 2) viewports have different frameOfReferenceUIDs then we look inside the
|
|
21
|
+
* registrationMetadataProvider to check if there is a corresponding matrix
|
|
22
|
+
* for mapping between the source and target viewport if so it is used to
|
|
23
|
+
* and is applied to the imagePositionPatient of the source viewport's to
|
|
24
|
+
* get the imagePositionPatient of the target viewport's closest image in
|
|
25
|
+
* its stack.
|
|
26
|
+
* Note for 2) The consuming apps using Cornerstone3D (OHIF, etc) are responsible
|
|
27
|
+
* to provide such data in the registrationMetadataProvider. This can be done
|
|
28
|
+
* by various methods 1) Using spatialRegistrationModule inside dicom 2) assuming
|
|
29
|
+
* the user has actually manually scrolled the target viewport to the correct
|
|
30
|
+
* slice before initiating the synchronization 3) using some other method
|
|
31
|
+
* But overall, the consuming app is responsible for providing the data.
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* @param synchronizerInstance - The Instance of the Synchronizer
|
|
35
|
+
* @param sourceViewport - The list of IDs defining the source viewport.
|
|
36
|
+
* @param targetViewport - The list of IDs defining the target viewport, never
|
|
37
|
+
* the same as sourceViewport.
|
|
38
|
+
* @param cameraModifiedEvent - The CAMERA_MODIFIED event.
|
|
39
|
+
*/
|
|
40
|
+
export default async function stackImageSyncCallback(
|
|
41
|
+
synchronizerInstance: Synchronizer,
|
|
42
|
+
sourceViewport: Types.IViewportId,
|
|
43
|
+
targetViewport: Types.IViewportId
|
|
44
|
+
): Promise<void> {
|
|
45
|
+
const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
|
|
46
|
+
if (!renderingEngine) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`No RenderingEngine for Id: ${targetViewport.renderingEngineId}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const sViewport = renderingEngine.getViewport(
|
|
53
|
+
sourceViewport.viewportId
|
|
54
|
+
) as Types.IStackViewport;
|
|
55
|
+
|
|
56
|
+
const tViewport = renderingEngine.getViewport(
|
|
57
|
+
targetViewport.viewportId
|
|
58
|
+
) as Types.IStackViewport;
|
|
59
|
+
|
|
60
|
+
const frameOfReferenceUID1 = sViewport.getFrameOfReferenceUID();
|
|
61
|
+
const frameOfReferenceUID2 = tViewport.getFrameOfReferenceUID();
|
|
62
|
+
|
|
63
|
+
const imageId1 = sViewport.getCurrentImageId();
|
|
64
|
+
const imagePlaneModule1 = metaData.get('imagePlaneModule', imageId1);
|
|
65
|
+
const sourceImagePositionPatient = imagePlaneModule1.imagePositionPatient;
|
|
66
|
+
|
|
67
|
+
const targetImageIds = tViewport.getImageIds();
|
|
68
|
+
|
|
69
|
+
if (!areViewportsCoplanar(sViewport, tViewport)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (frameOfReferenceUID1 === frameOfReferenceUID2) {
|
|
74
|
+
// if frames of references are the same we can use the absolute
|
|
75
|
+
// imagePositionPatient to find the closest image in the target viewport's stack
|
|
76
|
+
const closestImageIdIndex = _getClosestImageIdIndex(
|
|
77
|
+
sourceImagePositionPatient,
|
|
78
|
+
targetImageIds
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (
|
|
82
|
+
closestImageIdIndex.index !== -1 &&
|
|
83
|
+
tViewport.getCurrentImageIdIndex() !== closestImageIdIndex.index
|
|
84
|
+
) {
|
|
85
|
+
// await tViewport.setImageIdIndex(closestImageIdIndex.index);
|
|
86
|
+
await jumpToSlice(tViewport.element, {
|
|
87
|
+
imageIndex: closestImageIdIndex.index,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
// if the frame of reference is different we need to use the registrationMetadataProvider
|
|
94
|
+
// and add that to the imagePositionPatient of the source viewport to get the
|
|
95
|
+
// imagePositionPatient of the target viewport's closest image in its stack
|
|
96
|
+
const registrationMatrixMat4 =
|
|
97
|
+
utilities.spatialRegistrationMetadataProvider.get(
|
|
98
|
+
'spatialRegistrationModule',
|
|
99
|
+
[targetViewport.viewportId, sourceViewport.viewportId]
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (!registrationMatrixMat4) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
`No registration matrix found for sourceViewport: ${sourceViewport.viewportId} and targetViewport: ${targetViewport.viewportId}, viewports with different frameOfReferenceUIDs must have a registration matrix in the registrationMetadataProvider. Use calculateViewportsRegistrationMatrix to calculate the matrix.`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// apply the registration matrix to the source viewport's imagePositionPatient
|
|
109
|
+
// to get the target viewport's imagePositionPatient
|
|
110
|
+
const targetImagePositionPatientWithRegistrationMatrix = vec3.transformMat4(
|
|
111
|
+
vec3.create(),
|
|
112
|
+
sourceImagePositionPatient,
|
|
113
|
+
registrationMatrixMat4
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// find the closest image in the target viewport's stack to the
|
|
117
|
+
// targetImagePositionPatientWithRegistrationMatrix
|
|
118
|
+
const closestImageIdIndex2 = _getClosestImageIdIndex(
|
|
119
|
+
targetImagePositionPatientWithRegistrationMatrix,
|
|
120
|
+
targetImageIds
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
if (
|
|
124
|
+
closestImageIdIndex2.index !== -1 &&
|
|
125
|
+
tViewport.getCurrentImageIdIndex() !== closestImageIdIndex2.index
|
|
126
|
+
) {
|
|
127
|
+
await jumpToSlice(tViewport.element, {
|
|
128
|
+
imageIndex: closestImageIdIndex2.index,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function _getClosestImageIdIndex(targetPoint, imageIds) {
|
|
135
|
+
// todo: this does not assume orientation yet, but that can be added later
|
|
136
|
+
return imageIds.reduce(
|
|
137
|
+
(closestImageIdIndex, imageId, index) => {
|
|
138
|
+
const { imagePositionPatient } = metaData.get(
|
|
139
|
+
'imagePlaneModule',
|
|
140
|
+
imageId
|
|
141
|
+
);
|
|
142
|
+
const distance = vec3.distance(imagePositionPatient, targetPoint);
|
|
143
|
+
|
|
144
|
+
if (distance < closestImageIdIndex.distance) {
|
|
145
|
+
return {
|
|
146
|
+
distance,
|
|
147
|
+
index,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return closestImageIdIndex;
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
distance: Infinity,
|
|
154
|
+
index: -1,
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getRenderingEngine,
|
|
3
|
+
StackViewport,
|
|
4
|
+
Types,
|
|
5
|
+
VolumeViewport,
|
|
6
|
+
} from '@cornerstonejs/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Synchronizer callback to synchronize the voi of volumeActors of identical volumes
|
|
10
|
+
* in different viewports.
|
|
11
|
+
*
|
|
12
|
+
* @param synchronizerInstance - The Instance of the Synchronizer
|
|
13
|
+
* @param sourceViewport - The list of IDs defining the source viewport.
|
|
14
|
+
* @param targetViewport - The list of IDs defining the target viewport.
|
|
15
|
+
* @param voiModifiedEvent - The VOI_MODIFIED event.
|
|
16
|
+
*/
|
|
17
|
+
export default function voiSyncCallback(
|
|
18
|
+
synchronizerInstance,
|
|
19
|
+
sourceViewport: Types.IViewportId,
|
|
20
|
+
targetViewport: Types.IViewportId,
|
|
21
|
+
voiModifiedEvent: Types.EventTypes.VoiModifiedEvent
|
|
22
|
+
): void {
|
|
23
|
+
const eventDetail = voiModifiedEvent.detail;
|
|
24
|
+
const { volumeId, range } = eventDetail;
|
|
25
|
+
|
|
26
|
+
const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
|
|
27
|
+
if (!renderingEngine) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`Rendering Engine does not exist: ${targetViewport.renderingEngineId}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const tViewport = renderingEngine.getViewport(targetViewport.viewportId);
|
|
34
|
+
|
|
35
|
+
if (tViewport instanceof VolumeViewport) {
|
|
36
|
+
tViewport.setProperties(
|
|
37
|
+
{
|
|
38
|
+
voiRange: range,
|
|
39
|
+
},
|
|
40
|
+
volumeId
|
|
41
|
+
);
|
|
42
|
+
} else if (tViewport instanceof StackViewport) {
|
|
43
|
+
tViewport.setProperties({
|
|
44
|
+
voiRange: range,
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
throw new Error('Viewport type not supported.');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
tViewport.render();
|
|
51
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getRenderingEngine, Types } from '@cornerstonejs/core';
|
|
2
|
+
import { Synchronizer } from '../../store';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Synchronizer callback to synchronize the camera. Synchronization
|
|
6
|
+
*
|
|
7
|
+
* targetViewport.options.syncZoom set to false to not sync the zoom
|
|
8
|
+
* targetViewport.options.syncPan set to false to not sync the pan
|
|
9
|
+
|
|
10
|
+
* @param synchronizerInstance - The Instance of the Synchronizer
|
|
11
|
+
* @param sourceViewport - The list of IDs defining the source viewport.
|
|
12
|
+
* @param targetViewport - The list of IDs defining the target viewport, different
|
|
13
|
+
* from sourceViewport
|
|
14
|
+
*/
|
|
15
|
+
export default function zoomPanSyncCallback(
|
|
16
|
+
synchronizerInstance: Synchronizer,
|
|
17
|
+
sourceViewport: Types.IViewportId,
|
|
18
|
+
targetViewport: Types.IViewportId
|
|
19
|
+
): void {
|
|
20
|
+
const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
|
|
21
|
+
if (!renderingEngine) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`No RenderingEngine for Id: ${targetViewport.renderingEngineId}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const options = synchronizerInstance.getOptions(targetViewport.viewportId);
|
|
28
|
+
|
|
29
|
+
const tViewport = renderingEngine.getViewport(targetViewport.viewportId);
|
|
30
|
+
const sViewport = renderingEngine.getViewport(sourceViewport.viewportId);
|
|
31
|
+
|
|
32
|
+
if (options?.syncZoom !== false) {
|
|
33
|
+
const srcZoom = sViewport.getZoom();
|
|
34
|
+
// Do the zoom first, as the pan is relative to the zoom level
|
|
35
|
+
tViewport.setZoom(srcZoom);
|
|
36
|
+
}
|
|
37
|
+
if (options?.syncPan !== false) {
|
|
38
|
+
const srcPan = sViewport.getPan();
|
|
39
|
+
tViewport.setPan(srcPan);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
tViewport.render();
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import createCameraPositionSynchronizer from './synchronizers/createCameraPositionSynchronizer';
|
|
2
|
+
import createVOISynchronizer from './synchronizers/createVOISynchronizer';
|
|
3
|
+
import createZoomPanSynchronizer from './synchronizers/createZoomPanSynchronizer';
|
|
4
|
+
import createStackImageSynchronizer from './synchronizers/createStackImageSynchronizer';
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
createCameraPositionSynchronizer,
|
|
8
|
+
createVOISynchronizer,
|
|
9
|
+
createZoomPanSynchronizer,
|
|
10
|
+
createStackImageSynchronizer,
|
|
11
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSynchronizer } from '../../store/SynchronizerManager';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
import cameraSyncCallback from '../callbacks/cameraSyncCallback';
|
|
4
|
+
import Synchronizer from '../../store/SynchronizerManager/Synchronizer';
|
|
5
|
+
|
|
6
|
+
const { CAMERA_MODIFIED } = Enums.Events;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A helper that creates a new `Synchronizer` which listens to the `CAMERA_MODIFIED`
|
|
10
|
+
* rendering event and calls the `cameraSyncCallback`.
|
|
11
|
+
*
|
|
12
|
+
* @param synchronizerName - The name of the synchronizer.
|
|
13
|
+
* @returns A new `Synchronizer` instance.
|
|
14
|
+
*/
|
|
15
|
+
export default function createCameraPositionSynchronizer(
|
|
16
|
+
synchronizerName: string
|
|
17
|
+
): Synchronizer {
|
|
18
|
+
const cameraPositionSynchronizer = createSynchronizer(
|
|
19
|
+
synchronizerName,
|
|
20
|
+
CAMERA_MODIFIED,
|
|
21
|
+
cameraSyncCallback
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return cameraPositionSynchronizer;
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSynchronizer } from '../../store/SynchronizerManager';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
import stackImageSyncCallback from '../callbacks/stackImageSyncCallback';
|
|
4
|
+
import Synchronizer from '../../store/SynchronizerManager/Synchronizer';
|
|
5
|
+
|
|
6
|
+
const { STACK_NEW_IMAGE } = Enums.Events;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A helper that creates a new `Synchronizer` which listens to the `STACK_NEW_IMAGE`
|
|
10
|
+
* rendering event and calls the `stackImageSyncCallback`.
|
|
11
|
+
*
|
|
12
|
+
* @param synchronizerName - The name of the synchronizer.
|
|
13
|
+
* @returns A new `Synchronizer` instance.
|
|
14
|
+
*/
|
|
15
|
+
export default function createStackImageSynchronizer(
|
|
16
|
+
synchronizerName: string
|
|
17
|
+
): Synchronizer {
|
|
18
|
+
const stackImageSynchronizer = createSynchronizer(
|
|
19
|
+
synchronizerName,
|
|
20
|
+
STACK_NEW_IMAGE,
|
|
21
|
+
stackImageSyncCallback
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return stackImageSynchronizer;
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createSynchronizer } from '../../store/SynchronizerManager';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
import voiSyncCallback from '../callbacks/voiSyncCallback';
|
|
4
|
+
import Synchronizer from '../../store/SynchronizerManager/Synchronizer';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A helper that creates a new `Synchronizer`
|
|
8
|
+
* which listens to the `VOI_MODIFIED` rendering event and calls the `voiSyncCallback`.
|
|
9
|
+
*
|
|
10
|
+
* @param synchronizerName - The name of the synchronizer.
|
|
11
|
+
*
|
|
12
|
+
* @returns A new `Synchronizer` instance.
|
|
13
|
+
*/
|
|
14
|
+
export default function createVOISynchronizer(
|
|
15
|
+
synchronizerName: string
|
|
16
|
+
): Synchronizer {
|
|
17
|
+
const VOISynchronizer = createSynchronizer(
|
|
18
|
+
synchronizerName,
|
|
19
|
+
Enums.Events.VOI_MODIFIED,
|
|
20
|
+
voiSyncCallback
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
return VOISynchronizer;
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSynchronizer } from '../../store/SynchronizerManager';
|
|
2
|
+
import { Enums } from '@cornerstonejs/core';
|
|
3
|
+
import zoomPanSyncCallback from '../callbacks/zoomPanSyncCallback';
|
|
4
|
+
import Synchronizer from '../../store/SynchronizerManager/Synchronizer';
|
|
5
|
+
|
|
6
|
+
const { CAMERA_MODIFIED } = Enums.Events;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A helper that creates a new `Synchronizer` which listens to the `CAMERA_MODIFIED`
|
|
10
|
+
* rendering event and calls the `cameraSyncCallback`.
|
|
11
|
+
*
|
|
12
|
+
* @param synchronizerName - The name of the synchronizer.
|
|
13
|
+
* @returns A new `Synchronizer` instance.
|
|
14
|
+
*/
|
|
15
|
+
export default function createZoomPanSynchronizer(
|
|
16
|
+
synchronizerName: string
|
|
17
|
+
): Synchronizer {
|
|
18
|
+
const zoomPanSynchronizer = createSynchronizer(
|
|
19
|
+
synchronizerName,
|
|
20
|
+
CAMERA_MODIFIED,
|
|
21
|
+
zoomPanSyncCallback
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return zoomPanSynchronizer;
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import createCameraPositionSynchronizer from './createCameraPositionSynchronizer';
|
|
2
|
+
import createVOISynchronizer from './createVOISynchronizer';
|
|
3
|
+
import createZoomPanSynchronizer from './createZoomPanSynchronizer';
|
|
4
|
+
import createStackImageSynchronizer from './createStackImageSynchronizer';
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
createCameraPositionSynchronizer,
|
|
8
|
+
createVOISynchronizer,
|
|
9
|
+
createZoomPanSynchronizer,
|
|
10
|
+
createStackImageSynchronizer,
|
|
11
|
+
};
|