-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #654 from PaulHax/seg-group-trans
Segment Groups: opacity slider and visibility toggle button
- Loading branch information
Showing
18 changed files
with
195 additions
and
99 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,39 @@ | ||
<script setup lang="ts"> | ||
import { computed, toRefs } from 'vue'; | ||
import { useGlobalLayerColorConfig } from '@/src/composables/useGlobalLayerColorConfig'; | ||
const props = defineProps<{ | ||
groupId: string; | ||
}>(); | ||
const { groupId } = toRefs(props); | ||
const { sampledConfig, updateConfig } = useGlobalLayerColorConfig(groupId); | ||
const blendConfig = computed(() => sampledConfig.value!.config!.blendConfig); | ||
const setOpacity = (opacity: number) => { | ||
updateConfig({ | ||
blendConfig: { | ||
...blendConfig.value, | ||
// 1.0 puts us in Opaque render pass which changes stack order. | ||
opacity: Math.min(opacity, 0.9999), | ||
}, | ||
}); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<v-slider | ||
class="pa-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="setOpacity($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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { computed, MaybeRef, unref } from 'vue'; | ||
import { InitViewSpecs } from '@/src/config'; | ||
import useLayerColoringStore from '@/src/store/view-configs/layers'; | ||
import { LayersConfig } from '@/src/store/view-configs/types'; | ||
import { useSegmentGroupConfigInitializer } from '@/src/composables/useSegmentGroupConfigInitializer'; | ||
|
||
// Returns first existing view's config as the "value" and updates all views' configs with updateConfig() | ||
export const useGlobalLayerColorConfig = (layerId: MaybeRef<string>) => { | ||
const layerColoringStore = useLayerColoringStore(); | ||
|
||
const VIEWS_2D = Object.entries(InitViewSpecs) | ||
.filter(([, { viewType }]) => viewType === '2D') | ||
.map(([viewID]) => viewID); | ||
|
||
useSegmentGroupConfigInitializer(VIEWS_2D[0], unref(layerId)); | ||
|
||
const layerConfigs = computed(() => | ||
VIEWS_2D.map((viewID) => ({ | ||
config: layerColoringStore.getConfig(viewID, unref(layerId)), | ||
viewID, | ||
})) | ||
); | ||
|
||
const sampledConfig = computed(() => | ||
layerConfigs.value.find(({ config }) => config) | ||
); | ||
|
||
const updateConfig = (patch: Partial<LayersConfig>) => { | ||
layerConfigs.value.forEach(({ viewID }) => | ||
layerColoringStore.updateConfig(viewID, unref(layerId), patch) | ||
); | ||
}; | ||
|
||
return { sampledConfig, updateConfig }; | ||
}; |
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.initConfig(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
Oops, something went wrong.