Skip to content

Commit

Permalink
Fix updating window on frame change (#642)
Browse files Browse the repository at this point in the history
* Fix updating window on frame change

* Fix styling
  • Loading branch information
annehaley authored Jan 5, 2023
1 parent 5d17bd2 commit bf1050d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions web_client/src/components/WindowWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export default defineComponent({
width: currentWindowWidth.value,
level: currentWindowLevel.value,
}));
const data = props.representation.getInputDataSet();
const distribution = data.computeHistogram(data.getBounds());
const widthMin = computed(() => distribution.minimum || 0);
const widthMax = computed(() => distribution.maximum || 0);
const data = computed(() => props.representation.getInputDataSet());
const distribution = computed(() => data.value.computeHistogram(data.value.getBounds()));
const widthMin = computed(() => distribution.value.minimum || 0);
const widthMax = computed(() => distribution.value.maximum || 0);
const selectedPreset = ref();
const windowLocked = computed(() => store.state.windowLocked.lock);
const windowLockImage = computed(() => store.state.windowLocked.associatedImage);
Expand Down Expand Up @@ -71,8 +71,8 @@ export default defineComponent({
function autoRange() {
if (windowLocked.value) return;
currentRange.value = [
Math.floor(distribution.minimum + distribution.sigma),
Math.floor(distribution.maximum - distribution.sigma),
Math.floor(distribution.value.minimum + distribution.value.sigma),
Math.floor(distribution.value.maximum - distribution.value.sigma),
];
const ww = currentRange.value[1] - currentRange.value[0];
const wl = currentRange.value[0] + Math.floor(ww / 2);
Expand Down
4 changes: 3 additions & 1 deletion web_client/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ function prepareProxyManager(proxyManager) {
view.getRepresentations().forEach((representation) => {
representation.setInterpolationType(InterpolationType.NEAREST);
representation.onModified(macro.debounce(() => {
view.render(true);
if (view.getRepresentations()) {
view.render(true);
}
}, 0));
// debounce timer doesn't need a wait time because
// the many onModified changes that it needs to collapse to a single rerender
Expand Down

0 comments on commit bf1050d

Please sign in to comment.