diff --git a/src/composables/useWindowingConfigInitializer.ts b/src/composables/useWindowingConfigInitializer.ts index 0208fc0b..ce534574 100644 --- a/src/composables/useWindowingConfigInitializer.ts +++ b/src/composables/useWindowingConfigInitializer.ts @@ -124,6 +124,14 @@ export function useWindowingConfigInitializer( }, }); } + const forcedWL = store.runtimeConfigWindowLevel; + if (forcedWL) { + store.updateConfig(viewIdVal, imageIdVal, { + preset: { + ...forcedWL, + }, + }); + } store.resetWindowLevel(viewIdVal, imageIdVal); }); diff --git a/src/io/import/configJson.ts b/src/io/import/configJson.ts index 9ac10ee9..c23681a4 100644 --- a/src/io/import/configJson.ts +++ b/src/io/import/configJson.ts @@ -9,6 +9,7 @@ import { useRulerStore } from '@/src/store/tools/rulers'; import { useDataBrowserStore } from '@/src/store/data-browser'; import { usePolygonStore } from '@/src/store/tools/polygons'; import { useViewStore } from '@/src/store/views'; +import { useWindowingStore } from '@/src/store/view-configs/windowing'; import { actionToKey } from '@/src/composables/useKeyboardShortcuts'; import { useSegmentGroupStore } from '@/src/store/segmentGroups'; import { AnnotationToolStore } from '@/src/store/tools/useAnnotationTool'; @@ -70,12 +71,23 @@ const io = z }) .optional(); +// -------------------------------------------------------------------------- +// Window Level + +const windowing = z + .object({ + level: z.number(), + width: z.number(), + }) + .optional(); + export const config = z.object({ layout, dataBrowser, labels, shortcuts, io, + windowing, }); export type Config = z.infer; @@ -140,10 +152,17 @@ const applyIo = (manifest: Config) => { useLoadDataStore().segmentGroupExtension = manifest.io.segmentGroupExtension; }; +const applyWindowing = (manifest: Config) => { + if (!manifest.windowing) return; + + useWindowingStore().runtimeConfigWindowLevel = manifest.windowing; +}; + export const applyConfig = (manifest: Config) => { applyLayout(manifest); applyLabels(manifest); applySampleData(manifest); applyShortcuts(manifest); applyIo(manifest); + applyWindowing(manifest); }; diff --git a/src/store/view-configs/windowing.ts b/src/store/view-configs/windowing.ts index 6b38617b..935c3fa3 100644 --- a/src/store/view-configs/windowing.ts +++ b/src/store/view-configs/windowing.ts @@ -24,9 +24,15 @@ export const defaultWindowLevelConfig = (): WindowLevelConfig => ({ }, }); -const useWindowingStore = defineStore('windowing', () => { +type WindowLevel = { + width: number; + level: number; +}; + +export const useWindowingStore = defineStore('windowing', () => { const configs = reactive>({}); const syncAcrossViews = ref(true); + const runtimeConfigWindowLevel = ref(); const setSyncAcrossViews = (yn: boolean) => { syncAcrossViews.value = yn; @@ -69,6 +75,7 @@ const useWindowingStore = defineStore('windowing', () => { } }; + // not really reset, actually translate config object into W/L const resetWindowLevel = (viewID: string, dataID: string) => { const config = configs[viewID]?.[dataID]; if (config == null) return; @@ -105,6 +112,7 @@ const useWindowingStore = defineStore('windowing', () => { }; return { + runtimeConfigWindowLevel, configs, getConfig, setSyncAcrossViews,