@ohif/extension-cornerstone 3.14.0-beta.98 → 3.14.0-beta.99
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 +18 -8
- 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,671 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Enums as csEnums,
|
|
3
|
+
Types,
|
|
4
|
+
metaData,
|
|
5
|
+
utilities as csUtils,
|
|
6
|
+
CONSTANTS as csConstants,
|
|
7
|
+
isRegisteredRenderBackend,
|
|
8
|
+
} from '@cornerstonejs/core';
|
|
9
|
+
import type { RenderBackendValue } from '@cornerstonejs/core';
|
|
10
|
+
import { utilities as csToolsUtils } from '@cornerstonejs/tools';
|
|
11
|
+
import { isVolume3DViewportType } from '../../../utils/getLegacyViewportType';
|
|
12
|
+
import { getViewportRenderingOverride } from '../../../utils/nextViewports';
|
|
13
|
+
import type ViewportInfo from '../Viewport';
|
|
14
|
+
import type {
|
|
15
|
+
Presentations,
|
|
16
|
+
PositionPresentation,
|
|
17
|
+
LutPresentation,
|
|
18
|
+
} from '../../../types/Presentation';
|
|
19
|
+
import type { StackViewportData, VolumeViewportData } from '../../../types/CornerstoneCacheService';
|
|
20
|
+
import type { IViewportBackend, StackMountContext, VolumeMountContext } from './IViewportBackend';
|
|
21
|
+
import type { IViewportServiceInternals } from './IViewportServiceInternals';
|
|
22
|
+
import { DataIdRegistry, type DataIdPayload } from './dataIdRegistry';
|
|
23
|
+
|
|
24
|
+
// Mirrors WITH_ORIENTATION in CornerstoneViewportService (inlined to avoid a
|
|
25
|
+
// value import that would create a backend -> service circular dependency).
|
|
26
|
+
const WITH_ORIENTATION = { withNavigation: true, withOrientation: true };
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Per-mount render backend override for a planar mount, resolved from the
|
|
30
|
+
* `<viewportType>.viewportRendering` URL param / appConfig captured at init
|
|
31
|
+
* (e.g. `?orthographic.viewportRendering=cpu`). Validated at mount time (not
|
|
32
|
+
* init) because extension backends may call registerRenderBackend after the
|
|
33
|
+
* cornerstone extension initializes; an unregistered value is dropped with a
|
|
34
|
+
* warning rather than failing the mount.
|
|
35
|
+
*/
|
|
36
|
+
function getMountRenderBackend(viewportTypeKey: string): RenderBackendValue | undefined {
|
|
37
|
+
const backend = getViewportRenderingOverride(viewportTypeKey);
|
|
38
|
+
if (!backend) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
if (backend !== 'auto' && !isRegisteredRenderBackend(backend)) {
|
|
42
|
+
console.warn(
|
|
43
|
+
`${viewportTypeKey}.viewportRendering: "${backend}" is not a registered render backend; ignoring.`
|
|
44
|
+
);
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return backend as RenderBackendValue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// The PlanarViewState fields that encode pan/zoom/rotation/flip. Slice and
|
|
51
|
+
// orientation are deliberately EXCLUDED — they are restored via the view reference,
|
|
52
|
+
// and a partial setViewState patch that omits them leaves them untouched (the merge
|
|
53
|
+
// at PlanarViewport.setViewState preserves unspecified fields).
|
|
54
|
+
const NATIVE_VIEW_PRESENTATION_KEYS = [
|
|
55
|
+
'displayArea',
|
|
56
|
+
'anchorWorld',
|
|
57
|
+
'anchorCanvas',
|
|
58
|
+
'scale',
|
|
59
|
+
'scaleMode',
|
|
60
|
+
'rotation',
|
|
61
|
+
'flipHorizontal',
|
|
62
|
+
'flipVertical',
|
|
63
|
+
] as const;
|
|
64
|
+
|
|
65
|
+
// Minimal structural view of a native PlanarViewport's semantic accessors. These
|
|
66
|
+
// live on IGenericViewport (not IStackViewport/IViewport), so we cast at the boundary
|
|
67
|
+
// rather than import core-internal PlanarViewport/PlanarViewState types.
|
|
68
|
+
type NativePlanarViewport = Types.IViewport & {
|
|
69
|
+
getViewState: () => Record<string, unknown>;
|
|
70
|
+
setViewState: (patch: Record<string, unknown>) => void;
|
|
71
|
+
getViewReference: () => Types.ViewReference;
|
|
72
|
+
setViewReference: (ref: Types.ViewReference) => void;
|
|
73
|
+
isReferenceViewable?: (ref: Types.ViewReference, opts?: unknown) => boolean;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Picks the pan/zoom/rotation/flip subset out of a (deep-cloned) getViewState() result. */
|
|
77
|
+
function pickNativeViewPresentation(viewState: Record<string, unknown>): Record<string, unknown> {
|
|
78
|
+
const out: Record<string, unknown> = {};
|
|
79
|
+
for (const key of NATIVE_VIEW_PRESENTATION_KEYS) {
|
|
80
|
+
if (viewState[key] !== undefined) {
|
|
81
|
+
out[key] = viewState[key];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Derives a default VOI window/level range from an image's DICOM voiLutModule
|
|
89
|
+
* metadata (first WindowCenter/WindowWidth pair). Used to seed native viewport
|
|
90
|
+
* windowing, which (unlike legacy StackViewport) is not auto-applied from
|
|
91
|
+
* metadata. Returns undefined when the metadata has no usable window.
|
|
92
|
+
*/
|
|
93
|
+
function getDefaultVoiRangeFromMetadata(
|
|
94
|
+
imageId: string
|
|
95
|
+
): { lower: number; upper: number } | undefined {
|
|
96
|
+
if (!imageId) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const voiLutModule = metaData.get('voiLutModule', imageId);
|
|
100
|
+
const wc = Array.isArray(voiLutModule?.windowCenter)
|
|
101
|
+
? voiLutModule.windowCenter[0]
|
|
102
|
+
: voiLutModule?.windowCenter;
|
|
103
|
+
const ww = Array.isArray(voiLutModule?.windowWidth)
|
|
104
|
+
? voiLutModule.windowWidth[0]
|
|
105
|
+
: voiLutModule?.windowWidth;
|
|
106
|
+
if (wc == null || ww == null) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
return csUtils.windowLevel.toLowHighRange(ww, wc);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Native GenericViewport ("next") backend. Selected when `appConfig.useNextViewports`
|
|
114
|
+
* is on. Routes the mount by the bound data shape (native stack and volume content
|
|
115
|
+
* both report a single PLANAR_NEXT type, so the legacy runtime-type checks cannot
|
|
116
|
+
* classify them — §4.4), owns the per-family native MOUNT BODIES
|
|
117
|
+
* (mountStack/mountVolumes/mountEcg/mountOther/remount), and owns the ref-counted
|
|
118
|
+
* dataId lifecycle (§4.7) over cornerstone's global GenericViewport metadata
|
|
119
|
+
* provider. The service's shared methods hold no native branches.
|
|
120
|
+
*/
|
|
121
|
+
export class NextViewportBackend implements IViewportBackend {
|
|
122
|
+
private readonly registry = new DataIdRegistry();
|
|
123
|
+
|
|
124
|
+
constructor(private readonly service: IViewportServiceInternals) {}
|
|
125
|
+
|
|
126
|
+
dispatchMount(
|
|
127
|
+
viewport: Types.IViewport,
|
|
128
|
+
viewportData: StackViewportData | VolumeViewportData,
|
|
129
|
+
viewportInfo: ViewportInfo,
|
|
130
|
+
presentations: Presentations = {}
|
|
131
|
+
): Promise<void> {
|
|
132
|
+
// Non-planar native families (video / WSI / ECG) route by viewport TYPE to their
|
|
133
|
+
// dedicated mounts: the bound data shape cannot distinguish them, and each needs
|
|
134
|
+
// family-specific dataId registration. Mirrors the legacy backend's type dispatch.
|
|
135
|
+
const type = (viewport as { type?: string }).type;
|
|
136
|
+
|
|
137
|
+
if (type === csEnums.ViewportType.ECG_NEXT) {
|
|
138
|
+
return this.service._setEcgViewport(
|
|
139
|
+
viewport as unknown as Types.IECGViewport,
|
|
140
|
+
viewportData as StackViewportData
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (
|
|
145
|
+
type === csEnums.ViewportType.VIDEO_NEXT ||
|
|
146
|
+
type === csEnums.ViewportType.WHOLE_SLIDE_NEXT
|
|
147
|
+
) {
|
|
148
|
+
return this.service._setOtherViewport(
|
|
149
|
+
viewport as unknown as Types.IStackViewport,
|
|
150
|
+
viewportData as StackViewportData,
|
|
151
|
+
viewportInfo,
|
|
152
|
+
presentations
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Planar stack vs volume content both report PLANAR_NEXT, so infer from the
|
|
157
|
+
// persisted dataShapeType contract (§4.4) — the canonical discriminator set by
|
|
158
|
+
// CornerstoneCacheService and used everywhere else. Don't probe `'volume' in
|
|
159
|
+
// firstData`: that field can be lazily initialized after the data object is built,
|
|
160
|
+
// so the presence check is unreliable. Fall back to the probe only when an older
|
|
161
|
+
// viewportData has no dataShapeType.
|
|
162
|
+
const dataShapeType = (viewportData as { dataShapeType?: csEnums.ViewportType }).dataShapeType;
|
|
163
|
+
const firstData = (viewportData?.data?.[0] ?? {}) as Record<string, unknown>;
|
|
164
|
+
const isVolumeContent =
|
|
165
|
+
dataShapeType === csEnums.ViewportType.ORTHOGRAPHIC ||
|
|
166
|
+
dataShapeType === csEnums.ViewportType.VOLUME_3D ||
|
|
167
|
+
(dataShapeType === undefined && 'volume' in firstData);
|
|
168
|
+
|
|
169
|
+
if (isVolumeContent) {
|
|
170
|
+
return this.service._setVolumeViewport(
|
|
171
|
+
viewport as unknown as Types.IVolumeViewport,
|
|
172
|
+
viewportData as VolumeViewportData,
|
|
173
|
+
viewportInfo,
|
|
174
|
+
presentations
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return this.service._setStackViewport(
|
|
179
|
+
viewport as unknown as Types.IStackViewport,
|
|
180
|
+
viewportData as StackViewportData,
|
|
181
|
+
viewportInfo,
|
|
182
|
+
presentations
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Native stack mount: register the display set and mount it with
|
|
188
|
+
* setDisplaySets (render path inferred from the data), then apply
|
|
189
|
+
* VOI/colormap via setDisplaySetPresentation and pan/zoom/rotate/flip/
|
|
190
|
+
* displayArea via setViewState — instead of the legacy setStack/setProperties/
|
|
191
|
+
* setCamera surface, which a direct PLANAR_NEXT viewport does not expose.
|
|
192
|
+
*/
|
|
193
|
+
async mountStack(viewport: Types.IStackViewport, context: StackMountContext): Promise<void> {
|
|
194
|
+
const {
|
|
195
|
+
displaySetInstanceUIDs,
|
|
196
|
+
imageIds,
|
|
197
|
+
initialImageIndex,
|
|
198
|
+
properties,
|
|
199
|
+
displayArea,
|
|
200
|
+
rotation,
|
|
201
|
+
flipHorizontal,
|
|
202
|
+
presentations,
|
|
203
|
+
overlayProcessingResults,
|
|
204
|
+
} = context;
|
|
205
|
+
|
|
206
|
+
// Native stacks arrive as PLANAR_NEXT and bypass the legacy STACK-typed
|
|
207
|
+
// invalid-stack guard upstream, so guard empty/malformed stack data here
|
|
208
|
+
// before registering and indexing imageIds below.
|
|
209
|
+
if (!imageIds?.length) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const vp = viewport as unknown as NativePlanarViewport & {
|
|
214
|
+
setDisplaySets: (args: {
|
|
215
|
+
displaySetId: string;
|
|
216
|
+
options: Record<string, unknown>;
|
|
217
|
+
}) => Promise<void>;
|
|
218
|
+
setDisplaySetPresentation: (props: Record<string, unknown>) => void;
|
|
219
|
+
element: HTMLDivElement;
|
|
220
|
+
id: string;
|
|
221
|
+
};
|
|
222
|
+
const dataId = displaySetInstanceUIDs[0];
|
|
223
|
+
|
|
224
|
+
// Register through the ref-counted registry (§4.7) instead of the raw
|
|
225
|
+
// provider.add, so the registration is released on unmount and shared
|
|
226
|
+
// (MPR) registrations are not double-added or prematurely removed.
|
|
227
|
+
this.registerDataId(vp.id, dataId, {
|
|
228
|
+
kind: 'planar',
|
|
229
|
+
imageIds,
|
|
230
|
+
initialImageIdIndex: initialImageIndex,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const stackRenderBackend = getMountRenderBackend('stack');
|
|
234
|
+
await vp.setDisplaySets({
|
|
235
|
+
displaySetId: dataId,
|
|
236
|
+
options: {
|
|
237
|
+
orientation: csEnums.OrientationAxis.ACQUISITION,
|
|
238
|
+
role: 'source',
|
|
239
|
+
...(stackRenderBackend ? { renderBackend: stackRenderBackend } : {}),
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// Native viewports are presentation-driven and do NOT auto-derive a default
|
|
244
|
+
// window/level from the image's DICOM VOI metadata the way legacy StackViewport
|
|
245
|
+
// does, so without this the image renders with a raw/full-range VOI (too dark).
|
|
246
|
+
// When no explicit VOI is provided, seed it from the voiLutModule metadata.
|
|
247
|
+
if (!properties.voiRange) {
|
|
248
|
+
const defaultVoi = getDefaultVoiRangeFromMetadata(imageIds[initialImageIndex] ?? imageIds[0]);
|
|
249
|
+
if (defaultVoi) {
|
|
250
|
+
properties.voiRange = defaultVoi;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const presentationProps: Record<string, unknown> = {};
|
|
255
|
+
if (properties.voiRange) {
|
|
256
|
+
presentationProps.voiRange = properties.voiRange;
|
|
257
|
+
}
|
|
258
|
+
if (properties.invert !== undefined) {
|
|
259
|
+
presentationProps.invert = properties.invert;
|
|
260
|
+
}
|
|
261
|
+
if (properties.colormap) {
|
|
262
|
+
presentationProps.colormap = properties.colormap;
|
|
263
|
+
}
|
|
264
|
+
if (Object.keys(presentationProps).length > 0) {
|
|
265
|
+
vp.setDisplaySetPresentation(presentationProps);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const viewStatePatch: Record<string, unknown> = {};
|
|
269
|
+
if (displayArea) {
|
|
270
|
+
viewStatePatch.displayArea = displayArea;
|
|
271
|
+
}
|
|
272
|
+
if (rotation) {
|
|
273
|
+
viewStatePatch.rotation = rotation;
|
|
274
|
+
}
|
|
275
|
+
if (flipHorizontal) {
|
|
276
|
+
viewStatePatch.flipHorizontal = true;
|
|
277
|
+
}
|
|
278
|
+
if (Object.keys(viewStatePatch).length > 0) {
|
|
279
|
+
vp.setViewState(viewStatePatch);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Enable stack-context prefetch for the native path. setDisplaySets above has
|
|
283
|
+
// already populated imageIds via genericViewportDisplaySetMetadataProvider, so
|
|
284
|
+
// getStackData returns a valid stack at enable() time. Scroll re-prefetch is
|
|
285
|
+
// driven by the native STACK_NEW_IMAGE event.
|
|
286
|
+
csToolsUtils.stackContextPrefetch.enable(vp.element);
|
|
287
|
+
|
|
288
|
+
// Restore persisted pan/zoom/rotation/flip (+ view reference) on top of the
|
|
289
|
+
// HP-derived defaults applied above, so a returning display set recovers its
|
|
290
|
+
// camera presentation. The LUT was already applied inline above, so restore
|
|
291
|
+
// position + segmentation only. Replaying segmentationPresentation re-adds
|
|
292
|
+
// hydrated representations (RTSS contour / SEG labelmap) on this native re-mount;
|
|
293
|
+
// without it a hydrated overlay silently disappears (the contour-vanishes-on-
|
|
294
|
+
// hydrate bug), because the overlay display set is no longer in the viewport's
|
|
295
|
+
// display-set list after hydration. Native-safe: position via setViewReference/
|
|
296
|
+
// setViewState, and the replayed addSegmentationRepresentation routes through the
|
|
297
|
+
// native segmentation backend (no convertStackToVolumeViewport / getViewPresentation).
|
|
298
|
+
if (presentations?.positionPresentation || presentations?.segmentationPresentation) {
|
|
299
|
+
this.service.setPresentations(vp.id, {
|
|
300
|
+
positionPresentation: presentations.positionPresentation,
|
|
301
|
+
segmentationPresentation: presentations.segmentationPresentation,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
await this.service._addOverlayRepresentations(overlayProcessingResults);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Native volume/MPR mount: a direct PLANAR_NEXT viewport renders a volume by
|
|
310
|
+
* registering the dataset (with the already-cached volumeId) and calling
|
|
311
|
+
* setDisplaySets with the requested orientation; cornerstone selects the image
|
|
312
|
+
* vs reformatted-volume render path from that orientation. Returns true so the
|
|
313
|
+
* service skips the legacy setVolumes/setProperties tail; an overlay-only mount
|
|
314
|
+
* (no base volumes) returns false and traverses the shared tail, whose
|
|
315
|
+
* legacy-surface steps are lane-guarded via mountOverlayOnlyVolumes.
|
|
316
|
+
*/
|
|
317
|
+
async mountVolumes(viewport: Types.IViewport, context: VolumeMountContext): Promise<boolean> {
|
|
318
|
+
const {
|
|
319
|
+
filteredVolumeInputArray,
|
|
320
|
+
volumesProperties,
|
|
321
|
+
viewportInfo,
|
|
322
|
+
overlayProcessingResults,
|
|
323
|
+
presentations,
|
|
324
|
+
} = context;
|
|
325
|
+
|
|
326
|
+
if (!filteredVolumeInputArray.length) {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
await this._setNativeVolumeDisplaySets(
|
|
331
|
+
viewport,
|
|
332
|
+
filteredVolumeInputArray,
|
|
333
|
+
volumesProperties,
|
|
334
|
+
viewportInfo,
|
|
335
|
+
overlayProcessingResults
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
// Restore persisted pan/zoom/rotation/flip (+ view reference) so a returning
|
|
339
|
+
// MPR/volume pane recovers its camera. Also replay the stored lutPresentation so
|
|
340
|
+
// user window/level, colormap, invert, opacity or threshold edits survive the
|
|
341
|
+
// re-mount instead of resetting to the hanging-protocol defaults applied
|
|
342
|
+
// per-binding above (applied via setDisplaySetPresentation). And replay
|
|
343
|
+
// segmentationPresentation so hydrated overlays (SEG labelmap / RTSS contour)
|
|
344
|
+
// reappear on this native re-mount instead of vanishing. Native-safe: position
|
|
345
|
+
// via setViewReference/setViewState, segmentation via the native backend.
|
|
346
|
+
if (
|
|
347
|
+
presentations?.positionPresentation ||
|
|
348
|
+
presentations?.lutPresentation ||
|
|
349
|
+
presentations?.segmentationPresentation
|
|
350
|
+
) {
|
|
351
|
+
this.service.setPresentations(viewport.id, {
|
|
352
|
+
positionPresentation: presentations.positionPresentation,
|
|
353
|
+
lutPresentation: presentations.lutPresentation,
|
|
354
|
+
segmentationPresentation: presentations.segmentationPresentation,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async mountOverlayOnlyVolumes(): Promise<void> {
|
|
361
|
+
// Generic ("next") viewports don't expose the legacy setVolumes surface. A
|
|
362
|
+
// native overlay-only mount adds its overlays via _addOverlayRepresentations
|
|
363
|
+
// in the shared tail; there is nothing to mount here.
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Native ECG_NEXT has no setEcg; register the waveform under the display set's
|
|
368
|
+
* dataId and mount it through the generic setDisplaySets API (the native ECG data
|
|
369
|
+
* provider reads sourceDataId). Ref-counted via the registry (§4.7).
|
|
370
|
+
*/
|
|
371
|
+
async mountEcg(
|
|
372
|
+
viewport: Types.IECGViewport,
|
|
373
|
+
displaySet: { displaySetInstanceUID: string; imageIds?: string[] },
|
|
374
|
+
imageId: string
|
|
375
|
+
): Promise<void> {
|
|
376
|
+
const dataId = displaySet.displaySetInstanceUID;
|
|
377
|
+
this.registerDataId(viewport.id, dataId, { kind: 'ecg', sourceDataId: imageId });
|
|
378
|
+
this.service._trackViewportDisplaySets(viewport.id, [dataId]);
|
|
379
|
+
await (
|
|
380
|
+
viewport as unknown as {
|
|
381
|
+
setDisplaySets: (args: { displaySetId: string }) => Promise<void>;
|
|
382
|
+
}
|
|
383
|
+
).setDisplaySets({ displaySetId: dataId });
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Native VIDEO_NEXT / WHOLE_SLIDE_NEXT: register the family-specific dataId, then
|
|
388
|
+
* mount through the generic setDisplaySets API. The native video data provider
|
|
389
|
+
* reads sourceDataId; the WSI provider reads imageIds + a DICOMweb client, which
|
|
390
|
+
* we resolve from the WADO_WEB_CLIENT metadata exactly as the legacy WSI adapter
|
|
391
|
+
* does. Ref-counted via the registry (§4.7).
|
|
392
|
+
*/
|
|
393
|
+
async mountOther(
|
|
394
|
+
viewport: Types.IViewport,
|
|
395
|
+
displaySet: { displaySetInstanceUID: string; imageIds: string[] }
|
|
396
|
+
): Promise<void> {
|
|
397
|
+
const dataId = displaySet.displaySetInstanceUID;
|
|
398
|
+
const imageId = displaySet.imageIds[0];
|
|
399
|
+
const isWsi = (viewport as { type?: string }).type === csEnums.ViewportType.WHOLE_SLIDE_NEXT;
|
|
400
|
+
const payload = isWsi
|
|
401
|
+
? {
|
|
402
|
+
kind: 'wsi' as const,
|
|
403
|
+
imageIds: displaySet.imageIds,
|
|
404
|
+
options: {
|
|
405
|
+
webClient: metaData.get(csEnums.MetadataModules.WADO_WEB_CLIENT, imageId),
|
|
406
|
+
},
|
|
407
|
+
}
|
|
408
|
+
: { kind: 'video' as const, sourceDataId: imageId };
|
|
409
|
+
this.registerDataId(viewport.id, dataId, payload);
|
|
410
|
+
this.service._trackViewportDisplaySets(viewport.id, [dataId]);
|
|
411
|
+
await (
|
|
412
|
+
viewport as unknown as {
|
|
413
|
+
setDisplaySets: (args: { displaySetId: string }) => Promise<void>;
|
|
414
|
+
}
|
|
415
|
+
).setDisplaySets({ displaySetId: dataId });
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Native re-mount: no getCamera/setCamera. Snapshot/restore the camera via the
|
|
420
|
+
* semantic view state, and route the mount through dispatchMount (it routes by
|
|
421
|
+
* data shape, since native stack and volume both report PLANAR_NEXT).
|
|
422
|
+
*/
|
|
423
|
+
remount(
|
|
424
|
+
viewport: Types.IViewport,
|
|
425
|
+
viewportData: StackViewportData | VolumeViewportData,
|
|
426
|
+
viewportInfo: ViewportInfo,
|
|
427
|
+
keepCamera: boolean
|
|
428
|
+
): Promise<void> {
|
|
429
|
+
const vp = viewport as NativePlanarViewport;
|
|
430
|
+
const viewState = keepCamera ? (vp.getViewState?.() ?? {}) : undefined;
|
|
431
|
+
return this.dispatchMount(viewport, viewportData, viewportInfo).then(() => {
|
|
432
|
+
if (keepCamera && viewState) {
|
|
433
|
+
vp.setViewState?.(viewState);
|
|
434
|
+
viewport.render();
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Mounts one or more volumes on a native viewport for volume/MPR rendering.
|
|
441
|
+
* Each base volume is registered with its already-cached volumeId and bound via
|
|
442
|
+
* setDisplaySets at the viewport's requested orientation; the first base volume
|
|
443
|
+
* is the source binding, any others are overlays (fusion). VOI/colormap/invert
|
|
444
|
+
* are applied per-binding via setDisplaySetPresentation.
|
|
445
|
+
*/
|
|
446
|
+
private async _setNativeVolumeDisplaySets(
|
|
447
|
+
viewport: Types.IViewport,
|
|
448
|
+
filteredVolumeInputArray: VolumeMountContext['filteredVolumeInputArray'],
|
|
449
|
+
volumesProperties: VolumeMountContext['volumesProperties'],
|
|
450
|
+
viewportInfo: ViewportInfo,
|
|
451
|
+
overlayProcessingResults: VolumeMountContext['overlayProcessingResults']
|
|
452
|
+
): Promise<void> {
|
|
453
|
+
const orientation = viewportInfo.getOrientation();
|
|
454
|
+
// A native VOLUME_3D_NEXT viewport renders the volume as a 3D VTK volume
|
|
455
|
+
// (renderMode 'vtkVolume3d'), not a reformatted planar slice; its appearance is
|
|
456
|
+
// driven by a volume-rendering preset, not orientation/role.
|
|
457
|
+
const is3D = (viewport as { type?: string }).type === csEnums.ViewportType.VOLUME_3D_NEXT;
|
|
458
|
+
const nativeViewport = viewport as unknown as {
|
|
459
|
+
setDisplaySets: (
|
|
460
|
+
...entries: Array<{ displaySetId: string; options: Record<string, unknown> }>
|
|
461
|
+
) => Promise<void>;
|
|
462
|
+
setDisplaySetPresentation: (dataId: string, props: Record<string, unknown>) => void;
|
|
463
|
+
getDefaultActor?: () => { actor?: unknown } | undefined;
|
|
464
|
+
render: () => void;
|
|
465
|
+
};
|
|
466
|
+
const setDisplaySetsEntries: Array<{
|
|
467
|
+
displaySetId: string;
|
|
468
|
+
options: Record<string, unknown>;
|
|
469
|
+
}> = [];
|
|
470
|
+
const volumeRenderBackend = is3D ? undefined : getMountRenderBackend('orthographic');
|
|
471
|
+
|
|
472
|
+
// First pass: register each dataId and build the COMPLETE entry set. The native
|
|
473
|
+
// PlanarViewport.setDisplaySets has replace semantics (removeReplaceableData), so
|
|
474
|
+
// it must receive ALL entries in ONE call - the first entry (role 'source')
|
|
475
|
+
// resolves the source binding and the rest are overlays. Calling it once per
|
|
476
|
+
// volume instead drops the previously-set source (e.g. the fusion CT): the next
|
|
477
|
+
// single-entry overlay call (PT) finds no source entry, falls back to entries[0]
|
|
478
|
+
// (= PT), and removeReplaceableData tears down CT - leaving only the PT colormap.
|
|
479
|
+
for (const [index, { volumeInput }] of filteredVolumeInputArray.entries()) {
|
|
480
|
+
const { imageIds, volumeId, displaySetInstanceUID } = volumeInput;
|
|
481
|
+
const dataId = displaySetInstanceUID;
|
|
482
|
+
|
|
483
|
+
// Ref-counted registration (§4.7): the MPR triptych shares one dataId across
|
|
484
|
+
// panes, so register() adds to the provider once and release() removes only
|
|
485
|
+
// when the last pane unmounts. (kind is stored but ignored by the volume3d
|
|
486
|
+
// data provider, which reads imageIds/volumeId.)
|
|
487
|
+
this.registerDataId(viewport.id, dataId, {
|
|
488
|
+
kind: 'planar',
|
|
489
|
+
imageIds,
|
|
490
|
+
volumeId,
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
setDisplaySetsEntries.push({
|
|
494
|
+
displaySetId: dataId,
|
|
495
|
+
options: is3D
|
|
496
|
+
? { renderMode: 'vtkVolume3d' }
|
|
497
|
+
: {
|
|
498
|
+
orientation,
|
|
499
|
+
role: index === 0 ? 'source' : 'overlay',
|
|
500
|
+
// Volume/MPR panes are 'orthographic' viewports at the OHIF level;
|
|
501
|
+
// renderBackend is a planar mount option, so the 3D branch is exempt.
|
|
502
|
+
...(volumeRenderBackend ? { renderBackend: volumeRenderBackend } : {}),
|
|
503
|
+
},
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// Single replace call with the full entry set so the source (CT) is resolved
|
|
508
|
+
// and preserved instead of being torn down by per-volume calls.
|
|
509
|
+
await nativeViewport.setDisplaySets(...setDisplaySetsEntries);
|
|
510
|
+
|
|
511
|
+
// Second pass: per-dataId presentations and the 3D preset.
|
|
512
|
+
for (const [index, { volumeInput }] of filteredVolumeInputArray.entries()) {
|
|
513
|
+
const dataId = volumeInput.displaySetInstanceUID;
|
|
514
|
+
const props = volumesProperties[index]?.properties;
|
|
515
|
+
if (props) {
|
|
516
|
+
const presentationProps: Record<string, unknown> = {};
|
|
517
|
+
if (props.voiRange) {
|
|
518
|
+
presentationProps.voiRange = props.voiRange;
|
|
519
|
+
}
|
|
520
|
+
if (props.invert !== undefined) {
|
|
521
|
+
presentationProps.invert = props.invert;
|
|
522
|
+
}
|
|
523
|
+
// colormap is a planar (LUT) concept; 3D appearance comes from the preset.
|
|
524
|
+
if (props.colormap && !is3D) {
|
|
525
|
+
presentationProps.colormap = props.colormap;
|
|
526
|
+
}
|
|
527
|
+
// Slab/blend for projection viewports (e.g. the TMTV MIP pane: blendMode
|
|
528
|
+
// 'MIP' + slabThickness 'fullVolume'). The native volume-slice render path
|
|
529
|
+
// maps blendMode -> reslice SlabType (MAX/MIN/MEAN) and applies the slab
|
|
530
|
+
// thickness on the reslice mapper; without them the mapper renders a single
|
|
531
|
+
// slice instead of a projection. 3D volume rendering derives its look from
|
|
532
|
+
// the preset, not a slab, so this is planar-only. blendMode was already
|
|
533
|
+
// normalized from the HP string ('MIP') to a BlendModes enum by
|
|
534
|
+
// ViewportInfo.mapDisplaySetOptions, and slabThickness was resolved to a
|
|
535
|
+
// number by _getSlabThickness ('fullVolume' -> volume diagonal).
|
|
536
|
+
if (!is3D && volumeInput.blendMode !== undefined) {
|
|
537
|
+
presentationProps.blendMode = volumeInput.blendMode;
|
|
538
|
+
}
|
|
539
|
+
if (!is3D && volumeInput.slabThickness !== undefined) {
|
|
540
|
+
presentationProps.slabThickness = volumeInput.slabThickness;
|
|
541
|
+
}
|
|
542
|
+
if (Object.keys(presentationProps).length > 0) {
|
|
543
|
+
nativeViewport.setDisplaySetPresentation(dataId, presentationProps);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// 3D volume rendering needs an RGBA transfer function (preset) to be visible;
|
|
548
|
+
// the bare native VolumeViewport3D has no setProperties, so apply the preset to
|
|
549
|
+
// the volume actor directly (mirrors the legacy adapter's applyPresetToBinding).
|
|
550
|
+
if (is3D && index === 0 && props?.preset) {
|
|
551
|
+
const preset = csConstants.VIEWPORT_PRESETS?.find(p => p.name === props.preset);
|
|
552
|
+
const actor = nativeViewport.getDefaultActor?.()?.actor;
|
|
553
|
+
if (preset && actor) {
|
|
554
|
+
csUtils.applyPreset(actor as Parameters<typeof csUtils.applyPreset>[0], preset);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// Do NOT overwrite the service's viewport display-set bookkeeping here. The
|
|
560
|
+
// caller (_setVolumeViewport) already populated it with the COMPLETE set (base
|
|
561
|
+
// volumes + SEG/RT/fusion overlays) before this native mount; writing back the
|
|
562
|
+
// base-volume-only ids would drop the overlay UIDs from getViewportDisplaySets()
|
|
563
|
+
// and the later presentation/hydration flows.
|
|
564
|
+
|
|
565
|
+
await this.service._addOverlayRepresentations(overlayProcessingResults);
|
|
566
|
+
nativeViewport.render();
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
getPositionPresentation(
|
|
570
|
+
csViewport: Types.IViewport,
|
|
571
|
+
viewportInfo: ViewportInfo,
|
|
572
|
+
viewportId: string
|
|
573
|
+
): PositionPresentation {
|
|
574
|
+
const is3D = isVolume3DViewportType(csViewport);
|
|
575
|
+
const vp = csViewport as NativePlanarViewport;
|
|
576
|
+
|
|
577
|
+
// A direct PLANAR_NEXT viewport has no getViewPresentation; pan/zoom/rotation/flip
|
|
578
|
+
// live in the semantic view state. getViewState() is already deep-cloned, normalized
|
|
579
|
+
// and JSON-serializable, so snapshot the pan/zoom subset (slice/orientation come back
|
|
580
|
+
// via the view reference).
|
|
581
|
+
const viewState =
|
|
582
|
+
!is3D && typeof vp.getViewState === 'function' ? vp.getViewState() : undefined;
|
|
583
|
+
|
|
584
|
+
return {
|
|
585
|
+
viewportType: viewportInfo.getViewportType(),
|
|
586
|
+
viewReference: is3D ? null : vp.getViewReference(),
|
|
587
|
+
// Opaque native pan/zoom blob; cast at the boundary (legacy stores a Types.ViewPresentation).
|
|
588
|
+
viewPresentation: (viewState
|
|
589
|
+
? pickNativeViewPresentation(viewState)
|
|
590
|
+
: undefined) as unknown as Types.ViewPresentation,
|
|
591
|
+
viewportId,
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
setPositionPresentation(
|
|
596
|
+
viewport: Types.IViewport,
|
|
597
|
+
positionPresentation: PositionPresentation
|
|
598
|
+
): void {
|
|
599
|
+
const vp = viewport as NativePlanarViewport;
|
|
600
|
+
|
|
601
|
+
// 1) Slice + orientation first, via the view reference.
|
|
602
|
+
const viewRef = positionPresentation?.viewReference;
|
|
603
|
+
if (viewRef && vp.isReferenceViewable?.(viewRef, WITH_ORIENTATION)) {
|
|
604
|
+
vp.setViewReference(viewRef);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// 2) Pan/zoom/rotation/flip second, as a partial setViewState patch that omits
|
|
608
|
+
// slice/orientation so step 1 is preserved (the merge keeps unspecified fields).
|
|
609
|
+
const vpres = positionPresentation?.viewPresentation as unknown as
|
|
610
|
+
| Record<string, unknown>
|
|
611
|
+
| undefined;
|
|
612
|
+
if (vpres && typeof vp.setViewState === 'function') {
|
|
613
|
+
const patch: Record<string, unknown> = {};
|
|
614
|
+
for (const key of NATIVE_VIEW_PRESENTATION_KEYS) {
|
|
615
|
+
if (vpres[key] !== undefined) {
|
|
616
|
+
patch[key] = vpres[key];
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (Object.keys(patch).length > 0) {
|
|
620
|
+
// When the snapshot held live anchor/scale pan/zoom, displayArea was omitted;
|
|
621
|
+
// clear any stale displayArea explicitly so anchor/scale take effect (setViewState
|
|
622
|
+
// only rewrites displayArea when it is an own key of the patch).
|
|
623
|
+
if (!('displayArea' in patch)) {
|
|
624
|
+
patch.displayArea = undefined;
|
|
625
|
+
}
|
|
626
|
+
vp.setViewState(patch);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
setLutPresentation(viewport: Types.IViewport, lutPresentation: LutPresentation): void {
|
|
632
|
+
if (!lutPresentation) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
const { properties } = lutPresentation;
|
|
636
|
+
// Native LUT presentation is the getDisplaySetPresentation shape (voiRange/
|
|
637
|
+
// colormap/invert), not a per-volumeId Map; a PLANAR_NEXT viewport applies it via
|
|
638
|
+
// setDisplaySetPresentation (it has no legacy setProperties).
|
|
639
|
+
if (!properties || properties instanceof Map) {
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
const nativeViewport = viewport as unknown as {
|
|
643
|
+
setDisplaySetPresentation: (props: Record<string, unknown>) => void;
|
|
644
|
+
};
|
|
645
|
+
const presentationProps: Record<string, unknown> = {};
|
|
646
|
+
if (properties.voiRange) {
|
|
647
|
+
presentationProps.voiRange = properties.voiRange;
|
|
648
|
+
}
|
|
649
|
+
if (properties.invert !== undefined) {
|
|
650
|
+
presentationProps.invert = properties.invert;
|
|
651
|
+
}
|
|
652
|
+
if (properties.colormap) {
|
|
653
|
+
presentationProps.colormap = properties.colormap;
|
|
654
|
+
}
|
|
655
|
+
if (Object.keys(presentationProps).length > 0) {
|
|
656
|
+
nativeViewport.setDisplaySetPresentation(presentationProps);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
registerDataId(viewportId: string, dataId: string, payload: DataIdPayload): void {
|
|
661
|
+
this.registry.register(viewportId, dataId, payload);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
onViewportDisabled(viewportId: string): void {
|
|
665
|
+
this.registry.releaseViewport(viewportId);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
destroy(): void {
|
|
669
|
+
this.registry.destroy();
|
|
670
|
+
}
|
|
671
|
+
}
|