Skip to content

Commit

Permalink
Prettify
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Chauvin committed Oct 3, 2024
1 parent 7be4abe commit 4f0ebf5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
17 changes: 7 additions & 10 deletions src/components/ImageDataBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export default defineComponent({
{ immediate: true, deep: true }
);
// --- sync --- //
const sameSpaceImages = computed(() => {
// --- sync --- //
const sameSpaceImages = computed(() => {
return imageStore.checkAllImagesSameSpace();
});
const isSync = computed(() => {
Expand All @@ -132,13 +132,10 @@ export default defineComponent({
viewCameraStore.toggleSyncCameras();
viewCameraStore.disableCameraAutoReset = isSync.value;
}
watch(
isSync,
() => {
viewSliceStore.updateSyncConfigs();
viewCameraStore.updateSyncConfigs();
}
);
watch(isSync, () => {
viewSliceStore.updateSyncConfigs();
viewCameraStore.updateSyncConfigs();
});
// --- selection --- //
Expand Down Expand Up @@ -206,7 +203,7 @@ export default defineComponent({
:disabled="!sameSpaceImages"
@click.stop="toggleSyncImages"
>
<v-icon v-if="isSync">mdi-lock</v-icon>
<v-icon v-if="isSync">mdi-lock</v-icon>
<v-icon flip="vertical" v-else>mdi-lock-open-variant</v-icon>
<v-tooltip
:disabled="!sameSpaceImages"
Expand Down
7 changes: 5 additions & 2 deletions src/io/import/processors/importSingleFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ const importSingleFile: ImportHandler = async (dataSource, { done }) => {
// Create a default view for each viewID
useViewStore().viewIDs.forEach((viewID: string) => {
const { lpsOrientation, dimensions } = useImageStore().metadata[dataID];
const axisDir = InitViewSpecs[viewID].props.viewDirection
const axisDir = InitViewSpecs[viewID].props.viewDirection;
const lpsFromDir = getLPSAxisFromDir(axisDir);
const lpsOrient = lpsOrientation[lpsFromDir];

const dimMax = dimensions[lpsOrient];

useViewSliceStore().updateConfig(viewID, dataID, { axisDirection: axisDir, max: dimMax - 1 });
useViewSliceStore().updateConfig(viewID, dataID, {
axisDirection: axisDir,
max: dimMax - 1,
});
useViewSliceStore().resetSlice(viewID, dataID);
});

Expand Down
2 changes: 1 addition & 1 deletion src/store/datasets-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const useImageStore = defineStore('images', {

const dataFirst = this.dataIndex[this.idList[0]];
const allEqual = this.idList.slice(1).every((id) => {
return compareImageSpaces(this.dataIndex[id], dataFirst);
return compareImageSpaces(this.dataIndex[id], dataFirst);
});

return allEqual;
Expand Down
24 changes: 15 additions & 9 deletions src/store/view-configs/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export const useViewCameraStore = defineStore('viewCamera', () => {

patchDoubleKeyRecord(configs, viewID, dataID, config);
};

const disableCameraAutoReset = ref(false);

const toggleCameraAutoReset = () => {
disableCameraAutoReset.value = !disableCameraAutoReset.value;
}
};

const removeView = (viewID: string) => {
delete configs[viewID];
Expand All @@ -56,34 +56,40 @@ export const useViewCameraStore = defineStore('viewCamera', () => {
Object.keys(configs).forEach((viewID) => {
imageStore.idList.forEach((imageID) => {
const { syncState } = {
...getConfig(viewID, imageID)
...getConfig(viewID, imageID),
};
updateConfig(viewID, imageID, { syncState: !syncState });
});
});
}
};

const isSync = () => {
const allSync = Object.keys(configs).every((sc) => Object.keys(configs[sc]).every((c) => configs[sc][c].syncState));
const allSync = Object.keys(configs).every((sc) =>
Object.keys(configs[sc]).every((c) => configs[sc][c].syncState)
);

return allSync;
}
};

const updateSyncConfigs = () => {
Object.keys(configs).forEach((viewID) => {
const { currentImageID } = useCurrentImage();
const config = getConfig(viewID, currentImageID.value);
imageStore.idList.forEach((imageID) => {
const { syncState } = {
...getConfig(viewID, imageID)
...getConfig(viewID, imageID),
};

if (syncState) {
updateConfig(viewID, imageID, { position: config?.position, focalPoint: config?.focalPoint, parallelScale: config?.parallelScale });
updateConfig(viewID, imageID, {
position: config?.position,
focalPoint: config?.focalPoint,
parallelScale: config?.parallelScale,
});
}
});
});
}
};

const serialize = createViewConfigSerializer(configs, 'camera');

Expand Down
14 changes: 8 additions & 6 deletions src/store/view-configs/slicing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,20 @@ export const useViewSliceStore = defineStore('viewSlice', () => {
imageStore.idList.forEach((imageID) => {
const { syncState } = {
...defaultSliceConfig(),
...getConfig(viewID, imageID)
...getConfig(viewID, imageID),
};
updateConfig(viewID, imageID, { syncState: !syncState });
});
});
}
};

const isSync = () => {
const allSync = Object.keys(configs).every((sc) => Object.keys(configs[sc]).every((c) => configs[sc][c].syncState));
const allSync = Object.keys(configs).every((sc) =>
Object.keys(configs[sc]).every((c) => configs[sc][c].syncState)
);

return allSync;
}
};

const updateSyncConfigs = () => {
Object.keys(configs).forEach((viewID) => {
Expand All @@ -94,15 +96,15 @@ export const useViewSliceStore = defineStore('viewSlice', () => {
imageStore.idList.forEach((imageID) => {
const { syncState } = {
...defaultSliceConfig(),
...getConfig(viewID, imageID)
...getConfig(viewID, imageID),
};

if (syncState) {
updateConfig(viewID, imageID, { slice: config?.slice });
}
});
});
}
};

const serialize = createViewConfigSerializer(configs, 'slice');

Expand Down

0 comments on commit 4f0ebf5

Please sign in to comment.