@ohif/extension-cornerstone 3.14.0-beta.10 → 3.14.0-beta.100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/915.ohif-extension-cornerstone.umd.js +1 -1
- package/dist/ohif-extension-cornerstone.umd.js +1 -5
- package/package.json +33 -25
- package/src/Viewport/OHIFCornerstoneViewport.css +46 -0
- package/src/Viewport/OHIFCornerstoneViewport.tsx +502 -0
- package/src/Viewport/Overlays/CornerstoneOverlays.tsx +103 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.css +25 -0
- package/src/Viewport/Overlays/CustomizableViewportOverlay.tsx +469 -0
- package/src/Viewport/Overlays/ViewportImageScrollbar.tsx +106 -0
- package/src/Viewport/Overlays/ViewportImageSliceLoadingIndicator.tsx +87 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.css +41 -0
- package/src/Viewport/Overlays/ViewportOrientationMarkers.tsx +136 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/ViewportSliceProgressScrollbar.tsx +195 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/helpers.ts +46 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/hooks.ts +383 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/index.ts +1 -0
- package/src/Viewport/Overlays/ViewportSliceProgressScrollbar/types.ts +17 -0
- package/src/Viewport/Overlays/utils.ts +66 -0
- package/src/commandsModule.ts +2951 -0
- package/src/components/AccordionGroup/AccordionGroup.tsx +195 -0
- package/src/components/AccordionGroup/index.ts +4 -0
- package/src/components/ActiveViewportWindowLevel/ActiveViewportWindowLevel.tsx +23 -0
- package/src/components/ActiveViewportWindowLevel/index.js +1 -0
- package/src/components/AdvancedRenderingControls/AdvancedRenderingControls.tsx +149 -0
- package/src/components/AdvancedRenderingControls/index.ts +1 -0
- package/src/components/CinePlayer/CinePlayer.tsx +247 -0
- package/src/components/CinePlayer/index.ts +3 -0
- package/src/components/DicomUpload/DicomUpload.tsx +111 -0
- package/src/components/DicomUpload/DicomUploadProgress.tsx +396 -0
- package/src/components/DicomUpload/DicomUploadProgressItem.tsx +119 -0
- package/src/components/ExportSegmentationSubMenuItem.tsx +75 -0
- package/src/components/MeasurementItems.tsx +70 -0
- package/src/components/MeasurementTableNested.tsx +30 -0
- package/src/components/MeasurementsMenu.tsx +84 -0
- package/src/components/MeasurementsOrAdditionalFindings.tsx +82 -0
- package/src/components/ModalityLoadBadge/ModalityLoadBadge.tsx +171 -0
- package/src/components/ModalityLoadBadge/index.ts +1 -0
- package/src/components/NavigationComponent/NavigationComponent.tsx +138 -0
- package/src/components/NavigationComponent/index.ts +3 -0
- package/src/components/OHIFViewportActionCorners.tsx +94 -0
- package/src/components/OpacityMenu/OpacityMenu.tsx +54 -0
- package/src/components/OpacityMenu/OpacityMenuWrapper.tsx +85 -0
- package/src/components/OpacityMenu/index.ts +2 -0
- package/src/components/PanelAccordionTrigger.tsx +48 -0
- package/src/components/SegmentationToolConfig.tsx +71 -0
- package/src/components/SegmentationUtilityButton.tsx +61 -0
- package/src/components/SelectItemWithModality.tsx +29 -0
- package/src/components/SeriesMeasurements.tsx +90 -0
- package/src/components/SeriesSummaryFromDisplaySet.tsx +21 -0
- package/src/components/StudyMeasurements.tsx +88 -0
- package/src/components/StudyMeasurementsActions.tsx +75 -0
- package/src/components/StudySummaryFromMetadata.test.ts +47 -0
- package/src/components/StudySummaryFromMetadata.tsx +31 -0
- package/src/components/StudySummaryWithActions.tsx +14 -0
- package/src/components/ThresholdMenu/ThresholdMenu.tsx +104 -0
- package/src/components/ThresholdMenu/ThresholdMenuWrapper.tsx +85 -0
- package/src/components/ThresholdMenu/index.ts +2 -0
- package/src/components/TrackingStatus/TrackingStatus.tsx +32 -0
- package/src/components/TrackingStatus/index.ts +1 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenu.tsx +190 -0
- package/src/components/VOIManualControlMenu/VOIManualControlMenuWrapper.tsx +85 -0
- package/src/components/VOIManualControlMenu/index.ts +2 -0
- package/src/components/ViewportColorbar/ViewportColorbar.tsx +150 -0
- package/src/components/ViewportColorbar/ViewportColorbarsContainer.tsx +125 -0
- package/src/components/ViewportColorbar/index.ts +5 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenu.tsx +538 -0
- package/src/components/ViewportDataOverlaySettingMenu/ViewportDataOverlayMenuWrapper.tsx +91 -0
- package/src/components/ViewportDataOverlaySettingMenu/utils.ts +118 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenu.tsx +249 -0
- package/src/components/ViewportOrientationMenu/ViewportOrientationMenuWrapper.tsx +29 -0
- package/src/components/ViewportWindowLevel/ViewportWindowLevel.tsx +261 -0
- package/src/components/ViewportWindowLevel/getViewportVolumeHistogram.ts +72 -0
- package/src/components/ViewportWindowLevel/histogramWorker.js +97 -0
- package/src/components/ViewportWindowLevel/index.js +1 -0
- package/src/components/ViewportWindowLevel/utils.ts +176 -0
- package/src/components/WindowLevelActionMenu/Colorbar.tsx +30 -0
- package/src/components/WindowLevelActionMenu/Colormap.tsx +121 -0
- package/src/components/WindowLevelActionMenu/VolumeLighting.tsx +82 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingOptions.tsx +38 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresets.tsx +36 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingPresetsContent.tsx +78 -0
- package/src/components/WindowLevelActionMenu/VolumeRenderingQuality.tsx +64 -0
- package/src/components/WindowLevelActionMenu/VolumeShade.tsx +47 -0
- package/src/components/WindowLevelActionMenu/VolumeShift.tsx +92 -0
- package/src/components/WindowLevelActionMenu/WindowLevel.tsx +157 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenu.tsx +102 -0
- package/src/components/WindowLevelActionMenu/WindowLevelActionMenuWrapper.tsx +131 -0
- package/src/components/WindowLevelActionMenu/defaultWindowLevelPresets.ts +23 -0
- package/src/components/WindowLevelActionMenu/index.ts +11 -0
- package/src/components/WindowLevelActionMenu/windowLevelPresetHotkeys.test.ts +19 -0
- package/src/components/index.ts +12 -0
- package/src/constants/index.ts +13 -0
- package/src/customizations/CustomDropdownMenuContent.tsx +106 -0
- package/src/customizations/CustomSegmentStatisticsHeader.tsx +140 -0
- package/src/customizations/captureViewportModalCustomization.tsx +175 -0
- package/src/customizations/colorbarCustomization.ts +93 -0
- package/src/customizations/gpuSettingsPresetCustomization.ts +8 -0
- package/src/customizations/layoutSelectorCustomization.ts +104 -0
- package/src/customizations/measurementsCustomization.ts +124 -0
- package/src/customizations/miscCustomization.ts +22 -0
- package/src/customizations/modalityColorMapCustomization.ts +23 -0
- package/src/customizations/segmentationHydrationCustomization.ts +16 -0
- package/src/customizations/segmentationPanelCustomization.tsx +119 -0
- package/src/customizations/segmentationToolbarCustomization.ts +964 -0
- package/src/customizations/toolGroupToolsCustomization.ts +204 -0
- package/src/customizations/toolbarButtonsCustomization.ts +805 -0
- package/src/customizations/viewportClickCommandsCustomization.ts +15 -0
- package/src/customizations/viewportDownloadWarningCustomization.tsx +6 -0
- package/src/customizations/viewportOverlayCustomization.tsx +46 -0
- package/src/customizations/viewportScrollbarCustomization.tsx +27 -0
- package/src/customizations/viewportToolsCustomization.ts +33 -0
- package/src/customizations/volumeRenderingCustomization.ts +14 -0
- package/src/customizations/windowLevelPresetsCustomization.ts +5 -0
- package/src/enums.ts +9 -0
- package/src/getCustomizationModule.tsx +54 -0
- package/src/getHangingProtocolModule.ts +47 -0
- package/src/getPanelModule.tsx +128 -0
- package/src/getSopClassHandlerModule.js +284 -0
- package/src/getToolbarModule.tsx +622 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActiveViewportSegmentationRepresentations.ts +14 -0
- package/src/hooks/useMeasurementTracking.ts +132 -0
- package/src/hooks/useMeasurements.ts +104 -0
- package/src/hooks/useSegmentations.ts +147 -0
- package/src/hooks/useViewportDisplaySets.ts +284 -0
- package/src/hooks/useViewportHover.ts +77 -0
- package/src/hooks/useViewportRendering.tsx +868 -0
- package/src/hooks/useViewportSegmentations.ts +245 -0
- package/src/hps/fourUp.ts +117 -0
- package/src/hps/frameView.ts +1581 -0
- package/src/hps/main3D.ts +142 -0
- package/src/hps/mpr.ts +197 -0
- package/src/hps/mprAnd3DVolumeViewport.ts +124 -0
- package/src/hps/only3D.ts +70 -0
- package/src/hps/primary3D.ts +142 -0
- package/src/hps/primaryAxial.ts +114 -0
- package/src/id.js +5 -0
- package/src/index.tsx +350 -0
- package/src/init.tsx +445 -0
- package/src/initCineService.ts +75 -0
- package/src/initContextMenu.ts +94 -0
- package/src/initCornerstoneTools.js +188 -0
- package/src/initDoubleClick.ts +82 -0
- package/src/initMeasurementService.ts +576 -0
- package/src/initStudyPrefetcherService.ts +33 -0
- package/src/initWADOImageLoader.js +56 -0
- package/src/panels/PanelMeasurement.tsx +84 -0
- package/src/panels/PanelSegmentation.tsx +338 -0
- package/src/services/ColorbarService/ColorbarService.ts +242 -0
- package/src/services/ColorbarService/index.ts +2 -0
- package/src/services/CornerstoneCacheService/CornerstoneCacheService.ts +326 -0
- package/src/services/CornerstoneCacheService/index.js +3 -0
- package/src/services/SegmentationService/RTSTRUCT/mapROIContoursToRTStructData.ts +36 -0
- package/src/services/SegmentationService/SegmentationService.test.ts +3698 -0
- package/src/services/SegmentationService/SegmentationService.ts +2376 -0
- package/src/services/SegmentationService/backends/ISegmentationBackend.ts +102 -0
- package/src/services/SegmentationService/backends/ISegmentationServiceInternals.ts +44 -0
- package/src/services/SegmentationService/backends/LegacySegmentationBackend.ts +139 -0
- package/src/services/SegmentationService/backends/NextSegmentationBackend.ts +159 -0
- package/src/services/SegmentationService/backends/index.ts +4 -0
- package/src/services/SegmentationService/index.ts +3 -0
- package/src/services/SyncGroupService/SyncGroupService.ts +264 -0
- package/src/services/SyncGroupService/createHydrateSegmentationSynchronizer.ts +118 -0
- package/src/services/SyncGroupService/index.js +3 -0
- package/src/services/ToolGroupService/ToolGroupService.test.ts +83 -0
- package/src/services/ToolGroupService/ToolGroupService.ts +541 -0
- package/src/services/ToolGroupService/index.js +3 -0
- package/src/services/ViewedDataService/ViewedDataService.ts +58 -0
- package/src/services/ViewedDataService/index.ts +3 -0
- package/src/services/ViewportService/CornerstoneViewportService.ts +1814 -0
- package/src/services/ViewportService/IViewportService.ts +64 -0
- package/src/services/ViewportService/Viewport.ts +372 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.contract.test.ts +467 -0
- package/src/services/ViewportService/adapter/IViewportAdapter.ts +179 -0
- package/src/services/ViewportService/adapter/LegacyViewportAdapter.ts +240 -0
- package/src/services/ViewportService/adapter/NextViewportAdapter.ts +241 -0
- package/src/services/ViewportService/adapter/getViewportAdapter.ts +62 -0
- package/src/services/ViewportService/adapter/index.ts +16 -0
- package/src/services/ViewportService/backends/IViewportBackend.ts +195 -0
- package/src/services/ViewportService/backends/IViewportOperations.ts +98 -0
- package/src/services/ViewportService/backends/IViewportServiceInternals.ts +47 -0
- package/src/services/ViewportService/backends/LegacyViewportBackend.ts +264 -0
- package/src/services/ViewportService/backends/LegacyViewportOperations.ts +272 -0
- package/src/services/ViewportService/backends/NextViewportBackend.ts +671 -0
- package/src/services/ViewportService/backends/NextViewportOperations.ts +169 -0
- package/src/services/ViewportService/backends/README.md +62 -0
- package/src/services/ViewportService/backends/dataIdRegistry.ts +121 -0
- package/src/services/ViewportService/backends/viewportOperations.ts +71 -0
- package/src/services/ViewportService/constants.ts +3 -0
- package/src/state.ts +34 -0
- package/src/stores/index.ts +5 -0
- package/src/stores/presentationUtils.ts +42 -0
- package/src/stores/useLutPresentationStore.ts +166 -0
- package/src/stores/usePositionPresentationStore.ts +172 -0
- package/src/stores/useSegmentationPresentationStore.test.ts +146 -0
- package/src/stores/useSegmentationPresentationStore.ts +417 -0
- package/src/stores/useSelectedSegmentationsForViewportStore.ts +85 -0
- package/src/stores/useSynchronizersStore.ts +84 -0
- package/src/synchronizers/frameViewSynchronizer.ts +52 -0
- package/src/tools/CalibrationLineTool.ts +97 -0
- package/src/tools/ImageOverlayViewerTool.tsx +279 -0
- package/src/tools/OverlayPlaneModuleProvider.ts +40 -0
- package/src/tools/WindowLevelTool.test.ts +55 -0
- package/src/tools/WindowLevelTool.ts +22 -0
- package/src/types/AppTypes.ts +70 -0
- package/src/types/Colorbar.ts +114 -0
- package/src/types/Colormap.ts +16 -0
- package/src/types/CornerstoneCacheService.ts +40 -0
- package/src/types/CornerstoneServices.ts +18 -0
- package/src/types/Presentation.ts +83 -0
- package/src/types/SelectedSegmentationByTypeMap.ts +3 -0
- package/src/types/ViewportPresets.ts +53 -0
- package/src/types/VolumeLighting.ts +7 -0
- package/src/types/VolumeRenderingConfig.ts +8 -0
- package/src/types/WindowLevel.ts +5 -0
- package/src/types/index.ts +10 -0
- package/src/utils/ActiveViewportBehavior.tsx +80 -0
- package/src/utils/CornerstoneViewportDownloadForm.tsx +319 -0
- package/src/utils/DicomFileUploader.ts +204 -0
- package/src/utils/JumpPresets.ts +14 -0
- package/src/utils/autoHydrateViewportTypes.ts +69 -0
- package/src/utils/colormaps.js +1597 -0
- package/src/utils/createSegmentationForViewport.ts +83 -0
- package/src/utils/dicomLoaderService.js +225 -0
- package/src/utils/ecgMetadata.test.ts +137 -0
- package/src/utils/ecgMetadata.ts +109 -0
- package/src/utils/findNearbyToolData.test.ts +125 -0
- package/src/utils/findNearbyToolData.ts +21 -0
- package/src/utils/generateSegmentationCSVReport.test.ts +324 -0
- package/src/utils/generateSegmentationCSVReport.ts +131 -0
- package/src/utils/getActiveViewportEnabledElement.test.ts +70 -0
- package/src/utils/getActiveViewportEnabledElement.ts +8 -0
- package/src/utils/getCenterExtent.test.ts +313 -0
- package/src/utils/getCenterExtent.ts +46 -0
- package/src/utils/getCornerstoneBlendMode.test.ts +59 -0
- package/src/utils/getCornerstoneBlendMode.ts +25 -0
- package/src/utils/getCornerstoneOrientation.test.ts +78 -0
- package/src/utils/getCornerstoneOrientation.ts +31 -0
- package/src/utils/getCornerstoneViewportType.test.ts +169 -0
- package/src/utils/getCornerstoneViewportType.ts +88 -0
- package/src/utils/getInterleavedFrames.test.ts +85 -0
- package/src/utils/getInterleavedFrames.ts +73 -0
- package/src/utils/getLegacyViewportType.ts +64 -0
- package/src/utils/getNthFrames.test.ts +145 -0
- package/src/utils/getNthFrames.ts +31 -0
- package/src/utils/getViewportEnabledElement.test.ts +83 -0
- package/src/utils/getViewportEnabledElement.ts +8 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.test.ts +50 -0
- package/src/utils/getViewportOrientationFromImageOrientationPatient.ts +56 -0
- package/src/utils/hydrationUtils.test.ts +572 -0
- package/src/utils/hydrationUtils.ts +197 -0
- package/src/utils/imageSliceSync/calculateViewportRegistrations.ts +28 -0
- package/src/utils/imageSliceSync/toggleImageSliceSync.ts +101 -0
- package/src/utils/index.ts +29 -0
- package/src/utils/initGpuSettingsPreset.ts +51 -0
- package/src/utils/initViewTiming.test.ts +342 -0
- package/src/utils/initViewTiming.ts +52 -0
- package/src/utils/initWebWorkerProgressHandler.test.ts +381 -0
- package/src/utils/initWebWorkerProgressHandler.ts +110 -0
- package/src/utils/interleave.test.ts +304 -0
- package/src/utils/interleave.ts +32 -0
- package/src/utils/interleaveCenterLoader.test.ts +547 -0
- package/src/utils/interleaveCenterLoader.ts +143 -0
- package/src/utils/interleaveTopToBottom.test.ts +487 -0
- package/src/utils/interleaveTopToBottom.ts +132 -0
- package/src/utils/isAnyDisplaySetCommon.ts +18 -0
- package/src/utils/isDisplaySetOverlayable.ts +96 -0
- package/src/utils/isMeasurementWithinViewport.test.ts +340 -0
- package/src/utils/isMeasurementWithinViewport.ts +33 -0
- package/src/utils/isReferenceViewable.test.ts +581 -0
- package/src/utils/isReferenceViewable.ts +95 -0
- package/src/utils/loadDisplaySetData.ts +49 -0
- package/src/utils/measurementServiceMappings/Angle.ts +200 -0
- package/src/utils/measurementServiceMappings/ArrowAnnotate.ts +176 -0
- package/src/utils/measurementServiceMappings/Bidirectional.ts +193 -0
- package/src/utils/measurementServiceMappings/CircleROI.ts +227 -0
- package/src/utils/measurementServiceMappings/CobbAngle.ts +206 -0
- package/src/utils/measurementServiceMappings/EllipticalROI.ts +221 -0
- package/src/utils/measurementServiceMappings/Length.ts +206 -0
- package/src/utils/measurementServiceMappings/LivewireContour.ts +175 -0
- package/src/utils/measurementServiceMappings/PlanarFreehandROI.ts +228 -0
- package/src/utils/measurementServiceMappings/Probe.ts +192 -0
- package/src/utils/measurementServiceMappings/RectangleROI.ts +225 -0
- package/src/utils/measurementServiceMappings/SegmentBidirectional.ts +184 -0
- package/src/utils/measurementServiceMappings/SplineROI.ts +227 -0
- package/src/utils/measurementServiceMappings/UltrasoundDirectional.ts +214 -0
- package/src/utils/measurementServiceMappings/UltrasoundPleuraBLine.ts +179 -0
- package/src/utils/measurementServiceMappings/constants/supportedTools.js +21 -0
- package/src/utils/measurementServiceMappings/index.ts +3 -0
- package/src/utils/measurementServiceMappings/measurementServiceMappingsFactory.ts +324 -0
- package/src/utils/measurementServiceMappings/utils/getDisplayUnit.js +3 -0
- package/src/utils/measurementServiceMappings/utils/getHandlesFromPoints.js +14 -0
- package/src/utils/measurementServiceMappings/utils/getIsLocked.ts +5 -0
- package/src/utils/measurementServiceMappings/utils/getIsVisible.ts +6 -0
- package/src/utils/measurementServiceMappings/utils/getSOPInstanceAttributes.js +66 -0
- package/src/utils/measurementServiceMappings/utils/getValueDisplayString.js +12 -0
- package/src/utils/measurementServiceMappings/utils/index.ts +17 -0
- package/src/utils/measurementServiceMappings/utils/selection.ts +33 -0
- package/src/utils/mpr/getProtocolViewportStructureFromGridViewports.ts +74 -0
- package/src/utils/nextViewportPolicies.ts +41 -0
- package/src/utils/nextViewports.ts +157 -0
- package/src/utils/nthLoader.test.ts +317 -0
- package/src/utils/nthLoader.ts +78 -0
- package/src/utils/presentations/getViewportPresentations.test.ts +280 -0
- package/src/utils/presentations/getViewportPresentations.ts +151 -0
- package/src/utils/promptHydrationDialog.test.ts +490 -0
- package/src/utils/promptHydrationDialog.ts +197 -0
- package/src/utils/removeViewportSegmentationRepresentations.test.ts +129 -0
- package/src/utils/removeViewportSegmentationRepresentations.ts +17 -0
- package/src/utils/segmentUtils.test.ts +515 -0
- package/src/utils/segmentUtils.ts +46 -0
- package/src/utils/segmentationExportUtils.test.ts +100 -0
- package/src/utils/segmentationExportUtils.ts +171 -0
- package/src/utils/segmentationHandlers.test.ts +614 -0
- package/src/utils/segmentationHandlers.ts +164 -0
- package/src/utils/setUpAnnotationEventHandlers.ts +26 -0
- package/src/utils/setUpSegmentationEventHandlers.test.ts +372 -0
- package/src/utils/setUpSegmentationEventHandlers.ts +122 -0
- package/src/utils/toggleVOISliceSync.test.ts +606 -0
- package/src/utils/toggleVOISliceSync.ts +103 -0
- package/src/utils/transitions.test.ts +351 -0
- package/src/utils/transitions.ts +300 -0
- package/src/utils/updateSegmentationStats.test.ts +942 -0
- package/src/utils/updateSegmentationStats.ts +192 -0
- package/src/utils/viewportDataShape.ts +85 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSystem } from '@ohif/core';
|
|
3
|
+
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@ohif/ui-next';
|
|
4
|
+
import { ChevronDownIcon } from '@radix-ui/react-icons';
|
|
5
|
+
|
|
6
|
+
export type AccordionGrouping = {
|
|
7
|
+
[name: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type AccordionGroupProps = {
|
|
11
|
+
grouping: AccordionGrouping;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Searches for the required type from the provided allChildren list and
|
|
16
|
+
* renders them.
|
|
17
|
+
*/
|
|
18
|
+
export const CloneChildren = props => {
|
|
19
|
+
const { group, allChildren, children, childType, defaultTypes } = props;
|
|
20
|
+
|
|
21
|
+
const subType = group?.subType;
|
|
22
|
+
|
|
23
|
+
for (const child of allChildren) {
|
|
24
|
+
if (subType && child.props?.subType !== subType) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (childType && child.type === childType) {
|
|
28
|
+
return React.cloneElement(child, { ...props, children: child.props.children });
|
|
29
|
+
}
|
|
30
|
+
if (defaultTypes?.indexOf(child.type) === -1) {
|
|
31
|
+
return childType({ ...props, children: child });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!children) {
|
|
36
|
+
throw new Error(`No children defined for ${props.name} CloneChildren in group ${group?.name}`);
|
|
37
|
+
}
|
|
38
|
+
return React.cloneElement(children, props);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Used to exclude defaults */
|
|
42
|
+
const DEFAULT_TYPES = [GroupAccordion, Content, Trigger];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* An AccordionGroup is a component that splits a set of items into different
|
|
46
|
+
* groups according to a set of grouping rules. It then puts the groups
|
|
47
|
+
* into a set of accordion folds selected from the body of the accordion group,
|
|
48
|
+
* looking for matching trigger/content sections according to the type definition
|
|
49
|
+
* in the group with first one found being used.
|
|
50
|
+
*
|
|
51
|
+
* This design allows for easy customization of the component by declaring grouping
|
|
52
|
+
* functions with default grouping setups and then only overriding the specific
|
|
53
|
+
* children needing to be changed. See the PanelMeasurement for some example
|
|
54
|
+
* possibilities of how to modify the default grouping, or the test-extension
|
|
55
|
+
* measurements panel for a practical, working example.
|
|
56
|
+
*/
|
|
57
|
+
export function AccordionGroup(props) {
|
|
58
|
+
const { grouping, items, children, sourceChildren } = props;
|
|
59
|
+
const childProps = useSystem();
|
|
60
|
+
let defaultValue = props.defaultValue;
|
|
61
|
+
const groups = grouping.groupingFunction(items, grouping, childProps);
|
|
62
|
+
|
|
63
|
+
if (!defaultValue) {
|
|
64
|
+
const defaultGroup = groups.values().find(group => group.isSelected);
|
|
65
|
+
defaultValue = defaultGroup?.key || defaultGroup?.title;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const valueArr =
|
|
69
|
+
(Array.isArray(defaultValue) && defaultValue) || (defaultValue && [defaultValue]) || [];
|
|
70
|
+
const sourceChildrenArr = sourceChildren ? React.Children.toArray(sourceChildren) : [];
|
|
71
|
+
const childrenArr = children ? React.Children.toArray(children) : [];
|
|
72
|
+
const allChildren = sourceChildrenArr.concat(childrenArr);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<CloneChildren
|
|
76
|
+
allChildren={allChildren}
|
|
77
|
+
groups={groups}
|
|
78
|
+
childType={GroupAccordion}
|
|
79
|
+
grouping={grouping}
|
|
80
|
+
defaultValue={valueArr}
|
|
81
|
+
name={'grouping ' + grouping.name}
|
|
82
|
+
>
|
|
83
|
+
<DefaultAccordion name="DefaultAccordion" />
|
|
84
|
+
</CloneChildren>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function DefaultAccordion(props) {
|
|
89
|
+
const { groups, defaultValue, grouping, allChildren, asChild } = props;
|
|
90
|
+
if (!allChildren || !groups) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (asChild) {
|
|
95
|
+
return React.cloneElement(props.children, props);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Accordion
|
|
100
|
+
type={grouping.type || 'multiple'}
|
|
101
|
+
className="text-foreground"
|
|
102
|
+
defaultValue={defaultValue}
|
|
103
|
+
>
|
|
104
|
+
{[...groups.entries()].map(([key, group]) => {
|
|
105
|
+
return (
|
|
106
|
+
<AccordionItem
|
|
107
|
+
key={group.key + '-i'}
|
|
108
|
+
value={group.key}
|
|
109
|
+
>
|
|
110
|
+
<CloneChildren
|
|
111
|
+
allChildren={allChildren}
|
|
112
|
+
group={group}
|
|
113
|
+
childType={Trigger}
|
|
114
|
+
name="AccordionGroup.Trigger"
|
|
115
|
+
/>
|
|
116
|
+
<CloneChildren
|
|
117
|
+
allChildren={allChildren}
|
|
118
|
+
group={group}
|
|
119
|
+
childType={Content}
|
|
120
|
+
defaultTypes={DEFAULT_TYPES}
|
|
121
|
+
name="AccordionGroup.Content"
|
|
122
|
+
/>
|
|
123
|
+
</AccordionItem>
|
|
124
|
+
);
|
|
125
|
+
})}
|
|
126
|
+
</Accordion>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function GroupAccordion(props) {
|
|
131
|
+
const { groups, children } = props;
|
|
132
|
+
if (!groups) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
return [...groups.values()].map(group =>
|
|
136
|
+
React.cloneElement(children, {
|
|
137
|
+
...props,
|
|
138
|
+
children: children.props.children,
|
|
139
|
+
group,
|
|
140
|
+
...group,
|
|
141
|
+
key: group.title,
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function Content(props) {
|
|
147
|
+
const { children, asChild, ...childProps } = props;
|
|
148
|
+
const { group } = props;
|
|
149
|
+
Object.assign(childProps, group);
|
|
150
|
+
|
|
151
|
+
if (!group) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (asChild) {
|
|
155
|
+
return React.cloneElement(children, { ...group, ...props, children: children.props.children });
|
|
156
|
+
}
|
|
157
|
+
return (
|
|
158
|
+
<AccordionContent>
|
|
159
|
+
{React.cloneElement(children, { ...group, ...props, children: children.props.children })}
|
|
160
|
+
</AccordionContent>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function Trigger(props) {
|
|
165
|
+
const { children, asChild, ...childProps } = props;
|
|
166
|
+
const { group } = props;
|
|
167
|
+
Object.assign(childProps, group);
|
|
168
|
+
|
|
169
|
+
if (!group) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
if (asChild) {
|
|
173
|
+
return React.cloneElement(children, childProps);
|
|
174
|
+
}
|
|
175
|
+
return (
|
|
176
|
+
<AccordionTrigger
|
|
177
|
+
value={group.value}
|
|
178
|
+
asChild={true}
|
|
179
|
+
>
|
|
180
|
+
<div>
|
|
181
|
+
{React.cloneElement(children, childProps)}
|
|
182
|
+
<ChevronDownIcon
|
|
183
|
+
key="chevronDown"
|
|
184
|
+
className="text-primary h-4 w-4 shrink-0 transition-transform duration-200"
|
|
185
|
+
/>
|
|
186
|
+
</div>
|
|
187
|
+
</AccordionTrigger>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
AccordionGroup.Content = Content;
|
|
192
|
+
AccordionGroup.Trigger = Trigger;
|
|
193
|
+
AccordionGroup.Accordion = GroupAccordion;
|
|
194
|
+
|
|
195
|
+
export default AccordionGroup;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
import { useViewportGrid } from '@ohif/ui-next';
|
|
3
|
+
import ViewportWindowLevel from '../ViewportWindowLevel/ViewportWindowLevel';
|
|
4
|
+
|
|
5
|
+
const ActiveViewportWindowLevel = ({ servicesManager }: withAppTypes): ReactElement<any> => {
|
|
6
|
+
const [viewportGrid] = useViewportGrid();
|
|
7
|
+
const { activeViewportId } = viewportGrid;
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<>
|
|
11
|
+
{activeViewportId && (
|
|
12
|
+
<ViewportWindowLevel
|
|
13
|
+
servicesManager={servicesManager}
|
|
14
|
+
viewportId={activeViewportId}
|
|
15
|
+
/>
|
|
16
|
+
)}
|
|
17
|
+
</>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
export default ActiveViewportWindowLevel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ActiveViewportWindowLevel';
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { useToolbar, useViewportMousePosition } from '@ohif/core/src/hooks';
|
|
2
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
import { useViewportRendering } from '../../hooks';
|
|
4
|
+
import { ButtonLocation } from '@ohif/core/src/services/ToolBarService/ToolbarService';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
|
|
7
|
+
const mouseNearControlsRanges = {
|
|
8
|
+
[ButtonLocation.TopMiddle]: { minX: 0, minY: 0, maxX: 1, maxY: 0.1 },
|
|
9
|
+
[ButtonLocation.BottomMiddle]: { minX: 0, minY: 0.9, maxX: 1, maxY: 1 },
|
|
10
|
+
[ButtonLocation.LeftMiddle]: { minX: 0, minY: 0, maxX: 0.1, maxY: 1 },
|
|
11
|
+
[ButtonLocation.RightMiddle]: { minX: 0.9, minY: 0, maxX: 1, maxY: 1 },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const getFlexDirectionClassName = (location: ButtonLocation) =>
|
|
15
|
+
location === ButtonLocation.LeftMiddle || location === ButtonLocation.RightMiddle
|
|
16
|
+
? 'flex-col'
|
|
17
|
+
: 'flex-row';
|
|
18
|
+
|
|
19
|
+
function AdvancedRenderingControls({
|
|
20
|
+
viewportId,
|
|
21
|
+
location,
|
|
22
|
+
buttonSection,
|
|
23
|
+
}: {
|
|
24
|
+
viewportId: string;
|
|
25
|
+
location: number;
|
|
26
|
+
buttonSection: string;
|
|
27
|
+
}) {
|
|
28
|
+
const {
|
|
29
|
+
onInteraction,
|
|
30
|
+
toolbarButtons,
|
|
31
|
+
isItemOpen,
|
|
32
|
+
isItemLocked,
|
|
33
|
+
openItem,
|
|
34
|
+
closeItem,
|
|
35
|
+
toggleLock,
|
|
36
|
+
} = useToolbar({
|
|
37
|
+
buttonSection,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const mousePosition = useViewportMousePosition(viewportId);
|
|
41
|
+
const [isMouseNearControls, setIsMouseNearControls] = useState(false);
|
|
42
|
+
const [showAllIcons, setShowAllIcons] = useState(true);
|
|
43
|
+
const firstMountRef = useRef(true);
|
|
44
|
+
const { hasColorbar } = useViewportRendering(viewportId);
|
|
45
|
+
const [isAnItemOpen, setIsAnItemOpen] = useState(false);
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (firstMountRef.current) {
|
|
49
|
+
firstMountRef.current = false;
|
|
50
|
+
|
|
51
|
+
const timer = setTimeout(() => {
|
|
52
|
+
setShowAllIcons(false);
|
|
53
|
+
}, 3000);
|
|
54
|
+
|
|
55
|
+
return () => clearTimeout(timer);
|
|
56
|
+
}
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!showAllIcons && mousePosition.isInViewport) {
|
|
61
|
+
const mouseHoverLocation = mouseNearControlsRanges[location];
|
|
62
|
+
if (mousePosition.isWithinNormalizedBox(mouseHoverLocation)) {
|
|
63
|
+
setIsMouseNearControls(true);
|
|
64
|
+
} else {
|
|
65
|
+
setIsMouseNearControls(false);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, [location, mousePosition, showAllIcons]);
|
|
69
|
+
|
|
70
|
+
const handleOnItemOpen = useCallback(
|
|
71
|
+
(id, viewportId) => {
|
|
72
|
+
openItem(id, viewportId);
|
|
73
|
+
setIsAnItemOpen(true);
|
|
74
|
+
},
|
|
75
|
+
[openItem, setIsAnItemOpen]
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const handleOnItemClose = useCallback(
|
|
79
|
+
(id, viewportId) => {
|
|
80
|
+
closeItem(id, viewportId);
|
|
81
|
+
setIsAnItemOpen(false);
|
|
82
|
+
},
|
|
83
|
+
[closeItem, setIsAnItemOpen]
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (!toolbarButtons?.length) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!hasColorbar) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className={classNames('flex gap-2', getFlexDirectionClassName(location))}>
|
|
96
|
+
{toolbarButtons.map(toolDef => {
|
|
97
|
+
if (!toolDef) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const { id, Component, componentProps } = toolDef;
|
|
102
|
+
|
|
103
|
+
// Enhanced props with state and actions - respecting viewport specificity
|
|
104
|
+
const enhancedProps = {
|
|
105
|
+
...componentProps,
|
|
106
|
+
isOpen: isItemOpen(id, viewportId),
|
|
107
|
+
isLocked: isItemLocked(id, viewportId),
|
|
108
|
+
onOpen: () => handleOnItemOpen(id, viewportId),
|
|
109
|
+
onClose: () => handleOnItemClose(id, viewportId),
|
|
110
|
+
onToggleLock: () => toggleLock(id, viewportId),
|
|
111
|
+
viewportId,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const tool = (
|
|
115
|
+
<Component
|
|
116
|
+
key={id}
|
|
117
|
+
id={id}
|
|
118
|
+
location={location}
|
|
119
|
+
onInteraction={args => {
|
|
120
|
+
onInteraction({
|
|
121
|
+
...args,
|
|
122
|
+
itemId: id,
|
|
123
|
+
viewportId,
|
|
124
|
+
});
|
|
125
|
+
}}
|
|
126
|
+
{...enhancedProps}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// Always show all icons on first mount for 3 seconds
|
|
131
|
+
// After that, always show Colorbar, show others only when mouse is at bottom
|
|
132
|
+
const shouldBeVisible =
|
|
133
|
+
isAnItemOpen || showAllIcons || id === 'Colorbar' || isMouseNearControls;
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div
|
|
137
|
+
key={id}
|
|
138
|
+
className={shouldBeVisible ? 'opacity-100' : 'pointer-events-none opacity-0'}
|
|
139
|
+
style={{ transition: 'opacity 0.2s ease-in-out' }}
|
|
140
|
+
>
|
|
141
|
+
{tool}
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
})}
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default AdvancedRenderingControls;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './AdvancedRenderingControls';
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState, useRef } from 'react';
|
|
2
|
+
import { useCine } from '@ohif/ui-next';
|
|
3
|
+
import { Enums, eventTarget, cache } from '@cornerstonejs/core';
|
|
4
|
+
import { useAppConfig } from '@state';
|
|
5
|
+
|
|
6
|
+
function WrappedCinePlayer({
|
|
7
|
+
enabledVPElement,
|
|
8
|
+
viewportId,
|
|
9
|
+
servicesManager,
|
|
10
|
+
}: withAppTypes<{
|
|
11
|
+
enabledVPElement: HTMLElement;
|
|
12
|
+
viewportId: string;
|
|
13
|
+
}>) {
|
|
14
|
+
const { customizationService, displaySetService, viewportGridService } = servicesManager.services;
|
|
15
|
+
const [{ isCineEnabled, cines }, cineService] = useCine();
|
|
16
|
+
const [newStackFrameRate, setNewStackFrameRate] = useState(24);
|
|
17
|
+
const [dynamicInfo, setDynamicInfo] = useState(null);
|
|
18
|
+
const [appConfig] = useAppConfig();
|
|
19
|
+
const isMountedRef = useRef(null);
|
|
20
|
+
|
|
21
|
+
const cineHandler = () => {
|
|
22
|
+
if (!cines?.[viewportId] || !enabledVPElement) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { isPlaying = false, frameRate = 24 } = cines[viewportId];
|
|
27
|
+
const validFrameRate = Math.max(frameRate, 1);
|
|
28
|
+
|
|
29
|
+
return isPlaying
|
|
30
|
+
? cineService.playClip(enabledVPElement, { framesPerSecond: validFrameRate, viewportId })
|
|
31
|
+
: cineService.stopClip(enabledVPElement);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const newDisplaySetHandler = useCallback(() => {
|
|
35
|
+
if (!enabledVPElement || !isCineEnabled) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { viewports } = viewportGridService.getState();
|
|
40
|
+
const { displaySetInstanceUIDs } = viewports.get(viewportId);
|
|
41
|
+
let frameRate = 24;
|
|
42
|
+
let isPlaying = cines[viewportId]?.isPlaying || false;
|
|
43
|
+
displaySetInstanceUIDs.forEach(displaySetInstanceUID => {
|
|
44
|
+
const displaySet = displaySetService.getDisplaySetByUID(displaySetInstanceUID);
|
|
45
|
+
|
|
46
|
+
if (displaySet.FrameRate) {
|
|
47
|
+
// displaySet.FrameRate corresponds to DICOM tag (0018,1063) which is defined as the the frame time in milliseconds
|
|
48
|
+
// So a bit of math to get the actual frame rate.
|
|
49
|
+
frameRate = Math.round(1000 / displaySet.FrameRate);
|
|
50
|
+
isPlaying ||= !!appConfig.autoPlayCine;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// check if the displaySet is dynamic and set the dynamic info
|
|
54
|
+
if (displaySet.isDynamicVolume) {
|
|
55
|
+
const { dynamicVolumeInfo } = displaySet;
|
|
56
|
+
const numDimensionGroups = dynamicVolumeInfo.timePoints.length;
|
|
57
|
+
const label = dynamicVolumeInfo.splittingTag;
|
|
58
|
+
const dimensionGroupNumber = dynamicVolumeInfo.dimensionGroupNumber || 1;
|
|
59
|
+
setDynamicInfo({
|
|
60
|
+
volumeId: displaySet.displaySetInstanceUID,
|
|
61
|
+
dimensionGroupNumber,
|
|
62
|
+
numDimensionGroups,
|
|
63
|
+
label,
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
setDynamicInfo(null);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (isPlaying) {
|
|
71
|
+
cineService.setIsCineEnabled(isPlaying);
|
|
72
|
+
}
|
|
73
|
+
cineService.setCine({ id: viewportId, isPlaying, frameRate });
|
|
74
|
+
setNewStackFrameRate(frameRate);
|
|
75
|
+
}, [displaySetService, viewportId, viewportGridService, cines, isCineEnabled, enabledVPElement]);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
isMountedRef.current = true;
|
|
79
|
+
|
|
80
|
+
newDisplaySetHandler();
|
|
81
|
+
|
|
82
|
+
return () => {
|
|
83
|
+
isMountedRef.current = false;
|
|
84
|
+
};
|
|
85
|
+
}, [isCineEnabled, newDisplaySetHandler]);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (!isCineEnabled) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
cineHandler();
|
|
93
|
+
}, [isCineEnabled, cineHandler, enabledVPElement]);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Use effect for handling new display set
|
|
97
|
+
*/
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (!enabledVPElement) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
enabledVPElement.addEventListener(Enums.Events.VIEWPORT_NEW_IMAGE_SET, newDisplaySetHandler);
|
|
104
|
+
// this doesn't makes sense that we are listening to this event on viewport element
|
|
105
|
+
enabledVPElement.addEventListener(
|
|
106
|
+
Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,
|
|
107
|
+
newDisplaySetHandler
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
return () => {
|
|
111
|
+
cineService.setCine({ id: viewportId, isPlaying: false });
|
|
112
|
+
|
|
113
|
+
enabledVPElement.removeEventListener(
|
|
114
|
+
Enums.Events.VIEWPORT_NEW_IMAGE_SET,
|
|
115
|
+
newDisplaySetHandler
|
|
116
|
+
);
|
|
117
|
+
enabledVPElement.removeEventListener(
|
|
118
|
+
Enums.Events.VOLUME_VIEWPORT_NEW_VOLUME,
|
|
119
|
+
newDisplaySetHandler
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
}, [enabledVPElement, newDisplaySetHandler, viewportId]);
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (!cines || !cines[viewportId] || !enabledVPElement || !isMountedRef.current) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
cineHandler();
|
|
130
|
+
|
|
131
|
+
return () => {
|
|
132
|
+
cineService.stopClip(enabledVPElement, { viewportId });
|
|
133
|
+
};
|
|
134
|
+
}, [cines, viewportId, cineService, enabledVPElement, cineHandler]);
|
|
135
|
+
|
|
136
|
+
if (!isCineEnabled) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const cine = cines[viewportId];
|
|
141
|
+
const isPlaying = cine?.isPlaying || false;
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<RenderCinePlayer
|
|
145
|
+
viewportId={viewportId}
|
|
146
|
+
cineService={cineService}
|
|
147
|
+
newStackFrameRate={newStackFrameRate}
|
|
148
|
+
isPlaying={isPlaying}
|
|
149
|
+
dynamicInfo={dynamicInfo}
|
|
150
|
+
customizationService={customizationService}
|
|
151
|
+
/>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function RenderCinePlayer({
|
|
156
|
+
viewportId,
|
|
157
|
+
cineService,
|
|
158
|
+
newStackFrameRate,
|
|
159
|
+
isPlaying,
|
|
160
|
+
dynamicInfo: dynamicInfoProp,
|
|
161
|
+
customizationService,
|
|
162
|
+
}) {
|
|
163
|
+
const CinePlayerComponent = customizationService.getCustomization('cinePlayer');
|
|
164
|
+
|
|
165
|
+
const [dynamicInfo, setDynamicInfo] = useState(dynamicInfoProp);
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
setDynamicInfo(dynamicInfoProp);
|
|
169
|
+
}, [dynamicInfoProp]);
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Use effect for handling 4D time index changed
|
|
173
|
+
*/
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (!dynamicInfo) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const handleDimensionGroupChange = evt => {
|
|
180
|
+
const { volumeId, dimensionGroupNumber, numDimensionGroups, splittingTag } = evt.detail;
|
|
181
|
+
setDynamicInfo({ volumeId, dimensionGroupNumber, numDimensionGroups, label: splittingTag });
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
eventTarget.addEventListener(
|
|
185
|
+
Enums.Events.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED,
|
|
186
|
+
handleDimensionGroupChange
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
return () => {
|
|
190
|
+
eventTarget.removeEventListener(
|
|
191
|
+
Enums.Events.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED,
|
|
192
|
+
handleDimensionGroupChange
|
|
193
|
+
);
|
|
194
|
+
};
|
|
195
|
+
}, [dynamicInfo]);
|
|
196
|
+
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
if (!dynamicInfo) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const { volumeId, dimensionGroupNumber, numDimensionGroups, splittingTag } = dynamicInfo || {};
|
|
203
|
+
const volume = cache.getVolume(volumeId, true);
|
|
204
|
+
volume.dimensionGroupNumber = dimensionGroupNumber;
|
|
205
|
+
|
|
206
|
+
setDynamicInfo({ volumeId, dimensionGroupNumber, numDimensionGroups, label: splittingTag });
|
|
207
|
+
}, []);
|
|
208
|
+
|
|
209
|
+
const updateDynamicInfo = useCallback(props => {
|
|
210
|
+
const { volumeId, dimensionGroupNumber } = props;
|
|
211
|
+
const volume = cache.getVolume(volumeId, true);
|
|
212
|
+
volume.dimensionGroupNumber = dimensionGroupNumber;
|
|
213
|
+
}, []);
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<CinePlayerComponent
|
|
217
|
+
className="absolute left-1/2 bottom-3 -translate-x-1/2"
|
|
218
|
+
frameRate={newStackFrameRate}
|
|
219
|
+
isPlaying={isPlaying}
|
|
220
|
+
onClose={() => {
|
|
221
|
+
// also stop the clip
|
|
222
|
+
cineService.setCine({
|
|
223
|
+
id: viewportId,
|
|
224
|
+
isPlaying: false,
|
|
225
|
+
});
|
|
226
|
+
cineService.setIsCineEnabled(false);
|
|
227
|
+
cineService.setViewportCineClosed(viewportId);
|
|
228
|
+
}}
|
|
229
|
+
onPlayPauseChange={isPlaying => {
|
|
230
|
+
cineService.setCine({
|
|
231
|
+
id: viewportId,
|
|
232
|
+
isPlaying,
|
|
233
|
+
});
|
|
234
|
+
}}
|
|
235
|
+
onFrameRateChange={frameRate =>
|
|
236
|
+
cineService.setCine({
|
|
237
|
+
id: viewportId,
|
|
238
|
+
frameRate,
|
|
239
|
+
})
|
|
240
|
+
}
|
|
241
|
+
dynamicInfo={dynamicInfo}
|
|
242
|
+
updateDynamicInfo={updateDynamicInfo}
|
|
243
|
+
/>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export default WrappedCinePlayer;
|