@ohif/extension-cornerstone 3.14.0-beta.1 → 3.14.0-beta.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/915.ohif-extension-cornerstone.umd.js +1 -1
- package/dist/ohif-extension-cornerstone.umd.js +1 -5
- package/package.json +33 -25
- package/src/Viewport/OHIFCornerstoneViewport.css +46 -0
- package/src/Viewport/OHIFCornerstoneViewport.tsx +502 -0
- package/src/Viewport/Overlays/CornerstoneOverlays.tsx +103 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.css +25 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.tsx +469 -0
- package/src/Viewport/Overlays/ViewportImageScrollbar.tsx +106 -0
- package/src/Viewport/Overlays/ViewportImageSliceLoadingIndicator.tsx +87 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.css +41 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.tsx +136 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/ViewportSliceProgressScrollbar.tsx +195 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/helpers.ts +46 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/hooks.ts +383 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/index.ts +1 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/types.ts +17 -0
- package/src/Viewport/Overlays/utils.ts +66 -0
- package/src/commandsModule.ts +2951 -0
- package/src/components/AccordionGroup/AccordionGroup.tsx +195 -0
- package/src/components/AccordionGroup/index.ts +4 -0
- package/src/components/ActiveViewportWindowLevel/ActiveViewportWindowLevel.tsx +23 -0
- package/src/components/ActiveViewportWindowLevel/index.js +1 -0
- package/src/components/AdvancedRenderingControls/AdvancedRenderingControls.tsx +149 -0
- package/src/components/AdvancedRenderingControls/index.ts +1 -0
- package/src/components/CinePlayer/CinePlayer.tsx +247 -0
- package/src/components/CinePlayer/index.ts +3 -0
- package/src/components/DicomUpload/DicomUpload.tsx +111 -0
- package/src/components/DicomUpload/DicomUploadProgress.tsx +396 -0
- package/src/components/DicomUpload/DicomUploadProgressItem.tsx +119 -0
- package/src/components/ExportSegmentationSubMenuItem.tsx +75 -0
- package/src/components/MeasurementItems.tsx +70 -0
- package/src/components/MeasurementTableNested.tsx +30 -0
- package/src/components/MeasurementsMenu.tsx +84 -0
- package/src/components/MeasurementsOrAdditionalFindings.tsx +82 -0
- package/src/components/ModalityLoadBadge/ModalityLoadBadge.tsx +171 -0
- package/src/components/ModalityLoadBadge/index.ts +1 -0
- package/src/components/NavigationComponent/NavigationComponent.tsx +138 -0
- package/src/components/NavigationComponent/index.ts +3 -0
- package/src/components/OHIFViewportActionCorners.tsx +94 -0
- package/src/components/OpacityMenu/OpacityMenu.tsx +54 -0
- package/src/components/OpacityMenu/OpacityMenuWrapper.tsx +85 -0
- package/src/components/OpacityMenu/index.ts +2 -0
- package/src/components/PanelAccordionTrigger.tsx +48 -0
- package/src/components/SegmentationToolConfig.tsx +71 -0
- package/src/components/SegmentationUtilityButton.tsx +61 -0
- package/src/components/SelectItemWithModality.tsx +29 -0
- package/src/components/SeriesMeasurements.tsx +90 -0
- package/src/components/SeriesSummaryFromDisplaySet.tsx +21 -0
- package/src/components/StudyMeasurements.tsx +88 -0
- package/src/components/StudyMeasurementsActions.tsx +75 -0
- package/src/components/StudySummaryFromMetadata.test.ts +47 -0
- package/src/components/StudySummaryFromMetadata.tsx +31 -0
- package/src/components/StudySummaryWithActions.tsx +14 -0
- package/src/components/ThresholdMenu/ThresholdMenu.tsx +104 -0
- package/src/components/ThresholdMenu/ThresholdMenuWrapper.tsx +85 -0
- package/src/components/ThresholdMenu/index.ts +2 -0
- package/src/components/TrackingStatus/TrackingStatus.tsx +32 -0
- package/src/components/TrackingStatus/index.ts +1 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenu.tsx +190 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenuWrapper.tsx +85 -0
- package/src/components/VOIManualControlMenu/index.ts +2 -0
- package/src/components/ViewportColorbar/ViewportColorbar.tsx +150 -0
- package/src/components/ViewportColorbar/ViewportColorbarsContainer.tsx +125 -0
- package/src/components/ViewportColorbar/index.ts +5 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenu.tsx +538 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenuWrapper.tsx +91 -0
- package/src/components/ViewportDataOverlaySettingMenu/utils.ts +118 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenu.tsx +249 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenuWrapper.tsx +29 -0
- package/src/components/ViewportWindowLevel/ViewportWindowLevel.tsx +261 -0
- package/src/components/ViewportWindowLevel/getViewportVolumeHistogram.ts +72 -0
- package/src/components/ViewportWindowLevel/histogramWorker.js +97 -0
- package/src/components/ViewportWindowLevel/index.js +1 -0
- package/src/components/ViewportWindowLevel/utils.ts +176 -0
- package/src/components/WindowLevelActionMenu/Colorbar.tsx +30 -0
- package/src/components/WindowLevelActionMenu/Colormap.tsx +121 -0
- package/src/components/WindowLevelActionMenu/VolumeLighting.tsx +82 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingOptions.tsx +38 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresets.tsx +36 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresetsContent.tsx +78 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingQuality.tsx +64 -0
- package/src/components/WindowLevelActionMenu/VolumeShade.tsx +47 -0
- package/src/components/WindowLevelActionMenu/VolumeShift.tsx +92 -0
- package/src/components/WindowLevelActionMenu/WindowLevel.tsx +157 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenu.tsx +102 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenuWrapper.tsx +131 -0
- package/src/components/WindowLevelActionMenu/defaultWindowLevelPresets.ts +23 -0
- package/src/components/WindowLevelActionMenu/index.ts +11 -0
- package/src/components/WindowLevelActionMenu/windowLevelPresetHotkeys.test.ts +19 -0
- package/src/components/index.ts +12 -0
- package/src/constants/index.ts +13 -0
- package/src/customizations/CustomDropdownMenuContent.tsx +106 -0
- package/src/customizations/CustomSegmentStatisticsHeader.tsx +140 -0
- package/src/customizations/captureViewportModalCustomization.tsx +175 -0
- package/src/customizations/colorbarCustomization.ts +93 -0
- package/src/customizations/gpuSettingsPresetCustomization.ts +8 -0
- package/src/customizations/layoutSelectorCustomization.ts +104 -0
- package/src/customizations/measurementsCustomization.ts +124 -0
- package/src/customizations/miscCustomization.ts +22 -0
- package/src/customizations/modalityColorMapCustomization.ts +23 -0
- package/src/customizations/segmentationHydrationCustomization.ts +16 -0
- package/src/customizations/segmentationPanelCustomization.tsx +119 -0
- package/src/customizations/segmentationToolbarCustomization.ts +964 -0
- package/src/customizations/toolGroupToolsCustomization.ts +204 -0
- package/src/customizations/toolbarButtonsCustomization.ts +805 -0
- package/src/customizations/viewportClickCommandsCustomization.ts +15 -0
- package/src/customizations/viewportDownloadWarningCustomization.tsx +6 -0
- package/src/customizations/viewportOverlayCustomization.tsx +46 -0
- package/src/customizations/viewportScrollbarCustomization.tsx +27 -0
- package/src/customizations/viewportToolsCustomization.ts +33 -0
- package/src/customizations/volumeRenderingCustomization.ts +14 -0
- package/src/customizations/windowLevelPresetsCustomization.ts +5 -0
- package/src/enums.ts +9 -0
- package/src/getCustomizationModule.tsx +54 -0
- package/src/getHangingProtocolModule.ts +47 -0
- package/src/getPanelModule.tsx +128 -0
- package/src/getSopClassHandlerModule.js +284 -0
- package/src/getToolbarModule.tsx +622 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActiveViewportSegmentationRepresentations.ts +14 -0
- package/src/hooks/useMeasurementTracking.ts +132 -0
- package/src/hooks/useMeasurements.ts +104 -0
- package/src/hooks/useSegmentations.ts +147 -0
- package/src/hooks/useViewportDisplaySets.ts +284 -0
- package/src/hooks/useViewportHover.ts +77 -0
- package/src/hooks/useViewportRendering.tsx +868 -0
- package/src/hooks/useViewportSegmentations.ts +245 -0
- package/src/hps/fourUp.ts +117 -0
- package/src/hps/frameView.ts +1581 -0
- package/src/hps/main3D.ts +142 -0
- package/src/hps/mpr.ts +197 -0
- package/src/hps/mprAnd3DVolumeViewport.ts +124 -0
- package/src/hps/only3D.ts +70 -0
- package/src/hps/primary3D.ts +142 -0
- package/src/hps/primaryAxial.ts +114 -0
- package/src/id.js +5 -0
- package/src/index.tsx +350 -0
- package/src/init.tsx +445 -0
- package/src/initCineService.ts +75 -0
- package/src/initContextMenu.ts +94 -0
- package/src/initCornerstoneTools.js +188 -0
- package/src/initDoubleClick.ts +82 -0
- package/src/initMeasurementService.ts +576 -0
- package/src/initStudyPrefetcherService.ts +33 -0
- package/src/initWADOImageLoader.js +56 -0
- package/src/panels/PanelMeasurement.tsx +84 -0
- package/src/panels/PanelSegmentation.tsx +338 -0
- package/src/services/ColorbarService/ColorbarService.ts +242 -0
- package/src/services/ColorbarService/index.ts +2 -0
- package/src/services/CornerstoneCacheService/CornerstoneCacheService.ts +326 -0
- package/src/services/CornerstoneCacheService/index.js +3 -0
- package/src/services/SegmentationService/RTSTRUCT/mapROIContoursToRTStructData.ts +36 -0
- package/src/services/SegmentationService/SegmentationService.test.ts +3698 -0
- package/src/services/SegmentationService/SegmentationService.ts +2376 -0
- package/src/services/SegmentationService/backends/ISegmentationBackend.ts +102 -0
- package/src/services/SegmentationService/backends/ISegmentationServiceInternals.ts +44 -0
- package/src/services/SegmentationService/backends/LegacySegmentationBackend.ts +139 -0
- package/src/services/SegmentationService/backends/NextSegmentationBackend.ts +159 -0
- package/src/services/SegmentationService/backends/index.ts +4 -0
- package/src/services/SegmentationService/index.ts +3 -0
- package/src/services/SyncGroupService/SyncGroupService.ts +264 -0
- package/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts +118 -0
- package/src/services/SyncGroupService/index.js +3 -0
- package/src/services/ToolGroupService/ToolGroupService.test.ts +83 -0
- package/src/services/ToolGroupService/ToolGroupService.ts +541 -0
- package/src/services/ToolGroupService/index.js +3 -0
- package/src/services/ViewedDataService/ViewedDataService.ts +58 -0
- package/src/services/ViewedDataService/index.ts +3 -0
- package/src/services/ViewportService/CornerstoneViewportService.ts +1814 -0
- package/src/services/ViewportService/IViewportService.ts +64 -0
- package/src/services/ViewportService/Viewport.ts +372 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.contract.test.ts +467 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.ts +179 -0
- package/src/services/ViewportService/adapter/LegacyViewportAdapter.ts +240 -0
- package/src/services/ViewportService/adapter/NextViewportAdapter.ts +241 -0
- package/src/services/ViewportService/adapter/getViewportAdapter.ts +62 -0
- package/src/services/ViewportService/adapter/index.ts +16 -0
- package/src/services/ViewportService/backends/IViewportBackend.ts +195 -0
- package/src/services/ViewportService/backends/IViewportOperations.ts +98 -0
- package/src/services/ViewportService/backends/IViewportServiceInternals.ts +47 -0
- package/src/services/ViewportService/backends/LegacyViewportBackend.ts +264 -0
- package/src/services/ViewportService/backends/LegacyViewportOperations.ts +272 -0
- package/src/services/ViewportService/backends/NextViewportBackend.ts +671 -0
- package/src/services/ViewportService/backends/NextViewportOperations.ts +169 -0
- package/src/services/ViewportService/backends/README.md +62 -0
- package/src/services/ViewportService/backends/dataIdRegistry.ts +121 -0
- package/src/services/ViewportService/backends/viewportOperations.ts +71 -0
- package/src/services/ViewportService/constants.ts +3 -0
- package/src/state.ts +34 -0
- package/src/stores/index.ts +5 -0
- package/src/stores/presentationUtils.ts +42 -0
- package/src/stores/useLutPresentationStore.ts +166 -0
- package/src/stores/usePositionPresentationStore.ts +172 -0
- package/src/stores/useSegmentationPresentationStore.test.ts +146 -0
- package/src/stores/useSegmentationPresentationStore.ts +417 -0
- package/src/stores/useSelectedSegmentationsForViewportStore.ts +85 -0
- package/src/stores/useSynchronizersStore.ts +84 -0
- package/src/synchronizers/frameViewSynchronizer.ts +52 -0
- package/src/tools/CalibrationLineTool.ts +97 -0
- package/src/tools/ImageOverlayViewerTool.tsx +279 -0
- package/src/tools/OverlayPlaneModuleProvider.ts +40 -0
- package/src/tools/WindowLevelTool.test.ts +55 -0
- package/src/tools/WindowLevelTool.ts +22 -0
- package/src/types/AppTypes.ts +70 -0
- package/src/types/Colorbar.ts +114 -0
- package/src/types/Colormap.ts +16 -0
- package/src/types/CornerstoneCacheService.ts +40 -0
- package/src/types/CornerstoneServices.ts +18 -0
- package/src/types/Presentation.ts +83 -0
- package/src/types/SelectedSegmentationByTypeMap.ts +3 -0
- package/src/types/ViewportPresets.ts +53 -0
- package/src/types/VolumeLighting.ts +7 -0
- package/src/types/VolumeRenderingConfig.ts +8 -0
- package/src/types/WindowLevel.ts +5 -0
- package/src/types/index.ts +10 -0
- package/src/utils/ActiveViewportBehavior.tsx +80 -0
- package/src/utils/CornerstoneViewportDownloadForm.tsx +319 -0
- package/src/utils/DicomFileUploader.ts +204 -0
- package/src/utils/JumpPresets.ts +14 -0
- package/src/utils/autoHydrateViewportTypes.ts +69 -0
- package/src/utils/colormaps.js +1597 -0
- package/src/utils/createSegmentationForViewport.ts +83 -0
- package/src/utils/dicomLoaderService.js +225 -0
- package/src/utils/ecgMetadata.test.ts +137 -0
- package/src/utils/ecgMetadata.ts +109 -0
- package/src/utils/findNearbyToolData.test.ts +125 -0
- package/src/utils/findNearbyToolData.ts +21 -0
- package/src/utils/generateSegmentationCSVReport.test.ts +324 -0
- package/src/utils/generateSegmentationCSVReport.ts +131 -0
- package/src/utils/getActiveViewportEnabledElement.test.ts +70 -0
- package/src/utils/getActiveViewportEnabledElement.ts +8 -0
- package/src/utils/getCenterExtent.test.ts +313 -0
- package/src/utils/getCenterExtent.ts +46 -0
- package/src/utils/getCornerstoneBlendMode.test.ts +59 -0
- package/src/utils/getCornerstoneBlendMode.ts +25 -0
- package/src/utils/getCornerstoneOrientation.test.ts +78 -0
- package/src/utils/getCornerstoneOrientation.ts +31 -0
- package/src/utils/getCornerstoneViewportType.test.ts +169 -0
- package/src/utils/getCornerstoneViewportType.ts +88 -0
- package/src/utils/getInterleavedFrames.test.ts +85 -0
- package/src/utils/getInterleavedFrames.ts +73 -0
- package/src/utils/getLegacyViewportType.ts +64 -0
- package/src/utils/getNthFrames.test.ts +145 -0
- package/src/utils/getNthFrames.ts +31 -0
- package/src/utils/getViewportEnabledElement.test.ts +83 -0
- package/src/utils/getViewportEnabledElement.ts +8 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.test.ts +50 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.ts +56 -0
- package/src/utils/hydrationUtils.test.ts +572 -0
- package/src/utils/hydrationUtils.ts +197 -0
- package/src/utils/imageSliceSync/calculateViewportRegistrations.ts +28 -0
- package/src/utils/imageSliceSync/toggleImageSliceSync.ts +101 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/initGpuSettingsPreset.ts +51 -0
- package/src/utils/initViewTiming.test.ts +342 -0
- package/src/utils/initViewTiming.ts +52 -0
- package/src/utils/initWebWorkerProgressHandler.test.ts +381 -0
- package/src/utils/initWebWorkerProgressHandler.ts +110 -0
- package/src/utils/interleave.test.ts +304 -0
- package/src/utils/interleave.ts +32 -0
- package/src/utils/interleaveCenterLoader.test.ts +547 -0
- package/src/utils/interleaveCenterLoader.ts +143 -0
- package/src/utils/interleaveTopToBottom.test.ts +487 -0
- package/src/utils/interleaveTopToBottom.ts +132 -0
- package/src/utils/isAnyDisplaySetCommon.ts +18 -0
- package/src/utils/isDisplaySetOverlayable.ts +96 -0
- package/src/utils/isMeasurementWithinViewport.test.ts +340 -0
- package/src/utils/isMeasurementWithinViewport.ts +33 -0
- package/src/utils/isReferenceViewable.test.ts +581 -0
- package/src/utils/isReferenceViewable.ts +95 -0
- package/src/utils/loadDisplaySetData.ts +49 -0
- package/src/utils/measurementServiceMappings/Angle.ts +200 -0
- package/src/utils/measurementServiceMappings/ArrowAnnotate.ts +176 -0
- package/src/utils/measurementServiceMappings/Bidirectional.ts +193 -0
- package/src/utils/measurementServiceMappings/CircleROI.ts +227 -0
- package/src/utils/measurementServiceMappings/CobbAngle.ts +206 -0
- package/src/utils/measurementServiceMappings/EllipticalROI.ts +221 -0
- package/src/utils/measurementServiceMappings/Length.ts +206 -0
- package/src/utils/measurementServiceMappings/LivewireContour.ts +175 -0
- package/src/utils/measurementServiceMappings/PlanarFreehandROI.ts +228 -0
- package/src/utils/measurementServiceMappings/Probe.ts +192 -0
- package/src/utils/measurementServiceMappings/RectangleROI.ts +225 -0
- package/src/utils/measurementServiceMappings/SegmentBidirectional.ts +184 -0
- package/src/utils/measurementServiceMappings/SplineROI.ts +227 -0
- package/src/utils/measurementServiceMappings/UltrasoundDirectional.ts +214 -0
- package/src/utils/measurementServiceMappings/UltrasoundPleuraBLine.ts +179 -0
- package/src/utils/measurementServiceMappings/constants/supportedTools.js +21 -0
- package/src/utils/measurementServiceMappings/index.ts +3 -0
- package/src/utils/measurementServiceMappings/measurementServiceMappingsFactory.ts +324 -0
- package/src/utils/measurementServiceMappings/utils/getDisplayUnit.js +3 -0
- package/src/utils/measurementServiceMappings/utils/getHandlesFromPoints.js +14 -0
- package/src/utils/measurementServiceMappings/utils/getIsLocked.ts +5 -0
- package/src/utils/measurementServiceMappings/utils/getIsVisible.ts +6 -0
- package/src/utils/measurementServiceMappings/utils/getSOPInstanceAttributes.js +66 -0
- package/src/utils/measurementServiceMappings/utils/getValueDisplayString.js +12 -0
- package/src/utils/measurementServiceMappings/utils/index.ts +17 -0
- package/src/utils/measurementServiceMappings/utils/selection.ts +33 -0
- package/src/utils/mpr/getProtocolViewportStructureFromGridViewports.ts +74 -0
- package/src/utils/nextViewportPolicies.ts +41 -0
- package/src/utils/nextViewports.ts +157 -0
- package/src/utils/nthLoader.test.ts +317 -0
- package/src/utils/nthLoader.ts +78 -0
- package/src/utils/presentations/getViewportPresentations.test.ts +280 -0
- package/src/utils/presentations/getViewportPresentations.ts +151 -0
- package/src/utils/promptHydrationDialog.test.ts +490 -0
- package/src/utils/promptHydrationDialog.ts +197 -0
- package/src/utils/removeViewportSegmentationRepresentations.test.ts +129 -0
- package/src/utils/removeViewportSegmentationRepresentations.ts +17 -0
- package/src/utils/segmentUtils.test.ts +515 -0
- package/src/utils/segmentUtils.ts +46 -0
- package/src/utils/segmentationExportUtils.test.ts +100 -0
- package/src/utils/segmentationExportUtils.ts +171 -0
- package/src/utils/segmentationHandlers.test.ts +614 -0
- package/src/utils/segmentationHandlers.ts +164 -0
- package/src/utils/setUpAnnotationEventHandlers.ts +26 -0
- package/src/utils/setUpSegmentationEventHandlers.test.ts +372 -0
- package/src/utils/setUpSegmentationEventHandlers.ts +122 -0
- package/src/utils/toggleVOISliceSync.test.ts +606 -0
- package/src/utils/toggleVOISliceSync.ts +103 -0
- package/src/utils/transitions.test.ts +351 -0
- package/src/utils/transitions.ts +300 -0
- package/src/utils/updateSegmentationStats.test.ts +942 -0
- package/src/utils/updateSegmentationStats.ts +192 -0
- package/src/utils/viewportDataShape.ts +85 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getWebWorkerManager } from '@cornerstonejs/core';
|
|
2
|
+
|
|
3
|
+
const workerManager = getWebWorkerManager();
|
|
4
|
+
|
|
5
|
+
const WorkerOptions = {
|
|
6
|
+
maxWorkerInstances: 1,
|
|
7
|
+
autoTerminateOnIdle: {
|
|
8
|
+
enabled: true,
|
|
9
|
+
idleTimeThreshold: 1000,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Register the task
|
|
14
|
+
const workerFn = () => {
|
|
15
|
+
return new Worker(new URL('./histogramWorker.js', import.meta.url), {
|
|
16
|
+
name: 'histogram-worker', // name used by the browser to name the worker
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Register worker once at module load time
|
|
21
|
+
workerManager.registerWorker('histogram-worker', workerFn, WorkerOptions);
|
|
22
|
+
|
|
23
|
+
const getViewportVolumeHistogram = async (viewport, volume, options?) => {
|
|
24
|
+
const volumeImageData = viewport.getImageData(volume.volumeId);
|
|
25
|
+
|
|
26
|
+
if (!volumeImageData) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let scalarData = volume.scalarData;
|
|
31
|
+
|
|
32
|
+
if (volume.numTimePoints > 1) {
|
|
33
|
+
scalarData = volume.voxelManager.getDimensionGroupScalarData(volume.numTimePoints);
|
|
34
|
+
} else {
|
|
35
|
+
scalarData = volume.voxelManager.getCompleteScalarDataArray();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!scalarData?.length) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { dimensions, origin, direction, spacing } = volume;
|
|
43
|
+
|
|
44
|
+
const range = await workerManager.executeTask('histogram-worker', 'getRange', {
|
|
45
|
+
dimensions,
|
|
46
|
+
origin,
|
|
47
|
+
direction,
|
|
48
|
+
spacing,
|
|
49
|
+
scalarData,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const { minimum: min, maximum: max } = range;
|
|
53
|
+
|
|
54
|
+
if (min === Infinity || max === -Infinity) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const calcHistOptions = {
|
|
59
|
+
numBins: 256,
|
|
60
|
+
min: Math.max(min, options?.min ?? min),
|
|
61
|
+
max: Math.min(max, options?.max ?? max),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const histogram = await workerManager.executeTask('histogram-worker', 'calcHistogram', {
|
|
65
|
+
data: scalarData,
|
|
66
|
+
options: calcHistOptions,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return histogram;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { getViewportVolumeHistogram };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { expose } from 'comlink';
|
|
2
|
+
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
3
|
+
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This object simulates a heavy task by implementing a sleep function and a recursive Fibonacci function.
|
|
7
|
+
* It's used for testing or demonstrating purposes where a heavy or time-consuming task is needed.
|
|
8
|
+
*/
|
|
9
|
+
const obj = {
|
|
10
|
+
getRange: ({ dimensions, origin, direction, spacing, scalarData }) => {
|
|
11
|
+
const imageData = vtkImageData.newInstance();
|
|
12
|
+
imageData.setDimensions(dimensions);
|
|
13
|
+
imageData.setOrigin(origin);
|
|
14
|
+
imageData.setDirection(direction);
|
|
15
|
+
imageData.setSpacing(spacing);
|
|
16
|
+
|
|
17
|
+
const scalarArray = vtkDataArray.newInstance({
|
|
18
|
+
name: 'Pixels',
|
|
19
|
+
numberOfComponents: 1,
|
|
20
|
+
values: scalarData,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
imageData.getPointData().setScalars(scalarArray);
|
|
24
|
+
|
|
25
|
+
imageData.modified();
|
|
26
|
+
|
|
27
|
+
const range = imageData.computeHistogram(imageData.getBounds());
|
|
28
|
+
|
|
29
|
+
return range;
|
|
30
|
+
},
|
|
31
|
+
calcHistogram: ({ data, options }) => {
|
|
32
|
+
if (options === undefined) {
|
|
33
|
+
options = {};
|
|
34
|
+
}
|
|
35
|
+
const histogram = {
|
|
36
|
+
numBins: options.numBins || 256,
|
|
37
|
+
range: { min: 0, max: 0 },
|
|
38
|
+
bins: new Int32Array(1),
|
|
39
|
+
maxBin: 0,
|
|
40
|
+
maxBinValue: 0,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
let minToUse = options.min;
|
|
44
|
+
let maxToUse = options.max;
|
|
45
|
+
|
|
46
|
+
if (minToUse === undefined || maxToUse === undefined) {
|
|
47
|
+
let min = Infinity;
|
|
48
|
+
let max = -Infinity;
|
|
49
|
+
let index = data.length;
|
|
50
|
+
|
|
51
|
+
while (index--) {
|
|
52
|
+
const value = data[index];
|
|
53
|
+
if (value < min) {
|
|
54
|
+
min = value;
|
|
55
|
+
}
|
|
56
|
+
if (value > max) {
|
|
57
|
+
max = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
minToUse = min;
|
|
62
|
+
maxToUse = max;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
histogram.range = { min: minToUse, max: maxToUse };
|
|
66
|
+
|
|
67
|
+
const bins = new Int32Array(histogram.numBins);
|
|
68
|
+
const binScale = histogram.numBins / (maxToUse - minToUse);
|
|
69
|
+
|
|
70
|
+
for (let index = 0; index < data.length; index++) {
|
|
71
|
+
const value = data[index];
|
|
72
|
+
if (value < minToUse) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (value > maxToUse) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const bin = Math.floor((value - minToUse) * binScale);
|
|
79
|
+
bins[bin] += 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
histogram.bins = bins;
|
|
83
|
+
histogram.maxBin = 0;
|
|
84
|
+
histogram.maxBinValue = 0;
|
|
85
|
+
|
|
86
|
+
for (let bin = 0; bin < histogram.numBins; bin++) {
|
|
87
|
+
if (histogram.bins[bin] > histogram.maxBinValue) {
|
|
88
|
+
histogram.maxBin = bin;
|
|
89
|
+
histogram.maxBinValue = histogram.bins[bin];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return histogram;
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
expose(obj);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ViewportWindowLevel';
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { cache as cs3DCache, Types } from '@cornerstonejs/core';
|
|
2
|
+
import vtkColorMaps from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps';
|
|
3
|
+
import { utilities as csUtils } from '@cornerstonejs/core';
|
|
4
|
+
import { getViewportVolumeHistogram } from './getViewportVolumeHistogram';
|
|
5
|
+
import { getViewportAdapter } from '../../services/ViewportService/adapter';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Gets node opacity from volume actor
|
|
9
|
+
*/
|
|
10
|
+
export const getNodeOpacity = (volumeActor, nodeIndex) => {
|
|
11
|
+
if (!volumeActor) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const volumeOpacity = volumeActor.getProperty().getScalarOpacity(0);
|
|
16
|
+
const nodeValue = [];
|
|
17
|
+
|
|
18
|
+
volumeOpacity.getNodeValue(nodeIndex, nodeValue);
|
|
19
|
+
|
|
20
|
+
return nodeValue[1];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the opacity applied to the PET volume follows a specific pattern
|
|
25
|
+
*/
|
|
26
|
+
export const isPetVolumeWithDefaultOpacity = (volumeId: string, volumeActor) => {
|
|
27
|
+
if (!volumeActor) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const volume = cs3DCache.getVolume(volumeId);
|
|
32
|
+
|
|
33
|
+
if (!volume || volume.metadata.Modality !== 'PT') {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const volumeOpacity = volumeActor.getProperty().getScalarOpacity(0);
|
|
38
|
+
|
|
39
|
+
if (volumeOpacity.getSize() < 2) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const node1Value = [];
|
|
44
|
+
const node2Value = [];
|
|
45
|
+
|
|
46
|
+
volumeOpacity.getNodeValue(0, node1Value);
|
|
47
|
+
volumeOpacity.getNodeValue(1, node2Value);
|
|
48
|
+
|
|
49
|
+
if (node1Value[0] !== 0 || node1Value[1] !== 0 || node2Value[0] !== 0.1) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const expectedOpacity = node2Value[1];
|
|
54
|
+
const opacitySize = volumeOpacity.getSize();
|
|
55
|
+
const currentNodeValue = [];
|
|
56
|
+
|
|
57
|
+
for (let i = 2; i < opacitySize; i++) {
|
|
58
|
+
volumeOpacity.getNodeValue(i, currentNodeValue);
|
|
59
|
+
if (currentNodeValue[1] !== expectedOpacity) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return true;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Checks if volume has constant opacity
|
|
69
|
+
*/
|
|
70
|
+
export const isVolumeWithConstantOpacity = volumeActor => {
|
|
71
|
+
if (!volumeActor) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const volumeOpacity = volumeActor.getProperty().getScalarOpacity(0);
|
|
76
|
+
const opacitySize = volumeOpacity.getSize();
|
|
77
|
+
const firstNodeValue = [];
|
|
78
|
+
|
|
79
|
+
volumeOpacity.getNodeValue(0, firstNodeValue);
|
|
80
|
+
const firstNodeOpacity = firstNodeValue[1];
|
|
81
|
+
|
|
82
|
+
for (let i = 0; i < opacitySize; i++) {
|
|
83
|
+
const currentNodeValue = [];
|
|
84
|
+
volumeOpacity.getNodeValue(0, currentNodeValue);
|
|
85
|
+
if (currentNodeValue[1] !== firstNodeOpacity) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return true;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Gets window levels data for a viewport
|
|
95
|
+
*/
|
|
96
|
+
export const getWindowLevelsData = async (
|
|
97
|
+
viewport: Types.IStackViewport | Types.IVolumeViewport,
|
|
98
|
+
viewportInfo: any,
|
|
99
|
+
getVolumeOpacity: (viewport: any, volumeId: string) => number | undefined
|
|
100
|
+
) => {
|
|
101
|
+
if (!viewport) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// The per-volume histogram WL panel is a legacy volume-viewport feature; the
|
|
106
|
+
// adapter reports no volumeIds for native viewports (and legacy stacks), so
|
|
107
|
+
// those degrade gracefully to no histogram rows rather than erroring; the
|
|
108
|
+
// native WL path is driven by setViewportWindowLevel.
|
|
109
|
+
// TODO(next): port per-volume histograms to the native volume API.
|
|
110
|
+
const adapter = getViewportAdapter(viewport);
|
|
111
|
+
const volumeIds = adapter.getVolumeIds();
|
|
112
|
+
if (!volumeIds.length) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const viewportProperties = adapter.getPresentation();
|
|
117
|
+
const { voiRange } = viewportProperties || {};
|
|
118
|
+
const viewportVoi = voiRange
|
|
119
|
+
? {
|
|
120
|
+
windowWidth: voiRange.upper - voiRange.lower,
|
|
121
|
+
windowCenter: voiRange.lower + (voiRange.upper - voiRange.lower) / 2,
|
|
122
|
+
}
|
|
123
|
+
: undefined;
|
|
124
|
+
|
|
125
|
+
const windowLevels = await Promise.all(
|
|
126
|
+
volumeIds.map(async (volumeId, volumeIndex) => {
|
|
127
|
+
const volume = cs3DCache.getVolume(volumeId);
|
|
128
|
+
|
|
129
|
+
const opacity = getVolumeOpacity(viewport, volumeId);
|
|
130
|
+
const { metadata, scaling } = volume;
|
|
131
|
+
const modality = metadata.Modality;
|
|
132
|
+
|
|
133
|
+
const options = {
|
|
134
|
+
min: modality === 'PT' ? 0.1 : -999,
|
|
135
|
+
max: modality === 'PT' ? 5 : 10000,
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const histogram = await getViewportVolumeHistogram(viewport, volume, options);
|
|
139
|
+
|
|
140
|
+
if (!histogram || histogram.range.min === histogram.range.max) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (!viewportInfo.displaySetOptions || !viewportInfo.displaySetOptions[volumeIndex]) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const { voi: displaySetVOI, colormap: displaySetColormap } =
|
|
149
|
+
viewportInfo.displaySetOptions[volumeIndex];
|
|
150
|
+
|
|
151
|
+
let colormap;
|
|
152
|
+
if (displaySetColormap) {
|
|
153
|
+
colormap =
|
|
154
|
+
csUtils.colormap.getColormap(displaySetColormap.name) ??
|
|
155
|
+
vtkColorMaps.getPresetByName(displaySetColormap.name);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const voi = !volumeIndex ? (viewportVoi ?? displaySetVOI) : displaySetVOI;
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
viewportId: viewportInfo.viewportId,
|
|
162
|
+
modality,
|
|
163
|
+
volumeId,
|
|
164
|
+
volumeIndex,
|
|
165
|
+
voi,
|
|
166
|
+
histogram,
|
|
167
|
+
colormap,
|
|
168
|
+
step: scaling?.PT ? 0.05 : 1,
|
|
169
|
+
opacity,
|
|
170
|
+
showOpacitySlider: volumeIndex === 1 && opacity !== undefined,
|
|
171
|
+
};
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
return windowLevels.filter(Boolean);
|
|
176
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { Switch } from '@ohif/ui-next';
|
|
3
|
+
import { useViewportRendering } from '../../hooks/useViewportRendering';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
export function Colorbar({ viewportId }: { viewportId?: string } = {}): ReactElement<any> {
|
|
7
|
+
const { hasColorbar, toggleColorbar } = useViewportRendering(viewportId);
|
|
8
|
+
const { t } = useTranslation('WindowLevelActionMenu');
|
|
9
|
+
|
|
10
|
+
const handleToggle = () => {
|
|
11
|
+
toggleColorbar();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className="hover:bg-accent flex h-8 w-full flex-shrink-0 cursor-pointer items-center px-2 text-base hover:rounded">
|
|
16
|
+
<div className="flex w-7 flex-shrink-0 items-center justify-center"></div>
|
|
17
|
+
<span
|
|
18
|
+
className="flex-grow"
|
|
19
|
+
onClick={handleToggle}
|
|
20
|
+
>
|
|
21
|
+
{t('Display Color bar')}
|
|
22
|
+
</span>
|
|
23
|
+
<Switch
|
|
24
|
+
className="ml-2 flex-shrink-0"
|
|
25
|
+
checked={!!hasColorbar}
|
|
26
|
+
onCheckedChange={handleToggle}
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { ReactElement, useEffect, useState } from 'react';
|
|
2
|
+
import { AllInOneMenu, ScrollArea, Switch, Tabs, TabsList, TabsTrigger } from '@ohif/ui-next';
|
|
3
|
+
import { useViewportRendering } from '../../hooks/useViewportRendering';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
|
|
6
|
+
export function Colormap({ viewportId }: { viewportId?: string } = {}): ReactElement<any> {
|
|
7
|
+
const { viewportDisplaySets } = useViewportRendering(viewportId);
|
|
8
|
+
const { t } = useTranslation('WindowLevelActionMenu');
|
|
9
|
+
|
|
10
|
+
const [activeDisplaySetUID, setActiveDisplaySetUID] = useState<string | undefined>(
|
|
11
|
+
viewportDisplaySets?.[0]?.displaySetInstanceUID
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
// Use the hook with the active display set
|
|
15
|
+
const { colorbarProperties, setColormap } = useViewportRendering(viewportId, {
|
|
16
|
+
displaySetInstanceUID: activeDisplaySetUID,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const { colormaps } = colorbarProperties;
|
|
20
|
+
|
|
21
|
+
const [showPreview, setShowPreview] = useState(false);
|
|
22
|
+
const [prePreviewColormap, setPrePreviewColormap] = useState(null);
|
|
23
|
+
const [currentColormap, setCurrentColormap] = useState(null);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setCurrentColormap(null);
|
|
27
|
+
setPrePreviewColormap(null);
|
|
28
|
+
}, [activeDisplaySetUID]);
|
|
29
|
+
|
|
30
|
+
const handleSetColorLUT = (colormap, immediate = true) => {
|
|
31
|
+
// Check if it's a fusion viewport
|
|
32
|
+
const oneOpacityColormaps = ['Grayscale', 'X Ray'];
|
|
33
|
+
const opacity =
|
|
34
|
+
viewportDisplaySets.length > 1 && !oneOpacityColormaps.includes(colormap.name) ? 0.5 : 1;
|
|
35
|
+
|
|
36
|
+
setColormap({
|
|
37
|
+
colormap,
|
|
38
|
+
opacity,
|
|
39
|
+
immediate,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
{viewportDisplaySets && viewportDisplaySets.length > 1 && (
|
|
46
|
+
<div className="flex h-8 w-full flex-shrink-0 items-center justify-center px-2 text-base">
|
|
47
|
+
<Tabs
|
|
48
|
+
value={activeDisplaySetUID}
|
|
49
|
+
onValueChange={displaySetUID => {
|
|
50
|
+
setActiveDisplaySetUID(displaySetUID);
|
|
51
|
+
setPrePreviewColormap(null);
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<TabsList>
|
|
55
|
+
{viewportDisplaySets.map(ds => (
|
|
56
|
+
<TabsTrigger
|
|
57
|
+
key={ds.displaySetInstanceUID}
|
|
58
|
+
value={ds.displaySetInstanceUID}
|
|
59
|
+
>
|
|
60
|
+
{ds.Modality}
|
|
61
|
+
</TabsTrigger>
|
|
62
|
+
))}
|
|
63
|
+
</TabsList>
|
|
64
|
+
</Tabs>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
<div
|
|
69
|
+
className="hover:bg-accent flex h-8 w-full flex-shrink-0 cursor-pointer items-center px-2 text-base hover:rounded"
|
|
70
|
+
onClick={() => setShowPreview(!showPreview)}
|
|
71
|
+
>
|
|
72
|
+
<span className="flex-shrink-0">{t('Preview in viewport')}</span>
|
|
73
|
+
<Switch
|
|
74
|
+
className="ml-auto flex-shrink-0"
|
|
75
|
+
checked={showPreview}
|
|
76
|
+
onCheckedChange={checked => {
|
|
77
|
+
setShowPreview(checked);
|
|
78
|
+
|
|
79
|
+
if (!checked && currentColormap) {
|
|
80
|
+
handleSetColorLUT(currentColormap);
|
|
81
|
+
}
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<AllInOneMenu.DividerItem />
|
|
87
|
+
|
|
88
|
+
<div className="h-[300px] flex-grow">
|
|
89
|
+
<ScrollArea className="h-full w-full">
|
|
90
|
+
<div className="p-1">
|
|
91
|
+
{colormaps.map((colormap, index) => (
|
|
92
|
+
<AllInOneMenu.Item
|
|
93
|
+
key={index}
|
|
94
|
+
label={t(`Colormaps:${colormap.Name}`, { defaultValue: colormap.Name })}
|
|
95
|
+
useIconSpace={false}
|
|
96
|
+
onClick={() => {
|
|
97
|
+
setCurrentColormap(colormap);
|
|
98
|
+
handleSetColorLUT(colormap);
|
|
99
|
+
setPrePreviewColormap(null);
|
|
100
|
+
}}
|
|
101
|
+
onMouseEnter={() => {
|
|
102
|
+
if (showPreview) {
|
|
103
|
+
if (!prePreviewColormap) {
|
|
104
|
+
setPrePreviewColormap(colormap);
|
|
105
|
+
}
|
|
106
|
+
handleSetColorLUT(colormap);
|
|
107
|
+
}
|
|
108
|
+
}}
|
|
109
|
+
onMouseLeave={() => {
|
|
110
|
+
if (showPreview && prePreviewColormap) {
|
|
111
|
+
handleSetColorLUT(prePreviewColormap);
|
|
112
|
+
}
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
))}
|
|
116
|
+
</div>
|
|
117
|
+
</ScrollArea>
|
|
118
|
+
</div>
|
|
119
|
+
</>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { ReactElement, useState, useEffect, useCallback } from 'react';
|
|
2
|
+
import { VolumeLightingProps } from '../../types/ViewportPresets';
|
|
3
|
+
import { Numeric } from '@ohif/ui-next';
|
|
4
|
+
import { useSystem } from '@ohif/core';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
export function VolumeLighting({ viewportId, hasShade }: VolumeLightingProps): ReactElement<any> {
|
|
8
|
+
const { servicesManager, commandsManager } = useSystem();
|
|
9
|
+
const { cornerstoneViewportService } = servicesManager.services;
|
|
10
|
+
const [lightingValues, setLightingValues] = useState({
|
|
11
|
+
ambient: null,
|
|
12
|
+
diffuse: null,
|
|
13
|
+
specular: null,
|
|
14
|
+
});
|
|
15
|
+
const { t } = useTranslation('WindowLevelActionMenu');
|
|
16
|
+
|
|
17
|
+
// Single callback to handle all lighting property changes
|
|
18
|
+
const onLightingChange = useCallback(
|
|
19
|
+
(property, value) => {
|
|
20
|
+
commandsManager.runCommand('setVolumeLighting', {
|
|
21
|
+
viewportId,
|
|
22
|
+
options: { [property]: value },
|
|
23
|
+
});
|
|
24
|
+
setLightingValues(prev => ({
|
|
25
|
+
...prev,
|
|
26
|
+
[property]: value,
|
|
27
|
+
}));
|
|
28
|
+
},
|
|
29
|
+
[commandsManager, viewportId]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const viewport = cornerstoneViewportService.getCornerstoneViewport(viewportId);
|
|
34
|
+
const { actor } = viewport.getActors()[0];
|
|
35
|
+
const property = actor.getProperty();
|
|
36
|
+
|
|
37
|
+
const values = {
|
|
38
|
+
ambient: property.getAmbient(),
|
|
39
|
+
diffuse: property.getDiffuse(),
|
|
40
|
+
specular: property.getSpecular(),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
setLightingValues(values);
|
|
44
|
+
}, [viewportId, cornerstoneViewportService]);
|
|
45
|
+
|
|
46
|
+
const disableOption = hasShade ? '' : 'ohif-disabled !opacity-40';
|
|
47
|
+
|
|
48
|
+
// Configuration for our lighting properties
|
|
49
|
+
const lightingProperties = [
|
|
50
|
+
{ key: 'ambient', label: t('Ambient') },
|
|
51
|
+
{ key: 'diffuse', label: t('Diffuse') },
|
|
52
|
+
{ key: 'specular', label: t('Specular') },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className="my-1 mt-2 flex flex-col space-y-2">
|
|
57
|
+
{lightingProperties.map(
|
|
58
|
+
({ key, label }) =>
|
|
59
|
+
lightingValues[key] !== null && (
|
|
60
|
+
<div
|
|
61
|
+
key={key}
|
|
62
|
+
className={`w-full pl-2 pr-1 ${disableOption}`}
|
|
63
|
+
>
|
|
64
|
+
<Numeric.Container
|
|
65
|
+
mode="singleRange"
|
|
66
|
+
min={0}
|
|
67
|
+
max={1}
|
|
68
|
+
step={0.1}
|
|
69
|
+
value={lightingValues[key]}
|
|
70
|
+
onChange={value => onLightingChange(key, value)}
|
|
71
|
+
>
|
|
72
|
+
<div className="flex flex-row items-center">
|
|
73
|
+
<Numeric.Label className="w-16">{label}</Numeric.Label>
|
|
74
|
+
<Numeric.SingleRange sliderClassName="mx-2 flex-grow" />
|
|
75
|
+
</div>
|
|
76
|
+
</Numeric.Container>
|
|
77
|
+
</div>
|
|
78
|
+
)
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { ReactElement, useState } from 'react';
|
|
2
|
+
import { AllInOneMenu } from '@ohif/ui-next';
|
|
3
|
+
import { VolumeRenderingQuality } from './VolumeRenderingQuality';
|
|
4
|
+
import { VolumeShift } from './VolumeShift';
|
|
5
|
+
import { VolumeLighting } from './VolumeLighting';
|
|
6
|
+
import { VolumeShade } from './VolumeShade';
|
|
7
|
+
import { useViewportRendering } from '../../hooks/useViewportRendering';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
|
|
10
|
+
export function VolumeRenderingOptions({ viewportId }: { viewportId?: string } = {}): ReactElement<any> {
|
|
11
|
+
const { volumeRenderingQualityRange } = useViewportRendering(viewportId);
|
|
12
|
+
const [hasShade, setShade] = useState(false);
|
|
13
|
+
const { t } = useTranslation('WindowLevelActionMenu');
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<AllInOneMenu.ItemPanel>
|
|
17
|
+
<VolumeRenderingQuality
|
|
18
|
+
viewportId={viewportId}
|
|
19
|
+
volumeRenderingQualityRange={volumeRenderingQualityRange}
|
|
20
|
+
/>
|
|
21
|
+
<VolumeShift viewportId={viewportId} />
|
|
22
|
+
<div className="mt-2 flex h-8 !h-[20px] w-full flex-shrink-0 items-center justify-start px-2 text-base">
|
|
23
|
+
<div className="text-muted-foreground text-sm">{t('Lighting')}</div>
|
|
24
|
+
</div>
|
|
25
|
+
<div className="bg-background mt-1 mb-1 h-px w-full"></div>
|
|
26
|
+
<div className="hover:bg-accent flex h-8 w-full flex-shrink-0 items-center px-2 text-base hover:rounded">
|
|
27
|
+
<VolumeShade
|
|
28
|
+
viewportId={viewportId}
|
|
29
|
+
onClickShade={setShade}
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
<VolumeLighting
|
|
33
|
+
viewportId={viewportId}
|
|
34
|
+
hasShade={hasShade}
|
|
35
|
+
/>
|
|
36
|
+
</AllInOneMenu.ItemPanel>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AllInOneMenu } from '@ohif/ui-next';
|
|
2
|
+
import { Icons } from '@ohif/ui-next';
|
|
3
|
+
import React, { ReactElement } from 'react';
|
|
4
|
+
import { VolumeRenderingPresetsContent } from './VolumeRenderingPresetsContent';
|
|
5
|
+
import { useSystem } from '@ohif/core';
|
|
6
|
+
import { useViewportRendering } from '../../hooks/useViewportRendering';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
|
|
9
|
+
export function VolumeRenderingPresets({ viewportId }: { viewportId?: string } = {}): ReactElement<any> {
|
|
10
|
+
const { volumeRenderingPresets } = useViewportRendering(viewportId);
|
|
11
|
+
const { servicesManager } = useSystem();
|
|
12
|
+
const { uiDialogService } = servicesManager.services;
|
|
13
|
+
const { t } = useTranslation('WindowLevelActionMenu');
|
|
14
|
+
|
|
15
|
+
const onClickPresets = () => {
|
|
16
|
+
uiDialogService.show({
|
|
17
|
+
id: 'volume-rendering-presets',
|
|
18
|
+
content: VolumeRenderingPresetsContent,
|
|
19
|
+
title: t('Rendering Presets'),
|
|
20
|
+
isDraggable: true,
|
|
21
|
+
contentProps: {
|
|
22
|
+
presets: volumeRenderingPresets,
|
|
23
|
+
viewportId,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<AllInOneMenu.Item
|
|
30
|
+
label={t('Rendering Presets')}
|
|
31
|
+
icon={<Icons.VolumeRendering />}
|
|
32
|
+
rightIcon={<Icons.ByName name="action-new-dialog" />}
|
|
33
|
+
onClick={onClickPresets}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|