Skip to content

Commit

Permalink
fix(bugs): enhancements and bug fixes (#4036)
Browse files Browse the repository at this point in the history
  • Loading branch information
IbrahimCSAE authored Apr 16, 2024
1 parent 41a8d10 commit e80fc6f
Show file tree
Hide file tree
Showing 58 changed files with 768 additions and 148 deletions.
5 changes: 5 additions & 0 deletions extensions/cornerstone-dicom-rt/src/utils/promptHydrateRT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function _askHydrate(uiViewportDialogService, viewportId) {
uiViewportDialogService.hide();
resolve(RESPONSE.CANCEL);
},
onKeyPress: event => {
if (event.key === 'Enter') {
onSubmit(RESPONSE.HYDRATE_SEG);
}
},
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ function _askHydrate(uiViewportDialogService, viewportId) {
uiViewportDialogService.hide();
resolve(RESPONSE.CANCEL);
},
onKeyPress: event => {
if (event.key === 'Enter') {
onSubmit(RESPONSE.HYDRATE_SEG);
}
},
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Header = ({ title, tooltip }) => (
<div className="flex items-center space-x-1">
<Tooltip
content={<div className="text-white">{tooltip}</div>}
position="bottom"
position="bottom-left"
tight={true}
tooltipBoxClassName="max-w-xs"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export function Colormap({
key: index,
style: {
minWidth: `calc(100% / ${displaySets.length})`,
fontSize: '0.8rem',
textAlign: 'center',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
},
}));
}, [displaySets]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export function VolumeLighting({
min={0}
type="range"
step={0.1}
style={{ background: calculateBackground(ambient) }}
style={{
background: calculateBackground(ambient),
'--thumb-inner-color': '#5acce6',
'--thumb-outer-color': '#090c29',
}}
/>
)}
</div>
Expand All @@ -84,7 +88,11 @@ export function VolumeLighting({
min={0}
type="range"
step={0.1}
style={{ background: calculateBackground(diffuse) }}
style={{
background: calculateBackground(diffuse),
'--thumb-inner-color': '#5acce6',
'--thumb-outer-color': '#090c29',
}}
/>
)}
</div>
Expand All @@ -109,7 +117,11 @@ export function VolumeLighting({
min={0}
type="range"
step={0.1}
style={{ background: calculateBackground(specular) }}
style={{
background: calculateBackground(specular),
'--thumb-inner-color': '#5acce6',
'--thumb-outer-color': '#090c29',
}}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export function VolumeRenderingOptions({
commandsManager={commandsManager}
serviceManager={serviceManager}
/>
<div className="all-in-one-menu-item flex w-full justify-start">
<div className="all-in-one-menu-item flex !h-[20px] w-full justify-start">
<div className="text-aqua-pale text-[13px]">LIGHTING</div>
</div>
<AllInOneMenu.DividerItem />
<div className="bg-primary-dark mt-1 mb-1 h-[2px] w-full"></div>
<div className="all-in-one-menu-item flex w-full justify-center">
<VolumeShade
commandsManager={commandsManager}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function VolumeRenderingPresets({
commandsManager,
},
containerDimensions: 'h-[543px] w-[460px]',
contentDimensions: 'h-[493px] w-[460px] pl-[12px]',
contentDimensions: 'h-[493px] w-[460px] pl-[12px] pr-[12px]',
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export function VolumeRenderingQuality({
type="range"
step={step}
onChange={e => onChange(parseInt(e.target.value, 10))}
style={{ background: calculateBackground((quality - min) / (max - min)) }}
style={{
background: calculateBackground((quality - min) / (max - min)),
'--thumb-inner-color': '#5acce6',
'--thumb-outer-color': '#090c29',
}}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export function VolumeShift({
step={step}
style={{
background: calculateBackground((shift - minShift) / (maxShift - minShift)),
'--thumb-inner-color': '#5acce6',
'--thumb-outer-color': '#090c29',
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';

export type WindowLevelProps = {
viewportId: string;
presets: Record<string, Array<WindowLevelPreset>>;
presets: Array<Record<string, Array<WindowLevelPreset>>>;
commandsManager: CommandsManager;
};

Expand All @@ -23,25 +23,34 @@ export function WindowLevel({
commandName: 'setViewportWindowLevel',
commandOptions: {
...props,
viewportId,
},
context: 'CORNERSTONE',
});
},
[commandsManager]
[commandsManager, viewportId]
);

return (
<AllInOneMenu.ItemPanel>
<AllInOneMenu.HeaderItem>
{t('Modality Presets', { modality: Object.keys(presets)[0] })}
</AllInOneMenu.HeaderItem>
{Object.values(presets)[0].map((preset, index) => (
<AllInOneMenu.Item
key={index}
label={preset.description}
secondaryLabel={`${preset.window} / ${preset.level}`}
onClick={() => onSetWindowLevel({ ...preset, viewportId })}
></AllInOneMenu.Item>
{presets.map((modalityPresets, modalityIndex) => (
<React.Fragment key={modalityIndex}>
{Object.entries(modalityPresets).map(([modality, presetsArray]) => (
<React.Fragment key={modality}>
<AllInOneMenu.HeaderItem>
{t('Modality Presets', { modality })}
</AllInOneMenu.HeaderItem>
{presetsArray.map((preset, index) => (
<AllInOneMenu.Item
key={`${modality}-${index}`}
label={preset.description}
secondaryLabel={`${preset.window} / ${preset.level}`}
onClick={() => onSetWindowLevel(preset)}
/>
))}
</React.Fragment>
))}
</React.Fragment>
))}
</AllInOneMenu.ItemPanel>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { utilities } from '@cornerstonejs/core';
export type WindowLevelActionMenuProps = {
viewportId: string;
element: HTMLElement;
presets: Record<string, Array<WindowLevelPreset>>;
presets: Array<Record<string, Array<WindowLevelPreset>>>;
verticalDirection: AllInOneMenu.VerticalDirection;
horizontalDirection: AllInOneMenu.HorizontalDirection;
commandsManager: CommandsManager;
Expand Down Expand Up @@ -128,10 +128,8 @@ export function WindowLevelActionMenu({
iconClassName={classNames(
// Visible on hover and for the active viewport
activeViewportId === viewportId ? 'visible' : 'invisible group-hover:visible',
'flex shrink-0 cursor-pointer rounded active:text-white',
isLight
? 'text-aqua-pale hover:bg-secondary-dark'
: 'text-primary-light hover:bg-secondary-light/60'
'flex shrink-0 cursor-pointer rounded active:text-white text-primary-light',
isLight ? ' hover:bg-secondary-dark' : 'hover:bg-secondary-light/60'
)}
menuStyle={{ maxHeight: vpHeight - 32, minWidth: 218 }}
onVisibilityChange={() => {
Expand Down Expand Up @@ -166,10 +164,10 @@ export function WindowLevelActionMenu({
</AllInOneMenu.SubMenu>
)}

{presets && !is3DVolume && (
{presets && presets.length > 0 && !is3DVolume && (
<AllInOneMenu.SubMenu
key="windowLevelPresets"
itemLabel={t('Modality Window Presets', { modality: Object.keys(presets)[0] })}
itemLabel={t('Modality Window Presets')}
itemIcon="viewport-window-level"
>
<WindowLevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ export function getWindowLevelActionMenu({
return { [displaySet.Modality]: presets[displaySet.Modality] };
});

const hasMenu = displaySetPresets.length > 0;

return hasMenu ? (
return (
<WindowLevelActionMenu
viewportId={viewportId}
element={element}
presets={displaySetPresets[0]}
presets={displaySetPresets}
verticalDirection={verticalDirection}
horizontalDirection={horizontalDirection}
commandsManager={commandsManager}
Expand All @@ -40,5 +38,5 @@ export function getWindowLevelActionMenu({
volumeRenderingPresets={volumeRenderingPresets}
volumeRenderingQualityRange={volumeRenderingQualityRange}
/>
) : null;
);
}
4 changes: 2 additions & 2 deletions extensions/cornerstone/src/getToolbarModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default function getToolbarModule({ commandsManager, servicesManager }) {
return {
disabled: false,
className: isPrimaryActive
? '!text-black bg-primary-light'
: '!text-common-bright hover:!bg-primary-dark hover:!text-primary-light',
? '!text-black bg-primary-light rounded'
: '!text-common-bright hover:!bg-primary-dark hover:!text-primary-light rounded',
// Todo: isActive right now is used for nested buttons where the primary
// button needs to be fully rounded (vs partial rounded) when active
// otherwise it does not have any other use
Expand Down
7 changes: 5 additions & 2 deletions extensions/cornerstone/src/hps/fourUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ export const fourUp = {
{
id: 'mprDisplaySet',
options: {
// ToDo: choose appropriate preset
displayPreset: 'CT-Bone',
displayPreset: {
CT: 'CT-Bone',
MR: 'MR-Default',
default: 'CT-Bone',
},
},
},
],
Expand Down
7 changes: 5 additions & 2 deletions extensions/cornerstone/src/hps/main3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ export const main3D = {
{
id: 'mprDisplaySet',
options: {
// ToDo: choose appropriate preset
displayPreset: 'CT-Bone',
displayPreset: {
CT: 'CT-Bone',
MR: 'MR-Default',
default: 'CT-Bone',
},
},
},
],
Expand Down
6 changes: 5 additions & 1 deletion extensions/cornerstone/src/hps/mprAnd3DVolumeViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ export const mprAnd3DVolumeViewport = {
{
id: 'mprDisplaySet',
options: {
displayPreset: 'CT-Bone',
displayPreset: {
CT: 'CT-Bone',
MR: 'MR-Default',
default: 'CT-Bone',
},
},
},
],
Expand Down
7 changes: 5 additions & 2 deletions extensions/cornerstone/src/hps/only3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ export const only3D = {
{
id: 'mprDisplaySet',
options: {
// ToDo: choose appropriate preset
displayPreset: 'CT-Bone',
displayPreset: {
CT: 'CT-Bone',
MR: 'MR-Default',
default: 'CT-Bone',
},
},
},
],
Expand Down
7 changes: 5 additions & 2 deletions extensions/cornerstone/src/hps/primary3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ export const primary3D = {
{
id: 'mprDisplaySet',
options: {
// ToDo: choose appropriate preset
displayPreset: 'CT-Bone',
displayPreset: {
CT: 'CT-Bone',
MR: 'MR-Default',
default: 'CT-Bone',
},
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion extensions/cornerstone/src/init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default async function init({
const labelmapRepresentation = cornerstoneTools.Enums.SegmentationRepresentations.Labelmap;

cornerstoneTools.segmentation.config.setGlobalRepresentationConfig(labelmapRepresentation, {
fillAlpha: 0.3,
fillAlpha: 0.5,
fillAlphaInactive: 0.2,
outlineOpacity: 1,
outlineOpacityInactive: 0.65,
Expand Down
18 changes: 18 additions & 0 deletions extensions/cornerstone/src/initMeasurementService.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const initMeasurementService = (
PlanarFreehandROI,
SplineROI,
LivewireContour,
Probe,
UltrasoundDirectional,
} = measurementServiceMappingsFactory(
measurementService,
displaySetService,
Expand Down Expand Up @@ -157,6 +159,22 @@ const initMeasurementService = (
LivewireContour.toMeasurement
);

measurementService.addMapping(
csTools3DVer1MeasurementSource,
'Probe',
Probe.matchingCriteria,
Probe.toAnnotation,
Probe.toMeasurement
);

measurementService.addMapping(
csTools3DVer1MeasurementSource,
'UltrasoundDirectionalTool',
UltrasoundDirectional.matchingCriteria,
UltrasoundDirectional.toAnnotation,
UltrasoundDirectional.toMeasurement
);

return csTools3DVer1MeasurementSource;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,14 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
}

public async setVolumesForViewport(viewport, volumeInputArray, presentations) {
const { displaySetService, toolGroupService } = this.servicesManager.services;
const { displaySetService, toolGroupService, viewportGridService } =
this.servicesManager.services;

const viewportInfo = this.getViewportInfo(viewport.id);
const displaySetOptions = viewportInfo.getDisplaySetOptions();
const displaySetUIDs = viewportGridService.getDisplaySetsUIDsForViewport(viewport.id);
const displaySet = displaySetService.getDisplaySetByUID(displaySetUIDs[0]);
const displaySetModality = displaySet?.Modality;

// Todo: use presentations states
const volumesProperties = volumeInputArray.map((volumeInput, index) => {
Expand All @@ -750,7 +754,7 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
}

if (displayPreset !== undefined) {
properties.preset = displayPreset;
properties.preset = displayPreset[displaySetModality] || displayPreset.default;
}

return { properties, volumeId };
Expand Down
Loading

0 comments on commit e80fc6f

Please sign in to comment.