@geode/opengeodeweb-front 10.44.0-rc.4 → 10.44.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/app/assets/geode_objects.ts +1 -0
  2. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +12 -12
  3. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +17 -24
  4. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +12 -12
  5. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
  6. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +17 -24
  7. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +12 -12
  8. package/app/components/Viewer/Options/ColoringTypeSelector.vue +12 -0
  9. package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
  10. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
  11. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +12 -12
  12. package/app/components/Viewer/Surface/PolygonsColoring.vue +17 -24
  13. package/app/components/Viewer/Ui.vue +0 -1
  14. package/app/composables/batch_style_model.ts +34 -0
  15. package/app/composables/project_manager.ts +6 -97
  16. package/app/composables/project_manager_helpers/reset.ts +31 -0
  17. package/app/composables/project_manager_helpers/restore.ts +55 -0
  18. package/app/composables/project_manager_helpers/types.ts +22 -0
  19. package/app/composables/project_manager_helpers/viewer_session.ts +25 -0
  20. package/app/stores/menu_helpers/menus_data.ts +16 -120
  21. package/app/stores/menu_helpers/mesh/edged_curve.ts +12 -0
  22. package/app/stores/menu_helpers/mesh/grid.ts +24 -0
  23. package/app/stores/menu_helpers/mesh/point_set.ts +11 -0
  24. package/app/stores/menu_helpers/mesh/solid.ts +29 -0
  25. package/app/stores/menu_helpers/mesh/surface.ts +22 -0
  26. package/app/stores/menu_helpers/model.ts +25 -0
  27. package/app/stores/menu_helpers/types.ts +5 -0
  28. package/app/stores/viewer.ts +0 -1
  29. package/internal/stores/data_style/mesh/cells/color.ts +3 -1
  30. package/internal/stores/data_style/mesh/cells/index.ts +17 -1
  31. package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
  32. package/internal/stores/data_style/mesh/edges/color.ts +3 -1
  33. package/internal/stores/data_style/mesh/edges/index.ts +17 -1
  34. package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
  35. package/internal/stores/data_style/mesh/points/color.ts +3 -1
  36. package/internal/stores/data_style/mesh/points/index.ts +17 -1
  37. package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
  38. package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
  39. package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
  40. package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
  41. package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
  42. package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
  43. package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
  44. package/package.json +1 -1
@@ -13,6 +13,7 @@ import PointSet3D from "@ogw_front/assets/img/geode_objects/PointSet3D.svg";
13
13
  import PolygonalSurface2D from "@ogw_front/assets/img/geode_objects/PolygonalSurface2D.svg";
14
14
  import PolygonalSurface3D from "@ogw_front/assets/img/geode_objects/PolygonalSurface3D.svg";
15
15
  import PolyhedralSolid3D from "@ogw_front/assets/img/geode_objects/PolyhedralSolid3D.svg";
16
+ // oxlint-disable-next-line import/max-dependencies -- one icon import per geode object.
16
17
  import RasterImage2D from "@ogw_front/assets/img/geode_objects/RasterImage2D.svg";
17
18
  import RasterImage3D from "@ogw_front/assets/img/geode_objects/RasterImage3D.svg";
18
19
  import RegularGrid2D from "@ogw_front/assets/img/geode_objects/RegularGrid2D.svg";
@@ -6,6 +6,7 @@ import {
6
6
  } from "@ogw_front/composables/batch_style";
7
7
  import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
8
8
  import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
9
+ import { useBatchStyleModel } from "@ogw_front/composables/batch_style_model";
9
10
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
10
11
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
11
12
 
@@ -28,18 +29,16 @@ const coloring_style_key = computed<string>({
28
29
  hybridViewerStore.remoteRender();
29
30
  },
30
31
  });
31
- const color = computed<RGBAColor | undefined>({
32
- get: () => dataStyleStore.meshEdgesColor(id) as RGBAColor | undefined,
33
- set: async (newValue) => {
34
- if (newValue === undefined) {
35
- return;
36
- }
37
- await applyBatchStyle(id, (targetId: string) =>
38
- dataStyleStore.setMeshEdgesColor(targetId, newValue),
39
- );
40
- hybridViewerStore.remoteRender();
41
- },
42
- });
32
+ const color = useBatchStyleModel<RGBAColor>(
33
+ () => id,
34
+ (targetId) => dataStyleStore.meshEdgesColor(targetId) as RGBAColor | undefined,
35
+ (targetId, value) => dataStyleStore.setMeshEdgesColor(targetId, value),
36
+ );
37
+ const opacity = useBatchStyleModel<number>(
38
+ () => id,
39
+ (targetId) => dataStyleStore.meshEdgesOpacity(targetId),
40
+ (targetId, value) => dataStyleStore.setMeshEdgesOpacity(targetId, value),
41
+ );
43
42
  const vertex_attribute_name = computed<string | undefined>({
44
43
  get: () => dataStyleStore.meshEdgesVertexAttributeName(id),
45
44
  set: async (newValue) => {
@@ -191,6 +190,7 @@ async function setEdgeAttributeRangesPerData(ranges: RangesPerData): Promise<voi
191
190
  :id="id"
192
191
  v-model:coloring_style_key="coloring_style_key"
193
192
  v-model:color="color"
193
+ v-model:opacity="opacity"
194
194
  v-model:vertex_attribute_name="vertex_attribute_name"
195
195
  v-model:vertex_attribute_item="vertex_attribute_item"
196
196
  v-model:vertex_attribute_range="vertex_attribute_range"
@@ -6,6 +6,7 @@ import {
6
6
  } from "@ogw_front/composables/batch_style";
7
7
  import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
8
8
  import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
9
+ import { useBatchStyleModel } from "@ogw_front/composables/batch_style_model";
9
10
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
10
11
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
11
12
 
@@ -33,30 +34,21 @@ const coloring_style_key = computed<string>({
33
34
  hybridViewerStore.remoteRender();
34
35
  },
35
36
  });
36
- const color = computed<RGBAColor | undefined>({
37
- get: () => dataStyleStore.meshCellsColor(id) as RGBAColor | undefined,
38
- set: async (newValue) => {
39
- if (newValue === undefined) {
40
- return;
41
- }
42
- await applyBatchStyle(id, (targetId: string) =>
43
- dataStyleStore.setMeshCellsColor(targetId, newValue),
44
- );
45
- hybridViewerStore.remoteRender();
46
- },
47
- });
48
- const textures = computed<Texture[] | undefined>({
49
- get: () => dataStyleStore.meshCellsTextures(id) as Texture[] | undefined,
50
- set: async (newValue) => {
51
- if (newValue === undefined) {
52
- return;
53
- }
54
- await applyBatchStyle(id, (targetId: string) =>
55
- dataStyleStore.setMeshCellsTextures(targetId, newValue),
56
- );
57
- hybridViewerStore.remoteRender();
58
- },
59
- });
37
+ const color = useBatchStyleModel<RGBAColor>(
38
+ () => id,
39
+ (targetId) => dataStyleStore.meshCellsColor(targetId) as RGBAColor | undefined,
40
+ (targetId, value) => dataStyleStore.setMeshCellsColor(targetId, value),
41
+ );
42
+ const opacity = useBatchStyleModel<number>(
43
+ () => id,
44
+ (targetId) => dataStyleStore.meshCellsOpacity(targetId),
45
+ (targetId, value) => dataStyleStore.setMeshCellsOpacity(targetId, value),
46
+ );
47
+ const textures = useBatchStyleModel<Texture[]>(
48
+ () => id,
49
+ (targetId) => dataStyleStore.meshCellsTextures(targetId) as Texture[] | undefined,
50
+ (targetId, value) => dataStyleStore.setMeshCellsTextures(targetId, value),
51
+ );
60
52
 
61
53
  const vertex_attribute_name = computed<string | undefined>({
62
54
  get: () => dataStyleStore.meshCellsVertexAttributeName(id),
@@ -209,6 +201,7 @@ async function setCellAttributeRangesPerData(ranges: RangesPerData): Promise<voi
209
201
  :id="id"
210
202
  v-model:coloring_style_key="coloring_style_key"
211
203
  v-model:color="color"
204
+ v-model:opacity="opacity"
212
205
  v-model:textures="textures"
213
206
  v-model:vertex_attribute_name="vertex_attribute_name"
214
207
  v-model:vertex_attribute_item="vertex_attribute_item"
@@ -6,6 +6,7 @@ import {
6
6
  } from "@ogw_front/composables/batch_style";
7
7
  import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
8
8
  import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
9
+ import { useBatchStyleModel } from "@ogw_front/composables/batch_style_model";
9
10
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
10
11
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
11
12
 
@@ -29,18 +30,16 @@ const coloring_style_key = computed<string>({
29
30
  hybridViewerStore.remoteRender();
30
31
  },
31
32
  });
32
- const color = computed<RGBAColor | undefined>({
33
- get: () => dataStyleStore.meshEdgesColor(id) as RGBAColor | undefined,
34
- set: async (newValue) => {
35
- if (newValue === undefined) {
36
- return;
37
- }
38
- await applyBatchStyle(id, (targetId: string) =>
39
- dataStyleStore.setMeshEdgesColor(targetId, newValue),
40
- );
41
- hybridViewerStore.remoteRender();
42
- },
43
- });
33
+ const color = useBatchStyleModel<RGBAColor>(
34
+ () => id,
35
+ (targetId) => dataStyleStore.meshEdgesColor(targetId) as RGBAColor | undefined,
36
+ (targetId, value) => dataStyleStore.setMeshEdgesColor(targetId, value),
37
+ );
38
+ const opacity = useBatchStyleModel<number>(
39
+ () => id,
40
+ (targetId) => dataStyleStore.meshEdgesOpacity(targetId),
41
+ (targetId, value) => dataStyleStore.setMeshEdgesOpacity(targetId, value),
42
+ );
44
43
  const vertex_attribute_name = computed<string | undefined>({
45
44
  get: () => dataStyleStore.meshEdgesVertexAttributeName(id),
46
45
  set: async (newValue) => {
@@ -192,6 +191,7 @@ async function setEdgeAttributeRangesPerData(ranges: RangesPerData): Promise<voi
192
191
  :id="id"
193
192
  v-model:coloring_style_key="coloring_style_key"
194
193
  v-model:color="color"
194
+ v-model:opacity="opacity"
195
195
  v-model:vertex_attribute_name="vertex_attribute_name"
196
196
  v-model:vertex_attribute_item="vertex_attribute_item"
197
197
  v-model:vertex_attribute_range="vertex_attribute_range"
@@ -67,6 +67,18 @@ const color = computed<RGBAColor | undefined>({
67
67
  hybridViewerStore.remoteRender();
68
68
  },
69
69
  });
70
+ const opacity = computed<number | undefined>({
71
+ get: () => dataStyleStore.meshPointsOpacity(id.value),
72
+ set: async (newValue) => {
73
+ if (newValue === undefined) {
74
+ return;
75
+ }
76
+ await applyBatchStyle(id.value, (targetId: string) =>
77
+ dataStyleStore.setMeshPointsOpacity(targetId, newValue),
78
+ );
79
+ hybridViewerStore.remoteRender();
80
+ },
81
+ });
70
82
  const vertex_attribute_name = computed<string | undefined>({
71
83
  get: () => dataStyleStore.meshPointsVertexAttributeName(id.value),
72
84
  set: async (newValue) => {
@@ -165,6 +177,7 @@ async function setVertexAttributeRangesPerData(ranges: RangesPerData): Promise<v
165
177
  :id="id"
166
178
  v-model:coloring_style_key="coloring_style_key"
167
179
  v-model:color="color"
180
+ v-model:opacity="opacity"
168
181
  v-model:vertex_attribute_name="vertex_attribute_name"
169
182
  v-model:vertex_attribute_item="vertex_attribute_item"
170
183
  v-model:vertex_attribute_range="vertex_attribute_range"
@@ -6,6 +6,7 @@ import {
6
6
  } from "@ogw_front/composables/batch_style";
7
7
  import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
8
8
  import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
9
+ import { useBatchStyleModel } from "@ogw_front/composables/batch_style_model";
9
10
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
10
11
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
11
12
 
@@ -34,30 +35,21 @@ const coloring_style_key = computed<string>({
34
35
  hybridViewerStore.remoteRender();
35
36
  },
36
37
  });
37
- const color = computed<RGBAColor | undefined>({
38
- get: () => dataStyleStore.meshPolygonsColor(id) as RGBAColor | undefined,
39
- set: async (newValue) => {
40
- if (newValue === undefined) {
41
- return;
42
- }
43
- await applyBatchStyle(id, (targetId: string) =>
44
- dataStyleStore.setMeshPolygonsColor(targetId, newValue),
45
- );
46
- hybridViewerStore.remoteRender();
47
- },
48
- });
49
- const textures = computed<Texture[] | undefined>({
50
- get: () => dataStyleStore.meshPolygonsTextures(id) as Texture[] | undefined,
51
- set: async (newValue) => {
52
- if (newValue === undefined) {
53
- return;
54
- }
55
- await applyBatchStyle(id, (targetId: string) =>
56
- dataStyleStore.setMeshPolygonsTextures(targetId, newValue),
57
- );
58
- hybridViewerStore.remoteRender();
59
- },
60
- });
38
+ const color = useBatchStyleModel<RGBAColor>(
39
+ () => id,
40
+ (targetId) => dataStyleStore.meshPolygonsColor(targetId) as RGBAColor | undefined,
41
+ (targetId, value) => dataStyleStore.setMeshPolygonsColor(targetId, value),
42
+ );
43
+ const opacity = useBatchStyleModel<number>(
44
+ () => id,
45
+ (targetId) => dataStyleStore.meshPolygonsOpacity(targetId),
46
+ (targetId, value) => dataStyleStore.setMeshPolygonsOpacity(targetId, value),
47
+ );
48
+ const textures = useBatchStyleModel<Texture[]>(
49
+ () => id,
50
+ (targetId) => dataStyleStore.meshPolygonsTextures(targetId) as Texture[] | undefined,
51
+ (targetId, value) => dataStyleStore.setMeshPolygonsTextures(targetId, value),
52
+ );
61
53
 
62
54
  const vertex_attribute_name = computed<string | undefined>({
63
55
  get: () => dataStyleStore.meshPolygonsVertexAttributeName(id),
@@ -214,6 +206,7 @@ async function setPolygonAttributeRangesPerData(ranges: RangesPerData): Promise<
214
206
  :id="id"
215
207
  v-model:coloring_style_key="coloring_style_key"
216
208
  v-model:color="color"
209
+ v-model:opacity="opacity"
217
210
  v-model:textures="textures"
218
211
  v-model:vertex_attribute_name="vertex_attribute_name"
219
212
  v-model:vertex_attribute_item="vertex_attribute_item"
@@ -6,6 +6,7 @@ import {
6
6
  } from "@ogw_front/composables/batch_style";
7
7
  import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
8
8
  import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
9
+ import { useBatchStyleModel } from "@ogw_front/composables/batch_style_model";
9
10
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
10
11
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
11
12
 
@@ -28,18 +29,16 @@ const coloring_style_key = computed<string>({
28
29
  hybridViewerStore.remoteRender();
29
30
  },
30
31
  });
31
- const color = computed<RGBAColor | undefined>({
32
- get: () => dataStyleStore.meshPolyhedraColor(id) as RGBAColor | undefined,
33
- set: async (newValue) => {
34
- if (newValue === undefined) {
35
- return;
36
- }
37
- await applyBatchStyle(id, (targetId: string) =>
38
- dataStyleStore.setMeshPolyhedraColor(targetId, newValue),
39
- );
40
- hybridViewerStore.remoteRender();
41
- },
42
- });
32
+ const color = useBatchStyleModel<RGBAColor>(
33
+ () => id,
34
+ (targetId) => dataStyleStore.meshPolyhedraColor(targetId) as RGBAColor | undefined,
35
+ (targetId, value) => dataStyleStore.setMeshPolyhedraColor(targetId, value),
36
+ );
37
+ const opacity = useBatchStyleModel<number>(
38
+ () => id,
39
+ (targetId) => dataStyleStore.meshPolyhedraOpacity(targetId),
40
+ (targetId, value) => dataStyleStore.setMeshPolyhedraOpacity(targetId, value),
41
+ );
43
42
  const vertex_attribute_name = computed<string | undefined>({
44
43
  get: () => dataStyleStore.meshPolyhedraVertexAttributeName(id),
45
44
  set: async (newValue) => {
@@ -199,6 +198,7 @@ async function setPolyhedronAttributeRangesPerData(ranges: RangesPerData): Promi
199
198
  :id="id"
200
199
  v-model:coloring_style_key="coloring_style_key"
201
200
  v-model:color="color"
201
+ v-model:opacity="opacity"
202
202
  v-model:vertex_attribute_name="vertex_attribute_name"
203
203
  v-model:vertex_attribute_item="vertex_attribute_item"
204
204
  v-model:vertex_attribute_range="vertex_attribute_range"
@@ -9,6 +9,7 @@ import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
9
9
  import type { RangesPerData } from "@ogw_front/composables/batch_style";
10
10
  import ViewerOptionsAttributeSelector from "@ogw_front/components/Viewer/Options/AttributeSelector.vue";
11
11
  import ViewerOptionsColorPicker from "@ogw_front/components/Viewer/Options/ColorPicker.vue";
12
+ import ViewerOptionsOpacitySlider from "@ogw_front/components/Viewer/Options/Sliders/Opacity.vue";
12
13
  import ViewerOptionsTexturesSelector from "@ogw_front/components/Viewer/Options/TexturesSelector.vue";
13
14
 
14
15
  interface Texture {
@@ -34,6 +35,7 @@ interface Emits {
34
35
  const emit = defineEmits<Emits>();
35
36
 
36
37
  const color = defineModel<RGBAColor>("color");
38
+ const opacity = defineModel<number>("opacity");
37
39
  const textures = defineModel<Texture[]>("textures");
38
40
 
39
41
  const vertex_attribute_name = defineModel<string>("vertex_attribute_name");
@@ -169,6 +171,11 @@ const active_key = computed<string | undefined>(() => {
169
171
  return index === -1 ? coloring_style_key.value : coloring_styles.value.values[index];
170
172
  });
171
173
 
174
+ // The constant color picker already edits the opacity as its alpha
175
+ const has_opacity = computed<boolean>(
176
+ () => opacity.value !== undefined && active_key.value !== color_dict.value,
177
+ );
178
+
172
179
  watch(
173
180
  [
174
181
  coloring_style_label,
@@ -304,4 +311,9 @@ watch(
304
311
  </template>
305
312
  </v-col>
306
313
  </v-row>
314
+ <v-row v-if="has_opacity" class="mt-2" no-gutters>
315
+ <v-col cols="12">
316
+ <ViewerOptionsOpacitySlider v-model="opacity" />
317
+ </v-col>
318
+ </v-row>
307
319
  </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ const opacity = defineModel<number>();
3
+ </script>
4
+
5
+ <template>
6
+ <v-row align="center" no-gutters class="px-2">
7
+ <v-col cols="auto" class="mr-2">
8
+ <v-icon size="18" icon="mdi-circle-opacity" v-tooltip:left="'Opacity'" />
9
+ </v-col>
10
+ <v-col>
11
+ <v-slider
12
+ data-testid="opacitySlider"
13
+ v-model="opacity"
14
+ hide-details
15
+ min="0"
16
+ max="1"
17
+ step="0.05"
18
+ density="compact"
19
+ />
20
+ </v-col>
21
+ </v-row>
22
+ </template>
@@ -72,6 +72,18 @@ const color = computed<RGBAColor | undefined>({
72
72
  hybridViewerStore.remoteRender();
73
73
  },
74
74
  });
75
+ const opacity = computed<number | undefined>({
76
+ get: () => dataStyleStore.meshPointsOpacity(id.value),
77
+ set: async (newValue) => {
78
+ if (newValue === undefined) {
79
+ return;
80
+ }
81
+ await applyBatchStyle(id.value, (targetId: string) =>
82
+ dataStyleStore.setMeshPointsOpacity(targetId, newValue),
83
+ );
84
+ hybridViewerStore.remoteRender();
85
+ },
86
+ });
75
87
  const vertex_attribute_name = computed({
76
88
  get: () => dataStyleStore.meshPointsVertexAttributeName(id.value),
77
89
  set: async (newValue) => {
@@ -165,6 +177,7 @@ async function setVertexAttributeRangesPerData(ranges: RangesPerData): Promise<v
165
177
  :id="id"
166
178
  v-model:coloring_style_key="coloring_style_key"
167
179
  v-model:color="color"
180
+ v-model:opacity="opacity"
168
181
  v-model:vertex_attribute_name="vertex_attribute_name"
169
182
  v-model:vertex_attribute_item="vertex_attribute_item"
170
183
  v-model:vertex_attribute_range="vertex_attribute_range"
@@ -6,6 +6,7 @@ import {
6
6
  } from "@ogw_front/composables/batch_style";
7
7
  import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
8
8
  import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
9
+ import { useBatchStyleModel } from "@ogw_front/composables/batch_style_model";
9
10
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
10
11
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
11
12
 
@@ -28,18 +29,16 @@ const coloring_style_key = computed<string>({
28
29
  hybridViewerStore.remoteRender();
29
30
  },
30
31
  });
31
- const color = computed<RGBAColor | undefined>({
32
- get: () => dataStyleStore.meshPolyhedraColor(id) as RGBAColor | undefined,
33
- set: async (newValue) => {
34
- if (newValue === undefined) {
35
- return;
36
- }
37
- await applyBatchStyle(id, (targetId: string) =>
38
- dataStyleStore.setMeshPolyhedraColor(targetId, newValue),
39
- );
40
- hybridViewerStore.remoteRender();
41
- },
42
- });
32
+ const color = useBatchStyleModel<RGBAColor>(
33
+ () => id,
34
+ (targetId) => dataStyleStore.meshPolyhedraColor(targetId) as RGBAColor | undefined,
35
+ (targetId, value) => dataStyleStore.setMeshPolyhedraColor(targetId, value),
36
+ );
37
+ const opacity = useBatchStyleModel<number>(
38
+ () => id,
39
+ (targetId) => dataStyleStore.meshPolyhedraOpacity(targetId),
40
+ (targetId, value) => dataStyleStore.setMeshPolyhedraOpacity(targetId, value),
41
+ );
43
42
  const vertex_attribute_name = computed<string | undefined>({
44
43
  get: () => dataStyleStore.meshPolyhedraVertexAttributeName(id),
45
44
  set: async (newValue) => {
@@ -199,6 +198,7 @@ async function setPolyhedronAttributeRangesPerData(ranges: RangesPerData): Promi
199
198
  :id="id"
200
199
  v-model:coloring_style_key="coloring_style_key"
201
200
  v-model:color="color"
201
+ v-model:opacity="opacity"
202
202
  v-model:vertex_attribute_name="vertex_attribute_name"
203
203
  v-model:vertex_attribute_item="vertex_attribute_item"
204
204
  v-model:vertex_attribute_range="vertex_attribute_range"
@@ -6,6 +6,7 @@ import {
6
6
  } from "@ogw_front/composables/batch_style";
7
7
  import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
8
8
  import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
9
+ import { useBatchStyleModel } from "@ogw_front/composables/batch_style_model";
9
10
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
10
11
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
11
12
 
@@ -33,30 +34,21 @@ const coloring_style_key = computed<string>({
33
34
  hybridViewerStore.remoteRender();
34
35
  },
35
36
  });
36
- const color = computed<RGBAColor | undefined>({
37
- get: () => dataStyleStore.meshPolygonsColor(id) as RGBAColor | undefined,
38
- set: async (newValue) => {
39
- if (newValue === undefined) {
40
- return;
41
- }
42
- await applyBatchStyle(id, (targetId: string) =>
43
- dataStyleStore.setMeshPolygonsColor(targetId, newValue),
44
- );
45
- hybridViewerStore.remoteRender();
46
- },
47
- });
48
- const textures = computed<Texture[] | undefined>({
49
- get: () => dataStyleStore.meshPolygonsTextures(id) as Texture[] | undefined,
50
- set: async (newValue) => {
51
- if (newValue === undefined) {
52
- return;
53
- }
54
- await applyBatchStyle(id, (targetId: string) =>
55
- dataStyleStore.setMeshPolygonsTextures(targetId, newValue),
56
- );
57
- hybridViewerStore.remoteRender();
58
- },
59
- });
37
+ const color = useBatchStyleModel<RGBAColor>(
38
+ () => id,
39
+ (targetId) => dataStyleStore.meshPolygonsColor(targetId) as RGBAColor | undefined,
40
+ (targetId, value) => dataStyleStore.setMeshPolygonsColor(targetId, value),
41
+ );
42
+ const opacity = useBatchStyleModel<number>(
43
+ () => id,
44
+ (targetId) => dataStyleStore.meshPolygonsOpacity(targetId),
45
+ (targetId, value) => dataStyleStore.setMeshPolygonsOpacity(targetId, value),
46
+ );
47
+ const textures = useBatchStyleModel<Texture[]>(
48
+ () => id,
49
+ (targetId) => dataStyleStore.meshPolygonsTextures(targetId) as Texture[] | undefined,
50
+ (targetId, value) => dataStyleStore.setMeshPolygonsTextures(targetId, value),
51
+ );
60
52
  const vertex_attribute_name = computed<string | undefined>({
61
53
  get: () => dataStyleStore.meshPolygonsVertexAttributeName(id),
62
54
  set: async (newValue) => {
@@ -212,6 +204,7 @@ async function setPolygonAttributeRangesPerData(ranges: RangesPerData): Promise<
212
204
  :id="id"
213
205
  v-model:coloring_style_key="coloring_style_key"
214
206
  v-model:color="color"
207
+ v-model:opacity="opacity"
215
208
  v-model:textures="textures"
216
209
  v-model:vertex_attribute_name="vertex_attribute_name"
217
210
  v-model:vertex_attribute_item="vertex_attribute_item"
@@ -1,5 +1,4 @@
1
1
  <script setup lang="ts">
2
- // oxlint-disable max-dependencies
3
2
  import {
4
3
  type ViewerIdResult,
5
4
  useOverlappingPicker,
@@ -0,0 +1,34 @@
1
+ import { type MaybeRefOrGetter, type WritableComputedRef, computed, toValue } from "vue";
2
+ import { useBatchStyle } from "@ogw_front/composables/batch_style";
3
+ import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
4
+
5
+ // A style model applied to the whole batch of the data, then rendered
6
+ function useBatchStyleModel<Value>(
7
+ id: MaybeRefOrGetter<string>,
8
+ getter: (id: string) => Value | undefined,
9
+ setter: (id: string, value: Value) => Promise<unknown>,
10
+ ): WritableComputedRef<Value | undefined> {
11
+ const hybridViewerStore = useHybridViewerStore();
12
+ const { applyBatchStyle } = useBatchStyle();
13
+
14
+ async function applyValue(value: Value): Promise<void> {
15
+ await applyBatchStyle(toValue(id), async (targetId: string) => {
16
+ await setter(targetId, value);
17
+ });
18
+ await hybridViewerStore.remoteRender();
19
+ }
20
+
21
+ return computed<Value | undefined>({
22
+ get: () => getter(toValue(id)),
23
+ // Vue's WritableComputedOptions setter is strictly `(v: T) => void`: the async write is delegated.
24
+ set: (newValue: Value | undefined): void => {
25
+ if (newValue === undefined) {
26
+ return;
27
+ }
28
+ /* oxlint-disable-next-line promise/prefer-await-to-then -- setter cannot be async; see comment above. */
29
+ applyValue(newValue).catch(() => undefined);
30
+ },
31
+ });
32
+ }
33
+
34
+ export { useBatchStyleModel };