@ohif/extension-cornerstone 3.14.0-beta.10 → 3.14.0-beta.101
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,40 @@
|
|
|
1
|
+
import { Enums, Types } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
type StackData = {
|
|
4
|
+
StudyInstanceUID: string;
|
|
5
|
+
displaySetInstanceUID: string;
|
|
6
|
+
// A composite stack is one created from other display sets - kind of like
|
|
7
|
+
// madeInClient, but specific to indicating that the imageIds can come from
|
|
8
|
+
// different series or even studies.
|
|
9
|
+
isCompositeStack?: boolean;
|
|
10
|
+
imageIds: string[];
|
|
11
|
+
frameRate?: number;
|
|
12
|
+
initialImageIndex?: number | string | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type VolumeData = {
|
|
16
|
+
studyInstanceUID: string;
|
|
17
|
+
displaySetInstanceUID: string;
|
|
18
|
+
volume?: Types.IVolume;
|
|
19
|
+
imageIds?: string[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type StackViewportData = {
|
|
23
|
+
viewportType: Enums.ViewportType;
|
|
24
|
+
// The legacy stack/volume data-shape decision (STACK vs ORTHOGRAPHIC/VOLUME_3D),
|
|
25
|
+
// preserved even when `viewportType` is a native Generic type (PLANAR_NEXT) that
|
|
26
|
+
// collapses both. Consumers that must distinguish stack from volume content
|
|
27
|
+
// (data re-build on invalidation, orientation markers) read this instead of
|
|
28
|
+
// `viewportType`, which is ambiguous on the native path. See migration plan §4.7.
|
|
29
|
+
dataShapeType?: Enums.ViewportType;
|
|
30
|
+
data: StackData[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type VolumeViewportData = {
|
|
34
|
+
viewportType: Enums.ViewportType;
|
|
35
|
+
/** See StackViewportData.dataShapeType. */
|
|
36
|
+
dataShapeType?: Enums.ViewportType;
|
|
37
|
+
data: VolumeData[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type { StackViewportData, VolumeViewportData, StackData, VolumeData };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Types } from '@ohif/core';
|
|
2
|
+
import ToolGroupService from '../services/ToolGroupService';
|
|
3
|
+
import SyncGroupService from '../services/SyncGroupService';
|
|
4
|
+
import SegmentationService from '../services/SegmentationService';
|
|
5
|
+
import CornerstoneCacheService from '../services/CornerstoneCacheService';
|
|
6
|
+
import CornerstoneViewportService from '../services/ViewportService/CornerstoneViewportService';
|
|
7
|
+
import ColorbarService from '../services/ColorbarService';
|
|
8
|
+
|
|
9
|
+
interface CornerstoneServices extends Types.Services {
|
|
10
|
+
cornerstoneViewportService: CornerstoneViewportService;
|
|
11
|
+
toolGroupService: ToolGroupService;
|
|
12
|
+
syncGroupService: SyncGroupService;
|
|
13
|
+
segmentationService: SegmentationService;
|
|
14
|
+
cornerstoneCacheService: CornerstoneCacheService;
|
|
15
|
+
colorbarService: ColorbarService;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default CornerstoneServices;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
|
+
import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a position presentation in a viewport. This is basically
|
|
6
|
+
* viewport specific camera position and zoom, and not the display set
|
|
7
|
+
*/
|
|
8
|
+
export type PositionPresentation = {
|
|
9
|
+
viewportType: string;
|
|
10
|
+
// The view reference has the basic information as to what image orientation/slice is shown
|
|
11
|
+
viewReference: Types.ViewReference;
|
|
12
|
+
// The position information has the zoom/pan and possibly other related information, but not LUT
|
|
13
|
+
viewPresentation: Types.ViewPresentation;
|
|
14
|
+
/**
|
|
15
|
+
* Optionals
|
|
16
|
+
*/
|
|
17
|
+
initialImageIndex?: number;
|
|
18
|
+
// viewportId helps when hydrating SR or SEG - we can use it to filter
|
|
19
|
+
// presentations to get the one prior to the current viewport and reuse it
|
|
20
|
+
// for viewReference and viewPresentation
|
|
21
|
+
viewportId?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents a LUT presentation in a viewport, and is really related
|
|
26
|
+
* to displaySets and not the viewport itself. So that is why it can
|
|
27
|
+
* be an object with volumeId keys, or a single object with the properties
|
|
28
|
+
* itself
|
|
29
|
+
*/
|
|
30
|
+
export interface LutPresentation {
|
|
31
|
+
viewportType: string;
|
|
32
|
+
// either a single object with the properties itself or a map of properties with volumeId keys
|
|
33
|
+
properties: Record<string, Types.ViewportProperties> | Types.ViewportProperties;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Represents a LUT presentation in a viewport, and is really related
|
|
38
|
+
* to displaySets and not the viewport itself. So that is why it can
|
|
39
|
+
* be an object with volumeId keys, or a single object with the properties
|
|
40
|
+
* itself
|
|
41
|
+
*
|
|
42
|
+
* each presentation has a segmentationId and a type and a value for
|
|
43
|
+
* hydrated and config.
|
|
44
|
+
*
|
|
45
|
+
* The hydrated property can be a boolean or null. It's null if the segmentation
|
|
46
|
+
* representation hasn't been created yet. It's true if the representation is
|
|
47
|
+
* currently in the viewport. It's false if the representation was in the viewport
|
|
48
|
+
* but has been removed.
|
|
49
|
+
*
|
|
50
|
+
* It mirrors `DisplaySet.isHydrated` for this presentation: true means show the
|
|
51
|
+
* segmentation in the standard viewports matching this presentation id, false
|
|
52
|
+
* means it was explicitly removed and must not be shown in them again. The
|
|
53
|
+
* viewport converges on this value, so false actively removes the
|
|
54
|
+
* representation rather than merely being the absence of an add - otherwise a
|
|
55
|
+
* stale true would silently restore a segmentation the user dismissed.
|
|
56
|
+
*
|
|
57
|
+
* Config is the segmentation config, Todo: add stuff here
|
|
58
|
+
*/
|
|
59
|
+
export type SegmentationPresentationItem = {
|
|
60
|
+
segmentationId: string;
|
|
61
|
+
type: SegmentationRepresentations;
|
|
62
|
+
hydrated: boolean | null;
|
|
63
|
+
config?: unknown;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type SegmentationPresentation = SegmentationPresentationItem[];
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Presentation can be a PositionPresentation or a LutPresentation.
|
|
70
|
+
*/
|
|
71
|
+
type Presentation = PositionPresentation | LutPresentation | SegmentationPresentation;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Viewport presentations object that can contain a positionPresentation
|
|
75
|
+
* and or a lutPresentation.
|
|
76
|
+
*/
|
|
77
|
+
export type Presentations = {
|
|
78
|
+
positionPresentation?: PositionPresentation;
|
|
79
|
+
lutPresentation?: LutPresentation;
|
|
80
|
+
segmentationPresentation?: SegmentationPresentation;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default Presentation;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type ViewportPreset = {
|
|
2
|
+
name: string;
|
|
3
|
+
gradientOpacity: string;
|
|
4
|
+
specularPower: string;
|
|
5
|
+
scalarOpacity: string;
|
|
6
|
+
specular: string;
|
|
7
|
+
shade: string;
|
|
8
|
+
ambient: string;
|
|
9
|
+
colorTransfer: string;
|
|
10
|
+
diffuse: string;
|
|
11
|
+
interpolation: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type VolumeRenderingPresetsProps = {
|
|
15
|
+
viewportId: string;
|
|
16
|
+
volumeRenderingPresets: ViewportPreset[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type VolumeRenderingPresetsContentProps = {
|
|
20
|
+
presets: ViewportPreset[];
|
|
21
|
+
onClose: () => void;
|
|
22
|
+
viewportId: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type VolumeRenderingOptionsProps = {
|
|
26
|
+
viewportId: string;
|
|
27
|
+
volumeRenderingQualityRange: VolumeRenderingQualityRange;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type VolumeRenderingQualityRange = {
|
|
31
|
+
min: number;
|
|
32
|
+
max: number;
|
|
33
|
+
step: number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type VolumeRenderingQualityProps = {
|
|
37
|
+
viewportId: string;
|
|
38
|
+
volumeRenderingQualityRange: VolumeRenderingQualityRange;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type VolumeShiftProps = {
|
|
42
|
+
viewportId: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type VolumeShadeProps = {
|
|
46
|
+
viewportId: string;
|
|
47
|
+
onClickShade?: (bool: boolean) => void;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type VolumeLightingProps = {
|
|
51
|
+
viewportId: string;
|
|
52
|
+
hasShade: boolean;
|
|
53
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as CornerstoneCacheService from './CornerstoneCacheService';
|
|
2
|
+
import type CornerstoneServices from './CornerstoneServices';
|
|
3
|
+
export { type SyncGroup } from '../services/SyncGroupService';
|
|
4
|
+
export { type HydrationCallback } from '../utils/promptHydrationDialog';
|
|
5
|
+
export type { CornerstoneCacheService, CornerstoneServices };
|
|
6
|
+
export * from './Presentation';
|
|
7
|
+
export * from './ViewportPresets';
|
|
8
|
+
export * from './WindowLevel';
|
|
9
|
+
export * from './VolumeRenderingConfig';
|
|
10
|
+
export * from './VolumeLighting';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const ActiveViewportBehavior = ({
|
|
4
|
+
servicesManager,
|
|
5
|
+
viewportId,
|
|
6
|
+
}: withAppTypes<{ viewportId: string }>) => {
|
|
7
|
+
const {
|
|
8
|
+
displaySetService,
|
|
9
|
+
cineService,
|
|
10
|
+
viewportGridService,
|
|
11
|
+
customizationService,
|
|
12
|
+
cornerstoneViewportService,
|
|
13
|
+
} = servicesManager.services;
|
|
14
|
+
|
|
15
|
+
const [activeViewportId, setActiveViewportId] = useState(viewportId);
|
|
16
|
+
|
|
17
|
+
const handleCineEnable = () => {
|
|
18
|
+
if (cineService.isViewportCineClosed(activeViewportId)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const displaySetInstanceUIDs =
|
|
23
|
+
viewportGridService.getDisplaySetsUIDsForViewport(activeViewportId);
|
|
24
|
+
|
|
25
|
+
if (!displaySetInstanceUIDs) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const displaySets = displaySetInstanceUIDs.map(uid =>
|
|
30
|
+
displaySetService.getDisplaySetByUID(uid)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (!displaySets.length) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const modalities = displaySets.map(displaySet => displaySet?.Modality);
|
|
38
|
+
const isDynamicVolume = displaySets.some(displaySet => displaySet?.isDynamicVolume);
|
|
39
|
+
|
|
40
|
+
const sourceModalities = customizationService.getCustomization('autoCineModalities');
|
|
41
|
+
|
|
42
|
+
const requiresCine = modalities.some(modality => sourceModalities.includes(modality));
|
|
43
|
+
|
|
44
|
+
if ((requiresCine || isDynamicVolume) && !cineService.getState().isCineEnabled) {
|
|
45
|
+
cineService.setIsCineEnabled(true);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const subscription = viewportGridService.subscribe(
|
|
51
|
+
viewportGridService.EVENTS.ACTIVE_VIEWPORT_ID_CHANGED,
|
|
52
|
+
({ viewportId }) => setActiveViewportId(viewportId)
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return () => subscription.unsubscribe();
|
|
56
|
+
}, [viewportId, viewportGridService]);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const subscription = cornerstoneViewportService.subscribe(
|
|
60
|
+
cornerstoneViewportService.EVENTS.VIEWPORT_DATA_CHANGED,
|
|
61
|
+
() => {
|
|
62
|
+
const activeViewportId = viewportGridService.getActiveViewportId();
|
|
63
|
+
setActiveViewportId(activeViewportId);
|
|
64
|
+
handleCineEnable();
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return () => subscription.unsubscribe();
|
|
69
|
+
}, [viewportId, cornerstoneViewportService, viewportGridService, handleCineEnable]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
handleCineEnable();
|
|
73
|
+
}, [handleCineEnable]);
|
|
74
|
+
|
|
75
|
+
return null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
ActiveViewportBehavior.displayName = 'ActiveViewportBehavior';
|
|
79
|
+
|
|
80
|
+
export default ActiveViewportBehavior;
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { utils } from '@ohif/core';
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import html2canvas from 'html2canvas';
|
|
4
|
+
import { getEnabledElement } from '@cornerstonejs/core';
|
|
5
|
+
import { ToolGroupManager, segmentation, Enums } from '@cornerstonejs/tools';
|
|
6
|
+
import { getEnabledElement as OHIFgetEnabledElement } from '../state';
|
|
7
|
+
import { getViewportAdapter } from '../services/ViewportService/adapter';
|
|
8
|
+
import { useSystem } from '@ohif/core/src';
|
|
9
|
+
|
|
10
|
+
const { downloadUrl } = utils;
|
|
11
|
+
|
|
12
|
+
const DEFAULT_SIZE = 512;
|
|
13
|
+
const MAX_TEXTURE_SIZE = 10000;
|
|
14
|
+
const VIEWPORT_ID = 'cornerstone-viewport-download-form';
|
|
15
|
+
|
|
16
|
+
const FILE_TYPE_OPTIONS = [
|
|
17
|
+
{
|
|
18
|
+
value: 'jpg',
|
|
19
|
+
label: 'JPG',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
value: 'png',
|
|
23
|
+
label: 'PNG',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
type ViewportDownloadFormProps = {
|
|
28
|
+
hide: () => void;
|
|
29
|
+
activeViewportId: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Mounts the source viewport's displayed content onto the capture viewport and
|
|
34
|
+
* re-applies its segmentation overlays, returning the clamped capture size.
|
|
35
|
+
*
|
|
36
|
+
* Module scope on purpose: the optional chaining inside this try/catch is a
|
|
37
|
+
* React Compiler limitation ("value blocks within a try/catch") that bails the
|
|
38
|
+
* whole component when inlined. Plain functions are never compiled.
|
|
39
|
+
*/
|
|
40
|
+
async function mountCaptureViewport(
|
|
41
|
+
viewport: any,
|
|
42
|
+
downloadViewport: any,
|
|
43
|
+
segmentationRepresentations: any[] | undefined,
|
|
44
|
+
width: number,
|
|
45
|
+
height: number
|
|
46
|
+
): Promise<{ width: number; height: number } | undefined> {
|
|
47
|
+
try {
|
|
48
|
+
// Capture current viewport state. The download (capture) viewport is created
|
|
49
|
+
// with the SAME type as the source (see handleEnableViewport), so source and
|
|
50
|
+
// capture are both legacy or both native, and the source's adapter can mount
|
|
51
|
+
// its displayed content (data + appearance + view state) onto the capture
|
|
52
|
+
// viewport directly.
|
|
53
|
+
await getViewportAdapter(viewport).copyDisplayedContentTo(downloadViewport);
|
|
54
|
+
|
|
55
|
+
downloadViewport.render();
|
|
56
|
+
|
|
57
|
+
// Re-apply segmentation overlays to the download viewport
|
|
58
|
+
if (segmentationRepresentations?.length) {
|
|
59
|
+
segmentationRepresentations.forEach(segRepresentation => {
|
|
60
|
+
const { segmentationId, colorLUTIndex, type } = segRepresentation;
|
|
61
|
+
|
|
62
|
+
if (type === Enums.SegmentationRepresentations.Labelmap) {
|
|
63
|
+
segmentation.addLabelmapRepresentationToViewportMap({
|
|
64
|
+
[downloadViewport.id]: [
|
|
65
|
+
{
|
|
66
|
+
segmentationId,
|
|
67
|
+
type: Enums.SegmentationRepresentations.Labelmap,
|
|
68
|
+
config: { colorLUTOrIndex: colorLUTIndex },
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (type === Enums.SegmentationRepresentations.Contour) {
|
|
75
|
+
segmentation.addContourRepresentationToViewportMap({
|
|
76
|
+
[downloadViewport.id]: [
|
|
77
|
+
{
|
|
78
|
+
segmentationId,
|
|
79
|
+
type: Enums.SegmentationRepresentations.Contour,
|
|
80
|
+
config: { colorLUTOrIndex: colorLUTIndex },
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
width: Math.min(width || DEFAULT_SIZE, MAX_TEXTURE_SIZE),
|
|
90
|
+
height: Math.min(height || DEFAULT_SIZE, MAX_TEXTURE_SIZE),
|
|
91
|
+
};
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('Error loading image:', error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const CornerstoneViewportDownloadForm = ({
|
|
98
|
+
hide,
|
|
99
|
+
activeViewportId: activeViewportIdProp,
|
|
100
|
+
}: ViewportDownloadFormProps) => {
|
|
101
|
+
const { servicesManager } = useSystem();
|
|
102
|
+
const { customizationService, cornerstoneViewportService } = servicesManager.services;
|
|
103
|
+
const [showAnnotations, setShowAnnotations] = useState(true);
|
|
104
|
+
const [viewportDimensions, setViewportDimensions] = useState({
|
|
105
|
+
width: DEFAULT_SIZE,
|
|
106
|
+
height: DEFAULT_SIZE,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const warningState = customizationService.getCustomization('viewportDownload.warningMessage') as {
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
value: string;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const refViewportEnabledElementOHIF = OHIFgetEnabledElement(activeViewportIdProp);
|
|
115
|
+
const activeViewportElement = refViewportEnabledElementOHIF?.element;
|
|
116
|
+
const { viewportId: activeViewportId, renderingEngineId } =
|
|
117
|
+
getEnabledElement(activeViewportElement);
|
|
118
|
+
|
|
119
|
+
const renderingEngine = cornerstoneViewportService.getRenderingEngine();
|
|
120
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(activeViewportId, renderingEngineId);
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
const toolModeAndBindings = Object.keys(toolGroup.toolOptions).reduce((acc, toolName) => {
|
|
124
|
+
const tool = toolGroup.toolOptions[toolName];
|
|
125
|
+
const { mode, bindings } = tool;
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
...acc,
|
|
129
|
+
[toolName]: { mode, bindings },
|
|
130
|
+
};
|
|
131
|
+
}, {});
|
|
132
|
+
|
|
133
|
+
return () => {
|
|
134
|
+
Object.keys(toolModeAndBindings).forEach(toolName => {
|
|
135
|
+
const { mode, bindings } = toolModeAndBindings[toolName];
|
|
136
|
+
try {
|
|
137
|
+
toolGroup.setToolMode(toolName, mode, { bindings });
|
|
138
|
+
} catch (error) {
|
|
139
|
+
// Handle errors when restoring tool mode during cleanup (e.g., when tool state is undefined)
|
|
140
|
+
console.debug('Error restoring tool mode during cleanup:', toolName, error);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
}, []);
|
|
145
|
+
|
|
146
|
+
const handleEnableViewport = (viewportElement: HTMLElement) => {
|
|
147
|
+
if (!viewportElement) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const { viewport } = getEnabledElement(activeViewportElement);
|
|
152
|
+
|
|
153
|
+
const viewportInput = {
|
|
154
|
+
viewportId: VIEWPORT_ID,
|
|
155
|
+
element: viewportElement,
|
|
156
|
+
type: viewport.type,
|
|
157
|
+
defaultOptions: {
|
|
158
|
+
background: viewport.defaultOptions.background,
|
|
159
|
+
orientation: viewport.defaultOptions.orientation,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
renderingEngine.enableElement(viewportInput);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const handleDisableViewport = async () => {
|
|
167
|
+
renderingEngine.disableElement(VIEWPORT_ID);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const handleLoadImage = async (width: number, height: number) => {
|
|
171
|
+
if (!activeViewportElement) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const activeViewportEnabledElement = getEnabledElement(activeViewportElement);
|
|
176
|
+
if (!activeViewportEnabledElement) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const segmentationRepresentations =
|
|
181
|
+
segmentation.state.getViewportSegmentationRepresentations(activeViewportId);
|
|
182
|
+
|
|
183
|
+
const { viewport } = activeViewportEnabledElement;
|
|
184
|
+
const downloadViewport = renderingEngine.getViewport(VIEWPORT_ID);
|
|
185
|
+
|
|
186
|
+
return mountCaptureViewport(
|
|
187
|
+
viewport,
|
|
188
|
+
downloadViewport,
|
|
189
|
+
segmentationRepresentations,
|
|
190
|
+
width,
|
|
191
|
+
height
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const handleToggleAnnotations = (show: boolean) => {
|
|
196
|
+
const activeViewportEnabledElement = getEnabledElement(activeViewportElement);
|
|
197
|
+
if (!activeViewportEnabledElement) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const downloadViewport = renderingEngine.getViewport(VIEWPORT_ID);
|
|
202
|
+
if (!downloadViewport) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const { viewportId: activeViewportId, renderingEngineId } = activeViewportEnabledElement;
|
|
207
|
+
const { id: downloadViewportId } = downloadViewport;
|
|
208
|
+
|
|
209
|
+
const toolGroup = ToolGroupManager.getToolGroupForViewport(activeViewportId, renderingEngineId);
|
|
210
|
+
toolGroup.addViewport(downloadViewportId, renderingEngineId);
|
|
211
|
+
|
|
212
|
+
const toolInstances = toolGroup.getToolInstances();
|
|
213
|
+
const toolInstancesArray = Object.values(toolInstances);
|
|
214
|
+
|
|
215
|
+
toolInstancesArray.forEach(toolInstance => {
|
|
216
|
+
if (toolInstance.constructor.isAnnotation !== false) {
|
|
217
|
+
if (show) {
|
|
218
|
+
toolGroup.setToolEnabled(toolInstance.toolName);
|
|
219
|
+
} else {
|
|
220
|
+
toolGroup.setToolDisabled(toolInstance.toolName);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (viewportDimensions.width && viewportDimensions.height) {
|
|
228
|
+
setTimeout(() => {
|
|
229
|
+
handleLoadImage(viewportDimensions.width, viewportDimensions.height);
|
|
230
|
+
handleToggleAnnotations(showAnnotations);
|
|
231
|
+
// we need a resize here to make suer annotations world to canvas
|
|
232
|
+
// are properly calculated
|
|
233
|
+
renderingEngine.resize();
|
|
234
|
+
renderingEngine.render();
|
|
235
|
+
}, 100);
|
|
236
|
+
}
|
|
237
|
+
}, [viewportDimensions, showAnnotations]);
|
|
238
|
+
|
|
239
|
+
const handleDownload = async (baseFilename: string, fileType: string) => {
|
|
240
|
+
const divForDownloadViewport = document.querySelector(
|
|
241
|
+
`div[data-viewport-uid="${VIEWPORT_ID}"]`
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
if (!divForDownloadViewport) {
|
|
245
|
+
console.debug('No viewport found for download');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const filename = `${baseFilename}.${fileType}`;
|
|
250
|
+
const canvas = await html2canvas(divForDownloadViewport as HTMLElement);
|
|
251
|
+
downloadUrl(canvas.toDataURL(`image/${fileType}`, 1.0), { filename });
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const handleCopyToClipboard = async () => {
|
|
255
|
+
const divForDownloadViewport = document.querySelector(
|
|
256
|
+
`div[data-viewport-uid="${VIEWPORT_ID}"]`
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
if (!divForDownloadViewport) {
|
|
260
|
+
console.debug('No viewport found for copy');
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
try {
|
|
265
|
+
const canvas = await html2canvas(divForDownloadViewport as HTMLElement);
|
|
266
|
+
|
|
267
|
+
// Clipboard API only supports PNG format in most browsers
|
|
268
|
+
const blob = await new Promise<Blob>((resolve, reject) => {
|
|
269
|
+
canvas.toBlob(
|
|
270
|
+
blob => {
|
|
271
|
+
if (blob) {
|
|
272
|
+
resolve(blob);
|
|
273
|
+
} else {
|
|
274
|
+
reject(new Error('Failed to create blob from canvas'));
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
'image/png',
|
|
278
|
+
1.0
|
|
279
|
+
);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Copy to clipboard using the Clipboard API
|
|
283
|
+
await navigator.clipboard.write([
|
|
284
|
+
new ClipboardItem({
|
|
285
|
+
'image/png': blob,
|
|
286
|
+
}),
|
|
287
|
+
]);
|
|
288
|
+
|
|
289
|
+
console.log('Image copied to clipboard successfully');
|
|
290
|
+
} catch (error) {
|
|
291
|
+
console.error('Failed to copy image to clipboard:', error);
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const ViewportDownloadFormNew = customizationService.getCustomization(
|
|
297
|
+
'ohif.captureViewportModal'
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
return (
|
|
301
|
+
<ViewportDownloadFormNew
|
|
302
|
+
onClose={hide}
|
|
303
|
+
defaultSize={DEFAULT_SIZE}
|
|
304
|
+
fileTypeOptions={FILE_TYPE_OPTIONS}
|
|
305
|
+
viewportId={VIEWPORT_ID}
|
|
306
|
+
showAnnotations={showAnnotations}
|
|
307
|
+
onAnnotationsChange={setShowAnnotations}
|
|
308
|
+
dimensions={viewportDimensions}
|
|
309
|
+
onDimensionsChange={setViewportDimensions}
|
|
310
|
+
onEnableViewport={handleEnableViewport}
|
|
311
|
+
onDisableViewport={handleDisableViewport}
|
|
312
|
+
onDownload={handleDownload}
|
|
313
|
+
onCopyToClipboard={handleCopyToClipboard}
|
|
314
|
+
warningState={warningState}
|
|
315
|
+
/>
|
|
316
|
+
);
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export default CornerstoneViewportDownloadForm;
|