Skip to content

Commit

Permalink
feat(WindowLevelTool): Reset selection when width/level is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
bnmajor committed Oct 9, 2023
1 parent 6cb967b commit fa342ca
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/tools/windowing/WindowLevelTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import useWindowingStore, {
import { useCurrentImage } from '@/src/composables/useCurrentImage';
import vtkMouseRangeManipulator from '@kitware/vtk.js/Interaction/Manipulators/MouseRangeManipulator';
import { useViewStore } from '@/src/store/views';
import { WL_AUTO_DEFAULT } from '@/src/constants';
function computeStep(min: number, max: number) {
return Math.min(max - min, 1) / 256;
Expand Down Expand Up @@ -43,6 +44,12 @@ const WindowLevelToolComponent = defineComponent({
const wlConfig = computed(() =>
windowingStore.getConfig(viewID.value, currentImageID.value)
);
const wlDefaults = computed(() => {
return {
width: windowConfigDefaults.width,
level: windowConfigDefaults.level,
};
});
const wwRange = computed(() => ({
min: 1e-12, // ensure we don't hit zero and jump to white
Expand Down Expand Up @@ -119,6 +126,8 @@ const WindowLevelToolComponent = defineComponent({
if (currentImageID.value != null) {
windowingStore.updateConfig(viewID.value, currentImageID.value, {
width: v,
auto: WL_AUTO_DEFAULT,
preset: wlDefaults.value,
});
}
}
Expand All @@ -133,6 +142,8 @@ const WindowLevelToolComponent = defineComponent({
if (currentImageID.value != null) {
windowingStore.updateConfig(viewID.value, currentImageID.value, {
level: v,
auto: WL_AUTO_DEFAULT,
preset: wlDefaults.value,
});
}
}
Expand Down

0 comments on commit fa342ca

Please sign in to comment.