-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(segment-groups): add opacity slider per segment group
- Loading branch information
Showing
12 changed files
with
107 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<script setup lang="ts"> | ||
import { computed, toRefs } from 'vue'; | ||
import { BlendConfig } from '@/src/types/views'; | ||
import useLayerColoringStore from '@/src/store/view-configs/layers'; | ||
import { useSegmentGroupConfigInitializer } from '@/src/composables/useSegmentGroupConfigInitializer'; | ||
import { InitViewSpecs } from '../config'; | ||
const props = defineProps<{ | ||
groupId: string; | ||
}>(); | ||
const { groupId } = toRefs(props); | ||
const layerColoringStore = useLayerColoringStore(); | ||
const VIEWS_2D = Object.entries(InitViewSpecs) | ||
.filter(([, { viewType }]) => viewType === '2D') | ||
.map(([viewID]) => viewID); | ||
useSegmentGroupConfigInitializer(VIEWS_2D[0], groupId.value); | ||
const layerConfigs = computed(() => | ||
VIEWS_2D.map((viewID) => ({ | ||
config: layerColoringStore.getConfig(viewID, groupId.value), | ||
viewID, | ||
})) | ||
); | ||
const blendConfig = computed( | ||
() => layerConfigs.value.find(({ config }) => config)!.config!.blendConfig | ||
); | ||
const setBlendConfig = (key: keyof BlendConfig, value: any) => { | ||
layerConfigs.value.forEach(({ viewID }) => | ||
layerColoringStore.updateBlendConfig(viewID, groupId.value, { | ||
[key]: value, | ||
}) | ||
); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<v-slider | ||
class="py-4" | ||
label="Segment Group Opacity" | ||
min="0" | ||
max="1" | ||
step="0.01" | ||
density="compact" | ||
hide-details | ||
thumb-label | ||
:model-value="blendConfig.opacity" | ||
@update:model-value="setBlendConfig('opacity', $event)" | ||
/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import useLayerColoringStore from '@/src/store/view-configs/layers'; | ||
import { watchImmediate } from '@vueuse/core'; | ||
import { MaybeRef, computed, unref } from 'vue'; | ||
|
||
export function useSegmentGroupConfigInitializer( | ||
viewId: MaybeRef<string>, | ||
layerId: MaybeRef<string> | ||
) { | ||
const coloringStore = useLayerColoringStore(); | ||
const colorConfig = computed(() => | ||
coloringStore.getConfig(unref(viewId), unref(layerId)) | ||
); | ||
|
||
watchImmediate(colorConfig, (config) => { | ||
if (config) return; | ||
|
||
const viewIdVal = unref(viewId); | ||
const layerIdVal = unref(layerId); | ||
coloringStore.updateConfig(viewIdVal, layerIdVal, {}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters