From a29e746aed67525f24565eedd2964fbab61e3440 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Mon, 13 Apr 2026 14:54:00 +0200 Subject: [PATCH 01/34] feat(modelStyles): add logic to color all model_component by type --- app/components/Viewer/ContextMenuItem.vue | 3 +- .../Viewer/Generic/Model/ModelStyleCard.vue | 48 +++++++++++++++++-- app/components/Viewer/TreeComponent.vue | 5 +- app/stores/data_style.js | 11 ++++- app/stores/menu.js | 3 ++ internal/database/base_database.js | 2 + .../tables/model_component_type_datastyle.js | 4 ++ internal/stores/data_style/model/index.js | 30 +++++++++++- internal/stores/data_style/state.js | 39 ++++++++++++++- 9 files changed, 135 insertions(+), 10 deletions(-) create mode 100644 internal/database/tables/model_component_type_datastyle.js diff --git a/app/components/Viewer/ContextMenuItem.vue b/app/components/Viewer/ContextMenuItem.vue index 46341c53..fe5826fe 100644 --- a/app/components/Viewer/ContextMenuItem.vue +++ b/app/components/Viewer/ContextMenuItem.vue @@ -96,8 +96,9 @@ function toggleOptions() { variant="panel" padding="pa-0" class="elevation-24" + style="overflow: hidden; display: flex; flex-direction: column" > - + diff --git a/app/components/Viewer/Generic/Model/ModelStyleCard.vue b/app/components/Viewer/Generic/Model/ModelStyleCard.vue index 7a3fe8d6..8d73bc92 100644 --- a/app/components/Viewer/Generic/Model/ModelStyleCard.vue +++ b/app/components/Viewer/Generic/Model/ModelStyleCard.vue @@ -3,9 +3,11 @@ import ViewerOptionsColorPicker from "@ogw_front/components/Viewer/Options/Color import VisibilitySwitch from "@ogw_front/components/Viewer/Options/VisibilitySwitch.vue"; import { useDataStyleStore } from "@ogw_front/stores/data_style"; import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer"; +import { useDataStore } from "@ogw_front/stores/data"; const dataStyleStore = useDataStyleStore(); const hybridViewerStore = useHybridViewerStore(); +const dataStore = useDataStore(); const { itemProps } = defineProps({ itemProps: { type: Object, required: true }, @@ -14,6 +16,19 @@ const { itemProps } = defineProps({ const modelId = computed(() => itemProps.meta_data.modelId || itemProps.id); const componentId = computed(() => itemProps.meta_data.pickedComponentId); +const component_type = ref(null); + +watchEffect(async () => { + if (itemProps.meta_data.viewer_type === "model_component_type") { + component_type.value = itemProps.meta_data.modelComponentType; + } else if (componentId.value && modelId.value) { + const type = await dataStore.meshComponentType(modelId.value, componentId.value); + component_type.value = type || null; + } else { + component_type.value = null; + } +}); + const modelVisibility = computed({ get: () => dataStyleStore.modelVisibility(modelId.value), set: (value) => { @@ -27,13 +42,31 @@ const componentColor = computed({ componentId.value ? dataStyleStore.getModelComponentColor(modelId.value, componentId.value) : undefined, - set: async (newValue) => { + set: (newValue) => { if (componentId.value) { - await dataStyleStore.setModelComponentsColor(modelId.value, [componentId.value], newValue); + dataStyleStore.setModelComponentsColor(modelId.value, [componentId.value], newValue); hybridViewerStore.remoteRender(); } }, }); + +const modelComponentTypeColor = computed({ + get: () => + component_type.value + ? dataStyleStore.getModelComponentTypeColor(modelId.value, component_type.value) + : undefined, + set: (newValue) => { + if (component_type.value) { + dataStyleStore.setModelComponentTypeColor(modelId.value, component_type.value, newValue); + hybridViewerStore.remoteRender(); + } + }, +}); + +const modelComponentTypeLabel = computed(() => { + if (!component_type.value) return ""; + return `${component_type.value}s Options`; +});