Skip to content

Commit

Permalink
Merge pull request #656 from PaulHax/preset-fix
Browse files Browse the repository at this point in the history
fix(VolumeRendering): on switching dataset, ensure CTF preset valid
  • Loading branch information
floryst authored Oct 2, 2024
2 parents 8ebf62e + 62bf6bd commit a7535a4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
13 changes: 4 additions & 9 deletions src/components/VolumePresets.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script lang="ts">
import { computed, defineComponent, watch } from 'vue';
import { computed, defineComponent } from 'vue';
import { PresetNameList } from '@/src/vtk/ColorMaps';
import vtkColorMaps from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps';
import ItemGroup from '@/src/components/ItemGroup.vue';
import GroupableItem from '@/src/components/GroupableItem.vue';
import { useVolumeColoringInitializer } from '@/src/composables/useVolumeColoringInitializer';
import PersistentOverlay from './PersistentOverlay.vue';
import { useCurrentImage } from '../composables/useCurrentImage';
import useVolumeColoringStore from '../store/view-configs/volume-coloring';
Expand All @@ -26,18 +27,12 @@ export default defineComponent({
const { currentImageID, currentImageData } = useCurrentImage();
useVolumeColoringInitializer(TARGET_VIEW_ID, currentImageID);
const volumeColorConfig = computed(() =>
volumeColoringStore.getConfig(TARGET_VIEW_ID, currentImageID.value)
);
watch(volumeColorConfig, () => {
const imageID = currentImageID.value;
if (imageID && !volumeColorConfig.value) {
// creates a default color config
volumeColoringStore.updateConfig(TARGET_VIEW_ID, imageID, {});
}
});
const colorTransferFunctionRef = computed(
() => volumeColorConfig.value?.transferFunction
);
Expand Down
13 changes: 4 additions & 9 deletions src/components/VolumeProperties.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { computed, defineComponent, watch, ref } from 'vue';
import { computed, defineComponent, ref } from 'vue';
import { useVolumeColoringInitializer } from '@/src/composables/useVolumeColoringInitializer';
import { useCurrentImage } from '../composables/useCurrentImage';
import { CVRConfig } from '../types/views';
import useVolumeColoringStore from '../store/view-configs/volume-coloring';
Expand All @@ -19,18 +20,12 @@ export default defineComponent({
const { currentImageID } = useCurrentImage();
useVolumeColoringInitializer(TARGET_VIEW_ID, currentImageID);
const volumeColorConfig = computed(() =>
volumeColoringStore.getConfig(TARGET_VIEW_ID, currentImageID.value)
);
watch(volumeColorConfig, () => {
const imageID = currentImageID.value;
if (imageID && !volumeColorConfig.value) {
// creates a default color config
volumeColoringStore.updateConfig(TARGET_VIEW_ID, imageID, {});
}
});
// --- CVR --- //
const cvrParams = computed(() => volumeColorConfig.value?.cvr);
Expand Down
15 changes: 6 additions & 9 deletions src/components/VolumeRendering.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransf
import { onVTKEvent } from '@/src/composables/onVTKEvent';
import useViewAnimationStore from '@/src/store/view-animation';
import { useResetViewsEvents } from '@/src/components/tools/ResetViews.vue';
import { useVolumeColoringInitializer } from '@/src/composables/useVolumeColoringInitializer';
import { useResizeObserver } from '../composables/useResizeObserver';
import { useCurrentImage } from '../composables/useCurrentImage';
import useVolumeColoringStore from '../store/view-configs/volume-coloring';
Expand All @@ -43,18 +44,12 @@ export default defineComponent({
const { currentImageID, currentImageData } = useCurrentImage();
useVolumeColoringInitializer(TARGET_VIEW_ID, currentImageID);
const volumeColorConfig = computed(() =>
volumeColoringStore.getConfig(TARGET_VIEW_ID, currentImageID.value)
);
watch(volumeColorConfig, () => {
const imageID = currentImageID.value;
if (imageID && !volumeColorConfig.value) {
// creates a default color config
volumeColoringStore.updateConfig(TARGET_VIEW_ID, imageID, {});
}
});
const colorTransferFunctionRef = computed(
() => volumeColorConfig.value?.transferFunction
);
Expand Down Expand Up @@ -296,7 +291,9 @@ export default defineComponent({
watch([rangeShift, rangeWidth], ([shift, width]) => {
const imageID = currentImageID.value;
if (!imageID) return;
const config = volumeColoringStore.getConfig(TARGET_VIEW_ID, imageID);
// wait for config to be initialized with preset "all view default" for particular image
if (!imageID || !config) return;
const fullRange = fullMappingRange.value;
const fullWidth = fullMappingRangeWidth.value;
Expand Down
2 changes: 1 addition & 1 deletion src/store/view-configs/volume-coloring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const useVolumeColoringStore = defineStore('volumeColoring', () => {
};

/**
* Sets the view config defaults for a dataset.
* Sets all views' defaults for given dataset.
* @param dataID
* @param defaults
*/
Expand Down

0 comments on commit a7535a4

Please sign in to comment.