@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,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useMeasurements } from '../hooks/useMeasurements';
|
|
4
|
+
import StudyMeasurements from '../components/StudyMeasurements';
|
|
5
|
+
/**
|
|
6
|
+
* The PanelMeasurement is a fairly simple wrapper that gets the filtered
|
|
7
|
+
* measurements and then passes it on to the children component, default to
|
|
8
|
+
* the StudyMeasurements sub-component if no children are specified.
|
|
9
|
+
* Some example customizations that could work:
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* Creates a default study measurements panel with default children:
|
|
13
|
+
* ```
|
|
14
|
+
* <PanelMeasurement>
|
|
15
|
+
* <StudyMeasurements />
|
|
16
|
+
* </PanelMeasurement>
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* A study measurements with body replacement
|
|
20
|
+
* ```
|
|
21
|
+
* <StudyMeasurements>
|
|
22
|
+
* <SeriesMeasurements />
|
|
23
|
+
* </StudyMeasurements>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* A study measurements replacing just the trigger, leaving the default body
|
|
27
|
+
* ```
|
|
28
|
+
* <StudyMeasurements>
|
|
29
|
+
* <AccordionGroup.Trigger>
|
|
30
|
+
* This is a new custom trigger
|
|
31
|
+
* </AccordionGroup.Trigger>
|
|
32
|
+
*</StudyMeasurements>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* A study measurements with the trigger and body replaced
|
|
36
|
+
* ```
|
|
37
|
+
* <StudyMeasurements>
|
|
38
|
+
* <AccordionGroup.Trigger>
|
|
39
|
+
* This is a new custom trigger
|
|
40
|
+
* </AccordionGroup.Trigger>
|
|
41
|
+
* <SeriesMeasurements />
|
|
42
|
+
* </StudyMeasurements>
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* A study measurements with a custom header for the additional findings
|
|
46
|
+
* ```
|
|
47
|
+
* <StudyMeasurements>
|
|
48
|
+
* <MeasurementOrAdditionalFindings>
|
|
49
|
+
* <AccordionGroup.Trigger groupName="additionalFindings">
|
|
50
|
+
* <CustomAdditionalFindingsHeader />
|
|
51
|
+
* </AccordionGroup.Trigger>
|
|
52
|
+
* <AccordionGroup.Trigger groupName="measurements">
|
|
53
|
+
* <CustomMeasurementsHeader />
|
|
54
|
+
* </AccordionGroup.Trigger>
|
|
55
|
+
* </MeasurementOrAdditionalFindings>
|
|
56
|
+
* </StudyMeasurements>
|
|
57
|
+
*```
|
|
58
|
+
*/
|
|
59
|
+
export default function PanelMeasurement(props): React.ReactNode {
|
|
60
|
+
const { measurementFilter, emptyComponent: EmptyComponent, children } = props;
|
|
61
|
+
|
|
62
|
+
const displayMeasurements = useMeasurements({ measurementFilter });
|
|
63
|
+
|
|
64
|
+
if (!displayMeasurements.length) {
|
|
65
|
+
return EmptyComponent ? (
|
|
66
|
+
<EmptyComponent items={displayMeasurements} />
|
|
67
|
+
) : (
|
|
68
|
+
<span className="text-foreground">No Measurements</span>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (children) {
|
|
73
|
+
const cloned = React.Children.map(children, child =>
|
|
74
|
+
React.cloneElement(child, {
|
|
75
|
+
items: displayMeasurements,
|
|
76
|
+
filter: measurementFilter,
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
return cloned;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Need to merge defaults on the content props to ensure they get passed to children
|
|
83
|
+
return <StudyMeasurements items={displayMeasurements} />;
|
|
84
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
IconPresentationProvider,
|
|
4
|
+
Popover,
|
|
5
|
+
PopoverAnchor,
|
|
6
|
+
PopoverContent,
|
|
7
|
+
SegmentationTable,
|
|
8
|
+
ToolSettings,
|
|
9
|
+
} from '@ohif/ui-next';
|
|
10
|
+
import { useActiveViewportSegmentationRepresentations } from '../hooks/useActiveViewportSegmentationRepresentations';
|
|
11
|
+
import { useActiveToolOptions, useCustomization, useSystem } from '@ohif/core/src';
|
|
12
|
+
import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
|
13
|
+
import { Toolbar, useUIStateStore } from '@ohif/extension-default';
|
|
14
|
+
import SegmentationUtilityButton from '../components/SegmentationUtilityButton';
|
|
15
|
+
import { useSelectedSegmentationsForViewportStore } from '../stores';
|
|
16
|
+
import {
|
|
17
|
+
hasExportableLabelMapData,
|
|
18
|
+
hasExportableContourData,
|
|
19
|
+
} from '../utils/segmentationExportUtils';
|
|
20
|
+
|
|
21
|
+
type PanelSegmentationProps = {
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
|
|
24
|
+
// The representation types for this segmentation panel. Undefined means all types.
|
|
25
|
+
// The first element is the primary type. Additional elements are secondary types.
|
|
26
|
+
segmentationRepresentationTypes?: SegmentationRepresentations[];
|
|
27
|
+
} & withAppTypes;
|
|
28
|
+
|
|
29
|
+
export default function PanelSegmentation({
|
|
30
|
+
children,
|
|
31
|
+
segmentationRepresentationTypes,
|
|
32
|
+
}: PanelSegmentationProps) {
|
|
33
|
+
const { commandsManager, servicesManager } = useSystem();
|
|
34
|
+
const { displaySetService, viewportGridService, toolbarService, segmentationService } =
|
|
35
|
+
servicesManager.services;
|
|
36
|
+
const { activeViewportId } = viewportGridService.getState();
|
|
37
|
+
|
|
38
|
+
const utilitiesSectionMap = {
|
|
39
|
+
[SegmentationRepresentations.Labelmap]: toolbarService.sections.labelMapSegmentationUtilities,
|
|
40
|
+
[SegmentationRepresentations.Contour]: toolbarService.sections.contourSegmentationUtilities,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const selectedSegmentationsForViewportMap = useSelectedSegmentationsForViewportStore(
|
|
44
|
+
store => store.selectedSegmentationsForViewport[activeViewportId]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const selectedSegmentationIdForType = segmentationRepresentationTypes
|
|
48
|
+
? segmentationRepresentationTypes.reduce(
|
|
49
|
+
(selectedSegmentation, type) =>
|
|
50
|
+
selectedSegmentation ||
|
|
51
|
+
(selectedSegmentationsForViewportMap?.has(type)
|
|
52
|
+
? selectedSegmentationsForViewportMap?.get(type)
|
|
53
|
+
: undefined),
|
|
54
|
+
undefined
|
|
55
|
+
)
|
|
56
|
+
: segmentationService?.getActiveSegmentation(activeViewportId)?.segmentationId;
|
|
57
|
+
|
|
58
|
+
const buttonSection = segmentationRepresentationTypes?.[0]
|
|
59
|
+
? utilitiesSectionMap[segmentationRepresentationTypes[0]]
|
|
60
|
+
: undefined;
|
|
61
|
+
|
|
62
|
+
const { activeToolOptions: activeUtilityOptions } = useActiveToolOptions({
|
|
63
|
+
buttonSectionId: buttonSection,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const { segmentationsWithRepresentations, disabled } =
|
|
67
|
+
useActiveViewportSegmentationRepresentations();
|
|
68
|
+
|
|
69
|
+
const setUIState = useUIStateStore(store => store.setUIState);
|
|
70
|
+
|
|
71
|
+
// useEffect for handling clicks on any of the non-active viewports.
|
|
72
|
+
// The ViewportGrid stops the propagation of pointer/mouse events
|
|
73
|
+
// for non-active viewports so the Popover below
|
|
74
|
+
// is not closed when clicking on any of the non-active viewports.
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
setUIState('activeSegmentationUtility', null);
|
|
77
|
+
toolbarService.refreshToolbarState({ viewportId: activeViewportId });
|
|
78
|
+
}, [activeViewportId, setUIState, toolbarService]);
|
|
79
|
+
|
|
80
|
+
// The callback for handling clicks outside of the Popover and, the SegmentationUtilityButton
|
|
81
|
+
// that triggered it to open. Clicks outside those components must close the Popover.
|
|
82
|
+
// The Popover is made visible whenever the options associated with the
|
|
83
|
+
// activeSegmentationUtility exist. Thus clearing the activeSegmentationUtility
|
|
84
|
+
// clears the associated options and will keep the Popover closed.
|
|
85
|
+
const handlePopoverOpenChange = (open: boolean) => {
|
|
86
|
+
if (!open) {
|
|
87
|
+
setUIState('activeSegmentationUtility', null);
|
|
88
|
+
toolbarService.refreshToolbarState({ viewportId: activeViewportId });
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// Customizations are read through useCustomization rather than calling
|
|
93
|
+
// customizationService.getCustomization during render. Modes register these in
|
|
94
|
+
// onModeEnter, which can land after this panel has already mounted, and a
|
|
95
|
+
// render-time getCustomization call gets memoized by the React Compiler on the
|
|
96
|
+
// (stable) service reference - so it would serve the pre-registration default
|
|
97
|
+
// for the life of the panel. useCustomization subscribes to the service's
|
|
98
|
+
// change events instead. TMTV hit this twice: its 'expanded' tableMode stayed
|
|
99
|
+
// stuck on the 'collapsed' default, and its create-labelmap-from-PT
|
|
100
|
+
// onSegmentationAdd handler was ignored in favour of the default.
|
|
101
|
+
const segmentationTableMode = useCustomization('panelSegmentation.tableMode') as string;
|
|
102
|
+
const onSegmentationAdd = useCustomization('panelSegmentation.onSegmentationAdd');
|
|
103
|
+
const disableEditing = useCustomization('panelSegmentation.disableEditing');
|
|
104
|
+
const showAddSegment = useCustomization('panelSegmentation.showAddSegment');
|
|
105
|
+
const CustomDropdownMenuContent = useCustomization('panelSegmentation.customDropdownMenuContent');
|
|
106
|
+
const CustomSegmentStatisticsHeader = useCustomization(
|
|
107
|
+
'panelSegmentation.customSegmentStatisticsHeader'
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// Create handlers object for all command runs
|
|
111
|
+
const handlers = {
|
|
112
|
+
onSegmentationClick: (segmentationId: string) => {
|
|
113
|
+
commandsManager.run('setActiveSegmentation', { segmentationId });
|
|
114
|
+
},
|
|
115
|
+
onSegmentAdd: segmentationId => {
|
|
116
|
+
commandsManager.run('addSegment', { segmentationId });
|
|
117
|
+
commandsManager.run('setActiveSegmentation', { segmentationId });
|
|
118
|
+
},
|
|
119
|
+
onSegmentClick: (segmentationId, segmentIndex) => {
|
|
120
|
+
commandsManager.run('setActiveSegmentAndCenter', { segmentationId, segmentIndex });
|
|
121
|
+
},
|
|
122
|
+
onSegmentEdit: (segmentationId, segmentIndex) => {
|
|
123
|
+
commandsManager.run('editSegmentLabel', { segmentationId, segmentIndex });
|
|
124
|
+
},
|
|
125
|
+
onSegmentationEdit: segmentationId => {
|
|
126
|
+
commandsManager.run('editSegmentationLabel', { segmentationId });
|
|
127
|
+
},
|
|
128
|
+
onSegmentColorClick: (segmentationId, segmentIndex) => {
|
|
129
|
+
commandsManager.run('editSegmentColor', { segmentationId, segmentIndex });
|
|
130
|
+
},
|
|
131
|
+
onSegmentDelete: (segmentationId, segmentIndex) => {
|
|
132
|
+
commandsManager.run('deleteSegment', { segmentationId, segmentIndex });
|
|
133
|
+
},
|
|
134
|
+
onSegmentCopy:
|
|
135
|
+
segmentationRepresentationTypes?.[0] === SegmentationRepresentations.Contour
|
|
136
|
+
? (segmentationId, segmentIndex) => {
|
|
137
|
+
commandsManager.run('copyContourSegment', {
|
|
138
|
+
sourceSegmentInfo: { segmentationId, segmentIndex },
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
: undefined,
|
|
142
|
+
onToggleSegmentVisibility: (segmentationId, segmentIndex, type) => {
|
|
143
|
+
commandsManager.run('toggleSegmentVisibility', { segmentationId, segmentIndex, type });
|
|
144
|
+
},
|
|
145
|
+
onToggleSegmentLock: (segmentationId, segmentIndex) => {
|
|
146
|
+
commandsManager.run('toggleSegmentLock', { segmentationId, segmentIndex });
|
|
147
|
+
},
|
|
148
|
+
onToggleSegmentationRepresentationVisibility: (segmentationId, type) => {
|
|
149
|
+
commandsManager.run('toggleSegmentationVisibility', { segmentationId, type });
|
|
150
|
+
},
|
|
151
|
+
onSegmentationDownload: segmentationId => {
|
|
152
|
+
commandsManager.run('downloadSegmentation', { segmentationId });
|
|
153
|
+
},
|
|
154
|
+
setStyle: (segmentationId, type, key, value) => {
|
|
155
|
+
commandsManager.run('setSegmentationStyle', { segmentationId, type, key, value });
|
|
156
|
+
},
|
|
157
|
+
toggleRenderInactiveSegmentations: () => {
|
|
158
|
+
commandsManager.run('toggleRenderInactiveSegmentations');
|
|
159
|
+
},
|
|
160
|
+
onSegmentationRemoveFromViewport: segmentationId => {
|
|
161
|
+
commandsManager.run('removeSegmentationFromViewport', { segmentationId });
|
|
162
|
+
},
|
|
163
|
+
onSegmentationDelete: segmentationId => {
|
|
164
|
+
commandsManager.run('deleteSegmentation', { segmentationId });
|
|
165
|
+
},
|
|
166
|
+
setFillAlpha: ({ type }, value) => {
|
|
167
|
+
commandsManager.run('activateSelectedSegmentationOfType', {
|
|
168
|
+
segmentationRepresentationType: type,
|
|
169
|
+
});
|
|
170
|
+
commandsManager.run('setFillAlpha', { type, value });
|
|
171
|
+
},
|
|
172
|
+
setOutlineWidth: ({ type }, value) => {
|
|
173
|
+
commandsManager.run('activateSelectedSegmentationOfType', {
|
|
174
|
+
segmentationRepresentationType: type,
|
|
175
|
+
});
|
|
176
|
+
commandsManager.run('setOutlineWidth', { type, value });
|
|
177
|
+
},
|
|
178
|
+
setRenderFill: ({ type }, value) => {
|
|
179
|
+
commandsManager.run('activateSelectedSegmentationOfType', {
|
|
180
|
+
segmentationRepresentationType: type,
|
|
181
|
+
});
|
|
182
|
+
commandsManager.run('setRenderFill', { type, value });
|
|
183
|
+
},
|
|
184
|
+
setRenderFillInactive: ({ type }, value) => {
|
|
185
|
+
commandsManager.run('setRenderFillInactive', { type, value });
|
|
186
|
+
},
|
|
187
|
+
setRenderOutline: ({ type }, value) => {
|
|
188
|
+
commandsManager.run('activateSelectedSegmentationOfType', {
|
|
189
|
+
segmentationRepresentationType: type,
|
|
190
|
+
});
|
|
191
|
+
commandsManager.run('setRenderOutline', { type, value });
|
|
192
|
+
},
|
|
193
|
+
setRenderOutlineInactive: ({ type }, value) => {
|
|
194
|
+
commandsManager.run('setRenderOutlineInactive', { type, value });
|
|
195
|
+
},
|
|
196
|
+
setFillAlphaInactive: ({ type }: { type?: string }, value) => {
|
|
197
|
+
commandsManager.run('setFillAlphaInactive', { type, value });
|
|
198
|
+
},
|
|
199
|
+
getRenderInactiveSegmentations: () => {
|
|
200
|
+
return commandsManager.run('getRenderInactiveSegmentations');
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// Generate export options
|
|
205
|
+
// Map each segmentation to an export option for it.
|
|
206
|
+
// A segmentation is exportable if it has any labelmap or contour data.
|
|
207
|
+
const exportOptions = segmentationsWithRepresentations.map(({ segmentation }) => {
|
|
208
|
+
const { representationData, segmentationId } = segmentation;
|
|
209
|
+
const { Labelmap, Contour } = representationData;
|
|
210
|
+
|
|
211
|
+
if (!Labelmap && !Contour) {
|
|
212
|
+
return { segmentationId, isExportable: true };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (
|
|
216
|
+
!hasExportableLabelMapData(Labelmap, displaySetService) &&
|
|
217
|
+
!hasExportableContourData(Contour)
|
|
218
|
+
) {
|
|
219
|
+
return { segmentationId, isExportable: false };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return {
|
|
223
|
+
segmentationId,
|
|
224
|
+
isExportable: true,
|
|
225
|
+
};
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// Common props for SegmentationTable
|
|
229
|
+
const tableProps = {
|
|
230
|
+
disabled,
|
|
231
|
+
data: segmentationsWithRepresentations,
|
|
232
|
+
mode: segmentationTableMode,
|
|
233
|
+
title: `${segmentationRepresentationTypes?.[0] ? `${segmentationRepresentationTypes[0]} ` : ''}Segmentations`,
|
|
234
|
+
exportOptions,
|
|
235
|
+
disableEditing,
|
|
236
|
+
onSegmentationAdd,
|
|
237
|
+
showAddSegment,
|
|
238
|
+
renderInactiveSegmentations: handlers.getRenderInactiveSegmentations(),
|
|
239
|
+
segmentationRepresentationTypes,
|
|
240
|
+
selectedSegmentationIdForType,
|
|
241
|
+
...handlers,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const renderUtilitiesToolbar = () => {
|
|
245
|
+
if (!buttonSection) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<IconPresentationProvider
|
|
251
|
+
size="large"
|
|
252
|
+
IconContainer={SegmentationUtilityButton}
|
|
253
|
+
>
|
|
254
|
+
<div className="flex flex-wrap gap-[3px] bg-transparent pb-[2px] pl-[8px] pt-[6px]">
|
|
255
|
+
<Toolbar buttonSection={buttonSection} />
|
|
256
|
+
</div>
|
|
257
|
+
</IconPresentationProvider>
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const renderSegments = () => {
|
|
262
|
+
return (
|
|
263
|
+
<SegmentationTable.Segments>
|
|
264
|
+
<SegmentationTable.SegmentStatistics.Header>
|
|
265
|
+
<CustomSegmentStatisticsHeader />
|
|
266
|
+
</SegmentationTable.SegmentStatistics.Header>
|
|
267
|
+
<SegmentationTable.SegmentStatistics.Body />
|
|
268
|
+
</SegmentationTable.Segments>
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// Render content based on mode
|
|
273
|
+
const renderModeContent = () => {
|
|
274
|
+
if (tableProps.mode === 'collapsed') {
|
|
275
|
+
return (
|
|
276
|
+
<SegmentationTable.Collapsed>
|
|
277
|
+
{renderUtilitiesToolbar()}
|
|
278
|
+
<SegmentationTable.Collapsed.Header>
|
|
279
|
+
<SegmentationTable.Collapsed.DropdownMenu>
|
|
280
|
+
<CustomDropdownMenuContent />
|
|
281
|
+
</SegmentationTable.Collapsed.DropdownMenu>
|
|
282
|
+
<SegmentationTable.Collapsed.Selector />
|
|
283
|
+
<SegmentationTable.Collapsed.Info />
|
|
284
|
+
</SegmentationTable.Collapsed.Header>
|
|
285
|
+
<SegmentationTable.Collapsed.Content>
|
|
286
|
+
<SegmentationTable.AddSegmentRow />
|
|
287
|
+
{renderSegments()}
|
|
288
|
+
</SegmentationTable.Collapsed.Content>
|
|
289
|
+
</SegmentationTable.Collapsed>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<>
|
|
295
|
+
<SegmentationTable.Expanded>
|
|
296
|
+
{renderUtilitiesToolbar()}
|
|
297
|
+
<SegmentationTable.Expanded.Header>
|
|
298
|
+
<SegmentationTable.Expanded.DropdownMenu>
|
|
299
|
+
<CustomDropdownMenuContent />
|
|
300
|
+
</SegmentationTable.Expanded.DropdownMenu>
|
|
301
|
+
<SegmentationTable.Expanded.Label />
|
|
302
|
+
<SegmentationTable.Expanded.Info />
|
|
303
|
+
</SegmentationTable.Expanded.Header>
|
|
304
|
+
|
|
305
|
+
<SegmentationTable.Expanded.Content>
|
|
306
|
+
<SegmentationTable.AddSegmentRow />
|
|
307
|
+
{renderSegments()}
|
|
308
|
+
</SegmentationTable.Expanded.Content>
|
|
309
|
+
</SegmentationTable.Expanded>
|
|
310
|
+
</>
|
|
311
|
+
);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<Popover
|
|
316
|
+
open={!!activeUtilityOptions}
|
|
317
|
+
onOpenChange={handlePopoverOpenChange}
|
|
318
|
+
>
|
|
319
|
+
<PopoverAnchor>
|
|
320
|
+
<SegmentationTable {...tableProps}>
|
|
321
|
+
{children}
|
|
322
|
+
<SegmentationTable.Config />
|
|
323
|
+
<SegmentationTable.AddSegmentationRow />
|
|
324
|
+
{renderModeContent()}
|
|
325
|
+
</SegmentationTable>
|
|
326
|
+
</PopoverAnchor>
|
|
327
|
+
{activeUtilityOptions && (
|
|
328
|
+
<PopoverContent
|
|
329
|
+
side="left"
|
|
330
|
+
align="start"
|
|
331
|
+
className="w-auto"
|
|
332
|
+
>
|
|
333
|
+
<ToolSettings options={activeUtilityOptions} />
|
|
334
|
+
</PopoverContent>
|
|
335
|
+
)}
|
|
336
|
+
</Popover>
|
|
337
|
+
);
|
|
338
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { PubSubService, Types as OhifTypes } from '@ohif/core';
|
|
2
|
+
import { RENDERING_ENGINE_ID } from '../ViewportService/constants';
|
|
3
|
+
import { getRenderingEngine } from '@cornerstonejs/core';
|
|
4
|
+
import { getViewportAdapter } from '../ViewportService/adapter';
|
|
5
|
+
import { ColorbarOptions, ChangeTypes } from '../../types/Colorbar';
|
|
6
|
+
|
|
7
|
+
export default class ColorbarService extends PubSubService {
|
|
8
|
+
static EVENTS = {
|
|
9
|
+
STATE_CHANGED: 'event::ColorbarService:stateChanged',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
public static REGISTRATION = {
|
|
13
|
+
name: 'colorbarService',
|
|
14
|
+
create: ({ servicesManager }: OhifTypes.Extensions.ExtensionParams) => {
|
|
15
|
+
return new ColorbarService(servicesManager);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Structure of colorbars state:
|
|
21
|
+
* {
|
|
22
|
+
* [viewportId]: [
|
|
23
|
+
* {
|
|
24
|
+
* displaySetInstanceUID: string,
|
|
25
|
+
* colorbar: {
|
|
26
|
+
* activeColormapName: string,
|
|
27
|
+
* colormaps: array,
|
|
28
|
+
* volumeId: string (optional),
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
* ]
|
|
32
|
+
* }
|
|
33
|
+
*/
|
|
34
|
+
colorbars = {};
|
|
35
|
+
servicesManager: AppTypes.ServicesManager;
|
|
36
|
+
|
|
37
|
+
constructor(servicesManager: AppTypes.ServicesManager) {
|
|
38
|
+
super(ColorbarService.EVENTS);
|
|
39
|
+
this.servicesManager = servicesManager;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Adds a colorbar to a specific viewport identified by `viewportId`, using the provided `displaySetInstanceUIDs` and `options`.
|
|
44
|
+
* This method prepares the colorbar state that will be used by the ViewportColorbarsContainer component.
|
|
45
|
+
*
|
|
46
|
+
* @param viewportId The identifier for the viewport where the colorbar will be added.
|
|
47
|
+
* @param displaySetInstanceUIDs An array of display set instance UIDs to associate with the colorbar.
|
|
48
|
+
* @param options Configuration options for the colorbar, including position, colormaps, active colormap name, ticks, and width.
|
|
49
|
+
*/
|
|
50
|
+
public addColorbar(
|
|
51
|
+
viewportId: string,
|
|
52
|
+
displaySetInstanceUIDs: string[],
|
|
53
|
+
options = {} as ColorbarOptions
|
|
54
|
+
) {
|
|
55
|
+
const { displaySetService } = this.servicesManager.services;
|
|
56
|
+
const renderingEngine = getRenderingEngine(RENDERING_ENGINE_ID);
|
|
57
|
+
const viewport = renderingEngine.getViewport(viewportId);
|
|
58
|
+
|
|
59
|
+
if (!viewport) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const adapter = getViewportAdapter(viewport);
|
|
64
|
+
if (!adapter.hasContent()) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const { activeColormapName, colormaps } = options;
|
|
69
|
+
|
|
70
|
+
displaySetInstanceUIDs.forEach(displaySetInstanceUID => {
|
|
71
|
+
// don't show colorbar for overlay display sets (e.g. segmentation)
|
|
72
|
+
const displaySet = displaySetService.getDisplaySetByUID(displaySetInstanceUID);
|
|
73
|
+
if (displaySet.isOverlayDisplaySet) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const dataId = adapter.getDataIdForDisplaySet(displaySetInstanceUID);
|
|
78
|
+
const properties = adapter.getPresentation(dataId);
|
|
79
|
+
const colormap = properties?.colormap;
|
|
80
|
+
|
|
81
|
+
if (activeColormapName && !colormap) {
|
|
82
|
+
this.setViewportColormap(
|
|
83
|
+
viewportId,
|
|
84
|
+
displaySetInstanceUID,
|
|
85
|
+
colormaps[activeColormapName],
|
|
86
|
+
true
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Prepare colorbar data for the React component
|
|
91
|
+
const colorbarData = {
|
|
92
|
+
activeColormapName: colormap?.name || options?.activeColormapName || 'Grayscale',
|
|
93
|
+
colormaps: options.colormaps ? Object.values(options.colormaps) : [],
|
|
94
|
+
volumeId: dataId,
|
|
95
|
+
dataId,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Store the colorbar data in the service state
|
|
99
|
+
if (this.colorbars[viewportId]) {
|
|
100
|
+
// Check if there's already an entry for this displaySetInstanceUID
|
|
101
|
+
const existingIndex = this.colorbars[viewportId].findIndex(
|
|
102
|
+
item => item.displaySetInstanceUID === displaySetInstanceUID
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
if (existingIndex !== -1) {
|
|
106
|
+
// Update existing colorbar
|
|
107
|
+
this.colorbars[viewportId][existingIndex].colorbar = colorbarData;
|
|
108
|
+
} else {
|
|
109
|
+
// Add new colorbar
|
|
110
|
+
this.colorbars[viewportId].push({
|
|
111
|
+
colorbar: colorbarData,
|
|
112
|
+
displaySetInstanceUID,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
// Create new colorbar array for this viewport
|
|
117
|
+
this.colorbars[viewportId] = [
|
|
118
|
+
{
|
|
119
|
+
colorbar: colorbarData,
|
|
120
|
+
displaySetInstanceUID,
|
|
121
|
+
},
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Notify listeners about the state change
|
|
127
|
+
this._broadcastEvent(ColorbarService.EVENTS.STATE_CHANGED, {
|
|
128
|
+
viewportId,
|
|
129
|
+
changeType: ChangeTypes.Added,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Removes a colorbar from a specific viewport. If displaySetInstanceUID is provided,
|
|
135
|
+
* only the colorbar associated with that specific displaySetInstanceUID will be removed.
|
|
136
|
+
* Otherwise, all colorbars for the given viewport will be removed.
|
|
137
|
+
*
|
|
138
|
+
* @param viewportId The identifier for the viewport from which the colorbar will be removed.
|
|
139
|
+
* @param displaySetInstanceUID Optional. The specific display set instance UID associated with the colorbar to remove.
|
|
140
|
+
*/
|
|
141
|
+
public removeColorbar(viewportId, displaySetInstanceUID?: string) {
|
|
142
|
+
const colorbarInfo = this.colorbars[viewportId];
|
|
143
|
+
if (!colorbarInfo) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (displaySetInstanceUID) {
|
|
148
|
+
// Find the index of the colorbar with the matching displaySetInstanceUID
|
|
149
|
+
const index = colorbarInfo.findIndex(
|
|
150
|
+
info => info.displaySetInstanceUID === displaySetInstanceUID
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
if (index !== -1) {
|
|
154
|
+
// Remove the colorbar from the array
|
|
155
|
+
colorbarInfo.splice(index, 1);
|
|
156
|
+
|
|
157
|
+
// If there are no more colorbars for this viewport, remove the entry
|
|
158
|
+
if (colorbarInfo.length === 0) {
|
|
159
|
+
delete this.colorbars[viewportId];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
delete this.colorbars[viewportId];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
this._broadcastEvent(ColorbarService.EVENTS.STATE_CHANGED, {
|
|
167
|
+
viewportId,
|
|
168
|
+
displaySetInstanceUID,
|
|
169
|
+
changeType: ChangeTypes.Removed,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Checks whether a colorbar is associated with a given viewport ID.
|
|
175
|
+
*
|
|
176
|
+
* @param viewportId The identifier for the viewport to check.
|
|
177
|
+
* @returns `true` if a colorbar exists for the specified viewport, otherwise `false`.
|
|
178
|
+
*/
|
|
179
|
+
public hasColorbar(viewportId) {
|
|
180
|
+
return this.colorbars[viewportId] ? true : false;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Retrieves the current state of colorbars, including all active colorbars and their configurations.
|
|
185
|
+
*
|
|
186
|
+
* @returns An object representing the current state of all colorbars managed by this service.
|
|
187
|
+
*/
|
|
188
|
+
public getState() {
|
|
189
|
+
return this.colorbars;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Retrieves colorbar information for a specific viewport ID.
|
|
194
|
+
*
|
|
195
|
+
* @param viewportId The identifier for the viewport to retrieve colorbar information for.
|
|
196
|
+
* @returns The colorbar information associated with the specified viewport, if available.
|
|
197
|
+
*/
|
|
198
|
+
public getViewportColorbar(viewportId) {
|
|
199
|
+
return this.colorbars[viewportId];
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Handles the cleanup and removal of all colorbars from the viewports. This is typically called
|
|
204
|
+
* when exiting the mode or context in which the colorbars are used, ensuring that no DOM
|
|
205
|
+
* elements or references are left behind.
|
|
206
|
+
*/
|
|
207
|
+
public onModeExit() {
|
|
208
|
+
const viewportIds = Object.keys(this.colorbars);
|
|
209
|
+
viewportIds.forEach(viewportId => {
|
|
210
|
+
this.removeColorbar(viewportId);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Sets the colormap for a viewport. This function is used internally to update the colormap the viewport
|
|
216
|
+
*
|
|
217
|
+
* @param viewportId The identifier of the viewport to update.
|
|
218
|
+
* @param displaySetInstanceUID The display set instance UID associated with the viewport.
|
|
219
|
+
* @param colormap The colormap object to set on the viewport.
|
|
220
|
+
* @param immediate A boolean indicating whether the viewport should be re-rendered immediately after setting the colormap.
|
|
221
|
+
*/
|
|
222
|
+
private setViewportColormap(viewportId, displaySetInstanceUID, colormap, immediate = false) {
|
|
223
|
+
const renderingEngine = getRenderingEngine(RENDERING_ENGINE_ID);
|
|
224
|
+
const viewport = renderingEngine.getViewport(viewportId);
|
|
225
|
+
if (!viewport) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const adapter = getViewportAdapter(viewport);
|
|
229
|
+
if (!adapter.hasContent()) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Address the display set's binding (volumeId on legacy multi-volume, bare
|
|
234
|
+
// UID on native, active binding otherwise)
|
|
235
|
+
const dataId = adapter.getDataIdForDisplaySet(displaySetInstanceUID);
|
|
236
|
+
adapter.setPresentation({ colormap }, dataId);
|
|
237
|
+
|
|
238
|
+
if (immediate) {
|
|
239
|
+
viewport.render();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|