Skip to content

Commit 9cbc411

Browse files
committed
fix(layers): load whole image before resampling
1 parent 15c4e87 commit 9cbc411

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/store/datasets-layers.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ref } from 'vue';
1+
import { computed, ref, unref } from 'vue';
2+
import { until } from '@vueuse/core';
23
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
34
import vtkBoundingBox from '@kitware/vtk.js/Common/DataModel/BoundingBox';
45
import { defineStore } from 'pinia';
@@ -7,6 +8,7 @@ import { Maybe } from '@/src/types';
78
import { ensureSameSpace } from '@/src/io/resample/resample';
89
import { useErrorMessage } from '../composables/useErrorMessage';
910
import { Manifest, StateFile } from '../io/state-file/schema';
11+
import useChunkStore from './chunks';
1012

1113
// differ from Image/Volume IDs with a branded type
1214
export type LayerID = string & { __type: 'LayerID' };
@@ -66,6 +68,12 @@ export const useLayersStore = defineStore('layer', () => {
6668
parent: DataSelection,
6769
source: DataSelection
6870
) {
71+
// ensureSameSpace need final image array to resample, so wait for all chunks
72+
const doneLoading = computed(
73+
() => !unref(useChunkStore().chunkImageById[source].isLoading)
74+
);
75+
await until(doneLoading).toBe(true);
76+
6977
return useErrorMessage('Failed to build layer', async () => {
7078
try {
7179
await this._addLayer(parent, source);

0 commit comments

Comments
 (0)