@geode/opengeodeweb-front 10.44.0-rc.2 → 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 (160) hide show
  1. package/.build/server/utils/cleanup.js +7 -2
  2. package/.build/server/utils/microservices.js +9 -81
  3. package/.build/server/utils/microservices_process.js +85 -0
  4. package/.build/server/utils/typed_handler.js +5 -1
  5. package/.build/server/utils/ws_client.js +7 -2
  6. package/.build/shared/utils/fetch_raw.js +2 -2
  7. package/.build/shared/utils/parse_boolean.js +2 -1
  8. package/app/components/ClippingPlanes.vue +22 -78
  9. package/app/components/DragAndDrop.vue +16 -79
  10. package/app/components/FileSelector.vue +9 -6
  11. package/app/components/HybridViewerTooltip.vue +8 -2
  12. package/app/components/MissingFilesSelector.vue +10 -6
  13. package/app/components/ObjectSelector.vue +6 -3
  14. package/app/components/Screenshot.vue +9 -2
  15. package/app/components/ThresholdCard.vue +205 -0
  16. package/app/components/ThresholdFilter.vue +81 -216
  17. package/app/components/ViewToolbar.vue +15 -231
  18. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
  19. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
  20. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +228 -0
  21. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
  22. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
  23. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
  24. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +234 -0
  25. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
  26. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
  27. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
  28. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +7 -5
  29. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
  30. package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
  31. package/app/components/Viewer/Generic/Model/CornersOptions.vue +13 -292
  32. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
  33. package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
  34. package/app/components/Viewer/Generic/Model/LinesOptions.vue +13 -425
  35. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
  36. package/app/components/Viewer/Generic/Model/ModelEdgesCard.vue +12 -10
  37. package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +12 -10
  38. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +9 -5
  39. package/app/components/Viewer/ObjectTree/Base/ComponentRelations.vue +4 -1
  40. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +6 -1
  41. package/app/components/Viewer/Options/AttributeRangeSelector.vue +11 -4
  42. package/app/components/Viewer/Options/AttributeSelector.vue +40 -136
  43. package/app/components/Viewer/Options/ColorPicker.vue +4 -1
  44. package/app/components/Viewer/Options/ColoringTypeSelector.vue +36 -74
  45. package/app/components/Viewer/Options/ColormapQuickPicker.vue +13 -7
  46. package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
  47. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
  48. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
  49. package/app/components/Viewer/Surface/PolygonsColoring.vue +231 -0
  50. package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
  51. package/app/components/csv-preview/CsvPreviewer.vue +4 -1
  52. package/app/composables/attribute_coloring_style.ts +8 -2
  53. package/app/composables/attribute_selector.ts +126 -0
  54. package/app/composables/clipping_slices.ts +166 -0
  55. package/app/composables/global_attribute_style.ts +4 -3
  56. package/app/composables/hover_highlight.ts +6 -5
  57. package/app/composables/project_manager.ts +5 -5
  58. package/app/composables/stepper_tree.ts +10 -2
  59. package/app/composables/tree_filter.ts +11 -2
  60. package/app/composables/tree_keyboard_nav.ts +4 -2
  61. package/app/composables/use_overlapping_picker.ts +5 -5
  62. package/app/composables/view_toolbar_options.ts +126 -0
  63. package/app/composables/view_toolbar_tool_options.ts +115 -0
  64. package/app/composables/view_toolbar_tools.ts +108 -0
  65. package/app/composables/virtual_tree.ts +20 -131
  66. package/app/composables/virtual_tree_flatten.ts +86 -0
  67. package/app/composables/virtual_tree_types.ts +81 -0
  68. package/app/stores/app.ts +8 -55
  69. package/app/stores/app_helpers/extension.ts +1 -1
  70. package/app/stores/app_helpers/registry.ts +69 -0
  71. package/app/stores/feedback.ts +2 -2
  72. package/app/stores/hybrid_viewer.ts +1 -1
  73. package/app/stores/menu.ts +1 -124
  74. package/app/stores/menu_helpers/menus_data.ts +127 -0
  75. package/app/stores/treeview.ts +17 -10
  76. package/app/stores/viewer.ts +17 -78
  77. package/app/stores/viewer_helpers/actions.ts +68 -0
  78. package/app/stores/viewer_helpers/request.ts +61 -0
  79. package/app/utils/clipping_planes.ts +4 -131
  80. package/app/utils/clipping_planes_scene.ts +131 -0
  81. package/app/utils/coloring_styles.ts +101 -0
  82. package/app/utils/default_styles/mesh_components.ts +168 -0
  83. package/app/utils/default_styles/meshes.ts +13 -153
  84. package/app/utils/default_styles/model_components.ts +170 -0
  85. package/app/utils/default_styles/models.ts +16 -153
  86. package/app/utils/drag_and_drop.ts +80 -0
  87. package/app/utils/extension.ts +1 -1
  88. package/app/utils/import_workflow.ts +6 -4
  89. package/app/utils/model_component_coloring.ts +46 -0
  90. package/app/utils/threshold.ts +33 -0
  91. package/app/utils/threshold_sources.ts +51 -0
  92. package/app/utils/upload_path.ts +15 -9
  93. package/internal/database/database.ts +4 -1
  94. package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
  95. package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
  96. package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
  97. package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
  98. package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
  99. package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
  100. package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
  101. package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
  102. package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
  103. package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
  104. package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
  105. package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
  106. package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
  107. package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
  108. package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
  109. package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
  110. package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
  111. package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
  112. package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
  113. package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
  114. package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
  115. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
  116. package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
  117. package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
  118. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
  119. package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
  120. package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
  121. package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
  122. package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
  123. package/internal/stores/data_style/model/blocks/index.ts +12 -140
  124. package/internal/stores/data_style/model/blocks/polyhedron.ts +14 -10
  125. package/internal/stores/data_style/model/blocks/vertex.ts +14 -10
  126. package/internal/stores/data_style/model/common.ts +10 -119
  127. package/internal/stores/data_style/model/common_mutations.ts +184 -0
  128. package/internal/stores/data_style/model/corners/vertex.ts +14 -10
  129. package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
  130. package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
  131. package/internal/stores/data_style/model/lines/edge.ts +14 -10
  132. package/internal/stores/data_style/model/lines/index.ts +10 -134
  133. package/internal/stores/data_style/model/lines/vertex.ts +14 -10
  134. package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
  135. package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
  136. package/internal/stores/data_style/model/surfaces/index.ts +16 -160
  137. package/internal/stores/data_style/model/surfaces/polygon.ts +14 -10
  138. package/internal/stores/data_style/model/surfaces/vertex.ts +14 -10
  139. package/internal/stores/data_style/model/visibility.ts +3 -156
  140. package/internal/stores/data_style/model/visibility_dispatch.ts +160 -0
  141. package/internal/stores/data_style/state.ts +1 -181
  142. package/internal/stores/data_style/state_shared.ts +191 -0
  143. package/internal/stores/hybrid_viewer/brightness.ts +8 -2
  144. package/internal/stores/hybrid_viewer/camera.ts +7 -161
  145. package/internal/stores/hybrid_viewer/camera_animation.ts +4 -3
  146. package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
  147. package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
  148. package/internal/stores/hybrid_viewer/filters.ts +54 -11
  149. package/internal/stores/hybrid_viewer/highlight.ts +10 -9
  150. package/internal/stores/hybrid_viewer/ruler.ts +4 -3
  151. package/internal/utils/ws_client.ts +8 -1
  152. package/package.json +2 -2
  153. package/server/api/local/extensions/run.post.ts +6 -4
  154. package/server/utils/cleanup.ts +12 -2
  155. package/server/utils/microservices.ts +10 -102
  156. package/server/utils/microservices_process.ts +127 -0
  157. package/server/utils/typed_handler.ts +8 -1
  158. package/server/utils/ws_client.ts +15 -2
  159. package/shared/utils/fetch_raw.ts +2 -2
  160. package/shared/utils/parse_boolean.ts +4 -1
@@ -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 };
@@ -61,9 +61,10 @@ export function useGlobalAttributeStyle(
61
61
  return MESH_ELEMENTS.flatMap((element) => {
62
62
  const coloring: unknown = style[element.styleKey]?.coloring;
63
63
  const activeColoring = isColoring(coloring) ? coloring.active : undefined;
64
- return activeColoring !== undefined && ATTRIBUTE_COLORINGS.has(activeColoring)
65
- ? [meshColoring(dataId, element, activeColoring)]
66
- : [];
64
+ if (activeColoring !== undefined && ATTRIBUTE_COLORINGS.has(activeColoring)) {
65
+ return [meshColoring(dataId, element, activeColoring)];
66
+ }
67
+ return [];
67
68
  });
68
69
  });
69
70
 
@@ -40,11 +40,12 @@ export function useHoverhighlight(): {
40
40
  return;
41
41
  }
42
42
 
43
- let block_ids: number[] = [
44
- ...(typeof block_ids_provider === "function"
45
- ? await block_ids_provider()
46
- : block_ids_provider),
47
- ];
43
+ let block_ids: number[] = [];
44
+ if (typeof block_ids_provider === "function") {
45
+ block_ids = [...(await block_ids_provider())];
46
+ } else {
47
+ block_ids = [...block_ids_provider];
48
+ }
48
49
 
49
50
  block_ids = (Array.isArray(block_ids) ? block_ids : [])
50
51
  .map((blockId) => Math.trunc(blockId))
@@ -118,11 +118,11 @@ async function importProject(file: File): Promise<void> {
118
118
  // After every data item is added: on partial data the project CRS would follow them.
119
119
  // A project saved without a project CRS takes the one of its oldest data, read in the
120
120
  // Snapshot: the stored items carry the import time as creation date
121
- crsStore.importStores(
122
- snapshot.crs?.projectCrs === undefined
123
- ? { projectCrs: oldestCrs(snapshot.data?.items ?? []) }
124
- : snapshot.crs,
125
- );
121
+ if (snapshot.crs?.projectCrs === undefined) {
122
+ crsStore.importStores({ projectCrs: oldestCrs(snapshot.data?.items ?? []) });
123
+ } else {
124
+ crsStore.importStores(snapshot.crs);
125
+ }
126
126
  await hybridViewerStore.importStores(snapshot.hybridViewer);
127
127
  if (snapshot.dataStyle !== undefined) {
128
128
  await dataStyleStore.importStores(snapshot.dataStyle);
@@ -21,7 +21,11 @@ function build_initial_state_unref(
21
21
  const initial_state_unref: Record<string, unknown> = {};
22
22
  for (const [key, value] of Object.entries(initial_state)) {
23
23
  const unref_val: unknown = unref(value);
24
- initial_state_unref[key] = isUnknownArray(unref_val) ? [...unref_val] : unref_val;
24
+ if (isUnknownArray(unref_val)) {
25
+ initial_state_unref[key] = [...unref_val];
26
+ } else {
27
+ initial_state_unref[key] = unref_val;
28
+ }
25
29
  }
26
30
  return initial_state_unref;
27
31
  }
@@ -65,7 +69,11 @@ export function useStepperTree(
65
69
  state.current_step_index = 0;
66
70
  state.navigating_back = false;
67
71
  for (const [key, initial_val] of Object.entries(initial_state_unref)) {
68
- state[key] = isUnknownArray(initial_val) ? [...initial_val] : initial_val;
72
+ if (isUnknownArray(initial_val)) {
73
+ state[key] = [...initial_val];
74
+ } else {
75
+ state[key] = initial_val;
76
+ }
69
77
  }
70
78
  }
71
79
 
@@ -1,4 +1,4 @@
1
- import type { Ref } from "vue";
1
+ import type { ComputedRef, Ref } from "vue";
2
2
 
3
3
  // Same shape as Vue's MaybeRefOrGetter<T>, kept as a local alias for readability at call sites.
4
4
  type ReadonlyMaybeRefOrGetter<Value> = Value | Ref<Value> | (() => Value);
@@ -98,11 +98,20 @@ function sortAndFormatItems(
98
98
  return sorted;
99
99
  }
100
100
 
101
+ function toItemsRef(
102
+ itemsIn: ReadonlyMaybeRefOrGetter<readonly FilterableItem[]>,
103
+ ): ComputedRef<readonly FilterableItem[]> | Ref<readonly FilterableItem[]> {
104
+ if (typeof itemsIn === "function") {
105
+ return computed(itemsIn);
106
+ }
107
+ return toRef(itemsIn);
108
+ }
109
+
101
110
  function useTreeFilter(
102
111
  itemsIn: ReadonlyMaybeRefOrGetter<readonly FilterableItem[]>,
103
112
  options: TreeFilterOptions = {},
104
113
  ): UseTreeFilterReturn {
105
- const rawItems = typeof itemsIn === "function" ? computed(itemsIn) : toRef(itemsIn);
114
+ const rawItems = toItemsRef(itemsIn);
106
115
  const search = ref("");
107
116
  const sortType = ref(options.defaultSort ?? "name");
108
117
  const filterOptions = ref<Record<string, boolean>>({ ...options.defaultFilters });
@@ -82,8 +82,10 @@ export function useTreeKeyboardNav(
82
82
  return undefined;
83
83
  }
84
84
  const firstVisible = Math.max(0, Math.floor(info.scrollTop / info.itemHeight));
85
- const visibleCount =
86
- info.containerHeight > 0 ? Math.floor(info.containerHeight / info.itemHeight) : 1;
85
+ let visibleCount = 1;
86
+ if (info.containerHeight > 0) {
87
+ visibleCount = Math.floor(info.containerHeight / info.itemHeight);
88
+ }
87
89
  const lastVisible = Math.max(firstVisible, firstVisible + visibleCount - 1);
88
90
  return { firstVisible, lastVisible };
89
91
  }
@@ -172,11 +172,11 @@ export function useOverlappingPicker(): UseOverlappingPickerReturn {
172
172
  return new Promise<ViewerIdResult>((resolve) => {
173
173
  resolveIntermediate = (chosenResult: ProposedItem | undefined): void => {
174
174
  displayIntermediate.value = false;
175
- resolve(
176
- chosenResult
177
- ? { id: chosenResult.id, viewer_id: chosenResult.viewer_id }
178
- : { id: undefined, viewer_id: undefined },
179
- );
175
+ if (chosenResult) {
176
+ resolve({ id: chosenResult.id, viewer_id: chosenResult.viewer_id });
177
+ } else {
178
+ resolve({ id: undefined, viewer_id: undefined });
179
+ }
180
180
  };
181
181
  });
182
182
  }
@@ -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 };
@@ -0,0 +1,115 @@
1
+ import CameraBookmarkIcon from "@ogw_front/assets/viewer_svgs/camera-bookmark.svg";
2
+ import type { ViewToolbarTools } from "@ogw_front/composables/view_toolbar_tools";
3
+
4
+ interface CameraOptionAction {
5
+ title?: string;
6
+ testId: string;
7
+ tooltip?: string;
8
+ icon: string;
9
+ iconSize?: number;
10
+ color?: string;
11
+ action?: () => void;
12
+ menu?: CameraOptionAction[];
13
+ }
14
+
15
+ // The buttons opening a panel
16
+ function panelOptions(tools: ViewToolbarTools): CameraOptionAction[] {
17
+ return [
18
+ {
19
+ testId: "cameraOrientationButton",
20
+ tooltip: "Camera orientation",
21
+ icon: "mdi-rotate-3d",
22
+ action: (): void => {
23
+ tools.toggleTool(tools.showCameraOrientation);
24
+ },
25
+ },
26
+ {
27
+ testId: "cameraManagerButton",
28
+ tooltip: "Manage camera positions",
29
+ icon: CameraBookmarkIcon,
30
+ iconSize: 34,
31
+ action: (): void => {
32
+ tools.toggleTool(tools.showCameraManager);
33
+ },
34
+ },
35
+ {
36
+ testId: "screenshotButton",
37
+ tooltip: "Take a screenshot",
38
+ icon: "mdi-camera",
39
+ action: (): void => {
40
+ tools.toggleTool(tools.showScreenshot);
41
+ },
42
+ },
43
+ ];
44
+ }
45
+
46
+ // The buttons opening the scene controls
47
+ function controlOptions(tools: ViewToolbarTools): CameraOptionAction[] {
48
+ return [
49
+ {
50
+ testId: "zScalingButton",
51
+ tooltip: "Z Scaling Control",
52
+ icon: "mdi-sort",
53
+ action: (): void => {
54
+ tools.toggleTool(tools.showZScaling);
55
+ },
56
+ },
57
+ {
58
+ testId: "clippingPlanesButton",
59
+ tooltip: "Clipping Planes",
60
+ icon: "mdi-content-cut",
61
+ color: tools.showClippingPlanes.value ? "primary" : undefined,
62
+ action: (): void => {
63
+ tools.toggleTool(tools.showClippingPlanes);
64
+ },
65
+ },
66
+ ];
67
+ }
68
+
69
+ // The buttons opening the filters
70
+ function filterOptions(tools: ViewToolbarTools): CameraOptionAction[] {
71
+ return [
72
+ {
73
+ testId: "shrinkFilterButton",
74
+ tooltip: "Shrink Filter",
75
+ icon: "mdi-arrow-collapse-all",
76
+ color: tools.showShrinkFilter.value ? "primary" : undefined,
77
+ action: (): void => {
78
+ tools.toggleTool(tools.showShrinkFilter);
79
+ },
80
+ },
81
+ {
82
+ testId: "explodeFilterButton",
83
+ tooltip: "Exploded View",
84
+ icon: "mdi-arrow-expand-all",
85
+ color: tools.showExplodeFilter.value ? "primary" : undefined,
86
+ action: (): void => {
87
+ tools.toggleTool(tools.showExplodeFilter);
88
+ },
89
+ },
90
+ {
91
+ testId: "thresholdFilterButton",
92
+ tooltip: "Threshold Filter",
93
+ icon: "mdi-filter-variant",
94
+ color: tools.showThresholdFilter.value ? "primary" : undefined,
95
+ action: (): void => {
96
+ tools.toggleTool(tools.showThresholdFilter);
97
+ },
98
+ },
99
+ ];
100
+ }
101
+
102
+ function rulerOption(tools: ViewToolbarTools): CameraOptionAction {
103
+ return {
104
+ testId: "rulerButton",
105
+ tooltip: "Ruler",
106
+ icon: "mdi-ruler",
107
+ color: tools.showRuler.value ? "primary" : undefined,
108
+ action: (): void => {
109
+ tools.toggleTool(tools.showRuler);
110
+ },
111
+ };
112
+ }
113
+
114
+ export { controlOptions, filterOptions, panelOptions, rulerOption };
115
+ export type { CameraOptionAction };
@@ -0,0 +1,108 @@
1
+ import type { PickedFieldType } from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
2
+ import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
3
+ import { useViewerStore } from "@ogw_front/stores/viewer";
4
+
5
+ interface ToolRefs {
6
+ showScreenshot: Ref<boolean>;
7
+ showCameraManager: Ref<boolean>;
8
+ showCameraOrientation: Ref<boolean>;
9
+ showZScaling: Ref<boolean>;
10
+ showClippingPlanes: Ref<boolean>;
11
+ showShrinkFilter: Ref<boolean>;
12
+ showExplodeFilter: Ref<boolean>;
13
+ showThresholdFilter: Ref<boolean>;
14
+ showRuler: Ref<boolean>;
15
+ }
16
+
17
+ interface ViewToolbarTools extends ToolRefs {
18
+ is_picking: Ref<boolean>;
19
+ is_zoom_box_active: Ref<boolean>;
20
+ stopHoverHighlight: () => void;
21
+ toggleTool: (toolRef: Ref<boolean>) => void;
22
+ toggleHoverHighlight: (fieldType: PickedFieldType) => void;
23
+ }
24
+
25
+ function createToolRefs(): ToolRefs {
26
+ return {
27
+ showScreenshot: ref<boolean>(false),
28
+ showCameraManager: ref<boolean>(false),
29
+ showCameraOrientation: ref<boolean>(false),
30
+ showZScaling: ref<boolean>(false),
31
+ showClippingPlanes: ref<boolean>(false),
32
+ showShrinkFilter: ref<boolean>(false),
33
+ showExplodeFilter: ref<boolean>(false),
34
+ showThresholdFilter: ref<boolean>(false),
35
+ showRuler: ref<boolean>(false),
36
+ };
37
+ }
38
+
39
+ function exclusiveTools(toolRefs: ToolRefs, pickingTools: Ref<boolean>[]): Ref<boolean>[] {
40
+ return [
41
+ toolRefs.showCameraOrientation,
42
+ toolRefs.showCameraManager,
43
+ toolRefs.showScreenshot,
44
+ toolRefs.showZScaling,
45
+ toolRefs.showClippingPlanes,
46
+ toolRefs.showShrinkFilter,
47
+ toolRefs.showExplodeFilter,
48
+ toolRefs.showThresholdFilter,
49
+ toolRefs.showRuler,
50
+ ...pickingTools,
51
+ ];
52
+ }
53
+
54
+ // The toolbar tools are exclusive: opening one closes the others
55
+ function useViewToolbarTools(): ViewToolbarTools {
56
+ const hybridViewerStore = useHybridViewerStore();
57
+ const viewerStore = useViewerStore();
58
+ const { is_picking, is_zoom_box_active } = storeToRefs(hybridViewerStore);
59
+ const { picking_mode } = storeToRefs(viewerStore);
60
+ const toolRefs = createToolRefs();
61
+ const allTools = exclusiveTools(toolRefs, [is_picking, is_zoom_box_active, picking_mode]);
62
+
63
+ function stopHoverHighlight(): void {
64
+ hybridViewerStore.is_hover_highlight = false;
65
+ hybridViewerStore.clearHoverHighlight();
66
+ }
67
+
68
+ function closeAllToolsExcept(toolRef: Ref<boolean>): void {
69
+ for (const tool of allTools) {
70
+ if (tool !== toolRef) {
71
+ tool.value = false;
72
+ }
73
+ }
74
+ if (toolRef !== toolRefs.showRuler) {
75
+ void nextTick(stopHoverHighlight);
76
+ }
77
+ }
78
+
79
+ function toggleTool(toolRef: Ref<boolean>): void {
80
+ closeAllToolsExcept(toolRef);
81
+ toolRef.value = !toolRef.value;
82
+ }
83
+
84
+ function toggleHoverHighlight(fieldType: PickedFieldType): void {
85
+ const activate =
86
+ !hybridViewerStore.is_hover_highlight ||
87
+ hybridViewerStore.hover_highlight_field_type !== fieldType;
88
+ closeAllToolsExcept(toolRefs.showRuler);
89
+ if (activate) {
90
+ hybridViewerStore.is_hover_highlight = true;
91
+ hybridViewerStore.hover_highlight_field_type = fieldType;
92
+ } else {
93
+ stopHoverHighlight();
94
+ }
95
+ }
96
+
97
+ return {
98
+ ...toolRefs,
99
+ is_picking,
100
+ is_zoom_box_active,
101
+ stopHoverHighlight,
102
+ toggleTool,
103
+ toggleHoverHighlight,
104
+ };
105
+ }
106
+
107
+ export { useViewToolbarTools };
108
+ export type { ViewToolbarTools };