Skip to content

Commit 359e575

Browse files
committed
fix(windowing): fix range manipulator corrupting windowing
If mouse range manipulator sent just a level or width while windowing config state is on auto, we would go to default level/width instead of keeping the current one defined by auto
1 parent 89f8ba1 commit 359e575

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/composables/useWindowingConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export function useWindowingConfig(
1515
if (!imageIdVal) return undefined;
1616
const viewIdVal = unref(viewID);
1717
if (!viewIdVal) return undefined;
18-
return store.getConfig(viewIdVal, imageIdVal);
18+
return store.getConfig(viewIdVal, imageIdVal).value;
1919
});
2020

2121
const generateComputed = (prop: 'width' | 'level') => {
2222
return computed({
2323
get: () => {
24-
return config.value?.value?.[prop] ?? 0;
24+
return config.value?.[prop] ?? 0;
2525
},
2626
set: (val) => {
2727
const imageIdVal = unref(imageID);

src/store/view-configs/windowing.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const useWindowingStore = defineStore('windowing', () => {
7171
return {
7272
...internalConfig,
7373
...widthLevel,
74-
};
74+
} as const;
7575
});
7676
};
7777

@@ -100,6 +100,7 @@ export const useWindowingStore = defineStore('windowing', () => {
100100
const defaults = defaultWindowLevelConfig();
101101

102102
let effectiveUseAuto = currentInternalConfig?.useAuto ?? defaults.useAuto;
103+
let widthLevelPatchOnSwitchingFromAuto;
103104

104105
if (patch.useAuto !== undefined) {
105106
effectiveUseAuto = patch.useAuto;
@@ -109,14 +110,23 @@ export const useWindowingStore = defineStore('windowing', () => {
109110
if (patch.useAuto === undefined) {
110111
effectiveUseAuto = false;
111112
}
113+
if (!effectiveUseAuto) {
114+
// patch may be only width or level so ensure we have both in the end
115+
const config = getConfig(viewID, dataID).value;
116+
if (config) {
117+
widthLevelPatchOnSwitchingFromAuto = {
118+
width: config.width,
119+
level: config.level,
120+
};
121+
}
122+
}
112123
}
113124

114-
const newInternalConfig: WindowLevelConfig = {
115-
...defaults,
116-
...(currentInternalConfig ?? {}),
125+
const newInternalConfig = {
126+
...widthLevelPatchOnSwitchingFromAuto,
117127
...patch,
118128
useAuto: effectiveUseAuto,
119-
userTriggered: currentInternalConfig?.userTriggered || userTriggered,
129+
userTriggered: currentInternalConfig?.userTriggered || userTriggered, // one way from false to true
120130
};
121131

122132
patchDoubleKeyRecord(configs, viewID, dataID, newInternalConfig);

0 commit comments

Comments
 (0)