fix(WindowLevelActionMenu): The window level menu must show different contents for 3D volume viewports (#5113)

This commit is contained in:
Joe Boccanfuso 2025-06-07 13:55:33 -04:00 committed by GitHub
parent 2234121a19
commit 0afb3fc753
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 50 additions and 37 deletions

View File

@ -40,7 +40,7 @@
}, },
"addOns/externals/devDependencies": { "addOns/externals/devDependencies": {
"name": "@externals/devDependencies", "name": "@externals/devDependencies",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@kitware/vtk.js": "32.12.0", "@kitware/vtk.js": "32.12.0",
@ -127,14 +127,14 @@
}, },
"addOns/externals/dicom-microscopy-viewer": { "addOns/externals/dicom-microscopy-viewer": {
"name": "@externals/dicom-microscopy-viewer", "name": "@externals/dicom-microscopy-viewer",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"dicom-microscopy-viewer": "^0.46.1", "dicom-microscopy-viewer": "^0.46.1",
}, },
}, },
"extensions/cornerstone": { "extensions/cornerstone": {
"name": "@ohif/extension-cornerstone", "name": "@ohif/extension-cornerstone",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^3.15.6", "@cornerstonejs/adapters": "^3.15.6",
@ -173,7 +173,7 @@
}, },
"extensions/cornerstone-dicom-pmap": { "extensions/cornerstone-dicom-pmap": {
"name": "@ohif/extension-cornerstone-dicom-pmap", "name": "@ohif/extension-cornerstone-dicom-pmap",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^3.15.6", "@cornerstonejs/adapters": "^3.15.6",
@ -196,7 +196,7 @@
}, },
"extensions/cornerstone-dicom-rt": { "extensions/cornerstone-dicom-rt": {
"name": "@ohif/extension-cornerstone-dicom-rt", "name": "@ohif/extension-cornerstone-dicom-rt",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"react-color": "^2.19.3", "react-color": "^2.19.3",
@ -216,7 +216,7 @@
}, },
"extensions/cornerstone-dicom-seg": { "extensions/cornerstone-dicom-seg": {
"name": "@ohif/extension-cornerstone-dicom-seg", "name": "@ohif/extension-cornerstone-dicom-seg",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^3.15.6", "@cornerstonejs/adapters": "^3.15.6",
@ -239,7 +239,7 @@
}, },
"extensions/cornerstone-dicom-sr": { "extensions/cornerstone-dicom-sr": {
"name": "@ohif/extension-cornerstone-dicom-sr", "name": "@ohif/extension-cornerstone-dicom-sr",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@cornerstonejs/adapters": "^3.15.6", "@cornerstonejs/adapters": "^3.15.6",
@ -261,7 +261,7 @@
}, },
"extensions/cornerstone-dynamic-volume": { "extensions/cornerstone-dynamic-volume": {
"name": "@ohif/extension-cornerstone-dynamic-volume", "name": "@ohif/extension-cornerstone-dynamic-volume",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@cornerstonejs/core": "^3.15.6", "@cornerstonejs/core": "^3.15.6",
@ -283,7 +283,7 @@
}, },
"extensions/default": { "extensions/default": {
"name": "@ohif/extension-default", "name": "@ohif/extension-default",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@cornerstonejs/calculate-suv": "^1.1.0", "@cornerstonejs/calculate-suv": "^1.1.0",
@ -306,7 +306,7 @@
}, },
"extensions/dicom-microscopy": { "extensions/dicom-microscopy": {
"name": "@ohif/extension-dicom-microscopy", "name": "@ohif/extension-dicom-microscopy",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@cornerstonejs/codec-charls": "^1.2.3", "@cornerstonejs/codec-charls": "^1.2.3",
@ -331,7 +331,7 @@
}, },
"extensions/dicom-pdf": { "extensions/dicom-pdf": {
"name": "@ohif/extension-dicom-pdf", "name": "@ohif/extension-dicom-pdf",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"classnames": "^2.3.2", "classnames": "^2.3.2",
@ -348,7 +348,7 @@
}, },
"extensions/dicom-video": { "extensions/dicom-video": {
"name": "@ohif/extension-dicom-video", "name": "@ohif/extension-dicom-video",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"classnames": "^2.3.2", "classnames": "^2.3.2",
@ -365,7 +365,7 @@
}, },
"extensions/measurement-tracking": { "extensions/measurement-tracking": {
"name": "@ohif/extension-measurement-tracking", "name": "@ohif/extension-measurement-tracking",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@ohif/ui": "platform/ui", "@ohif/ui": "platform/ui",
@ -391,7 +391,7 @@
}, },
"extensions/test-extension": { "extensions/test-extension": {
"name": "@ohif/extension-test", "name": "@ohif/extension-test",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"classnames": "^2.3.2", "classnames": "^2.3.2",
@ -408,7 +408,7 @@
}, },
"extensions/tmtv": { "extensions/tmtv": {
"name": "@ohif/extension-tmtv", "name": "@ohif/extension-tmtv",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"classnames": "^2.3.2", "classnames": "^2.3.2",
@ -425,7 +425,7 @@
}, },
"modes/basic-dev-mode": { "modes/basic-dev-mode": {
"name": "@ohif/mode-basic-dev-mode", "name": "@ohif/mode-basic-dev-mode",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"i18next": "^17.0.3", "i18next": "^17.0.3",
@ -445,7 +445,7 @@
}, },
"modes/basic-test-mode": { "modes/basic-test-mode": {
"name": "@ohif/mode-test", "name": "@ohif/mode-test",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"i18next": "^17.0.3", "i18next": "^17.0.3",
@ -467,7 +467,7 @@
}, },
"modes/longitudinal": { "modes/longitudinal": {
"name": "@ohif/mode-longitudinal", "name": "@ohif/mode-longitudinal",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"i18next": "^17.0.3", "i18next": "^17.0.3",
@ -490,7 +490,7 @@
}, },
"modes/microscopy": { "modes/microscopy": {
"name": "@ohif/mode-microscopy", "name": "@ohif/mode-microscopy",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"i18next": "^17.0.3", "i18next": "^17.0.3",
@ -502,7 +502,7 @@
}, },
"modes/preclinical-4d": { "modes/preclinical-4d": {
"name": "@ohif/mode-preclinical-4d", "name": "@ohif/mode-preclinical-4d",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
}, },
@ -521,7 +521,7 @@
}, },
"modes/segmentation": { "modes/segmentation": {
"name": "@ohif/mode-segmentation", "name": "@ohif/mode-segmentation",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"i18next": "^17.0.3", "i18next": "^17.0.3",
@ -565,7 +565,7 @@
}, },
"modes/tmtv": { "modes/tmtv": {
"name": "@ohif/mode-tmtv", "name": "@ohif/mode-tmtv",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"i18next": "^17.0.3", "i18next": "^17.0.3",
@ -586,7 +586,7 @@
}, },
"platform/app": { "platform/app": {
"name": "@ohif/app", "name": "@ohif/app",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"@cornerstonejs/codec-charls": "^1.2.3", "@cornerstonejs/codec-charls": "^1.2.3",
@ -652,7 +652,7 @@
}, },
"platform/cli": { "platform/cli": {
"name": "@ohif/cli", "name": "@ohif/cli",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/core": "7.24.7", "@babel/core": "7.24.7",
"axios": "^1.8.4", "axios": "^1.8.4",
@ -673,7 +673,7 @@
}, },
"platform/core": { "platform/core": {
"name": "@ohif/core", "name": "@ohif/core",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"dcmjs": "*", "dcmjs": "*",
@ -707,7 +707,7 @@
}, },
"platform/i18n": { "platform/i18n": {
"name": "@ohif/i18n", "name": "@ohif/i18n",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.13", "@babel/runtime": "^7.20.13",
"i18next-locize-backend": "^2.0.0", "i18next-locize-backend": "^2.0.0",
@ -732,7 +732,7 @@
}, },
"platform/ui": { "platform/ui": {
"name": "@ohif/ui", "name": "@ohif/ui",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@testing-library/react": "^13.1.0", "@testing-library/react": "^13.1.0",
"browser-detect": "^0.2.28", "browser-detect": "^0.2.28",
@ -792,7 +792,7 @@
}, },
"platform/ui-next": { "platform/ui-next": {
"name": "@ohif/ui-next", "name": "@ohif/ui-next",
"version": "3.11.0-beta.47", "version": "3.11.0-beta.48",
"dependencies": { "dependencies": {
"@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-checkbox": "^1.1.1", "@radix-ui/react-checkbox": "^1.1.1",

View File

@ -2,17 +2,14 @@ import { Icons, FooterAction } from '@ohif/ui-next';
import React, { ReactElement, useState, useCallback } from 'react'; import React, { ReactElement, useState, useCallback } from 'react';
import { PresetDialog } from '@ohif/ui-next'; import { PresetDialog } from '@ohif/ui-next';
import { ViewportPreset, VolumeRenderingPresetsContentProps } from '../../types/ViewportPresets'; import { ViewportPreset, VolumeRenderingPresetsContentProps } from '../../types/ViewportPresets';
import { useSystem } from '@ohif/core';
interface Props extends VolumeRenderingPresetsContentProps { interface Props extends VolumeRenderingPresetsContentProps {
hide: () => void; hide: () => void;
} }
export function VolumeRenderingPresetsContent({ export function VolumeRenderingPresetsContent({ presets, viewportId, hide }: Props): ReactElement {
presets, const { commandsManager } = useSystem();
viewportId,
commandsManager,
hide,
}: Props): ReactElement {
const [searchValue, setSearchValue] = useState(''); const [searchValue, setSearchValue] = useState('');
const [selectedPreset, setSelectedPreset] = useState<ViewportPreset | null>(null); const [selectedPreset, setSelectedPreset] = useState<ViewportPreset | null>(null);

View File

@ -53,7 +53,6 @@ export function WindowLevelActionMenuContent({
return ( return (
<AllInOneMenu.Menu <AllInOneMenu.Menu
menuKey={menuKey}
key={menuKey} key={menuKey}
// the visibility is handled by the parent component // the visibility is handled by the parent component
isVisible={true} isVisible={true}

View File

@ -104,6 +104,11 @@ const opacityToLinear = (opacityValue: number): number => {
return Math.pow(opacityValue, 1.0 / GAMMA); return Math.pow(opacityValue, 1.0 / GAMMA);
}; };
const is3DViewport = ({ viewportId, cornerstoneViewportService }) => {
const viewport = cornerstoneViewportService.getCornerstoneViewport(viewportId);
return viewport instanceof VolumeViewport3D;
};
/** /**
* Hook to access window level functionality for a specific viewport * Hook to access window level functionality for a specific viewport
* *
@ -119,7 +124,9 @@ export function useViewportRendering(
const { cornerstoneViewportService, colorbarService, customizationService } = const { cornerstoneViewportService, colorbarService, customizationService } =
servicesManager.services; servicesManager.services;
const [is3DVolume, setIs3DVolume] = useState(false); const [is3DVolume, setIs3DVolume] = useState(
is3DViewport({ viewportId, cornerstoneViewportService })
);
const [hasColorbar, setHasColorbar] = useState(colorbarService.hasColorbar(viewportId)); const [hasColorbar, setHasColorbar] = useState(colorbarService.hasColorbar(viewportId));
const [colorbarPosition, setColorbarPosition] = useState<ColorbarPositionType>( const [colorbarPosition, setColorbarPosition] = useState<ColorbarPositionType>(
options?.location ? getPosition(options.location) : 'bottom' options?.location ? getPosition(options.location) : 'bottom'
@ -233,8 +240,9 @@ export function useViewportRendering(
}, [allWindowLevelPresets, activeDisplaySetInstanceUID]); }, [allWindowLevelPresets, activeDisplaySetInstanceUID]);
useEffect(() => { useEffect(() => {
setIs3DVolume(is3DViewport({ viewportId, cornerstoneViewportService }));
const viewport = cornerstoneViewportService.getCornerstoneViewport(viewportId); const viewport = cornerstoneViewportService.getCornerstoneViewport(viewportId);
setIs3DVolume(viewport instanceof VolumeViewport3D);
// Initialize the VOI range from the viewport // Initialize the VOI range from the viewport
if (viewport && activeDisplaySetInstanceUID) { if (viewport && activeDisplaySetInstanceUID) {

View File

@ -108,6 +108,15 @@ const Menu = (props: MenuProps) => {
]); ]);
const [itemPanelLabels, setItemPanelLabels] = useState<Array<string>>([]); const [itemPanelLabels, setItemPanelLabels] = useState<Array<string>>([]);
// If the props change for the this top level menu then we have to update the menu path
// because the props to be rendered are maintained in the state.
useEffect(() => {
setMenuPath(menuPath => [
{ props, activePanelIndex: activePanelIndex || 0 },
...menuPath.slice(1),
]);
}, [activePanelIndex, props]);
const hideMenu = useCallback(() => { const hideMenu = useCallback(() => {
if (preventHideMenu) { if (preventHideMenu) {
return; return;