@ohif/extension-cornerstone 3.14.0-beta.10 → 3.14.0-beta.100
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 +502 -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 +2951 -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/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 +94 -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/ViewportOrientationMenu.tsx +249 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenuWrapper.tsx +29 -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 +12 -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 +8 -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/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 +350 -0
- package/src/init.tsx +445 -0
- package/src/initCineService.ts +75 -0
- package/src/initContextMenu.ts +94 -0
- package/src/initCornerstoneTools.js +188 -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 +3698 -0
- package/src/services/SegmentationService/SegmentationService.ts +2376 -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 +671 -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.ts +83 -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/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 +96 -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/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
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import {
|
|
2
|
+
utilities as csUtils,
|
|
3
|
+
CONSTANTS as csConstants,
|
|
4
|
+
Types as CoreTypes,
|
|
5
|
+
} from '@cornerstonejs/core';
|
|
6
|
+
import { getViewportAdapter } from '../adapter';
|
|
7
|
+
import { legacyViewportOperations } from './LegacyViewportOperations';
|
|
8
|
+
import type {
|
|
9
|
+
IViewportOperations,
|
|
10
|
+
FlipValue,
|
|
11
|
+
RotationMode,
|
|
12
|
+
VolumeLightingOptions,
|
|
13
|
+
WindowLevelParams,
|
|
14
|
+
ColormapParams,
|
|
15
|
+
} from './IViewportOperations';
|
|
16
|
+
|
|
17
|
+
// Native PLANAR_NEXT semantic accessors not covered by the viewport adapter.
|
|
18
|
+
// They live on IGenericViewport, so cast structurally at the boundary.
|
|
19
|
+
type NativePlanarViewport = CoreTypes.IViewport & {
|
|
20
|
+
resetViewState?: () => void;
|
|
21
|
+
resetDisplaySetPresentation?: (dataId?: string) => void;
|
|
22
|
+
getZoom?: () => number;
|
|
23
|
+
setZoom?: (zoom: number) => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Native ("next") lane of IViewportOperations for direct PLANAR_NEXT viewports.
|
|
28
|
+
* Appearance and camera/view-state ops go through the viewport adapter (which
|
|
29
|
+
* encapsulates the native getViewState/setViewState and
|
|
30
|
+
* getDisplaySetPresentation/setDisplaySetPresentation primitives, including the
|
|
31
|
+
* active-binding dataId default); the remaining ops use the native semantic API
|
|
32
|
+
* directly. The dispatcher only routes generic viewports here.
|
|
33
|
+
*
|
|
34
|
+
* No method calls viewport.render() — the command renders.
|
|
35
|
+
*/
|
|
36
|
+
export const nextViewportOperations: IViewportOperations = {
|
|
37
|
+
flipHorizontal(viewport: CoreTypes.IViewport, newValue: FlipValue = 'toggle'): void {
|
|
38
|
+
const adapter = getViewportAdapter(viewport);
|
|
39
|
+
const flipHorizontal =
|
|
40
|
+
newValue === 'toggle' ? !adapter.getViewState().flipHorizontal : newValue;
|
|
41
|
+
adapter.setViewState({ flipHorizontal });
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
flipVertical(viewport: CoreTypes.IViewport, newValue: FlipValue = 'toggle'): void {
|
|
45
|
+
const adapter = getViewportAdapter(viewport);
|
|
46
|
+
const flipVertical = newValue === 'toggle' ? !adapter.getViewState().flipVertical : newValue;
|
|
47
|
+
adapter.setViewState({ flipVertical });
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
invert(viewport: CoreTypes.IViewport): void {
|
|
51
|
+
const adapter = getViewportAdapter(viewport);
|
|
52
|
+
const { invert } = adapter.getPresentation();
|
|
53
|
+
adapter.setPresentation({ invert: !invert });
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
rotate(viewport: CoreTypes.IViewport, rotation: number, mode: RotationMode = 'apply'): void {
|
|
57
|
+
// rotation/flip live in the semantic view state; getViewPresentation is absent.
|
|
58
|
+
const adapter = getViewportAdapter(viewport);
|
|
59
|
+
const state = adapter.getViewState();
|
|
60
|
+
const currentRotation = (state.rotation as number) ?? 0;
|
|
61
|
+
const newRotation =
|
|
62
|
+
mode === 'apply'
|
|
63
|
+
? (currentRotation + rotation + 360) % 360
|
|
64
|
+
: (() => {
|
|
65
|
+
const flipsParity = (state.flipHorizontal ? 1 : 0) + (state.flipVertical ? 1 : 0);
|
|
66
|
+
const effectiveRotation = flipsParity % 2 === 1 ? -rotation : rotation;
|
|
67
|
+
return (effectiveRotation + 360) % 360;
|
|
68
|
+
})();
|
|
69
|
+
adapter.setViewState({ rotation: newRotation });
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
reset(viewport: CoreTypes.IViewport): void {
|
|
73
|
+
const vp = viewport as NativePlanarViewport;
|
|
74
|
+
// Reset the per-display-set presentation (VOI/colormap/invert) to defaults.
|
|
75
|
+
vp.resetDisplaySetPresentation?.();
|
|
76
|
+
// No resetCamera on PLANAR_NEXT; resetViewState resets pan/zoom/rotation/orientation/flip.
|
|
77
|
+
vp.resetViewState?.();
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
scaleBy(viewport: CoreTypes.IViewport, direction: number): void {
|
|
81
|
+
// parallelScale and zoom are inversely related (smaller parallelScale = more
|
|
82
|
+
// zoomed in = larger zoom), so divide by scaleFactor to match the legacy direction.
|
|
83
|
+
const scaleFactor = direction > 0 ? 0.9 : 1.1;
|
|
84
|
+
const vp = viewport as unknown as {
|
|
85
|
+
getZoom?: () => number;
|
|
86
|
+
setZoom?: (zoom: number) => void;
|
|
87
|
+
resetViewState?: (options?: { resetOrientation?: boolean }) => void;
|
|
88
|
+
};
|
|
89
|
+
if (direction) {
|
|
90
|
+
// Zoom is only meaningful on planar (stack / volume-slice / MPR) native viewports.
|
|
91
|
+
// VolumeViewport3D is also a generic viewport but exposes no getZoom/setZoom, so
|
|
92
|
+
// guard before calling — a no-op there matches the legacy lane, which only zoomed
|
|
93
|
+
// stack viewports (otherwise the zoom hotkey would throw on a native 3D viewport).
|
|
94
|
+
if (vp.getZoom && vp.setZoom) {
|
|
95
|
+
vp.setZoom(vp.getZoom() / scaleFactor);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
// direction === 0 is the fitViewportToWindow command. Legacy resetCamera()
|
|
99
|
+
// resets pan/zoom/rotation/flip but never the viewing orientation, while a
|
|
100
|
+
// full native resetViewState() would also snap an MPR back to its requested
|
|
101
|
+
// axis — so keep the orientation.
|
|
102
|
+
vp.resetViewState?.({ resetOrientation: false });
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
getViewPlaneNormal(viewport: CoreTypes.IViewport): CoreTypes.Point3 | undefined {
|
|
107
|
+
return getViewportAdapter(viewport).getViewPlaneNormal();
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
centerOnMeasurement(): boolean {
|
|
111
|
+
// CS-14: native PLANAR_NEXT has no getCamera/setCamera for in-plane pan; the
|
|
112
|
+
// caller's setViewReference already navigated to the measurement's slice.
|
|
113
|
+
// TODO(next): port in-plane centering via the camera bridge + setViewState pan.
|
|
114
|
+
return false;
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
setWindowLevel(viewport: CoreTypes.IViewport, params: WindowLevelParams): void {
|
|
118
|
+
const { lower, upper } = csUtils.windowLevel.toLowHighRange(
|
|
119
|
+
params.windowWidth,
|
|
120
|
+
params.windowCenter
|
|
121
|
+
);
|
|
122
|
+
// Target the binding for params.displaySetInstanceUID so a PT/CT *fusion* W/L lands
|
|
123
|
+
// on the intended layer (e.g. the PT overlay) instead of always the source (CT) —
|
|
124
|
+
// mirroring setColormap. When no id is given (single stack/volume) the adapter falls
|
|
125
|
+
// back to the source binding.
|
|
126
|
+
getViewportAdapter(viewport).setPresentation(
|
|
127
|
+
{ voiRange: { upper, lower } },
|
|
128
|
+
params.displaySetInstanceUID
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
setColormap(viewport: CoreTypes.IViewport, params: ColormapParams): void {
|
|
133
|
+
// Target the binding for params.displaySetInstanceUID. OHIF's dataId scheme maps a
|
|
134
|
+
// display set 1:1 onto its native dataId (bare UID), so a PT/CT *fusion* colormap lands
|
|
135
|
+
// on the overlay (PT) binding instead of defaulting to the source (CT). When no id is
|
|
136
|
+
// given (single-volume / plain stack colormap) the adapter falls back to the source.
|
|
137
|
+
getViewportAdapter(viewport).setPresentation(
|
|
138
|
+
{ colormap: params.colormap },
|
|
139
|
+
params.displaySetInstanceUID
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
setPreset(viewport: CoreTypes.IViewport, preset: string): void {
|
|
144
|
+
// The native VolumeViewport3D has no setProperties; apply the volume-rendering
|
|
145
|
+
// preset (RGBA transfer function) to the volume actor directly.
|
|
146
|
+
const presetObj = csConstants.VIEWPORT_PRESETS?.find(p => p.name === preset);
|
|
147
|
+
const actor = (
|
|
148
|
+
viewport as unknown as { getDefaultActor?: () => { actor?: unknown } | undefined }
|
|
149
|
+
).getDefaultActor?.()?.actor;
|
|
150
|
+
if (presetObj && actor) {
|
|
151
|
+
csUtils.applyPreset(actor as Parameters<typeof csUtils.applyPreset>[0], presetObj);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
// VR sample-distance / opacity-points / lighting operate on the vtk volume actor via
|
|
156
|
+
// getActors, which the native VolumeViewport3D exposes; the work is lane-agnostic, so
|
|
157
|
+
// reuse the legacy actor-based implementations.
|
|
158
|
+
setVolumeRenderingQuality(viewport: CoreTypes.IViewport, volumeQuality: number): void {
|
|
159
|
+
legacyViewportOperations.setVolumeRenderingQuality(viewport, volumeQuality);
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
shiftVolumeOpacityPoints(viewport: CoreTypes.IViewport, shift: number): void {
|
|
163
|
+
legacyViewportOperations.shiftVolumeOpacityPoints(viewport, shift);
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
setVolumeLighting(viewport: CoreTypes.IViewport, options: VolumeLightingOptions): void {
|
|
167
|
+
legacyViewportOperations.setVolumeLighting(viewport, options);
|
|
168
|
+
},
|
|
169
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Next-viewport dispatch: how legacy-vs-native is decided
|
|
2
|
+
|
|
3
|
+
The `useNextViewports` opt-in routes OHIF onto cornerstone3D's native
|
|
4
|
+
("next" / GenericViewport) API. This document is the single description of
|
|
5
|
+
where and how the two lanes are selected. If you are adding a new legacy/native
|
|
6
|
+
divergence, one of the homes below is the right place — never an inline
|
|
7
|
+
`isGenericViewport` / flag check at the call site (enforced by
|
|
8
|
+
`scripts/check-next-viewport-boundaries.sh`).
|
|
9
|
+
|
|
10
|
+
## The three homes for divergence
|
|
11
|
+
|
|
12
|
+
| Home | What belongs there |
|
|
13
|
+
|---|---|
|
|
14
|
+
| `../adapter/` (`IViewportAdapter`) | API-surface bridging on a live viewport: reads/writes that exist on both lanes with different spellings (camera vs view state, properties vs display-set presentation, volumeId vs dataId, classification). The contract is next-shaped; the legacy adapter does the adapting. |
|
|
15
|
+
| `./` (`IViewportBackend`, `IViewportOperations`, and the segmentation twins in `../../SegmentationService/backends/`) | Lifecycle and interaction bodies: mount/re-mount, presentation capture/restore, dataId registration, per-command operations (flip/rotate/W-L/...), labelmap add/assembly. |
|
|
16
|
+
| `../../../utils/nextViewportPolicies.ts` | Behavioral policy: appearance defaults and workflow rules that differ by choice, not by API (fusion opacity flattening, overlay opacity, RTSTRUCT hydrate stack-pin). |
|
|
17
|
+
|
|
18
|
+
Pre-mount classification of `viewportData` (no live viewport yet) lives in
|
|
19
|
+
`../../../utils/viewportDataShape.ts`; the persisted `dataShapeType` field set
|
|
20
|
+
by `CornerstoneCacheService` is the sanctioned way to survive the native
|
|
21
|
+
type collapse (stack/volume/MPR all report `PLANAR_NEXT` at runtime).
|
|
22
|
+
|
|
23
|
+
## Two dispatch strategies (deliberately different)
|
|
24
|
+
|
|
25
|
+
- **Session flag, selected once** — `isNextViewportsEnabled()`. Used where no
|
|
26
|
+
viewport exists yet, or for per-session lifecycle:
|
|
27
|
+
`IViewportBackend` (the `get backend()` getter on CornerstoneViewportService),
|
|
28
|
+
`getCornerstoneViewportType` (viewport-type resolution), the SEG assembly
|
|
29
|
+
path, and the policies module.
|
|
30
|
+
- **Per-viewport predicate** — `isNextViewport(viewport)` (the adapter module's
|
|
31
|
+
wrapper around `csUtils.isGenericViewport`). Used where a self-describing
|
|
32
|
+
viewport is in hand, because a flag-on session can hold BOTH native and
|
|
33
|
+
legacy viewports: `getViewportAdapter`, `viewportOperations`, and the
|
|
34
|
+
segmentation backend twins.
|
|
35
|
+
|
|
36
|
+
Do not "unify" these: lifecycle genuinely is per-session; everything else
|
|
37
|
+
genuinely is per-viewport.
|
|
38
|
+
|
|
39
|
+
## Sanctioned flag reads (`isNextViewportsEnabled`) — the exhaustive list
|
|
40
|
+
|
|
41
|
+
1. `utils/getCornerstoneViewportType.ts` — maps requested OHIF viewport types
|
|
42
|
+
to native types.
|
|
43
|
+
2. `services/ViewportService/CornerstoneViewportService.ts` — the lazy
|
|
44
|
+
`get backend()` selection.
|
|
45
|
+
3. `services/SegmentationService/SegmentationService.ts` —
|
|
46
|
+
`assembleSegmentationDataForSEG` (dispatched at SEG-load time, before any
|
|
47
|
+
target viewport exists).
|
|
48
|
+
4. `utils/nextViewportPolicies.ts` — policy rules that apply before viewports
|
|
49
|
+
exist (e.g. the RTSTRUCT hydrate stack-pin).
|
|
50
|
+
5. `extensions/tmtv/src/getHangingProtocolModule.ts` — applies the
|
|
51
|
+
`NEXT_FUSION_PT_OPACITY` policy when the HP module is gathered (the flag is
|
|
52
|
+
settled by then; the legacy ramp in `hpViewports` stays untouched).
|
|
53
|
+
|
|
54
|
+
Adding a sixth read requires updating this list AND the whitelist in
|
|
55
|
+
`scripts/check-next-viewport-boundaries.sh` — if you can express the change as
|
|
56
|
+
an adapter capability, a backend method, or a policy entry instead, do that.
|
|
57
|
+
|
|
58
|
+
## Sanctioned `csUtils.isGenericViewport` calls
|
|
59
|
+
|
|
60
|
+
Only `../adapter/getViewportAdapter.ts` (which also exports the
|
|
61
|
+
`isNextViewport` predicate for the dispatchers above). Everyone else consumes
|
|
62
|
+
`IViewportAdapter` methods.
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { utilities as csUtils } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Payload registered with cornerstone's global GenericViewport dataset metadata
|
|
5
|
+
* provider. The shape is family-specific and mirrors what each native viewport's
|
|
6
|
+
* data provider reads (see the cornerstone genericViewport examples):
|
|
7
|
+
* - planar : imageIds (+ optional volumeId) — stack / volume-slice / MPR / 3D
|
|
8
|
+
* - video : sourceDataId (the video imageId)
|
|
9
|
+
* - ecg : sourceDataId (the waveform imageId)
|
|
10
|
+
* - wsi : imageIds + a DICOMweb webClient used to fetch tiles
|
|
11
|
+
*/
|
|
12
|
+
export type DataIdPayload =
|
|
13
|
+
| { kind: 'planar'; imageIds: string[]; volumeId?: string; initialImageIdIndex?: number }
|
|
14
|
+
| { kind: 'video' | 'ecg'; sourceDataId: string }
|
|
15
|
+
| { kind: 'wsi'; imageIds: string[]; options: { webClient: unknown } };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Owns the lifecycle of OHIF's `dataId` registrations against cornerstone's
|
|
19
|
+
* process-global `genericViewportDisplaySetMetadataProvider` (see migration plan §4.7).
|
|
20
|
+
*
|
|
21
|
+
* Why this exists: cornerstone's `removeData`/`setDisplaySets` do NOT garbage-collect
|
|
22
|
+
* the global registration store (upstream blocker CS-18), so OHIF must own add/remove.
|
|
23
|
+
* The MPR triptych mounts the SAME `dataId` (the displaySetInstanceUID-derived volume)
|
|
24
|
+
* from N panes, so a naive add-on-every-mount / never-remove both over-registers and
|
|
25
|
+
* leaks. This registry ref-counts per `dataId` and keeps a per-viewport ledger so:
|
|
26
|
+
* - `provider.add` fires only on the 0 -> 1 transition,
|
|
27
|
+
* - `provider.remove` fires only on the 1 -> 0 transition,
|
|
28
|
+
* - unmounting one pane of a shared-volume triptych does not unregister data the
|
|
29
|
+
* other panes still need.
|
|
30
|
+
*
|
|
31
|
+
* Used by the native ("next") backend for all families, and by the legacy
|
|
32
|
+
* backend for its one provider-backed family (WSI mounts via mountOther).
|
|
33
|
+
*/
|
|
34
|
+
export class DataIdRegistry {
|
|
35
|
+
// Global ref-count keyed by dataId (the provider store is a single global namespace).
|
|
36
|
+
private readonly refCounts = new Map<string, number>();
|
|
37
|
+
// Last payload registered per dataId, so a re-registration that promotes a
|
|
38
|
+
// stack-only dataId to volume-backed can be detected and forwarded to the provider.
|
|
39
|
+
private readonly payloads = new Map<string, DataIdPayload>();
|
|
40
|
+
// Per-viewport ledger of the dataIds it registered, to drive release on unmount.
|
|
41
|
+
private readonly byViewport = new Map<string, string[]>();
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Builds the registration dataId for a display set. PT/CT *fusion* overlays are
|
|
45
|
+
* distinct display sets with their own UIDs, so the bare displaySetInstanceUID is
|
|
46
|
+
* already collision-free and is used for both source and overlay bindings (the LUT
|
|
47
|
+
* presentation store keys by the same UID, giving a clean 1:1 dataId mapping). The
|
|
48
|
+
* `'overlay'` suffix is reserved for the case where a source and an overlay share the
|
|
49
|
+
* SAME displaySetInstanceUID but need distinct registrations — i.e. derived labelmap
|
|
50
|
+
* overlays (segmentation / M4), which are not yet on the native path.
|
|
51
|
+
*/
|
|
52
|
+
static dataIdFor(displaySetInstanceUID: string, role?: 'overlay'): string {
|
|
53
|
+
return role === 'overlay' ? `${displaySetInstanceUID}::overlay` : displaySetInstanceUID;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Registers (or ref-bumps) a dataId for a viewport. Adds to the cornerstone
|
|
58
|
+
* provider only on the first reference. Idempotent payloads across panes that
|
|
59
|
+
* share a dataId are expected (same imageIds/volumeId), so first-writer wins —
|
|
60
|
+
* EXCEPT when a later payload promotes a previously stack-only registration to
|
|
61
|
+
* a volume-backed one (gains a `volumeId`). That happens when a data overlay
|
|
62
|
+
* (fusion) is added to a viewport whose source was first mounted as a vtkImage
|
|
63
|
+
* stack: the source is re-registered with its volumeId so it can render as a
|
|
64
|
+
* volume slice alongside the overlay. Without updating the provider here, the
|
|
65
|
+
* source would keep its volumeId-less payload and stay vtkImage while the
|
|
66
|
+
* overlay is a vtkVolumeSlice (broken fusion).
|
|
67
|
+
*/
|
|
68
|
+
register(viewportId: string, dataId: string, payload: DataIdPayload): void {
|
|
69
|
+
const prev = this.refCounts.get(dataId) ?? 0;
|
|
70
|
+
const existing = this.payloads.get(dataId);
|
|
71
|
+
const promotesToVolume =
|
|
72
|
+
!!(payload as { volumeId?: string }).volumeId &&
|
|
73
|
+
!(existing as { volumeId?: string } | undefined)?.volumeId;
|
|
74
|
+
|
|
75
|
+
if (prev === 0 || promotesToVolume) {
|
|
76
|
+
csUtils.genericViewportDisplaySetMetadataProvider.add(dataId, payload);
|
|
77
|
+
this.payloads.set(dataId, payload);
|
|
78
|
+
}
|
|
79
|
+
this.refCounts.set(dataId, prev + 1);
|
|
80
|
+
|
|
81
|
+
const list = this.byViewport.get(viewportId) ?? [];
|
|
82
|
+
list.push(dataId);
|
|
83
|
+
this.byViewport.set(viewportId, list);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Releases every dataId a viewport registered (called on element disable).
|
|
88
|
+
* Removes from the provider only when the last reference is gone.
|
|
89
|
+
*/
|
|
90
|
+
releaseViewport(viewportId: string): void {
|
|
91
|
+
const dataIds = this.byViewport.get(viewportId);
|
|
92
|
+
if (!dataIds) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
for (const dataId of dataIds) {
|
|
96
|
+
const next = (this.refCounts.get(dataId) ?? 1) - 1;
|
|
97
|
+
if (next <= 0) {
|
|
98
|
+
this.refCounts.delete(dataId);
|
|
99
|
+
this.payloads.delete(dataId);
|
|
100
|
+
csUtils.genericViewportDisplaySetMetadataProvider.remove(dataId);
|
|
101
|
+
} else {
|
|
102
|
+
this.refCounts.set(dataId, next);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
this.byViewport.delete(viewportId);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Flushes all remaining registrations (called on service destroy). Removes each
|
|
110
|
+
* dataId individually rather than `provider.clear()`, which would wipe
|
|
111
|
+
* registrations owned by other rendering contexts / service instances.
|
|
112
|
+
*/
|
|
113
|
+
destroy(): void {
|
|
114
|
+
for (const dataId of this.refCounts.keys()) {
|
|
115
|
+
csUtils.genericViewportDisplaySetMetadataProvider.remove(dataId);
|
|
116
|
+
}
|
|
117
|
+
this.refCounts.clear();
|
|
118
|
+
this.payloads.clear();
|
|
119
|
+
this.byViewport.clear();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Types as CoreTypes } from '@cornerstonejs/core';
|
|
2
|
+
import { isNextViewport } from '../adapter';
|
|
3
|
+
import type {
|
|
4
|
+
IViewportOperations,
|
|
5
|
+
FlipValue,
|
|
6
|
+
RotationMode,
|
|
7
|
+
VolumeLightingOptions,
|
|
8
|
+
WindowLevelParams,
|
|
9
|
+
ColormapParams,
|
|
10
|
+
} from './IViewportOperations';
|
|
11
|
+
import { legacyViewportOperations } from './LegacyViewportOperations';
|
|
12
|
+
import { nextViewportOperations } from './NextViewportOperations';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Picks the operations lane for a SPECIFIC viewport. Unlike the IViewportBackend
|
|
16
|
+
* lifecycle backend (selected once by the appConfig flag because it owns the
|
|
17
|
+
* per-session mount), operations route per viewport: the viewport is already created
|
|
18
|
+
* and self-describing, and a session can hold both legacy and native viewports.
|
|
19
|
+
*/
|
|
20
|
+
function backendFor(viewport: CoreTypes.IViewport): IViewportOperations {
|
|
21
|
+
return isNextViewport(viewport) ? nextViewportOperations : legacyViewportOperations;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Singleton facade over the legacy/next operations backends. commandsModule (and any
|
|
26
|
+
* other caller) imports this and calls e.g. `viewportOperations.flipHorizontal(viewport)`,
|
|
27
|
+
* keeping native-vs-legacy interaction logic out of the command bodies (migration §4.3).
|
|
28
|
+
* Stateless and dependency-free (each op takes an already-resolved viewport), so it is a
|
|
29
|
+
* plain singleton rather than a registered service.
|
|
30
|
+
*/
|
|
31
|
+
export const viewportOperations: IViewportOperations = {
|
|
32
|
+
flipHorizontal: (viewport: CoreTypes.IViewport, newValue?: FlipValue) =>
|
|
33
|
+
backendFor(viewport).flipHorizontal(viewport, newValue),
|
|
34
|
+
|
|
35
|
+
flipVertical: (viewport: CoreTypes.IViewport, newValue?: FlipValue) =>
|
|
36
|
+
backendFor(viewport).flipVertical(viewport, newValue),
|
|
37
|
+
|
|
38
|
+
invert: (viewport: CoreTypes.IViewport) => backendFor(viewport).invert(viewport),
|
|
39
|
+
|
|
40
|
+
rotate: (viewport: CoreTypes.IViewport, rotation: number, mode?: RotationMode) =>
|
|
41
|
+
backendFor(viewport).rotate(viewport, rotation, mode),
|
|
42
|
+
|
|
43
|
+
reset: (viewport: CoreTypes.IViewport) => backendFor(viewport).reset(viewport),
|
|
44
|
+
|
|
45
|
+
scaleBy: (viewport: CoreTypes.IViewport, direction: number) =>
|
|
46
|
+
backendFor(viewport).scaleBy(viewport, direction),
|
|
47
|
+
|
|
48
|
+
getViewPlaneNormal: (viewport: CoreTypes.IViewport) =>
|
|
49
|
+
backendFor(viewport).getViewPlaneNormal(viewport),
|
|
50
|
+
|
|
51
|
+
centerOnMeasurement: (viewport: CoreTypes.IViewport, measurement: Record<string, unknown>) =>
|
|
52
|
+
backendFor(viewport).centerOnMeasurement(viewport, measurement),
|
|
53
|
+
|
|
54
|
+
setWindowLevel: (viewport: CoreTypes.IViewport, params: WindowLevelParams) =>
|
|
55
|
+
backendFor(viewport).setWindowLevel(viewport, params),
|
|
56
|
+
|
|
57
|
+
setColormap: (viewport: CoreTypes.IViewport, params: ColormapParams) =>
|
|
58
|
+
backendFor(viewport).setColormap(viewport, params),
|
|
59
|
+
|
|
60
|
+
setPreset: (viewport: CoreTypes.IViewport, preset: string) =>
|
|
61
|
+
backendFor(viewport).setPreset(viewport, preset),
|
|
62
|
+
|
|
63
|
+
setVolumeRenderingQuality: (viewport: CoreTypes.IViewport, volumeQuality: number) =>
|
|
64
|
+
backendFor(viewport).setVolumeRenderingQuality(viewport, volumeQuality),
|
|
65
|
+
|
|
66
|
+
shiftVolumeOpacityPoints: (viewport: CoreTypes.IViewport, shift: number) =>
|
|
67
|
+
backendFor(viewport).shiftVolumeOpacityPoints(viewport, shift),
|
|
68
|
+
|
|
69
|
+
setVolumeLighting: (viewport: CoreTypes.IViewport, options: VolumeLightingOptions) =>
|
|
70
|
+
backendFor(viewport).setVolumeLighting(viewport, options),
|
|
71
|
+
};
|
package/src/state.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const state = {
|
|
2
|
+
// The `defaultContext` of an extension's commandsModule
|
|
3
|
+
DEFAULT_CONTEXT: 'CORNERSTONE',
|
|
4
|
+
enabledElements: {},
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Sets the enabled element `dom` reference for an active viewport.
|
|
9
|
+
* @param {HTMLElement} dom Active viewport element.
|
|
10
|
+
* @return void
|
|
11
|
+
*/
|
|
12
|
+
const setEnabledElement = (viewportId: string, element: HTMLElement, context?: string): void => {
|
|
13
|
+
const targetContext = context || state.DEFAULT_CONTEXT;
|
|
14
|
+
|
|
15
|
+
state.enabledElements[viewportId] = {
|
|
16
|
+
element,
|
|
17
|
+
context: targetContext,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Grabs the enabled element `dom` reference of an active viewport.
|
|
23
|
+
*
|
|
24
|
+
* @return {HTMLElement} Active viewport element.
|
|
25
|
+
*/
|
|
26
|
+
const getEnabledElement = viewportId => {
|
|
27
|
+
return state.enabledElements[viewportId];
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const reset = () => {
|
|
31
|
+
state.enabledElements = {};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { setEnabledElement, getEnabledElement, reset };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useLutPresentationStore } from './useLutPresentationStore';
|
|
2
|
+
export { usePositionPresentationStore } from './usePositionPresentationStore';
|
|
3
|
+
export { useSegmentationPresentationStore } from './useSegmentationPresentationStore';
|
|
4
|
+
export { useSynchronizersStore } from './useSynchronizersStore';
|
|
5
|
+
export { useSelectedSegmentationsForViewportStore } from './useSelectedSegmentationsForViewportStore';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const JOIN_STR = '&';
|
|
2
|
+
|
|
3
|
+
// The default lut presentation id if none defined
|
|
4
|
+
const DEFAULT_STR = 'default';
|
|
5
|
+
|
|
6
|
+
// This code finds the first unique index to add to the presentation id so that
|
|
7
|
+
// two viewports containing the same display set in the same type of viewport
|
|
8
|
+
// can have different presentation information. This allows comparison of
|
|
9
|
+
// a single display set in two or more viewports, when the user has simply
|
|
10
|
+
// dragged and dropped the view in twice. For example, it allows displaying
|
|
11
|
+
// bone, brain and soft tissue views of a single display set, and to still
|
|
12
|
+
// remember the specific changes to each viewport.
|
|
13
|
+
const addUniqueIndex = (
|
|
14
|
+
arr,
|
|
15
|
+
key,
|
|
16
|
+
viewports: AppTypes.ViewportGrid.Viewports,
|
|
17
|
+
isUpdatingSameViewport
|
|
18
|
+
) => {
|
|
19
|
+
arr.push(0);
|
|
20
|
+
|
|
21
|
+
// If we are updating the viewport, we should not increment the index
|
|
22
|
+
if (isUpdatingSameViewport) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// The 128 is just a value that is larger than how many viewports we
|
|
27
|
+
// display at once, used as an upper bound on how many unique presentation
|
|
28
|
+
// ID's might exist for a single display set at once.
|
|
29
|
+
for (let displayInstance = 0; displayInstance < 128; displayInstance++) {
|
|
30
|
+
arr[arr.length - 1] = displayInstance;
|
|
31
|
+
const testId = arr.join(JOIN_STR);
|
|
32
|
+
if (
|
|
33
|
+
!Array.from(viewports.values()).find(
|
|
34
|
+
viewport => viewport.viewportOptions?.presentationIds?.[key] === testId
|
|
35
|
+
)
|
|
36
|
+
) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { addUniqueIndex, DEFAULT_STR, JOIN_STR };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { devtools } from 'zustand/middleware';
|
|
3
|
+
import { LutPresentation } from '../types/Presentation';
|
|
4
|
+
import { addUniqueIndex, DEFAULT_STR, JOIN_STR } from './presentationUtils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Identifier for the LUT Presentation store type.
|
|
8
|
+
*/
|
|
9
|
+
const PRESENTATION_TYPE_ID = 'lutPresentationId';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Flag to enable or disable debug mode for the store.
|
|
13
|
+
* Set to `true` to enable zustand devtools.
|
|
14
|
+
*/
|
|
15
|
+
const DEBUG_STORE = false;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents the state and actions for managing LUT presentations.
|
|
19
|
+
*/
|
|
20
|
+
type LutPresentationState = {
|
|
21
|
+
/**
|
|
22
|
+
* Type identifier for the store.
|
|
23
|
+
*/
|
|
24
|
+
type: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Stores LUT presentations indexed by their presentation ID.
|
|
28
|
+
*/
|
|
29
|
+
lutPresentationStore: Record<string, LutPresentation>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sets the LUT presentation for a given key.
|
|
33
|
+
*
|
|
34
|
+
* @param key - The key identifying the LUT presentation.
|
|
35
|
+
* @param value - The `LutPresentation` to associate with the key.
|
|
36
|
+
*/
|
|
37
|
+
setLutPresentation: (key: string, value: LutPresentation) => void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Clears all LUT presentations from the store.
|
|
41
|
+
*/
|
|
42
|
+
clearLutPresentationStore: () => void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves the presentation ID based on the provided parameters.
|
|
46
|
+
*
|
|
47
|
+
* @param id - The presentation ID to check.
|
|
48
|
+
* @param options - Configuration options.
|
|
49
|
+
* @param options.viewport - The current viewport in grid
|
|
50
|
+
* @param options.viewports - All available viewports in grid
|
|
51
|
+
* @param options.isUpdatingSameViewport - Indicates if the same viewport is being updated.
|
|
52
|
+
* @returns The presentation ID or undefined.
|
|
53
|
+
*/
|
|
54
|
+
getPresentationId: (
|
|
55
|
+
id: string,
|
|
56
|
+
options: {
|
|
57
|
+
viewport: AppTypes.ViewportGrid.Viewport;
|
|
58
|
+
viewports: AppTypes.ViewportGrid.Viewports;
|
|
59
|
+
isUpdatingSameViewport: boolean;
|
|
60
|
+
}
|
|
61
|
+
) => string | undefined;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Generates a presentation ID for LUT based on the viewport configuration.
|
|
66
|
+
*
|
|
67
|
+
* @param id - The ID to check.
|
|
68
|
+
* @param options - Configuration options.
|
|
69
|
+
* @param options.viewport - The current viewport.
|
|
70
|
+
* @param options.viewports - All available viewports.
|
|
71
|
+
* @param options.isUpdatingSameViewport - Indicates if the same viewport is being updated.
|
|
72
|
+
* @returns The LUT presentation ID or undefined.
|
|
73
|
+
*/
|
|
74
|
+
const getLutPresentationId = (
|
|
75
|
+
id: string,
|
|
76
|
+
{
|
|
77
|
+
viewport,
|
|
78
|
+
viewports,
|
|
79
|
+
isUpdatingSameViewport,
|
|
80
|
+
}: {
|
|
81
|
+
viewport: AppTypes.ViewportGrid.Viewport;
|
|
82
|
+
viewports: AppTypes.ViewportGrid.Viewports;
|
|
83
|
+
isUpdatingSameViewport: boolean;
|
|
84
|
+
}
|
|
85
|
+
): string | undefined => {
|
|
86
|
+
if (id !== PRESENTATION_TYPE_ID) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const getLutId = (ds): string => {
|
|
91
|
+
if (!ds || !ds.options) {
|
|
92
|
+
return DEFAULT_STR;
|
|
93
|
+
}
|
|
94
|
+
if (ds.options.id) {
|
|
95
|
+
return ds.options.id;
|
|
96
|
+
}
|
|
97
|
+
const arr = Object.entries(ds.options).map(([key, val]) => `${key}=${val}`);
|
|
98
|
+
if (!arr.length) {
|
|
99
|
+
return DEFAULT_STR;
|
|
100
|
+
}
|
|
101
|
+
return arr.join(JOIN_STR);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
if (!viewport || !viewport.viewportOptions || !viewport.displaySetInstanceUIDs?.length) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const { displaySetOptions, displaySetInstanceUIDs } = viewport;
|
|
109
|
+
const lutId = getLutId(displaySetOptions[0]);
|
|
110
|
+
const lutPresentationArr = [lutId];
|
|
111
|
+
|
|
112
|
+
for (const uid of displaySetInstanceUIDs) {
|
|
113
|
+
lutPresentationArr.push(uid);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
addUniqueIndex(lutPresentationArr, PRESENTATION_TYPE_ID, viewports, isUpdatingSameViewport);
|
|
117
|
+
|
|
118
|
+
return lutPresentationArr.join(JOIN_STR);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Creates the LUT Presentation store.
|
|
123
|
+
*
|
|
124
|
+
* @param set - The zustand set function.
|
|
125
|
+
* @returns The LUT Presentation store state and actions.
|
|
126
|
+
*/
|
|
127
|
+
const createLutPresentationStore = (set): LutPresentationState => ({
|
|
128
|
+
type: PRESENTATION_TYPE_ID,
|
|
129
|
+
lutPresentationStore: {},
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Sets the LUT presentation for a given key.
|
|
133
|
+
*/
|
|
134
|
+
setLutPresentation: (key, value) =>
|
|
135
|
+
set(
|
|
136
|
+
state => ({
|
|
137
|
+
lutPresentationStore: {
|
|
138
|
+
...state.lutPresentationStore,
|
|
139
|
+
[key]: value,
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
false,
|
|
143
|
+
'setLutPresentation'
|
|
144
|
+
),
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Clears all LUT presentations from the store.
|
|
148
|
+
*/
|
|
149
|
+
clearLutPresentationStore: () =>
|
|
150
|
+
set({ lutPresentationStore: {} }, false, 'clearLutPresentationStore'),
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Retrieves the presentation ID based on the provided parameters.
|
|
154
|
+
*/
|
|
155
|
+
getPresentationId: getLutPresentationId,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Zustand store for managing LUT presentations.
|
|
160
|
+
* Applies devtools middleware when DEBUG_STORE is enabled.
|
|
161
|
+
*/
|
|
162
|
+
export const useLutPresentationStore = create<LutPresentationState>()(
|
|
163
|
+
DEBUG_STORE
|
|
164
|
+
? devtools(createLutPresentationStore, { name: 'LutPresentationStore' })
|
|
165
|
+
: createLutPresentationStore
|
|
166
|
+
);
|