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

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 (106) hide show
  1. package/.build/server/utils/microservices.js +9 -85
  2. package/.build/server/utils/microservices_process.js +85 -0
  3. package/app/components/ClippingPlanes.vue +16 -82
  4. package/app/components/DragAndDrop.vue +1 -74
  5. package/app/components/ThresholdCard.vue +205 -0
  6. package/app/components/ThresholdFilter.vue +77 -216
  7. package/app/components/ViewToolbar.vue +15 -231
  8. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
  9. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
  10. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +228 -0
  11. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
  12. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
  13. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
  14. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +234 -0
  15. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
  16. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
  17. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
  18. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
  19. package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
  20. package/app/components/Viewer/Generic/Model/CornersOptions.vue +13 -294
  21. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
  22. package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
  23. package/app/components/Viewer/Generic/Model/LinesOptions.vue +13 -425
  24. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
  25. package/app/components/Viewer/Options/AttributeSelector.vue +26 -133
  26. package/app/components/Viewer/Options/ColoringTypeSelector.vue +36 -74
  27. package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
  28. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
  29. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
  30. package/app/components/Viewer/Surface/PolygonsColoring.vue +231 -0
  31. package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
  32. package/app/composables/attribute_selector.ts +126 -0
  33. package/app/composables/clipping_slices.ts +166 -0
  34. package/app/composables/view_toolbar_options.ts +126 -0
  35. package/app/composables/view_toolbar_tool_options.ts +115 -0
  36. package/app/composables/view_toolbar_tools.ts +108 -0
  37. package/app/composables/virtual_tree.ts +20 -138
  38. package/app/composables/virtual_tree_flatten.ts +86 -0
  39. package/app/composables/virtual_tree_types.ts +81 -0
  40. package/app/stores/app.ts +8 -55
  41. package/app/stores/app_helpers/registry.ts +69 -0
  42. package/app/stores/menu.ts +1 -124
  43. package/app/stores/menu_helpers/menus_data.ts +127 -0
  44. package/app/stores/viewer.ts +17 -78
  45. package/app/stores/viewer_helpers/actions.ts +68 -0
  46. package/app/stores/viewer_helpers/request.ts +61 -0
  47. package/app/utils/clipping_planes.ts +4 -132
  48. package/app/utils/clipping_planes_scene.ts +131 -0
  49. package/app/utils/coloring_styles.ts +101 -0
  50. package/app/utils/default_styles/mesh_components.ts +168 -0
  51. package/app/utils/default_styles/meshes.ts +13 -153
  52. package/app/utils/default_styles/model_components.ts +170 -0
  53. package/app/utils/default_styles/models.ts +16 -153
  54. package/app/utils/drag_and_drop.ts +80 -0
  55. package/app/utils/model_component_coloring.ts +46 -0
  56. package/app/utils/threshold.ts +33 -0
  57. package/app/utils/threshold_sources.ts +51 -0
  58. package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
  59. package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
  60. package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
  61. package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
  62. package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
  63. package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
  64. package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
  65. package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
  66. package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
  67. package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
  68. package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
  69. package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
  70. package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
  71. package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
  72. package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
  73. package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
  74. package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
  75. package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
  76. package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
  77. package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
  78. package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
  79. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
  80. package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
  81. package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
  82. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
  83. package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
  84. package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
  85. package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
  86. package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
  87. package/internal/stores/data_style/model/blocks/index.ts +12 -140
  88. package/internal/stores/data_style/model/common.ts +10 -119
  89. package/internal/stores/data_style/model/common_mutations.ts +184 -0
  90. package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
  91. package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
  92. package/internal/stores/data_style/model/lines/index.ts +10 -134
  93. package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
  94. package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
  95. package/internal/stores/data_style/model/surfaces/index.ts +16 -160
  96. package/internal/stores/data_style/model/visibility.ts +3 -156
  97. package/internal/stores/data_style/model/visibility_dispatch.ts +160 -0
  98. package/internal/stores/data_style/state.ts +1 -181
  99. package/internal/stores/data_style/state_shared.ts +191 -0
  100. package/internal/stores/hybrid_viewer/camera.ts +7 -161
  101. package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
  102. package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
  103. package/internal/stores/hybrid_viewer/filters.ts +54 -11
  104. package/package.json +1 -1
  105. package/server/utils/microservices.ts +10 -109
  106. package/server/utils/microservices_process.ts +127 -0
@@ -1,16 +1,11 @@
1
1
  <script setup lang="ts">
2
- import {
3
- type RangesPerData,
4
- applyRangesPerData,
5
- useBatchStyle,
6
- } from "@ogw_front/composables/batch_style";
7
2
  import ViewerContextMenuItem, {
8
3
  type ItemProps,
9
4
  } from "@ogw_front/components/Viewer/ContextMenu/ContextMenuItem.vue";
10
5
  import PolygonalSurfacePolygons from "@ogw_front/assets/viewer_svgs/surface_triangles.svg";
11
- import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
12
- import ViewerOptionsColoringTypeSelector from "@ogw_front/components/Viewer/Options/ColoringTypeSelector.vue";
13
6
  import ViewerOptionsVisibilitySwitch from "@ogw_front/components/Viewer/Options/VisibilitySwitch.vue";
7
+ import ViewerSurfacePolygonsColoring from "@ogw_front/components/Viewer/Surface/PolygonsColoring.vue";
8
+ import { useBatchStyle } from "@ogw_front/composables/batch_style";
14
9
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
15
10
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
16
11
 
@@ -18,11 +13,6 @@ const dataStyleStore = useDataStyleStore();
18
13
  const hybridViewerStore = useHybridViewerStore();
19
14
  const { applyBatchStyle } = useBatchStyle();
20
15
 
21
- interface Texture {
22
- id: string;
23
- texture_name: string;
24
- }
25
-
26
16
  interface Props {
27
17
  itemProps: ItemProps & { index: number };
28
18
  tooltip?: string;
@@ -41,187 +31,6 @@ const visibility = computed<boolean>({
41
31
  hybridViewerStore.remoteRender();
42
32
  },
43
33
  });
44
- const coloring_style_key = computed<string>({
45
- get: () => dataStyleStore.meshPolygonsActiveColoring(id.value),
46
- set: async (newValue) => {
47
- await applyBatchStyle(id.value, (targetId: string) =>
48
- dataStyleStore.setMeshPolygonsActiveColoring(targetId, newValue),
49
- );
50
- hybridViewerStore.remoteRender();
51
- },
52
- });
53
- const color = computed<RGBAColor | undefined>({
54
- get: () => dataStyleStore.meshPolygonsColor(id.value) as RGBAColor | undefined,
55
- set: async (newValue) => {
56
- if (newValue === undefined) {
57
- return;
58
- }
59
- await applyBatchStyle(id.value, (targetId: string) =>
60
- dataStyleStore.setMeshPolygonsColor(targetId, newValue),
61
- );
62
- hybridViewerStore.remoteRender();
63
- },
64
- });
65
- const textures = computed<Texture[] | undefined>({
66
- get: () => dataStyleStore.meshPolygonsTextures(id.value) as Texture[] | undefined,
67
- set: async (newValue) => {
68
- if (newValue === undefined) {
69
- return;
70
- }
71
- await applyBatchStyle(id.value, (targetId: string) =>
72
- dataStyleStore.setMeshPolygonsTextures(targetId, newValue),
73
- );
74
- hybridViewerStore.remoteRender();
75
- },
76
- });
77
- const vertex_attribute_name = computed<string | undefined>({
78
- get: () => dataStyleStore.meshPolygonsVertexAttributeName(id.value),
79
- set: async (newValue) => {
80
- if (newValue === undefined) {
81
- return;
82
- }
83
- await applyBatchStyle(id.value, (targetId: string) =>
84
- Promise.resolve(dataStyleStore.setMeshPolygonsVertexAttributeName(targetId, newValue)),
85
- );
86
- hybridViewerStore.remoteRender();
87
- },
88
- });
89
-
90
- const vertex_attribute_time_step = computed<number | undefined>({
91
- get: () => dataStyleStore.meshPolygonsVertexAttributeTimeStep(id.value),
92
- set: async (newValue) => {
93
- if (newValue === undefined) {
94
- return;
95
- }
96
- await applyBatchStyle(id.value, (targetId: string) =>
97
- Promise.resolve(dataStyleStore.setMeshPolygonsVertexAttributeTimeStep(targetId, newValue)),
98
- );
99
- hybridViewerStore.remoteRender();
100
- },
101
- });
102
- const vertex_attribute_item = computed<string | undefined>({
103
- get: () => dataStyleStore.meshPolygonsVertexAttributeItem(id.value),
104
- set: async (newValue) => {
105
- await applyBatchStyle(id.value, (targetId: string) =>
106
- Promise.resolve(dataStyleStore.setMeshPolygonsVertexAttributeItem(targetId, newValue)),
107
- );
108
- hybridViewerStore.remoteRender();
109
- },
110
- });
111
- const vertex_attribute_range = computed<[number, number] | undefined>({
112
- get: () => dataStyleStore.meshPolygonsVertexAttributeRange(id.value),
113
- set: async (newValue) => {
114
- const [minimum, maximum] = newValue;
115
- if (minimum === undefined || maximum === undefined) {
116
- return;
117
- }
118
- await applyBatchStyle(id.value, (targetId: string) =>
119
- Promise.resolve(
120
- dataStyleStore.setMeshPolygonsVertexAttributeRange(targetId, minimum, maximum),
121
- ),
122
- );
123
- hybridViewerStore.remoteRender();
124
- },
125
- });
126
- const vertex_attribute_color_map = computed<Map<string, RGBAColor> | undefined>({
127
- get: () => dataStyleStore.meshPolygonsVertexAttributeColorMap(id.value),
128
- set: async (newValue) => {
129
- await applyBatchStyle(id.value, (targetId: string) =>
130
- Promise.resolve(dataStyleStore.setMeshPolygonsVertexAttributeColorMap(targetId, newValue)),
131
- );
132
- hybridViewerStore.remoteRender();
133
- },
134
- });
135
- const vertex_attribute_no_data_color = computed<RGBAColor>({
136
- get: () => dataStyleStore.meshPolygonsVertexAttributeNoDataColor(id.value),
137
- set: async (newValue) => {
138
- await applyBatchStyle(id.value, (targetId: string) =>
139
- dataStyleStore.setMeshPolygonsVertexAttributeNoDataColor(targetId, newValue),
140
- );
141
- hybridViewerStore.remoteRender();
142
- },
143
- });
144
- const polygon_attribute_name = computed<string | undefined>({
145
- get: () => dataStyleStore.meshPolygonsPolygonAttributeName(id.value),
146
- set: async (newValue) => {
147
- if (newValue === undefined) {
148
- return;
149
- }
150
- await applyBatchStyle(id.value, (targetId: string) =>
151
- Promise.resolve(dataStyleStore.setMeshPolygonsPolygonAttributeName(targetId, newValue)),
152
- );
153
- hybridViewerStore.remoteRender();
154
- },
155
- });
156
-
157
- const polygon_attribute_time_step = computed<number | undefined>({
158
- get: () => dataStyleStore.meshPolygonsPolygonAttributeTimeStep(id.value),
159
- set: async (newValue) => {
160
- if (newValue === undefined) {
161
- return;
162
- }
163
- await applyBatchStyle(id.value, (targetId: string) =>
164
- Promise.resolve(dataStyleStore.setMeshPolygonsPolygonAttributeTimeStep(targetId, newValue)),
165
- );
166
- hybridViewerStore.remoteRender();
167
- },
168
- });
169
- const polygon_attribute_item = computed<string | undefined>({
170
- get: () => dataStyleStore.meshPolygonsPolygonAttributeItem(id.value),
171
- set: async (newValue) => {
172
- await applyBatchStyle(id.value, (targetId: string) =>
173
- Promise.resolve(dataStyleStore.setMeshPolygonsPolygonAttributeItem(targetId, newValue)),
174
- );
175
- hybridViewerStore.remoteRender();
176
- },
177
- });
178
- const polygon_attribute_range = computed<[number, number] | undefined>({
179
- get: () => dataStyleStore.meshPolygonsPolygonAttributeRange(id.value),
180
- set: async (newValue) => {
181
- const [minimum, maximum] = newValue;
182
- if (minimum === undefined || maximum === undefined) {
183
- return;
184
- }
185
- await applyBatchStyle(id.value, (targetId: string) =>
186
- Promise.resolve(
187
- dataStyleStore.setMeshPolygonsPolygonAttributeRange(targetId, minimum, maximum),
188
- ),
189
- );
190
- hybridViewerStore.remoteRender();
191
- },
192
- });
193
- const polygon_attribute_color_map = computed<Map<string, RGBAColor> | undefined>({
194
- get: () => dataStyleStore.meshPolygonsPolygonAttributeColorMap(id.value),
195
- set: async (newValue) => {
196
- await applyBatchStyle(id.value, (targetId: string) =>
197
- Promise.resolve(dataStyleStore.setMeshPolygonsPolygonAttributeColorMap(targetId, newValue)),
198
- );
199
- hybridViewerStore.remoteRender();
200
- },
201
- });
202
- const polygon_attribute_no_data_color = computed<RGBAColor>({
203
- get: () => dataStyleStore.meshPolygonsPolygonAttributeNoDataColor(id.value),
204
- set: async (newValue) => {
205
- await applyBatchStyle(id.value, (targetId: string) =>
206
- dataStyleStore.setMeshPolygonsPolygonAttributeNoDataColor(targetId, newValue),
207
- );
208
- hybridViewerStore.remoteRender();
209
- },
210
- });
211
-
212
- async function setVertexAttributeRangesPerData(ranges: RangesPerData): Promise<void> {
213
- await applyRangesPerData(ranges, (targetId, minimum, maximum) =>
214
- dataStyleStore.setMeshPolygonsVertexAttributeRange(targetId, minimum, maximum),
215
- );
216
- hybridViewerStore.remoteRender();
217
- }
218
-
219
- async function setPolygonAttributeRangesPerData(ranges: RangesPerData): Promise<void> {
220
- await applyRangesPerData(ranges, (targetId, minimum, maximum) =>
221
- dataStyleStore.setMeshPolygonsPolygonAttributeRange(targetId, minimum, maximum),
222
- );
223
- hybridViewerStore.remoteRender();
224
- }
225
34
  </script>
226
35
 
227
36
  <template>
@@ -238,26 +47,7 @@ async function setPolygonAttributeRangesPerData(ranges: RangesPerData): Promise<
238
47
  v-model="visibility"
239
48
  />
240
49
  <template v-if="visibility">
241
- <ViewerOptionsColoringTypeSelector
242
- :id="id"
243
- v-model:coloring_style_key="coloring_style_key"
244
- v-model:color="color"
245
- v-model:textures="textures"
246
- v-model:vertex_attribute_name="vertex_attribute_name"
247
- v-model:vertex_attribute_item="vertex_attribute_item"
248
- v-model:vertex_attribute_range="vertex_attribute_range"
249
- @vertex_attribute_ranges_per_data="setVertexAttributeRangesPerData"
250
- v-model:vertex_attribute_color_map="vertex_attribute_color_map"
251
- v-model:vertex_attribute_no_data_color="vertex_attribute_no_data_color"
252
- v-model:vertex_attribute_time_step="vertex_attribute_time_step"
253
- v-model:polygon_attribute_name="polygon_attribute_name"
254
- v-model:polygon_attribute_item="polygon_attribute_item"
255
- v-model:polygon_attribute_range="polygon_attribute_range"
256
- @polygon_attribute_ranges_per_data="setPolygonAttributeRangesPerData"
257
- v-model:polygon_attribute_color_map="polygon_attribute_color_map"
258
- v-model:polygon_attribute_no_data_color="polygon_attribute_no_data_color"
259
- v-model:polygon_attribute_time_step="polygon_attribute_time_step"
260
- />
50
+ <ViewerSurfacePolygonsColoring :id="id" />
261
51
  </template>
262
52
  </template>
263
53
  </ViewerContextMenuItem>
@@ -0,0 +1,126 @@
1
+ import type { AttributeRangeInfo, AttributeSchemas } from "@ogw_front/utils/attribute_range";
2
+ import type { AttributeRange } from "@ogw_front/composables/batch_style";
3
+ import { getAttributeRange } from "@ogw_front/utils/attributes";
4
+
5
+ interface AttributeInfo {
6
+ attribute_name: string;
7
+ nb_items: number;
8
+ time_steps?: number[];
9
+ [key: string]: unknown;
10
+ }
11
+
12
+ // The minimum and maximum of an attribute range: each one is clamped by the other
13
+ function useAttributeRangeBounds(attributeRange: Ref<(number | undefined)[]>): {
14
+ rangeMin: WritableComputedRef<number | undefined>;
15
+ rangeMax: WritableComputedRef<number | undefined>;
16
+ } {
17
+ const rangeMin = computed<number | undefined>({
18
+ get: () => attributeRange.value[0],
19
+ set: (val: number | undefined) => {
20
+ if (val === undefined) {
21
+ return;
22
+ }
23
+ const [, currentMax] = attributeRange.value;
24
+ let newMin = val;
25
+ if (typeof currentMax === "number" && val > currentMax) {
26
+ newMin = currentMax;
27
+ }
28
+ attributeRange.value = [newMin, currentMax];
29
+ },
30
+ });
31
+ const rangeMax = computed<number | undefined>({
32
+ get: () => attributeRange.value[1],
33
+ set: (val: number | undefined) => {
34
+ if (val === undefined) {
35
+ return;
36
+ }
37
+ const [currentMin] = attributeRange.value;
38
+ let newMax = val;
39
+ if (typeof currentMin === "number" && val < currentMin) {
40
+ newMax = currentMin;
41
+ }
42
+ attributeRange.value = [currentMin, newMax];
43
+ },
44
+ });
45
+ return { rangeMin, rangeMax };
46
+ }
47
+
48
+ // The items of an attribute with several components
49
+ function attributeItemOptions(itemCount: number): { title: string; value: number }[] {
50
+ return Array.from({ length: itemCount }, (_, index) => ({
51
+ title: `Item ${index + 1}`,
52
+ value: index,
53
+ }));
54
+ }
55
+
56
+ // The range of every target for the picked item
57
+ function attributeRangesPerTarget(
58
+ rangesPerTarget: ReadonlyMap<string, AttributeRangeInfo>,
59
+ item: number,
60
+ ): Map<string, AttributeRange> {
61
+ const ranges = new Map<string, AttributeRange>();
62
+ for (const [targetId, range] of rangesPerTarget) {
63
+ const { min, max } = getAttributeRange(range, item);
64
+ ranges.set(targetId, [min, max]);
65
+ }
66
+ return ranges;
67
+ }
68
+
69
+ // Commits the first time step when the picked series changes and the stored one is not valid
70
+ function useSeriesTimeStepCommit(
71
+ timeSteps: ComputedRef<number[]>,
72
+ seriesName: () => string | undefined,
73
+ attributeTimeStep: Readonly<Ref<number | undefined>>,
74
+ resetTimeStep: () => void,
75
+ ): () => void {
76
+ let committedSeries: string | undefined = undefined;
77
+
78
+ return (): void => {
79
+ if (timeSteps.value.length === 0) {
80
+ committedSeries = undefined;
81
+ return;
82
+ }
83
+ const name = seriesName();
84
+ if (name === committedSeries) {
85
+ return;
86
+ }
87
+ committedSeries = name;
88
+ const current = attributeTimeStep.value;
89
+ const valid = current !== undefined && current >= 0 && current < timeSteps.value.length;
90
+ // A valid step is already stored and applied with the series: emitting it again re-applies the attribute
91
+ if (!valid) {
92
+ resetTimeStep();
93
+ }
94
+ };
95
+ }
96
+
97
+ interface AttributeRequestParams {
98
+ id: string;
99
+ component_ids?: string[];
100
+ }
101
+
102
+ // Params of the "names" request, or undefined when the schema needs components and none is selected
103
+ function attributeRequestParams(
104
+ schemas: AttributeSchemas,
105
+ id: string,
106
+ componentIds: string[] | undefined,
107
+ ): AttributeRequestParams | undefined {
108
+ const { properties } = schemas.names;
109
+ if (typeof properties !== "object" || properties === null || !("component_ids" in properties)) {
110
+ return { id };
111
+ }
112
+ if (!Array.isArray(componentIds) || componentIds.length === 0) {
113
+ return undefined;
114
+ }
115
+ return { id, component_ids: componentIds };
116
+ }
117
+
118
+ export {
119
+ type AttributeInfo,
120
+ type AttributeRequestParams,
121
+ attributeItemOptions,
122
+ attributeRequestParams,
123
+ attributeRangesPerTarget,
124
+ useAttributeRangeBounds,
125
+ useSeriesTimeStepCommit,
126
+ };
@@ -0,0 +1,166 @@
1
+ import {
2
+ DEFAULT_SLICE_AXIS,
3
+ SLICE_AXES,
4
+ type SliceAxis,
5
+ areAllGrids,
6
+ } from "@ogw_front/utils/slice";
7
+ import type { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
8
+
9
+ interface Slice {
10
+ id: number;
11
+ axis: SliceAxis;
12
+ index: number;
13
+ }
14
+
15
+ interface SliceList {
16
+ sliceEnabled: Ref<boolean>;
17
+ slices: Ref<Slice[]>;
18
+ addSlice: () => void;
19
+ removeSlice: (index: number) => void;
20
+ resetSlices: () => void;
21
+ }
22
+
23
+ interface SliceSyncParams {
24
+ slices: Ref<Slice[]>;
25
+ sliceMaxIndices: Ref<[number, number, number]>;
26
+ isAllGrid: ComputedRef<boolean>;
27
+ isSliceActive: ComputedRef<boolean>;
28
+ targetIds: ComputedRef<string[]>;
29
+ getUntargetedIds: () => string[];
30
+ hybridViewerStore: ReturnType<typeof useHybridViewerStore>;
31
+ }
32
+
33
+ interface ClippingSlicesParams {
34
+ allItems: ComputedRef<{ id: string; geode_object_type: string }[]>;
35
+ targetIds: ComputedRef<string[]>;
36
+ getUntargetedIds: () => string[];
37
+ newItemId: () => number;
38
+ hybridViewerStore: ReturnType<typeof useHybridViewerStore>;
39
+ }
40
+
41
+ interface ClippingSlices extends SliceList {
42
+ sliceMaxIndices: Ref<[number, number, number]>;
43
+ isAllGrid: ComputedRef<boolean>;
44
+ isSliceActive: ComputedRef<boolean>;
45
+ applySlices: () => Promise<void>;
46
+ removeSlices: (allIds: string[]) => Promise<void>;
47
+ }
48
+
49
+ function useSliceList(newItemId: () => number): SliceList {
50
+ const sliceEnabled = ref<boolean>(false);
51
+ const slices = ref<Slice[]>([{ id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 }]);
52
+
53
+ function addSlice(): void {
54
+ const lastSlice = slices.value.at(-1);
55
+ slices.value.push({
56
+ id: newItemId(),
57
+ axis: lastSlice ? SLICE_AXES[lastSlice.axis].next : DEFAULT_SLICE_AXIS,
58
+ index: 0,
59
+ });
60
+ }
61
+
62
+ function removeSlice(index: number): void {
63
+ slices.value.splice(index, 1);
64
+ }
65
+
66
+ function resetSlices(): void {
67
+ sliceEnabled.value = false;
68
+ slices.value = [{ id: newItemId(), axis: DEFAULT_SLICE_AXIS, index: 0 }];
69
+ }
70
+
71
+ return { sliceEnabled, slices, addSlice, removeSlice, resetSlices };
72
+ }
73
+
74
+ // Runs the tasks one after the other, whatever the outcome of the previous one
75
+ function createSliceQueue(): (task: () => Promise<void>) => Promise<void> {
76
+ let pendingSlices: Promise<void> = Promise.resolve();
77
+
78
+ return async (task) => {
79
+ const previous = pendingSlices;
80
+ pendingSlices = (async (): Promise<void> => {
81
+ await Promise.allSettled([previous]);
82
+ await task();
83
+ })();
84
+ await pendingSlices;
85
+ };
86
+ }
87
+
88
+ function useSliceSync(params: SliceSyncParams): {
89
+ applySlices: () => Promise<void>;
90
+ removeSlices: (allIds: string[]) => Promise<void>;
91
+ } {
92
+ const { slices, sliceMaxIndices, isAllGrid, isSliceActive, targetIds, hybridViewerStore } =
93
+ params;
94
+ const queueSliceTask = createSliceQueue();
95
+ let areSlicesApplied = false;
96
+
97
+ function getSlicesPayload(isActive: boolean): { axis: SliceAxis; index: number }[] {
98
+ if (!isActive) {
99
+ return [];
100
+ }
101
+ return slices.value.map(({ axis, index }) => ({ axis, index }));
102
+ }
103
+
104
+ async function sendSlices(): Promise<void> {
105
+ if (!isAllGrid.value && !areSlicesApplied) {
106
+ return;
107
+ }
108
+ const isActive = isSliceActive.value;
109
+ const untargetedIds = params.getUntargetedIds();
110
+ if (targetIds.value.length > 0) {
111
+ const maxIndices = await hybridViewerStore.setSlice(
112
+ targetIds.value,
113
+ getSlicesPayload(isActive),
114
+ );
115
+ if (isAllGrid.value) {
116
+ sliceMaxIndices.value = maxIndices;
117
+ }
118
+ if (isActive) {
119
+ for (const slice of slices.value) {
120
+ slice.index = Math.min(slice.index, maxIndices[slice.axis]);
121
+ }
122
+ }
123
+ }
124
+ if (areSlicesApplied && untargetedIds.length > 0) {
125
+ await hybridViewerStore.setSlice(untargetedIds, []);
126
+ }
127
+ areSlicesApplied = isActive;
128
+ }
129
+
130
+ async function applySlices(): Promise<void> {
131
+ await queueSliceTask(sendSlices);
132
+ }
133
+
134
+ async function removeSlices(allIds: string[]): Promise<void> {
135
+ await queueSliceTask(async () => {
136
+ if (areSlicesApplied) {
137
+ await hybridViewerStore.setSlice(allIds, []);
138
+ areSlicesApplied = false;
139
+ }
140
+ });
141
+ }
142
+
143
+ return { applySlices, removeSlices };
144
+ }
145
+
146
+ // The slices applied to the targeted grids
147
+ function useClippingSlices(params: ClippingSlicesParams): ClippingSlices {
148
+ const { allItems, targetIds, getUntargetedIds, newItemId, hybridViewerStore } = params;
149
+ const list = useSliceList(newItemId);
150
+ const sliceMaxIndices = ref<[number, number, number]>([0, 0, 0]);
151
+ const isAllGrid = computed<boolean>(() => areAllGrids(allItems.value, targetIds.value));
152
+ const isSliceActive = computed<boolean>(() => isAllGrid.value && list.sliceEnabled.value);
153
+ const sync = useSliceSync({
154
+ slices: list.slices,
155
+ sliceMaxIndices,
156
+ isAllGrid,
157
+ isSliceActive,
158
+ targetIds,
159
+ getUntargetedIds,
160
+ hybridViewerStore,
161
+ });
162
+
163
+ return { ...list, ...sync, sliceMaxIndices, isAllGrid, isSliceActive };
164
+ }
165
+
166
+ export { useClippingSlices };
@@ -0,0 +1,126 @@
1
+ import {
2
+ type CameraOptionAction,
3
+ controlOptions,
4
+ filterOptions,
5
+ panelOptions,
6
+ rulerOption,
7
+ } from "@ogw_front/composables/view_toolbar_tool_options";
8
+ import type { ViewToolbarTools } from "@ogw_front/composables/view_toolbar_tools";
9
+ import schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
10
+ import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
11
+ import { useViewerStore } from "@ogw_front/stores/viewer";
12
+
13
+ type HybridViewerStore = ReturnType<typeof useHybridViewerStore>;
14
+
15
+ function pickingOptions(
16
+ hybridViewerStore: HybridViewerStore,
17
+ tools: ViewToolbarTools,
18
+ ): CameraOptionAction[] {
19
+ return [
20
+ {
21
+ testId: "resetCameraButton",
22
+ tooltip: "Reset camera",
23
+ icon: "mdi-cube-scan",
24
+ action: (): void => {
25
+ hybridViewerStore.resetCamera();
26
+ },
27
+ },
28
+ {
29
+ testId: "centerOnClickButton",
30
+ tooltip: "Center on click",
31
+ icon: "mdi-crosshairs-question",
32
+ color: hybridViewerStore.is_picking ? "primary" : undefined,
33
+ action: (): void => {
34
+ tools.toggleTool(tools.is_picking);
35
+ },
36
+ },
37
+ {
38
+ testId: "zoomToBoxButton",
39
+ tooltip: "Zoom to box",
40
+ icon: "mdi-magnify-scan",
41
+ color: hybridViewerStore.is_zoom_box_active ? "primary" : undefined,
42
+ action: (): void => {
43
+ tools.toggleTool(tools.is_zoom_box_active);
44
+ },
45
+ },
46
+ ];
47
+ }
48
+
49
+ function hoverHighlightOption(
50
+ hybridViewerStore: HybridViewerStore,
51
+ tools: ViewToolbarTools,
52
+ ): CameraOptionAction {
53
+ return {
54
+ testId: "highlightOnHoverButton",
55
+ tooltip: "Highlight on hover",
56
+ icon: "mdi-cursor-default-click",
57
+ color: hybridViewerStore.is_hover_highlight ? "primary" : undefined,
58
+ action: hybridViewerStore.is_hover_highlight ? tools.stopHoverHighlight : undefined,
59
+ menu: [
60
+ {
61
+ title: "Cells",
62
+ testId: "highlightOnHoverCellsButton",
63
+ icon: "mdi-select-all",
64
+ action: (): void => {
65
+ tools.toggleHoverHighlight("CELL");
66
+ },
67
+ },
68
+ {
69
+ title: "Points",
70
+ testId: "highlightOnHoverPointsButton",
71
+ icon: "mdi-select-drag",
72
+ action: (): void => {
73
+ tools.toggleHoverHighlight("POINT");
74
+ },
75
+ },
76
+ ],
77
+ };
78
+ }
79
+
80
+ function gridScaleOption(
81
+ hybridViewerStore: HybridViewerStore,
82
+ viewerStore: ReturnType<typeof useViewerStore>,
83
+ gridScale: Ref<boolean>,
84
+ ): CameraOptionAction {
85
+ return {
86
+ testId: "gridScaleButton",
87
+ tooltip: "Toggle grid scale",
88
+ icon: "mdi-ruler-square",
89
+ color: gridScale.value ? "primary" : undefined,
90
+ action: (): void => {
91
+ const schema = schemas.opengeodeweb_viewer.viewer.grid_scale;
92
+ const params = { visibility: !gridScale.value };
93
+ void viewerStore.request(
94
+ {
95
+ schema,
96
+ params,
97
+ },
98
+ {
99
+ response_function: () => {
100
+ gridScale.value = !gridScale.value;
101
+ void hybridViewerStore.remoteRender();
102
+ },
103
+ },
104
+ );
105
+ },
106
+ };
107
+ }
108
+
109
+ // The buttons of the view toolbar
110
+ function useViewToolbarOptions(tools: ViewToolbarTools): ComputedRef<CameraOptionAction[]> {
111
+ const hybridViewerStore = useHybridViewerStore();
112
+ const viewerStore = useViewerStore();
113
+ const gridScale = ref<boolean>(false);
114
+
115
+ return computed<CameraOptionAction[]>(() => [
116
+ ...pickingOptions(hybridViewerStore, tools),
117
+ hoverHighlightOption(hybridViewerStore, tools),
118
+ ...panelOptions(tools),
119
+ gridScaleOption(hybridViewerStore, viewerStore, gridScale),
120
+ ...controlOptions(tools),
121
+ ...filterOptions(tools),
122
+ rulerOption(tools),
123
+ ]);
124
+ }
125
+
126
+ export { useViewToolbarOptions };