@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,19 +1,10 @@
1
1
  <script setup lang="ts">
2
- import { type AttributeSchemas, fetchAttributeRange } from "@ogw_front/utils/attribute_range";
3
- import {
4
- MESH_ELEMENT_KINDS,
5
- MODEL_COMPONENT_ATTRIBUTE_SCHEMAS,
6
- MODEL_COMPONENT_KINDS,
7
- attributeArrayName,
8
- getAttributeRange,
9
- } from "@ogw_front/utils/attributes";
10
- import type { JsonRpcSchema } from "@ogw_shared/utils/types.js";
2
+ import type { Threshold, ThresholdAttribute } from "@ogw_internal/stores/hybrid_viewer/filters";
3
+ import type { AttributeSource } from "@ogw_front/utils/threshold";
4
+ import ThresholdCard from "@ogw_front/components/ThresholdCard.vue";
11
5
  import ToolPanel from "@ogw_front/components/ToolPanel.vue";
12
- import ViewerOptionsAttributeRangeSelector from "@ogw_front/components/Viewer/Options/AttributeRangeSelector.vue";
13
- import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
14
- import { useBackStore } from "@ogw_front/stores/back";
6
+ import { fetchSources } from "@ogw_front/utils/threshold_sources";
15
7
  import { useDataStore } from "@ogw_front/stores/data";
16
- import { useDataStyleStore } from "@ogw_front/stores/data_style";
17
8
  import { useDebounceFn } from "@vueuse/core";
18
9
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
19
10
 
@@ -25,34 +16,18 @@ interface Props {
25
16
 
26
17
  const { escapeFunction = undefined } = defineProps<Props>();
27
18
 
28
- interface AttributeSource {
29
- title: string;
30
- schemas: AttributeSchemas;
31
- timeStepKey: string;
32
- params: { id: string; component_ids?: string[] };
33
- location: "point" | "cell";
34
- }
35
-
36
- interface AttributeInfo {
37
- attribute_name: string;
38
- nb_items: number;
39
- time_steps?: number[];
40
- [key: string]: unknown;
41
- }
42
-
43
19
  const show = defineModel<boolean>("show", { default: false });
44
- const backStore = useBackStore();
45
20
  const dataStore = useDataStore();
46
- const dataStyleStore = useDataStyleStore();
47
21
  const hybridViewerStore = useHybridViewerStore();
48
22
  const selectedDatasetId = ref<string>();
49
23
  const sources = ref<AttributeSource[]>([]);
50
- const selectedSourceIndex = ref<number>();
51
- const attributes = ref<AttributeInfo[]>([]);
52
- const attributeName = ref<string>();
53
- const attributeItem = ref<number>(0);
54
- const minimum = ref<number>();
55
- const maximum = ref<number>();
24
+ const thresholds = computed<Threshold[]>(() => {
25
+ if (!selectedDatasetId.value) {
26
+ return [];
27
+ }
28
+ return hybridViewerStore.getThresholds(selectedDatasetId.value);
29
+ });
30
+ const cards = useTemplateRef("cards");
56
31
 
57
32
  const allItems = dataStore.refAllItems();
58
33
  const availableDatasets = computed<{ title: string; value: string }[]>(() =>
@@ -61,169 +36,74 @@ const availableDatasets = computed<{ title: string; value: string }[]>(() =>
61
36
  value: item.id,
62
37
  })),
63
38
  );
64
- const availableSources = computed<{ title: string; value: number }[]>(() =>
65
- sources.value.map((source, index) => ({ title: source.title, value: index })),
66
- );
67
- const currentAttribute = computed<AttributeInfo | undefined>(() =>
68
- attributes.value.find((attribute) => attribute.attribute_name === attributeName.value),
69
- );
70
- const currentTimeStep = computed<number | undefined>(() => {
71
- const source = sources.value[selectedSourceIndex.value ?? -1];
72
- if (!selectedDatasetId.value || !source || !currentAttribute.value?.time_steps?.length) {
73
- return undefined;
74
- }
75
- const step =
76
- dataStyleStore.attributeTimeStep(
77
- selectedDatasetId.value,
78
- source.timeStepKey,
79
- attributeName.value,
80
- ) ?? 0;
81
- return Math.min(step, currentAttribute.value.time_steps.length - 1);
82
- });
83
- const itemOptions = computed<{ title: string; value: number }[]>(() =>
84
- Array.from({ length: currentAttribute.value?.nb_items ?? 0 }, (_, index) => ({
85
- title: `Item ${index + 1}`,
86
- value: index,
87
- })),
88
- );
89
39
 
90
- function attributeSchema(kind: string, isModel: boolean, route: "names" | "range"): JsonRpcSchema {
91
- const prefix = isModel ? "model_component_" : "";
92
- return back_schemas.opengeodeweb_back[
93
- `${prefix}${kind}_attribute_${route}` as keyof typeof back_schemas.opengeodeweb_back
94
- ] as JsonRpcSchema;
40
+ async function applyThresholds(): Promise<void> {
41
+ if (!selectedDatasetId.value) {
42
+ return;
43
+ }
44
+ await hybridViewerStore.setThreshold(
45
+ [selectedDatasetId.value],
46
+ thresholds.value
47
+ .map((threshold) => threshold.thresholdAttribute)
48
+ .filter((attribute): attribute is ThresholdAttribute => attribute !== undefined),
49
+ );
95
50
  }
96
51
 
97
- function attributeSource(
98
- kind: string,
99
- title: string,
100
- params: { id: string; component_ids?: string[] },
101
- modelType?: string,
102
- ): AttributeSource {
103
- const isModel = modelType !== undefined;
104
- const schema = attributeSchema(kind, isModel, "names");
105
- return {
106
- title: `${title}${kind} attribute`,
107
- schemas: { names: schema, range: attributeSchema(kind, isModel, "range") },
108
- timeStepKey:
109
- modelType === undefined
110
- ? schema.$id
111
- : (MODEL_COMPONENT_ATTRIBUTE_SCHEMAS[modelType]?.[kind]?.$id ?? schema.$id),
112
- params,
113
- location: kind === "vertex" ? "point" : "cell",
114
- };
115
- }
52
+ const debouncedApply = useDebounceFn(() => applyThresholds(), DEBOUNCE_DELAY);
116
53
 
117
- async function fetchSources(id: string): Promise<AttributeSource[]> {
118
- const item = await dataStore.item(id);
119
- if (item.viewer_type !== "model") {
120
- return ["vertex", MESH_ELEMENT_KINDS[item.geode_object_type]]
121
- .filter((kind): kind is string => kind !== undefined)
122
- .map((kind) => attributeSource(kind, "", { id }));
54
+ function addThreshold(): void {
55
+ if (selectedDatasetId.value) {
56
+ hybridViewerStore.addThreshold(selectedDatasetId.value);
123
57
  }
124
- const modelSources = await Promise.all(
125
- Object.entries(MODEL_COMPONENT_KINDS).map(async ([type, kinds]) => {
126
- const component_ids = await dataStore.getMeshComponentGeodeIds(id, type);
127
- if (component_ids.length === 0) {
128
- return [];
129
- }
130
- return kinds.map((kind) => attributeSource(kind, `${type} `, { id, component_ids }, type));
131
- }),
132
- );
133
- return modelSources.flat();
134
58
  }
135
59
 
136
- async function applyThreshold(): Promise<void> {
137
- const source = sources.value[selectedSourceIndex.value ?? -1];
138
- if (
139
- !selectedDatasetId.value ||
140
- !source ||
141
- !attributeName.value ||
142
- minimum.value === undefined ||
143
- maximum.value === undefined ||
144
- minimum.value > maximum.value
145
- ) {
146
- return;
60
+ function removeThreshold(index: number): void {
61
+ if (selectedDatasetId.value) {
62
+ hybridViewerStore.removeThreshold(selectedDatasetId.value, index);
147
63
  }
148
- await hybridViewerStore.setThreshold([selectedDatasetId.value], {
149
- name: attributeArrayName(attributeName.value, currentTimeStep.value),
150
- location: source.location,
151
- item: attributeItem.value,
152
- minimum: minimum.value,
153
- maximum: maximum.value,
154
- });
155
64
  }
156
65
 
157
- const debouncedApply = useDebounceFn(() => applyThreshold(), DEBOUNCE_DELAY);
66
+ async function clearThresholds(id: string): Promise<void> {
67
+ hybridViewerStore.removeThresholds(id);
68
+ await hybridViewerStore.setThreshold([id], []);
69
+ }
158
70
 
159
- async function resetRange(): Promise<void> {
160
- const source = sources.value[selectedSourceIndex.value ?? -1];
161
- const name = attributeName.value;
162
- if (!source || name === undefined) {
163
- return;
164
- }
165
- const range = await fetchAttributeRange(source.schemas.range, source.params, name);
166
- if (name !== attributeName.value) {
167
- return;
168
- }
169
- const { min, max } = getAttributeRange(range, attributeItem.value);
170
- minimum.value = min;
171
- maximum.value = max;
71
+ async function resetRanges(): Promise<void> {
72
+ await Promise.all((cards.value ?? []).map((card) => card?.resetRange()));
172
73
  }
173
74
 
174
- async function removeThreshold(): Promise<void> {
175
- attributeName.value = undefined;
75
+ async function removeThresholds(): Promise<void> {
176
76
  if (selectedDatasetId.value) {
177
- await hybridViewerStore.setThreshold([selectedDatasetId.value]);
77
+ await clearThresholds(selectedDatasetId.value);
78
+ hybridViewerStore.addThreshold(selectedDatasetId.value);
178
79
  }
179
80
  }
180
81
 
181
82
  watch(selectedDatasetId, async (id, previousId) => {
182
83
  if (previousId) {
183
- await hybridViewerStore.setThreshold([previousId]);
84
+ await clearThresholds(previousId);
184
85
  }
185
- selectedSourceIndex.value = undefined;
186
86
  if (id) {
187
- sources.value = await fetchSources(id);
87
+ sources.value = await fetchSources(dataStore, id);
188
88
  } else {
189
89
  sources.value = [];
190
90
  }
191
- });
192
-
193
- watch(selectedSourceIndex, async (index) => {
194
- attributeName.value = undefined;
195
- attributes.value = [];
196
- const source = sources.value[index ?? -1];
197
- if (!source) {
198
- return;
91
+ if (id && hybridViewerStore.getThresholds(id).length === 0) {
92
+ hybridViewerStore.addThreshold(id);
199
93
  }
200
- const response = (await backStore.request({
201
- schema: source.schemas.names,
202
- params: source.params,
203
- })) as { attributes: AttributeInfo[] };
204
- attributes.value = response.attributes;
205
94
  });
206
95
 
207
- watch(attributeName, async () => {
208
- attributeItem.value = 0;
209
- await resetRange();
210
- });
211
-
212
- watch(attributeItem, async () => {
213
- await resetRange();
214
- });
215
-
216
- watch(currentTimeStep, () => {
217
- debouncedApply();
218
- });
219
-
220
- watch([minimum, maximum], () => {
221
- debouncedApply();
222
- });
96
+ watch(
97
+ thresholds,
98
+ () => {
99
+ debouncedApply();
100
+ },
101
+ { deep: true },
102
+ );
223
103
 
224
104
  watch(show, (visible) => {
225
105
  if (visible) {
226
- applyThreshold();
106
+ applyThresholds();
227
107
  }
228
108
  });
229
109
  </script>
@@ -249,50 +129,31 @@ watch(show, (visible) => {
249
129
  class="mb-3 text-caption"
250
130
  />
251
131
 
252
- <v-select
253
- v-if="selectedDatasetId"
254
- v-model="selectedSourceIndex"
255
- data-testid="thresholdAttributeTypeSelect"
256
- :items="availableSources"
257
- label="Select an attribute type"
258
- variant="outlined"
259
- density="compact"
260
- hide-details
261
- class="mb-3 text-caption"
262
- />
263
-
264
- <v-select
265
- v-if="selectedSourceIndex !== undefined"
266
- v-model="attributeName"
267
- data-testid="thresholdAttributeSelect"
268
- :items="attributes.map((attribute) => attribute.attribute_name)"
269
- label="Select an attribute"
270
- variant="outlined"
271
- density="compact"
272
- hide-details
273
- class="mb-3 text-caption"
274
- />
275
-
276
- <v-select
277
- v-if="currentAttribute && currentAttribute.nb_items > 1"
278
- v-model="attributeItem"
279
- data-testid="thresholdItemSelect"
280
- :items="itemOptions"
281
- label="Select an item"
282
- variant="outlined"
283
- density="compact"
284
- hide-details
285
- class="mb-3 text-caption"
286
- />
287
-
288
- <template v-if="attributeName">
289
- <v-divider class="my-3" />
290
- <span class="text-caption font-weight-bold">Range</span>
291
- <ViewerOptionsAttributeRangeSelector
292
- v-model:minimum="minimum"
293
- v-model:maximum="maximum"
294
- class="mt-2"
295
- @reset="resetRange"
132
+ <template v-if="selectedDatasetId">
133
+ <v-divider class="my-2" />
134
+ <v-row align="center" justify="space-between" no-gutters class="mb-2">
135
+ <v-col class="text-caption font-weight-bold">Thresholds ({{ thresholds.length }})</v-col>
136
+ <v-col cols="auto">
137
+ <v-btn
138
+ data-testid="addThresholdButton"
139
+ size="x-small"
140
+ variant="tonal"
141
+ color="primary"
142
+ icon="mdi-plus"
143
+ @click="addThreshold"
144
+ />
145
+ </v-col>
146
+ </v-row>
147
+
148
+ <ThresholdCard
149
+ v-for="(threshold, idx) in thresholds"
150
+ :key="threshold.id"
151
+ ref="cards"
152
+ :threshold="threshold"
153
+ :dataset-id="selectedDatasetId"
154
+ :sources="sources"
155
+ :index="idx"
156
+ @remove="removeThreshold(idx)"
296
157
  />
297
158
  </template>
298
159
  </v-card-text>
@@ -305,9 +166,9 @@ watch(show, (visible) => {
305
166
  size="small"
306
167
  color="error"
307
168
  class="text-caption text-none"
308
- @click="removeThreshold"
169
+ @click="removeThresholds"
309
170
  >
310
- Remove Threshold
171
+ Remove all thresholds
311
172
  </v-btn>
312
173
  <v-btn
313
174
  data-testid="resetThresholdButton"
@@ -315,7 +176,7 @@ watch(show, (visible) => {
315
176
  size="small"
316
177
  color="secondary"
317
178
  class="text-caption text-none"
318
- @click="resetRange"
179
+ @click="resetRanges"
319
180
  >
320
181
  Reset
321
182
  </v-btn>
@@ -1,9 +1,5 @@
1
1
  <script setup lang="ts">
2
- import schemas, {
3
- type PickedFieldType,
4
- } from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
5
2
  import ActionButton from "@ogw_front/components/ActionButton.vue";
6
- import CameraBookmarkIcon from "@ogw_front/assets/viewer_svgs/camera-bookmark.svg";
7
3
  import CameraManager from "@ogw_front/components/CameraManager.vue";
8
4
  import CameraOrientation from "@ogw_front/components/CameraOrientation.vue";
9
5
  import ClippingPlanes from "@ogw_front/components/ClippingPlanes.vue";
@@ -15,35 +11,25 @@ import ThresholdFilter from "@ogw_front/components/ThresholdFilter.vue";
15
11
  import ZScaling from "@ogw_front/components/ZScaling.vue";
16
12
  import { onKeyStroke } from "@vueuse/core";
17
13
  import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
18
- import { useViewerStore } from "@ogw_front/stores/viewer";
14
+ import { useViewToolbarOptions } from "@ogw_front/composables/view_toolbar_options";
15
+ import { useViewToolbarTools } from "@ogw_front/composables/view_toolbar_tools";
19
16
 
20
17
  const hybridViewerStore = useHybridViewerStore();
21
- const viewerStore = useViewerStore();
22
- const { is_picking, is_zoom_box_active } = storeToRefs(hybridViewerStore);
23
- const { picking_mode } = storeToRefs(viewerStore);
24
- const showScreenshot = ref<boolean>(false);
25
- const showCameraManager = ref<boolean>(false);
26
- const showCameraOrientation = ref<boolean>(false);
27
- const showZScaling = ref<boolean>(false);
28
- const showClippingPlanes = ref<boolean>(false);
29
- const showShrinkFilter = ref<boolean>(false);
30
- const showExplodeFilter = ref<boolean>(false);
31
- const showThresholdFilter = ref<boolean>(false);
32
- const showRuler = ref<boolean>(false);
33
- const gridScale = ref<boolean>(false);
18
+ const tools = useViewToolbarTools();
19
+ const {
20
+ showScreenshot,
21
+ showCameraManager,
22
+ showCameraOrientation,
23
+ showZScaling,
24
+ showClippingPlanes,
25
+ showShrinkFilter,
26
+ showExplodeFilter,
27
+ showThresholdFilter,
28
+ showRuler,
29
+ } = tools;
34
30
  const zScale = ref<number>(hybridViewerStore.zScale);
35
31
  const openSubMenus = ref<Record<string, boolean>>({});
36
-
37
- interface CameraOptionAction {
38
- title?: string;
39
- testId: string;
40
- tooltip?: string;
41
- icon: string;
42
- iconSize?: number;
43
- color?: string;
44
- action?: () => void;
45
- menu?: CameraOptionAction[];
46
- }
32
+ const camera_options = useViewToolbarOptions(tools);
47
33
 
48
34
  watch(
49
35
  () => hybridViewerStore.zScale,
@@ -65,208 +51,6 @@ onKeyStroke("Escape", () => {
65
51
  }
66
52
  }
67
53
  });
68
-
69
- function stopHoverHighlight(): void {
70
- hybridViewerStore.is_hover_highlight = false;
71
- hybridViewerStore.clearHoverHighlight();
72
- }
73
-
74
- function closeAllToolsExcept(toolRef: Ref<boolean>): void {
75
- const tools = [
76
- showCameraOrientation,
77
- showCameraManager,
78
- showScreenshot,
79
- showZScaling,
80
- showClippingPlanes,
81
- showShrinkFilter,
82
- showExplodeFilter,
83
- showThresholdFilter,
84
- showRuler,
85
- is_picking,
86
- is_zoom_box_active,
87
- picking_mode,
88
- ];
89
- for (const tool of tools) {
90
- if (tool !== toolRef) {
91
- tool.value = false;
92
- }
93
- }
94
- if (toolRef !== showRuler) {
95
- void nextTick(stopHoverHighlight);
96
- }
97
- }
98
-
99
- function toggleTool(toolRef: Ref<boolean>): void {
100
- closeAllToolsExcept(toolRef);
101
- toolRef.value = !toolRef.value;
102
- }
103
-
104
- function toggleHoverHighlight(fieldType: PickedFieldType): void {
105
- const activate =
106
- !hybridViewerStore.is_hover_highlight ||
107
- hybridViewerStore.hover_highlight_field_type !== fieldType;
108
- closeAllToolsExcept(showRuler);
109
- if (activate) {
110
- hybridViewerStore.is_hover_highlight = true;
111
- hybridViewerStore.hover_highlight_field_type = fieldType;
112
- } else {
113
- stopHoverHighlight();
114
- }
115
- }
116
-
117
- const camera_options = computed<CameraOptionAction[]>(() => [
118
- {
119
- testId: "resetCameraButton",
120
- tooltip: "Reset camera",
121
- icon: "mdi-cube-scan",
122
- action: (): void => {
123
- hybridViewerStore.resetCamera();
124
- },
125
- },
126
- {
127
- testId: "centerOnClickButton",
128
- tooltip: "Center on click",
129
- icon: "mdi-crosshairs-question",
130
- color: hybridViewerStore.is_picking ? "primary" : undefined,
131
- action: (): void => {
132
- toggleTool(is_picking);
133
- },
134
- },
135
- {
136
- testId: "zoomToBoxButton",
137
- tooltip: "Zoom to box",
138
- icon: "mdi-magnify-scan",
139
- color: hybridViewerStore.is_zoom_box_active ? "primary" : undefined,
140
- action: (): void => {
141
- toggleTool(is_zoom_box_active);
142
- },
143
- },
144
- {
145
- testId: "highlightOnHoverButton",
146
- tooltip: "Highlight on hover",
147
- icon: "mdi-cursor-default-click",
148
- color: hybridViewerStore.is_hover_highlight ? "primary" : undefined,
149
- action: hybridViewerStore.is_hover_highlight ? stopHoverHighlight : undefined,
150
- menu: [
151
- {
152
- title: "Cells",
153
- testId: "highlightOnHoverCellsButton",
154
- icon: "mdi-select-all",
155
- action: (): void => {
156
- toggleHoverHighlight("CELL");
157
- },
158
- },
159
- {
160
- title: "Points",
161
- testId: "highlightOnHoverPointsButton",
162
- icon: "mdi-select-drag",
163
- action: (): void => {
164
- toggleHoverHighlight("POINT");
165
- },
166
- },
167
- ],
168
- },
169
- {
170
- testId: "cameraOrientationButton",
171
- tooltip: "Camera orientation",
172
- icon: "mdi-rotate-3d",
173
- action: (): void => {
174
- toggleTool(showCameraOrientation);
175
- },
176
- },
177
- {
178
- testId: "cameraManagerButton",
179
- tooltip: "Manage camera positions",
180
- icon: CameraBookmarkIcon,
181
- iconSize: 34,
182
- action: (): void => {
183
- toggleTool(showCameraManager);
184
- },
185
- },
186
- {
187
- testId: "screenshotButton",
188
- tooltip: "Take a screenshot",
189
- icon: "mdi-camera",
190
- action: (): void => {
191
- toggleTool(showScreenshot);
192
- },
193
- },
194
- {
195
- testId: "gridScaleButton",
196
- tooltip: "Toggle grid scale",
197
- icon: "mdi-ruler-square",
198
- color: gridScale.value ? "primary" : undefined,
199
- action: (): void => {
200
- const schema = schemas.opengeodeweb_viewer.viewer.grid_scale;
201
- const params = { visibility: !gridScale.value };
202
- viewerStore.request(
203
- {
204
- schema,
205
- params,
206
- },
207
- {
208
- response_function: () => {
209
- gridScale.value = !gridScale.value;
210
- hybridViewerStore.remoteRender();
211
- },
212
- },
213
- );
214
- },
215
- },
216
- {
217
- testId: "zScalingButton",
218
- tooltip: "Z Scaling Control",
219
- icon: "mdi-sort",
220
- action: (): void => {
221
- toggleTool(showZScaling);
222
- },
223
- },
224
- {
225
- testId: "clippingPlanesButton",
226
- tooltip: "Clipping Planes",
227
- icon: "mdi-content-cut",
228
- color: showClippingPlanes.value ? "primary" : undefined,
229
- action: (): void => {
230
- toggleTool(showClippingPlanes);
231
- },
232
- },
233
- {
234
- testId: "shrinkFilterButton",
235
- tooltip: "Shrink Filter",
236
- icon: "mdi-arrow-collapse-all",
237
- color: showShrinkFilter.value ? "primary" : undefined,
238
- action: (): void => {
239
- toggleTool(showShrinkFilter);
240
- },
241
- },
242
- {
243
- testId: "explodeFilterButton",
244
- tooltip: "Exploded View",
245
- icon: "mdi-arrow-expand-all",
246
- color: showExplodeFilter.value ? "primary" : undefined,
247
- action: (): void => {
248
- toggleTool(showExplodeFilter);
249
- },
250
- },
251
- {
252
- testId: "thresholdFilterButton",
253
- tooltip: "Threshold Filter",
254
- icon: "mdi-filter-variant",
255
- color: showThresholdFilter.value ? "primary" : undefined,
256
- action: (): void => {
257
- toggleTool(showThresholdFilter);
258
- },
259
- },
260
- {
261
- testId: "rulerButton",
262
- tooltip: "Ruler",
263
- icon: "mdi-ruler",
264
- color: showRuler.value ? "primary" : undefined,
265
- action: (): void => {
266
- toggleTool(showRuler);
267
- },
268
- },
269
- ]);
270
54
  </script>
271
55
 
272
56
  <template>