@ohif/extension-cornerstone 3.14.0-beta.12 → 3.14.0-beta.121
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/915.ohif-extension-cornerstone.umd.js +1 -1
- package/dist/ohif-extension-cornerstone.umd.js +1 -5
- package/package.json +33 -25
- package/src/Viewport/OHIFCornerstoneViewport.css +46 -0
- package/src/Viewport/OHIFCornerstoneViewport.tsx +498 -0
- package/src/Viewport/Overlays/CornerstoneOverlays.tsx +103 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.css +25 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.tsx +469 -0
- package/src/Viewport/Overlays/ViewportImageScrollbar.tsx +106 -0
- package/src/Viewport/Overlays/ViewportImageSliceLoadingIndicator.tsx +87 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.css +41 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.tsx +136 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/ViewportSliceProgressScrollbar.tsx +195 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/helpers.ts +46 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/hooks.ts +383 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/index.ts +1 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/types.ts +17 -0
- package/src/Viewport/Overlays/utils.ts +66 -0
- package/src/commandsModule.ts +3008 -0
- package/src/components/AccordionGroup/AccordionGroup.tsx +195 -0
- package/src/components/AccordionGroup/index.ts +4 -0
- package/src/components/ActiveViewportWindowLevel/ActiveViewportWindowLevel.tsx +23 -0
- package/src/components/ActiveViewportWindowLevel/index.js +1 -0
- package/src/components/AdvancedRenderingControls/AdvancedRenderingControls.tsx +149 -0
- package/src/components/AdvancedRenderingControls/index.ts +1 -0
- package/src/components/CinePlayer/CinePlayer.tsx +247 -0
- package/src/components/CinePlayer/index.ts +3 -0
- package/src/components/DicomUpload/DicomUpload.tsx +111 -0
- package/src/components/DicomUpload/DicomUploadProgress.tsx +396 -0
- package/src/components/DicomUpload/DicomUploadProgressItem.tsx +119 -0
- package/src/components/ExportSegmentationSubMenuItem.tsx +75 -0
- package/src/components/FidelityIndicator/FidelityIndicator.tsx +152 -0
- package/src/components/FidelityIndicator/index.ts +1 -0
- package/src/components/MeasurementItems.tsx +70 -0
- package/src/components/MeasurementTableNested.tsx +30 -0
- package/src/components/MeasurementsMenu.tsx +84 -0
- package/src/components/MeasurementsOrAdditionalFindings.tsx +82 -0
- package/src/components/ModalityLoadBadge/ModalityLoadBadge.tsx +171 -0
- package/src/components/ModalityLoadBadge/index.ts +1 -0
- package/src/components/NavigationComponent/NavigationComponent.tsx +138 -0
- package/src/components/NavigationComponent/index.ts +3 -0
- package/src/components/OHIFViewportActionCorners.tsx +109 -0
- package/src/components/OpacityMenu/OpacityMenu.tsx +54 -0
- package/src/components/OpacityMenu/OpacityMenuWrapper.tsx +85 -0
- package/src/components/OpacityMenu/index.ts +2 -0
- package/src/components/PanelAccordionTrigger.tsx +48 -0
- package/src/components/SegmentationToolConfig.tsx +71 -0
- package/src/components/SegmentationUtilityButton.tsx +61 -0
- package/src/components/SelectItemWithModality.tsx +29 -0
- package/src/components/SeriesMeasurements.tsx +90 -0
- package/src/components/SeriesSummaryFromDisplaySet.tsx +21 -0
- package/src/components/StudyMeasurements.tsx +88 -0
- package/src/components/StudyMeasurementsActions.tsx +75 -0
- package/src/components/StudySummaryFromMetadata.test.ts +47 -0
- package/src/components/StudySummaryFromMetadata.tsx +31 -0
- package/src/components/StudySummaryWithActions.tsx +14 -0
- package/src/components/ThresholdMenu/ThresholdMenu.tsx +104 -0
- package/src/components/ThresholdMenu/ThresholdMenuWrapper.tsx +85 -0
- package/src/components/ThresholdMenu/index.ts +2 -0
- package/src/components/TrackingStatus/TrackingStatus.tsx +32 -0
- package/src/components/TrackingStatus/index.ts +1 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenu.tsx +190 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenuWrapper.tsx +85 -0
- package/src/components/VOIManualControlMenu/index.ts +2 -0
- package/src/components/ViewportColorbar/ViewportColorbar.tsx +150 -0
- package/src/components/ViewportColorbar/ViewportColorbarsContainer.tsx +125 -0
- package/src/components/ViewportColorbar/index.ts +5 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenu.tsx +538 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenuWrapper.tsx +91 -0
- package/src/components/ViewportDataOverlaySettingMenu/utils.ts +118 -0
- package/src/components/ViewportOrientationMenu/Viewport3DCompassMenu.tsx +261 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenu.tsx +249 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenuWrapper.tsx +40 -0
- package/src/components/ViewportWindowLevel/ViewportWindowLevel.tsx +261 -0
- package/src/components/ViewportWindowLevel/getViewportVolumeHistogram.ts +72 -0
- package/src/components/ViewportWindowLevel/histogramWorker.js +97 -0
- package/src/components/ViewportWindowLevel/index.js +1 -0
- package/src/components/ViewportWindowLevel/utils.ts +176 -0
- package/src/components/WindowLevelActionMenu/Colorbar.tsx +30 -0
- package/src/components/WindowLevelActionMenu/Colormap.tsx +121 -0
- package/src/components/WindowLevelActionMenu/VolumeLighting.tsx +82 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingOptions.tsx +38 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresets.tsx +36 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresetsContent.tsx +78 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingQuality.tsx +64 -0
- package/src/components/WindowLevelActionMenu/VolumeShade.tsx +47 -0
- package/src/components/WindowLevelActionMenu/VolumeShift.tsx +92 -0
- package/src/components/WindowLevelActionMenu/WindowLevel.tsx +157 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenu.tsx +102 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenuWrapper.tsx +131 -0
- package/src/components/WindowLevelActionMenu/defaultWindowLevelPresets.ts +23 -0
- package/src/components/WindowLevelActionMenu/index.ts +11 -0
- package/src/components/WindowLevelActionMenu/windowLevelPresetHotkeys.test.ts +19 -0
- package/src/components/index.ts +13 -0
- package/src/constants/index.ts +13 -0
- package/src/customizations/CustomDropdownMenuContent.tsx +106 -0
- package/src/customizations/CustomSegmentStatisticsHeader.tsx +140 -0
- package/src/customizations/captureViewportModalCustomization.tsx +175 -0
- package/src/customizations/colorbarCustomization.ts +93 -0
- package/src/customizations/gpuSettingsPresetCustomization.ts +8 -0
- package/src/customizations/layoutSelectorCustomization.ts +104 -0
- package/src/customizations/measurementsCustomization.ts +124 -0
- package/src/customizations/miscCustomization.ts +22 -0
- package/src/customizations/modalityColorMapCustomization.ts +23 -0
- package/src/customizations/segmentationHydrationCustomization.ts +16 -0
- package/src/customizations/segmentationPanelCustomization.tsx +119 -0
- package/src/customizations/segmentationToolbarCustomization.ts +964 -0
- package/src/customizations/toolGroupToolsCustomization.ts +204 -0
- package/src/customizations/toolbarButtonsCustomization.ts +805 -0
- package/src/customizations/viewportClickCommandsCustomization.ts +15 -0
- package/src/customizations/viewportDownloadWarningCustomization.tsx +6 -0
- package/src/customizations/viewportOverlayCustomization.tsx +46 -0
- package/src/customizations/viewportScrollbarCustomization.tsx +27 -0
- package/src/customizations/viewportToolsCustomization.ts +33 -0
- package/src/customizations/volumeRenderingCustomization.ts +14 -0
- package/src/customizations/windowLevelPresetsCustomization.ts +5 -0
- package/src/enums.ts +9 -0
- package/src/getCustomizationModule.tsx +54 -0
- package/src/getHangingProtocolModule.ts +47 -0
- package/src/getPanelModule.tsx +128 -0
- package/src/getSopClassHandlerModule.js +284 -0
- package/src/getToolbarModule.tsx +622 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useActiveViewportSegmentationRepresentations.ts +14 -0
- package/src/hooks/useMeasurementTracking.ts +132 -0
- package/src/hooks/useMeasurements.ts +104 -0
- package/src/hooks/useSegmentations.ts +147 -0
- package/src/hooks/useViewportDisplaySets.ts +284 -0
- package/src/hooks/useViewportFidelity.ts +243 -0
- package/src/hooks/useViewportHover.ts +77 -0
- package/src/hooks/useViewportRendering.tsx +868 -0
- package/src/hooks/useViewportSegmentations.ts +245 -0
- package/src/hps/fourUp.ts +117 -0
- package/src/hps/frameView.ts +1581 -0
- package/src/hps/main3D.ts +142 -0
- package/src/hps/mpr.ts +197 -0
- package/src/hps/mprAnd3DVolumeViewport.ts +124 -0
- package/src/hps/only3D.ts +70 -0
- package/src/hps/primary3D.ts +142 -0
- package/src/hps/primaryAxial.ts +114 -0
- package/src/id.js +5 -0
- package/src/index.tsx +352 -0
- package/src/init.tsx +450 -0
- package/src/initCineService.ts +75 -0
- package/src/initContextMenu.ts +94 -0
- package/src/initCornerstoneTools.js +191 -0
- package/src/initDoubleClick.ts +82 -0
- package/src/initMeasurementService.ts +576 -0
- package/src/initStudyPrefetcherService.ts +33 -0
- package/src/initWADOImageLoader.js +56 -0
- package/src/panels/PanelMeasurement.tsx +84 -0
- package/src/panels/PanelSegmentation.tsx +338 -0
- package/src/services/ColorbarService/ColorbarService.ts +242 -0
- package/src/services/ColorbarService/index.ts +2 -0
- package/src/services/CornerstoneCacheService/CornerstoneCacheService.ts +326 -0
- package/src/services/CornerstoneCacheService/index.js +3 -0
- package/src/services/SegmentationService/RTSTRUCT/mapROIContoursToRTStructData.ts +36 -0
- package/src/services/SegmentationService/SegmentationService.test.ts +3727 -0
- package/src/services/SegmentationService/SegmentationService.ts +2390 -0
- package/src/services/SegmentationService/backends/ISegmentationBackend.ts +102 -0
- package/src/services/SegmentationService/backends/ISegmentationServiceInternals.ts +44 -0
- package/src/services/SegmentationService/backends/LegacySegmentationBackend.ts +139 -0
- package/src/services/SegmentationService/backends/NextSegmentationBackend.ts +159 -0
- package/src/services/SegmentationService/backends/index.ts +4 -0
- package/src/services/SegmentationService/index.ts +3 -0
- package/src/services/SyncGroupService/SyncGroupService.ts +264 -0
- package/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts +118 -0
- package/src/services/SyncGroupService/index.js +3 -0
- package/src/services/ToolGroupService/ToolGroupService.test.ts +83 -0
- package/src/services/ToolGroupService/ToolGroupService.ts +541 -0
- package/src/services/ToolGroupService/index.js +3 -0
- package/src/services/ViewedDataService/ViewedDataService.ts +58 -0
- package/src/services/ViewedDataService/index.ts +3 -0
- package/src/services/ViewportService/CornerstoneViewportService.ts +1814 -0
- package/src/services/ViewportService/IViewportService.ts +64 -0
- package/src/services/ViewportService/Viewport.ts +372 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.contract.test.ts +467 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.ts +179 -0
- package/src/services/ViewportService/adapter/LegacyViewportAdapter.ts +240 -0
- package/src/services/ViewportService/adapter/NextViewportAdapter.ts +241 -0
- package/src/services/ViewportService/adapter/getViewportAdapter.ts +62 -0
- package/src/services/ViewportService/adapter/index.ts +16 -0
- package/src/services/ViewportService/backends/IViewportBackend.ts +195 -0
- package/src/services/ViewportService/backends/IViewportOperations.ts +98 -0
- package/src/services/ViewportService/backends/IViewportServiceInternals.ts +47 -0
- package/src/services/ViewportService/backends/LegacyViewportBackend.ts +264 -0
- package/src/services/ViewportService/backends/LegacyViewportOperations.ts +272 -0
- package/src/services/ViewportService/backends/NextViewportBackend.ts +673 -0
- package/src/services/ViewportService/backends/NextViewportOperations.ts +169 -0
- package/src/services/ViewportService/backends/README.md +62 -0
- package/src/services/ViewportService/backends/dataIdRegistry.ts +121 -0
- package/src/services/ViewportService/backends/viewportOperations.ts +71 -0
- package/src/services/ViewportService/constants.ts +3 -0
- package/src/state.ts +34 -0
- package/src/stores/index.ts +5 -0
- package/src/stores/presentationUtils.ts +42 -0
- package/src/stores/useLutPresentationStore.ts +166 -0
- package/src/stores/usePositionPresentationStore.ts +172 -0
- package/src/stores/useSegmentationPresentationStore.test.ts +146 -0
- package/src/stores/useSegmentationPresentationStore.ts +417 -0
- package/src/stores/useSelectedSegmentationsForViewportStore.ts +85 -0
- package/src/stores/useSynchronizersStore.ts +84 -0
- package/src/synchronizers/frameViewSynchronizer.ts +52 -0
- package/src/tools/CalibrationLineTool.ts +97 -0
- package/src/tools/ImageOverlayViewerTool.tsx +279 -0
- package/src/tools/OverlayPlaneModuleProvider.ts +40 -0
- package/src/tools/WindowLevelTool.test.ts +55 -0
- package/src/tools/WindowLevelTool.ts +22 -0
- package/src/types/AppTypes.ts +70 -0
- package/src/types/Colorbar.ts +114 -0
- package/src/types/Colormap.ts +16 -0
- package/src/types/CornerstoneCacheService.ts +40 -0
- package/src/types/CornerstoneServices.ts +18 -0
- package/src/types/Presentation.ts +83 -0
- package/src/types/SelectedSegmentationByTypeMap.ts +3 -0
- package/src/types/ViewportPresets.ts +53 -0
- package/src/types/VolumeLighting.ts +7 -0
- package/src/types/VolumeRenderingConfig.ts +8 -0
- package/src/types/WindowLevel.ts +5 -0
- package/src/types/index.ts +10 -0
- package/src/utils/ActiveViewportBehavior.tsx +80 -0
- package/src/utils/CornerstoneViewportDownloadForm.tsx +319 -0
- package/src/utils/DicomFileUploader.ts +204 -0
- package/src/utils/JumpPresets.ts +14 -0
- package/src/utils/autoHydrateViewportTypes.ts +69 -0
- package/src/utils/colormaps.js +1597 -0
- package/src/utils/createSegmentationForViewport.test.ts +93 -0
- package/src/utils/createSegmentationForViewport.ts +123 -0
- package/src/utils/dicomLoaderService.js +225 -0
- package/src/utils/ecgMetadata.test.ts +137 -0
- package/src/utils/ecgMetadata.ts +109 -0
- package/src/utils/findNearbyToolData.test.ts +125 -0
- package/src/utils/findNearbyToolData.ts +21 -0
- package/src/utils/findWindowLevelPreset.test.ts +55 -0
- package/src/utils/findWindowLevelPreset.ts +46 -0
- package/src/utils/generateSegmentationCSVReport.test.ts +324 -0
- package/src/utils/generateSegmentationCSVReport.ts +131 -0
- package/src/utils/getActiveViewportEnabledElement.test.ts +70 -0
- package/src/utils/getActiveViewportEnabledElement.ts +8 -0
- package/src/utils/getCenterExtent.test.ts +313 -0
- package/src/utils/getCenterExtent.ts +46 -0
- package/src/utils/getCornerstoneBlendMode.test.ts +59 -0
- package/src/utils/getCornerstoneBlendMode.ts +25 -0
- package/src/utils/getCornerstoneOrientation.test.ts +78 -0
- package/src/utils/getCornerstoneOrientation.ts +31 -0
- package/src/utils/getCornerstoneViewportType.test.ts +169 -0
- package/src/utils/getCornerstoneViewportType.ts +88 -0
- package/src/utils/getInterleavedFrames.test.ts +85 -0
- package/src/utils/getInterleavedFrames.ts +73 -0
- package/src/utils/getLegacyViewportType.ts +64 -0
- package/src/utils/getNthFrames.test.ts +145 -0
- package/src/utils/getNthFrames.ts +31 -0
- package/src/utils/getViewportEnabledElement.test.ts +83 -0
- package/src/utils/getViewportEnabledElement.ts +8 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.test.ts +50 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.ts +56 -0
- package/src/utils/hydrationUtils.test.ts +572 -0
- package/src/utils/hydrationUtils.ts +197 -0
- package/src/utils/imageSliceSync/calculateViewportRegistrations.ts +28 -0
- package/src/utils/imageSliceSync/toggleImageSliceSync.ts +101 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/initGpuSettingsPreset.ts +51 -0
- package/src/utils/initViewTiming.test.ts +342 -0
- package/src/utils/initViewTiming.ts +52 -0
- package/src/utils/initWebWorkerProgressHandler.test.ts +381 -0
- package/src/utils/initWebWorkerProgressHandler.ts +110 -0
- package/src/utils/interleave.test.ts +304 -0
- package/src/utils/interleave.ts +32 -0
- package/src/utils/interleaveCenterLoader.test.ts +547 -0
- package/src/utils/interleaveCenterLoader.ts +143 -0
- package/src/utils/interleaveTopToBottom.test.ts +487 -0
- package/src/utils/interleaveTopToBottom.ts +132 -0
- package/src/utils/isAnyDisplaySetCommon.ts +18 -0
- package/src/utils/isDisplaySetOverlayable.ts +106 -0
- package/src/utils/isMeasurementWithinViewport.test.ts +340 -0
- package/src/utils/isMeasurementWithinViewport.ts +33 -0
- package/src/utils/isReferenceViewable.test.ts +581 -0
- package/src/utils/isReferenceViewable.ts +95 -0
- package/src/utils/loadDisplaySetData.ts +49 -0
- package/src/utils/measurementServiceMappings/Angle.ts +200 -0
- package/src/utils/measurementServiceMappings/ArrowAnnotate.ts +176 -0
- package/src/utils/measurementServiceMappings/Bidirectional.ts +193 -0
- package/src/utils/measurementServiceMappings/CircleROI.ts +227 -0
- package/src/utils/measurementServiceMappings/CobbAngle.ts +206 -0
- package/src/utils/measurementServiceMappings/EllipticalROI.ts +221 -0
- package/src/utils/measurementServiceMappings/Length.ts +206 -0
- package/src/utils/measurementServiceMappings/LivewireContour.ts +175 -0
- package/src/utils/measurementServiceMappings/PlanarFreehandROI.ts +228 -0
- package/src/utils/measurementServiceMappings/Probe.ts +192 -0
- package/src/utils/measurementServiceMappings/RectangleROI.ts +225 -0
- package/src/utils/measurementServiceMappings/SegmentBidirectional.ts +184 -0
- package/src/utils/measurementServiceMappings/SplineROI.ts +227 -0
- package/src/utils/measurementServiceMappings/UltrasoundDirectional.ts +214 -0
- package/src/utils/measurementServiceMappings/UltrasoundPleuraBLine.ts +179 -0
- package/src/utils/measurementServiceMappings/constants/supportedTools.js +21 -0
- package/src/utils/measurementServiceMappings/index.ts +3 -0
- package/src/utils/measurementServiceMappings/measurementServiceMappingsFactory.ts +324 -0
- package/src/utils/measurementServiceMappings/utils/getDisplayUnit.js +3 -0
- package/src/utils/measurementServiceMappings/utils/getHandlesFromPoints.js +14 -0
- package/src/utils/measurementServiceMappings/utils/getIsLocked.ts +5 -0
- package/src/utils/measurementServiceMappings/utils/getIsVisible.ts +6 -0
- package/src/utils/measurementServiceMappings/utils/getSOPInstanceAttributes.js +66 -0
- package/src/utils/measurementServiceMappings/utils/getValueDisplayString.js +12 -0
- package/src/utils/measurementServiceMappings/utils/index.ts +17 -0
- package/src/utils/measurementServiceMappings/utils/selection.ts +33 -0
- package/src/utils/mpr/getProtocolViewportStructureFromGridViewports.ts +74 -0
- package/src/utils/nextViewportPolicies.ts +41 -0
- package/src/utils/nextViewports.ts +157 -0
- package/src/utils/nthLoader.test.ts +317 -0
- package/src/utils/nthLoader.ts +78 -0
- package/src/utils/presentations/getViewportPresentations.test.ts +280 -0
- package/src/utils/presentations/getViewportPresentations.ts +151 -0
- package/src/utils/promptHydrationDialog.test.ts +490 -0
- package/src/utils/promptHydrationDialog.ts +197 -0
- package/src/utils/promptTimePointScope.tsx +82 -0
- package/src/utils/removeViewportSegmentationRepresentations.test.ts +129 -0
- package/src/utils/removeViewportSegmentationRepresentations.ts +17 -0
- package/src/utils/segmentUtils.test.ts +515 -0
- package/src/utils/segmentUtils.ts +46 -0
- package/src/utils/segmentationExportUtils.test.ts +100 -0
- package/src/utils/segmentationExportUtils.ts +171 -0
- package/src/utils/segmentationHandlers.test.ts +614 -0
- package/src/utils/segmentationHandlers.ts +164 -0
- package/src/utils/setUpAnnotationEventHandlers.ts +26 -0
- package/src/utils/setUpSegmentationEventHandlers.test.ts +372 -0
- package/src/utils/setUpSegmentationEventHandlers.ts +122 -0
- package/src/utils/toggleVOISliceSync.test.ts +606 -0
- package/src/utils/toggleVOISliceSync.ts +103 -0
- package/src/utils/transitions.test.ts +351 -0
- package/src/utils/transitions.ts +300 -0
- package/src/utils/updateSegmentationStats.test.ts +942 -0
- package/src/utils/updateSegmentationStats.ts +192 -0
- package/src/utils/viewportDataShape.ts +85 -0
- package/src/utils/volume3dView.test.ts +48 -0
- package/src/utils/volume3dView.ts +113 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DERIVED_OVERLAY_MODALITIES,
|
|
3
|
+
isDisplaySetOverlayable,
|
|
4
|
+
} from '../../utils/isDisplaySetOverlayable';
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_COLORMAP = 'hsv';
|
|
7
|
+
export const DEFAULT_OPACITY = 0.5;
|
|
8
|
+
export const DEFAULT_OPACITY_PERCENT = DEFAULT_OPACITY * 100;
|
|
9
|
+
export { DERIVED_OVERLAY_MODALITIES };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get modality-specific color and opacity settings from the customization service
|
|
13
|
+
*/
|
|
14
|
+
export function getModalityOverlayColormap(customizationService, modality) {
|
|
15
|
+
const modalityOverlayDefaultColorMaps = customizationService?.getCustomization(
|
|
16
|
+
'cornerstone.modalityOverlayDefaultColorMaps'
|
|
17
|
+
) || { defaultSettings: {} };
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
modalityOverlayDefaultColorMaps.defaultSettings[modality] || {
|
|
21
|
+
colormap: DEFAULT_COLORMAP,
|
|
22
|
+
opacity: DEFAULT_OPACITY,
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Identifies display sets that can be used as overlays for a specific viewport.
|
|
29
|
+
*
|
|
30
|
+
* "Enhanced" display sets are those that:
|
|
31
|
+
* 1. Are not already in the viewport
|
|
32
|
+
* 2. Are evaluated for their ability to be overlaid onto the background display set
|
|
33
|
+
* 3. Have an "isOverlayable" flag indicating if they're compatible with the viewport
|
|
34
|
+
*
|
|
35
|
+
* This is the viewport-driven caller of `isDisplaySetOverlayable`: it resolves
|
|
36
|
+
* the viewport's background display set and applies the shared rule to every
|
|
37
|
+
* other display set. The rule itself lives in utils/isDisplaySetOverlayable so
|
|
38
|
+
* that hydration - which has no viewport to start from - can use it too.
|
|
39
|
+
*
|
|
40
|
+
* @returns {Object} Object containing:
|
|
41
|
+
* - viewportDisplaySets: Display sets already in the viewport
|
|
42
|
+
* - enhancedDisplaySets: Other display sets with overlayability assessment
|
|
43
|
+
*/
|
|
44
|
+
export function getEnhancedDisplaySets({ viewportId, services }) {
|
|
45
|
+
const { displaySetService, viewportGridService } = services;
|
|
46
|
+
const displaySetsUIDs = viewportGridService.getDisplaySetsUIDsForViewport(viewportId);
|
|
47
|
+
|
|
48
|
+
if (!displaySetsUIDs?.length) {
|
|
49
|
+
return {
|
|
50
|
+
viewportDisplaySets: [],
|
|
51
|
+
enhancedDisplaySets: [],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const allDisplaySets = displaySetService.getActiveDisplaySets();
|
|
56
|
+
|
|
57
|
+
const otherDisplaySets = allDisplaySets.filter(
|
|
58
|
+
displaySet => !displaySetsUIDs.includes(displaySet.displaySetInstanceUID)
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const viewportDisplaySets = displaySetsUIDs.map(displaySetUID =>
|
|
62
|
+
displaySetService.getDisplaySetByUID(displaySetUID)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const backgroundDisplaySet = viewportDisplaySets[0];
|
|
66
|
+
|
|
67
|
+
const enhancedDisplaySets = otherDisplaySets.map(displaySet => ({
|
|
68
|
+
...displaySet,
|
|
69
|
+
isOverlayable: isDisplaySetOverlayable({ displaySet, backgroundDisplaySet }),
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
viewportDisplaySets,
|
|
74
|
+
enhancedDisplaySets,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Sort function: puts disabled items (isOverlayable: false) at the end
|
|
80
|
+
*/
|
|
81
|
+
export const sortByOverlayable = (a, b) => {
|
|
82
|
+
if (a.isOverlayable === b.isOverlayable) {
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
return a.isOverlayable ? -1 : 1;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Create display set options based on modality and opacity settings
|
|
90
|
+
*/
|
|
91
|
+
export function createColormapOverlayDisplaySetOptions(displaySet, opacity, customizationService) {
|
|
92
|
+
if (displaySet.Modality === 'SEG') {
|
|
93
|
+
return {};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const modalitySettings = getModalityOverlayColormap(customizationService, displaySet.Modality);
|
|
97
|
+
return {
|
|
98
|
+
colormap: {
|
|
99
|
+
name: modalitySettings.colormap || DEFAULT_COLORMAP,
|
|
100
|
+
opacity: opacity / 100, // Convert from percentage to 0-1 range
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get segmentations that can be added as overlays to the viewport
|
|
107
|
+
*
|
|
108
|
+
* Note: This function is deprecated as we now use display sets for segmentations
|
|
109
|
+
*/
|
|
110
|
+
export function getAvailableSegmentations(segmentationService) {
|
|
111
|
+
const segmentations = segmentationService.getSegmentations() || [];
|
|
112
|
+
return segmentations.map(segmentation => ({
|
|
113
|
+
segmentationId: segmentation.segmentationId,
|
|
114
|
+
label: segmentation.label || 'Segmentation',
|
|
115
|
+
segments: segmentation.segments,
|
|
116
|
+
frameOfReferenceUID: segmentation.frameOfReferenceUID,
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { useSystem } from '@ohif/core';
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
Icons,
|
|
6
|
+
Popover,
|
|
7
|
+
PopoverContent,
|
|
8
|
+
PopoverTrigger,
|
|
9
|
+
useIconPresentation,
|
|
10
|
+
} from '@ohif/ui-next';
|
|
11
|
+
import { getVolume3DSpin, type ViewDirection } from '../../utils/volume3dView';
|
|
12
|
+
|
|
13
|
+
const CENTER = 50;
|
|
14
|
+
const LINE_RADIUS = 30;
|
|
15
|
+
const LABEL_RADIUS = 42;
|
|
16
|
+
|
|
17
|
+
// Screen angle of each label; P-A is drawn as a diagonal to suggest depth.
|
|
18
|
+
const DIRECTIONS: { direction: ViewDirection; angle: number }[] = [
|
|
19
|
+
{ direction: 'S', angle: -90 },
|
|
20
|
+
{ direction: 'I', angle: 90 },
|
|
21
|
+
{ direction: 'R', angle: 180 },
|
|
22
|
+
{ direction: 'L', angle: 0 },
|
|
23
|
+
{ direction: 'P', angle: 225 },
|
|
24
|
+
{ direction: 'A', angle: 45 },
|
|
25
|
+
];
|
|
26
|
+
const AXIS_ANGLES = [180, -90, 225];
|
|
27
|
+
|
|
28
|
+
const toXY = (angleDegrees: number, radius: number) => {
|
|
29
|
+
const radians = (angleDegrees * Math.PI) / 180;
|
|
30
|
+
return { x: CENTER + radius * Math.cos(radians), y: CENTER + radius * Math.sin(radians) };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Orientation menu of a volume3d viewport, in the style of the 3D Slicer view controller:
|
|
35
|
+
* click S, I, R, L, A or P to look from that side, and set a continuous spin speed.
|
|
36
|
+
*/
|
|
37
|
+
function Viewport3DCompassMenu({
|
|
38
|
+
location,
|
|
39
|
+
viewportId,
|
|
40
|
+
isOpen = false,
|
|
41
|
+
onOpen,
|
|
42
|
+
onClose,
|
|
43
|
+
disabled,
|
|
44
|
+
...props
|
|
45
|
+
}: withAppTypes<{
|
|
46
|
+
location?: string;
|
|
47
|
+
viewportId: string;
|
|
48
|
+
isOpen?: boolean;
|
|
49
|
+
onOpen?: () => void;
|
|
50
|
+
onClose?: () => void;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
}>) {
|
|
53
|
+
const { servicesManager, commandsManager } = useSystem();
|
|
54
|
+
const { toolbarService } = servicesManager.services;
|
|
55
|
+
const { IconContainer, className: iconClassName, containerProps } = useIconPresentation();
|
|
56
|
+
const [spin, setSpin] = useState(0);
|
|
57
|
+
const triggerRef = useRef<HTMLDivElement>(null);
|
|
58
|
+
const interactedOutsideRef = useRef(false);
|
|
59
|
+
|
|
60
|
+
const changeSpin = (speed: number) => {
|
|
61
|
+
commandsManager.runCommand('setViewport3DSpin', { viewportId, speed });
|
|
62
|
+
setSpin(speed);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const lookFrom = (direction: ViewDirection) =>
|
|
66
|
+
commandsManager.runCommand('setViewport3DViewDirection', { viewportId, direction });
|
|
67
|
+
|
|
68
|
+
const handleOpenChange = (openState: boolean) => {
|
|
69
|
+
if (openState) {
|
|
70
|
+
// The spin can stop without this menu, for example when the viewport changes.
|
|
71
|
+
setSpin(getVolume3DSpin(viewportId));
|
|
72
|
+
onOpen?.();
|
|
73
|
+
} else {
|
|
74
|
+
onClose?.();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const { align, side } = toolbarService.getAlignAndSide(Number(location));
|
|
79
|
+
const Icon = <Icons.OrientationSwitch className={iconClassName} />;
|
|
80
|
+
const gradientId = `compass-sphere-${viewportId}`;
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Popover
|
|
84
|
+
open={isOpen}
|
|
85
|
+
onOpenChange={handleOpenChange}
|
|
86
|
+
>
|
|
87
|
+
<PopoverTrigger
|
|
88
|
+
asChild
|
|
89
|
+
className="flex items-center justify-center"
|
|
90
|
+
>
|
|
91
|
+
<div ref={triggerRef}>
|
|
92
|
+
{IconContainer ? (
|
|
93
|
+
<IconContainer
|
|
94
|
+
disabled={disabled}
|
|
95
|
+
icon="OrientationSwitch"
|
|
96
|
+
label="3D orientation"
|
|
97
|
+
{...props}
|
|
98
|
+
{...containerProps}
|
|
99
|
+
>
|
|
100
|
+
{Icon}
|
|
101
|
+
</IconContainer>
|
|
102
|
+
) : (
|
|
103
|
+
<Button
|
|
104
|
+
variant="ghost"
|
|
105
|
+
size="icon"
|
|
106
|
+
disabled={disabled}
|
|
107
|
+
aria-label="3D orientation"
|
|
108
|
+
>
|
|
109
|
+
{Icon}
|
|
110
|
+
</Button>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
</PopoverTrigger>
|
|
114
|
+
<PopoverContent
|
|
115
|
+
onInteractOutside={() => {
|
|
116
|
+
interactedOutsideRef.current = true;
|
|
117
|
+
}}
|
|
118
|
+
// The trigger is a wrapper div that cannot take focus; return focus to its button,
|
|
119
|
+
// except after a click outside, where the focus stays where the user put it.
|
|
120
|
+
onCloseAutoFocus={event => {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
if (!interactedOutsideRef.current) {
|
|
123
|
+
triggerRef.current?.querySelector('button')?.focus();
|
|
124
|
+
}
|
|
125
|
+
interactedOutsideRef.current = false;
|
|
126
|
+
}}
|
|
127
|
+
className="w-auto flex-shrink-0 rounded-lg border-0 bg-neutral-800 p-1 shadow-none"
|
|
128
|
+
align={align}
|
|
129
|
+
side={side}
|
|
130
|
+
style={{ left: 0 }}
|
|
131
|
+
>
|
|
132
|
+
<svg
|
|
133
|
+
viewBox="0 0 100 100"
|
|
134
|
+
className="h-36 w-36"
|
|
135
|
+
role="group"
|
|
136
|
+
aria-label="View direction"
|
|
137
|
+
>
|
|
138
|
+
<defs>
|
|
139
|
+
<radialGradient
|
|
140
|
+
id={gradientId}
|
|
141
|
+
cx="35%"
|
|
142
|
+
cy="35%"
|
|
143
|
+
r="65%"
|
|
144
|
+
fx="35%"
|
|
145
|
+
fy="35%"
|
|
146
|
+
>
|
|
147
|
+
<stop
|
|
148
|
+
offset="0%"
|
|
149
|
+
stopColor="hsl(var(--secondary-foreground))"
|
|
150
|
+
stopOpacity="0.9"
|
|
151
|
+
/>
|
|
152
|
+
<stop
|
|
153
|
+
offset="45%"
|
|
154
|
+
stopColor="hsl(var(--secondary))"
|
|
155
|
+
stopOpacity="1"
|
|
156
|
+
/>
|
|
157
|
+
<stop
|
|
158
|
+
offset="100%"
|
|
159
|
+
stopColor="hsl(var(--secondary))"
|
|
160
|
+
stopOpacity="0.55"
|
|
161
|
+
/>
|
|
162
|
+
</radialGradient>
|
|
163
|
+
</defs>
|
|
164
|
+
{AXIS_ANGLES.map(angle => {
|
|
165
|
+
const start = toXY(angle, LINE_RADIUS);
|
|
166
|
+
const end = toXY(angle + 180, LINE_RADIUS);
|
|
167
|
+
return (
|
|
168
|
+
<line
|
|
169
|
+
key={angle}
|
|
170
|
+
x1={start.x}
|
|
171
|
+
y1={start.y}
|
|
172
|
+
x2={end.x}
|
|
173
|
+
y2={end.y}
|
|
174
|
+
stroke="white"
|
|
175
|
+
strokeWidth="1.2"
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
})}
|
|
179
|
+
<circle
|
|
180
|
+
cx={CENTER}
|
|
181
|
+
cy={CENTER}
|
|
182
|
+
r={5}
|
|
183
|
+
fill={`url(#${gradientId})`}
|
|
184
|
+
className="drop-shadow-[0_0_6px_hsl(var(--secondary)/0.7)]"
|
|
185
|
+
/>
|
|
186
|
+
{DIRECTIONS.map(({ direction, angle }) => {
|
|
187
|
+
const { x, y } = toXY(angle, LABEL_RADIUS);
|
|
188
|
+
return (
|
|
189
|
+
<g
|
|
190
|
+
key={direction}
|
|
191
|
+
className="group cursor-pointer select-none outline-none"
|
|
192
|
+
onClick={() => lookFrom(direction)}
|
|
193
|
+
onKeyDown={event => {
|
|
194
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
lookFrom(direction);
|
|
197
|
+
}
|
|
198
|
+
}}
|
|
199
|
+
role="button"
|
|
200
|
+
tabIndex={0}
|
|
201
|
+
aria-label={`View from ${direction}`}
|
|
202
|
+
>
|
|
203
|
+
<circle
|
|
204
|
+
cx={x}
|
|
205
|
+
cy={y}
|
|
206
|
+
r={10}
|
|
207
|
+
fill="transparent"
|
|
208
|
+
className="group-focus-visible:stroke-white"
|
|
209
|
+
/>
|
|
210
|
+
<text
|
|
211
|
+
x={x}
|
|
212
|
+
y={y}
|
|
213
|
+
textAnchor="middle"
|
|
214
|
+
dominantBaseline="central"
|
|
215
|
+
fill="white"
|
|
216
|
+
fontSize="11"
|
|
217
|
+
fontWeight="600"
|
|
218
|
+
fontFamily="sans-serif"
|
|
219
|
+
className="pointer-events-none"
|
|
220
|
+
>
|
|
221
|
+
{direction}
|
|
222
|
+
</text>
|
|
223
|
+
</g>
|
|
224
|
+
);
|
|
225
|
+
})}
|
|
226
|
+
</svg>
|
|
227
|
+
<div className="mt-2 flex items-center justify-center">
|
|
228
|
+
<button
|
|
229
|
+
type="button"
|
|
230
|
+
className="mr-2 cursor-pointer text-lg text-neutral-400 outline-none hover:text-neutral-200 focus:text-neutral-200"
|
|
231
|
+
onClick={() => changeSpin(spin === 0 ? 1 : 0)}
|
|
232
|
+
aria-label={spin === 0 ? 'Start spin' : 'Stop spin'}
|
|
233
|
+
>
|
|
234
|
+
Spin
|
|
235
|
+
</button>
|
|
236
|
+
<Button
|
|
237
|
+
variant="ghost"
|
|
238
|
+
size="icon"
|
|
239
|
+
className="h-7 w-7"
|
|
240
|
+
onClick={() => changeSpin(spin - 1)}
|
|
241
|
+
aria-label="Decrease spin"
|
|
242
|
+
>
|
|
243
|
+
<Icons.ChevronLeft className="h-4 w-4" />
|
|
244
|
+
</Button>
|
|
245
|
+
<span className="min-w-[1.75rem] text-center font-mono text-sm font-medium">{spin}</span>
|
|
246
|
+
<Button
|
|
247
|
+
variant="ghost"
|
|
248
|
+
size="icon"
|
|
249
|
+
className="h-7 w-7"
|
|
250
|
+
onClick={() => changeSpin(spin + 1)}
|
|
251
|
+
aria-label="Increase spin"
|
|
252
|
+
>
|
|
253
|
+
<Icons.ChevronRight className="h-4 w-4" />
|
|
254
|
+
</Button>
|
|
255
|
+
</div>
|
|
256
|
+
</PopoverContent>
|
|
257
|
+
</Popover>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export default Viewport3DCompassMenu;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn, Icons, useIconPresentation } from '@ohif/ui-next';
|
|
3
|
+
import { useSystem } from '@ohif/core';
|
|
4
|
+
import { Enums } from '@cornerstonejs/core';
|
|
5
|
+
import { getViewportAdapter } from '../../services/ViewportService/adapter';
|
|
6
|
+
import { Popover, PopoverTrigger, PopoverContent, Button, useViewportGrid } from '@ohif/ui-next';
|
|
7
|
+
|
|
8
|
+
function ViewportOrientationMenu({
|
|
9
|
+
location,
|
|
10
|
+
viewportId,
|
|
11
|
+
displaySets,
|
|
12
|
+
isOpen = false,
|
|
13
|
+
onOpen,
|
|
14
|
+
onClose,
|
|
15
|
+
disabled,
|
|
16
|
+
...props
|
|
17
|
+
}: withAppTypes<{
|
|
18
|
+
location?: string;
|
|
19
|
+
viewportId: string;
|
|
20
|
+
displaySets: AppTypes.DisplaySet[];
|
|
21
|
+
isOpen?: boolean;
|
|
22
|
+
onOpen?: () => void;
|
|
23
|
+
onClose?: () => void;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}>) {
|
|
26
|
+
const { servicesManager, commandsManager } = useSystem();
|
|
27
|
+
const { cornerstoneViewportService, toolbarService } = servicesManager.services;
|
|
28
|
+
const viewportInfo = cornerstoneViewportService.getViewportInfo(viewportId);
|
|
29
|
+
const viewportOrientation = viewportInfo.getOrientation();
|
|
30
|
+
|
|
31
|
+
const [gridState] = useViewportGrid();
|
|
32
|
+
const viewportIdToUse = viewportId || gridState.activeViewportId;
|
|
33
|
+
const { IconContainer, className: iconClassName, containerProps } = useIconPresentation();
|
|
34
|
+
const [currentOrientation, setCurrentOrientation] = React.useState<string>(
|
|
35
|
+
typeof viewportOrientation === 'string' ? viewportOrientation : 'axial'
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const handleOrientationChange = (orientation: string) => {
|
|
39
|
+
setCurrentOrientation(orientation);
|
|
40
|
+
|
|
41
|
+
if (!displaySets.length) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Check if at least one displaySet is reconstructable
|
|
46
|
+
const hasReconstructableDisplaySet = displaySets.some(ds => ds.isReconstructable);
|
|
47
|
+
|
|
48
|
+
if (!hasReconstructableDisplaySet) {
|
|
49
|
+
console.warn('Cannot change orientation: No reconstructable display sets in viewport');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Set the orientation enum based on the selected orientation
|
|
54
|
+
let orientationEnum;
|
|
55
|
+
switch (orientation.toLowerCase()) {
|
|
56
|
+
case 'axial':
|
|
57
|
+
orientationEnum = Enums.OrientationAxis.AXIAL;
|
|
58
|
+
break;
|
|
59
|
+
case 'sagittal':
|
|
60
|
+
orientationEnum = Enums.OrientationAxis.SAGITTAL;
|
|
61
|
+
break;
|
|
62
|
+
case 'coronal':
|
|
63
|
+
orientationEnum = Enums.OrientationAxis.CORONAL;
|
|
64
|
+
break;
|
|
65
|
+
case 'reformat':
|
|
66
|
+
orientationEnum = Enums.OrientationAxis.REFORMAT;
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
orientationEnum = Enums.OrientationAxis.ACQUISITION;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const displaySetUIDs = displaySets.map(ds => ds.displaySetInstanceUID);
|
|
73
|
+
|
|
74
|
+
// A viewport already rendering in volume mode (legacy ORTHOGRAPHIC OR a next
|
|
75
|
+
// viewport that reports planarNext but renders volume actors, e.g. a CT+PET
|
|
76
|
+
// fusion) can be reoriented in place. Recreating it via setDisplaySetsForViewports
|
|
77
|
+
// would pass empty displaySetOptions and drop per-display-set presentation such
|
|
78
|
+
// as the PET overlay colormap/opacity. Only the genuine stack -> volume (MPR)
|
|
79
|
+
// case needs recreation.
|
|
80
|
+
const csViewport = cornerstoneViewportService.getCornerstoneViewport(viewportIdToUse);
|
|
81
|
+
const isVolumeMode = !!csViewport && getViewportAdapter(csViewport).canReorientInPlace();
|
|
82
|
+
|
|
83
|
+
// If viewport is not already in volume mode, we need to convert it
|
|
84
|
+
if (!isVolumeMode) {
|
|
85
|
+
// Configure the viewport to be a volume viewport with current display sets
|
|
86
|
+
const updatedViewport = {
|
|
87
|
+
viewportId: viewportIdToUse,
|
|
88
|
+
displaySetInstanceUIDs: displaySetUIDs,
|
|
89
|
+
viewportOptions: {
|
|
90
|
+
viewportType: Enums.ViewportType.ORTHOGRAPHIC,
|
|
91
|
+
orientation: orientationEnum,
|
|
92
|
+
},
|
|
93
|
+
displaySetOptions: displaySetUIDs.map(() => ({})),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Update the viewport to be a volume viewport
|
|
97
|
+
commandsManager.run('setDisplaySetsForViewports', {
|
|
98
|
+
viewportsToUpdate: [updatedViewport],
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
// Set the viewport orientation
|
|
102
|
+
commandsManager.runCommand('setViewportOrientation', {
|
|
103
|
+
viewportId: viewportIdToUse,
|
|
104
|
+
orientation: orientationEnum,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Close the menu after selection
|
|
109
|
+
onClose?.();
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const handleOpenChange = (openState: boolean) => {
|
|
113
|
+
if (openState) {
|
|
114
|
+
onOpen?.();
|
|
115
|
+
} else {
|
|
116
|
+
onClose?.();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
if (!displaySets.length) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Get proper alignment and side based on the location using toolbar service
|
|
125
|
+
const { align, side } = toolbarService.getAlignAndSide(Number(location));
|
|
126
|
+
|
|
127
|
+
const Icon = React.createElement(getIcon(currentOrientation), { className: iconClassName });
|
|
128
|
+
return (
|
|
129
|
+
<Popover
|
|
130
|
+
open={isOpen}
|
|
131
|
+
onOpenChange={handleOpenChange}
|
|
132
|
+
>
|
|
133
|
+
<PopoverTrigger
|
|
134
|
+
asChild
|
|
135
|
+
className={cn('flex items-center justify-center')}
|
|
136
|
+
>
|
|
137
|
+
<div>
|
|
138
|
+
{IconContainer ? (
|
|
139
|
+
<IconContainer
|
|
140
|
+
disabled={disabled}
|
|
141
|
+
icon="OrientationSwitch"
|
|
142
|
+
{...props}
|
|
143
|
+
{...containerProps}
|
|
144
|
+
>
|
|
145
|
+
{Icon}
|
|
146
|
+
</IconContainer>
|
|
147
|
+
) : (
|
|
148
|
+
<Button
|
|
149
|
+
variant="ghost"
|
|
150
|
+
size="icon"
|
|
151
|
+
disabled={disabled}
|
|
152
|
+
onClick={() => {}}
|
|
153
|
+
>
|
|
154
|
+
{Icon}
|
|
155
|
+
</Button>
|
|
156
|
+
)}
|
|
157
|
+
</div>
|
|
158
|
+
</PopoverTrigger>
|
|
159
|
+
<PopoverContent
|
|
160
|
+
className="h-[170px] w-[130px] flex-shrink-0 flex-col items-start rounded p-1"
|
|
161
|
+
align={align}
|
|
162
|
+
side={side}
|
|
163
|
+
style={{ left: 0 }}
|
|
164
|
+
>
|
|
165
|
+
<Button
|
|
166
|
+
variant="ghost"
|
|
167
|
+
className="flex h-7 w-full flex-shrink-0 items-center justify-start self-stretch px-1 py-0"
|
|
168
|
+
onClick={() => handleOrientationChange('axial')}
|
|
169
|
+
>
|
|
170
|
+
<div className="mr-1 flex w-6 items-center justify-start">
|
|
171
|
+
{currentOrientation === 'axial' ? (
|
|
172
|
+
<Icons.Checked className="text-primary h-6 w-6" />
|
|
173
|
+
) : null}
|
|
174
|
+
</div>
|
|
175
|
+
<div className="flex-1 text-left">Axial</div>
|
|
176
|
+
</Button>
|
|
177
|
+
<Button
|
|
178
|
+
variant="ghost"
|
|
179
|
+
className="flex h-7 w-full flex-shrink-0 items-center justify-start self-stretch px-1 py-0"
|
|
180
|
+
onClick={() => handleOrientationChange('sagittal')}
|
|
181
|
+
>
|
|
182
|
+
<div className="mr-1 flex w-6 items-center justify-start">
|
|
183
|
+
{currentOrientation === 'sagittal' ? (
|
|
184
|
+
<Icons.Checked className="text-primary h-6 w-6" />
|
|
185
|
+
) : null}
|
|
186
|
+
</div>
|
|
187
|
+
<div className="flex-1 text-left">Sagittal</div>
|
|
188
|
+
</Button>
|
|
189
|
+
<Button
|
|
190
|
+
variant="ghost"
|
|
191
|
+
className="flex h-7 w-full flex-shrink-0 items-center justify-start self-stretch px-1 py-0"
|
|
192
|
+
onClick={() => handleOrientationChange('coronal')}
|
|
193
|
+
>
|
|
194
|
+
<div className="mr-1 flex w-6 items-center justify-start">
|
|
195
|
+
{currentOrientation === 'coronal' ? (
|
|
196
|
+
<Icons.Checked className="text-primary h-6 w-6" />
|
|
197
|
+
) : null}
|
|
198
|
+
</div>
|
|
199
|
+
<div className="flex-1 text-left">Coronal</div>
|
|
200
|
+
</Button>
|
|
201
|
+
<Button
|
|
202
|
+
variant="ghost"
|
|
203
|
+
className="flex h-7 w-full flex-shrink-0 items-center justify-start self-stretch px-1 py-0"
|
|
204
|
+
onClick={() => handleOrientationChange('acquisition')}
|
|
205
|
+
>
|
|
206
|
+
<div className="mr-1 flex w-6 items-center justify-start">
|
|
207
|
+
{currentOrientation === 'acquisition' ? (
|
|
208
|
+
<Icons.Checked className="text-primary h-6 w-6" />
|
|
209
|
+
) : null}
|
|
210
|
+
</div>
|
|
211
|
+
<div className="flex-1 text-left">Acquisition</div>
|
|
212
|
+
</Button>
|
|
213
|
+
{/* Divider */}
|
|
214
|
+
<div className="border-input mx-1 my-2 border-t" />
|
|
215
|
+
<Button
|
|
216
|
+
variant="ghost"
|
|
217
|
+
className="flex h-7 w-full flex-shrink-0 items-center justify-start self-stretch px-1 py-0"
|
|
218
|
+
onClick={() => handleOrientationChange('reformat')}
|
|
219
|
+
>
|
|
220
|
+
<div className="mr-1 flex w-6 items-center justify-start">
|
|
221
|
+
{currentOrientation === 'reformat' ? (
|
|
222
|
+
<Icons.Checked className="text-primary h-6 w-6" />
|
|
223
|
+
) : null}
|
|
224
|
+
</div>
|
|
225
|
+
<div className="flex-1 text-left">Reformat</div>
|
|
226
|
+
</Button>
|
|
227
|
+
</PopoverContent>
|
|
228
|
+
</Popover>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const getIcon = (orientationName: string) => {
|
|
233
|
+
switch (orientationName.toLowerCase()) {
|
|
234
|
+
case 'axial':
|
|
235
|
+
return Icons.OrientationSwitchA;
|
|
236
|
+
case 'sagittal':
|
|
237
|
+
return Icons.OrientationSwitchS;
|
|
238
|
+
case 'coronal':
|
|
239
|
+
return Icons.OrientationSwitchC;
|
|
240
|
+
case 'reformat':
|
|
241
|
+
return Icons.OrientationSwitchR;
|
|
242
|
+
case 'acquisition':
|
|
243
|
+
return Icons.OrientationSwitch;
|
|
244
|
+
default:
|
|
245
|
+
return Icons.OrientationSwitch;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export default ViewportOrientationMenu;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { useSystem } from '@ohif/core';
|
|
3
|
+
import ViewportOrientationMenu from './ViewportOrientationMenu';
|
|
4
|
+
import Viewport3DCompassMenu from './Viewport3DCompassMenu';
|
|
5
|
+
import { useViewportDisplaySets } from '../../hooks/useViewportDisplaySets';
|
|
6
|
+
import { getViewportAdapter } from '../../services/ViewportService/adapter';
|
|
7
|
+
|
|
8
|
+
export function ViewportOrientationMenuWrapper(
|
|
9
|
+
props: withAppTypes<{
|
|
10
|
+
viewportId: string;
|
|
11
|
+
location: string;
|
|
12
|
+
isOpen?: boolean;
|
|
13
|
+
onOpen?: () => void;
|
|
14
|
+
onClose?: () => void;
|
|
15
|
+
iconSize?: number;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}>
|
|
18
|
+
): ReactNode {
|
|
19
|
+
const { viewportId } = props;
|
|
20
|
+
const { viewportDisplaySets } = useViewportDisplaySets(viewportId);
|
|
21
|
+
const { servicesManager } = useSystem();
|
|
22
|
+
|
|
23
|
+
if (!viewportDisplaySets.length) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const viewport = servicesManager.services.cornerstoneViewportService.getCornerstoneViewport(
|
|
28
|
+
viewportId
|
|
29
|
+
);
|
|
30
|
+
if (viewport && getViewportAdapter(viewport).getShape() === 'volume3d') {
|
|
31
|
+
return <Viewport3DCompassMenu {...props} />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<ViewportOrientationMenu
|
|
36
|
+
{...props}
|
|
37
|
+
displaySets={viewportDisplaySets}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|