Skip to content

Commit

Permalink
feat(WindowLevelControls): Remove reset
Browse files Browse the repository at this point in the history
Replace instead with an option to use the full data range that lives under the
"auto" menu. This also renames the auto options to low/medium/high contrast.
  • Loading branch information
bnmajor committed Oct 23, 2023
1 parent 1d88dff commit 6ca7d71
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 49 deletions.
9 changes: 5 additions & 4 deletions src/components/VtkTwoView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,13 @@ export default defineComponent({
});
if (firstTag.value?.width) {
windowingStore.updateConfig(viewID.value, curImageID.value, {
width: parseFloat(firstTag.value.width),
level: parseFloat(firstTag.value.level),
preset: {
width: parseFloat(firstTag.value.width),
level: parseFloat(firstTag.value.level),
},
});
} else {
windowingStore.resetWindowLevel(viewID.value, curImageID.value);
}
windowingStore.resetWindowLevel(viewID.value, curImageID.value);
},
{
immediate: true,
Expand Down
56 changes: 17 additions & 39 deletions src/components/tools/windowing/WindowLevelControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ export default defineComponent({
return text.replace(/([A-Z])/g, ' $1').trim();
}
// --- Automatic Range Options --- //
const filteredWLAutoRanges = computed(
() =>
Object.fromEntries(
Object.entries(WLAutoRanges).filter(([, value]) => value !== 0)
) as Record<string, number>
);
// --- CT Preset Options --- //
const modality = computed(() => {
Expand Down Expand Up @@ -82,10 +73,12 @@ export default defineComponent({
const wlOptions = computed({
get() {
const config = wlConfig.value;
if (config?.auto && config.auto !== WL_AUTO_DEFAULT) {
return config.auto;
const { width, level } = config?.preset || wlDefaults.value;
const { width: defaultWidth, level: defaultLevel } = wlDefaults.value;
if (width !== defaultWidth && level !== defaultLevel) {
return { width: wlWidth.value, level: wlLevel.value };
}
return { width: wlWidth.value, level: wlLevel.value };
return config?.auto || WL_AUTO_DEFAULT;
},
set(selection: AutoRangeKey | PresetValue) {
const imageID = currentImageID.value;
Expand Down Expand Up @@ -124,29 +117,14 @@ export default defineComponent({
return [];
});
// --- Reset --- //
const resetWindowLevel = () => {
const imageID = currentImageID.value;
// All views will be synchronized, just reset the first
const viewID = viewIDs.value[0];
if (!imageID || !viewID) return;
windowingStore.updateConfig(viewID, imageID, {
preset: wlDefaults.value,
auto: WL_AUTO_DEFAULT,
});
windowingStore.resetWindowLevel(viewID, imageID);
};
return {
resetWindowLevel,
parseLabel,
wlOptions,
WLPresetsCT,
isCT,
tags,
panel,
filteredWLAutoRanges,
WLAutoRanges,
};
},
});
Expand Down Expand Up @@ -199,24 +177,24 @@ export default defineComponent({
<v-expansion-panel-text>
<v-radio-group v-model="wlOptions" hide-details>
<v-radio
v-for="(value, key) in filteredWLAutoRanges"
v-for="(value, key) in WLAutoRanges"
:key="key"
:label="`${value} Percentile`"
:label="parseLabel(key)"
:value="key"
density="compact"
/>
>
<v-tooltip activator="parent" location="bottom">
{{
value
? `Remove the top and bottom ${value} percent of data`
: 'Use the full data range'
}}
</v-tooltip>
</v-radio>
</v-radio-group>
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansion-panels>
<v-btn
prepend-icon="mdi-restore"
variant="text"
block
@click="resetWindowLevel"
>
Reset
</v-btn>
</v-card-text>
</v-card>
</template>
Expand Down
11 changes: 5 additions & 6 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,13 @@ export const ACTIONS = {
export type Action = keyof typeof ACTIONS;

export const WLAutoRanges = {
None: 0,
OneTenthPercent: 0.1,
OnePercent: 1.0,
TwoPercent: 2.0,
FivePercent: 5.0,
FullRange: 0,
LowContrast: 1.0,
MediumContrast: 2.0,
HighContrast: 5.0,
};

export const WL_AUTO_DEFAULT = 'None';
export const WL_AUTO_DEFAULT = 'FullRange';
export const WL_HIST_BINS = 512;

export const WLPresetsCT = {
Expand Down

0 comments on commit 6ca7d71

Please sign in to comment.