@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,127 @@
1
+ // PointSet components
2
+ import PointSetPointsOptions from "@ogw_front/components/Viewer/PointSet/SpecificPointsOptions.vue";
3
+
4
+ // EdgedCurve components
5
+ import EdgedCurveEdgesOptions from "@ogw_front/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue";
6
+ import EdgedCurvePointsOptions from "@ogw_front/components/Viewer/EdgedCurve/PointsOptions.vue";
7
+
8
+ // Surface components
9
+ import SurfaceEdgesOptions from "@ogw_front/components/Viewer/Surface/EdgesOptions.vue";
10
+ import SurfacePointsOptions from "@ogw_front/components/Viewer/Surface/PointsOptions.vue";
11
+ import SurfacePolygonsOptions from "@ogw_front/components/Viewer/Surface/PolygonsOptions.vue";
12
+
13
+ // TriangulatedSurface components
14
+ import TriangulatedSurfaceTrianglesOptions from "@ogw_front/components/Viewer/Surface/Triangulated/TrianglesOptions.vue";
15
+
16
+ // Grid 2D components
17
+ import Grid2DCellsOptions from "@ogw_front/components/Viewer/Grid/2D/CellsOptions.vue";
18
+ import Grid2DEdgesOptions from "@ogw_front/components/Viewer/Grid/2D/EdgesOptions.vue";
19
+ import Grid2DPointsOptions from "@ogw_front/components/Viewer/Grid/2D/PointsOptions.vue";
20
+
21
+ // Grid 3D components
22
+ import Grid3DCellsOptions from "@ogw_front/components/Viewer/Grid/3D/CellsOptions.vue";
23
+ import Grid3DEdgesOptions from "@ogw_front/components/Viewer/Grid/3D/EdgesOptions.vue";
24
+ import Grid3DPointsOptions from "@ogw_front/components/Viewer/Grid/3D/PointsOptions.vue";
25
+
26
+ // Solid components
27
+ import SolidEdgesOptions from "@ogw_front/components/Viewer/Solid/EdgesOptions.vue";
28
+ import SolidPointsOptions from "@ogw_front/components/Viewer/Solid/PointsOptions.vue";
29
+ import SolidPolygonsOptions from "@ogw_front/components/Viewer/Solid/PolygonsOptions.vue";
30
+ import SolidPolyhedraOptions from "@ogw_front/components/Viewer/Solid/SpecificPolyhedraOptions.vue";
31
+
32
+ // TetrahedralSolid components
33
+ import TetrahedralSolidTetrahedraOptions from "@ogw_front/components/Viewer/TetrahedralSolid/TetrahedraOptions.vue";
34
+ import TetrahedralSolidTrianglesOptions from "@ogw_front/components/Viewer/TetrahedralSolid/TrianglesOptions.vue";
35
+
36
+ // Model components
37
+ import ModelEdgesOptions from "@ogw_front/components/Viewer/Generic/Model/EdgesOptions.vue";
38
+ import ModelPointsOptions from "@ogw_front/components/Viewer/Generic/Model/PointsOptions.vue";
39
+ import ModelStyleOptions from "@ogw_front/components/Viewer/Generic/Model/ModelStyleOptions.vue";
40
+
41
+ import type { Component } from "vue";
42
+
43
+ type MenuItems = Component[];
44
+
45
+ const PointSet_menu = [PointSetPointsOptions];
46
+
47
+ const EdgedCurve_menu = [EdgedCurvePointsOptions, EdgedCurveEdgesOptions];
48
+
49
+ const PolygonalSurface_menu = [SurfacePointsOptions, SurfaceEdgesOptions, SurfacePolygonsOptions];
50
+
51
+ const TriangulatedSurface_menu = [
52
+ SurfacePointsOptions,
53
+ SurfaceEdgesOptions,
54
+ TriangulatedSurfaceTrianglesOptions,
55
+ ];
56
+
57
+ const Grid2D_menu = [Grid2DPointsOptions, Grid2DEdgesOptions, Grid2DCellsOptions];
58
+ const Grid3D_menu = [
59
+ Grid3DPointsOptions,
60
+ Grid3DEdgesOptions,
61
+ // Grid3DFacetsOptions,
62
+ Grid3DCellsOptions,
63
+ ];
64
+
65
+ const Solid_menu = [
66
+ SolidPointsOptions,
67
+ SolidEdgesOptions,
68
+ SolidPolygonsOptions,
69
+ SolidPolyhedraOptions,
70
+ ];
71
+
72
+ const TetrahedralSolid_menu = [
73
+ SolidPointsOptions,
74
+ SolidEdgesOptions,
75
+ TetrahedralSolidTrianglesOptions,
76
+ TetrahedralSolidTetrahedraOptions,
77
+ ];
78
+
79
+ const BRep_menu = [ModelEdgesOptions, ModelPointsOptions, ModelStyleOptions];
80
+
81
+ const CrossSection_menu = [ModelEdgesOptions, ModelPointsOptions, ModelStyleOptions];
82
+
83
+ const ImplicitCrossSection_menu = [ModelEdgesOptions, ModelPointsOptions, ModelStyleOptions];
84
+ const ImplicitStructuralModel_menu = [ModelEdgesOptions, ModelPointsOptions, ModelStyleOptions];
85
+
86
+ const Section_menu = [ModelEdgesOptions, ModelPointsOptions, ModelStyleOptions];
87
+
88
+ const StructuralModel_menu = [ModelEdgesOptions, ModelPointsOptions, ModelStyleOptions];
89
+
90
+ const ModelComponent_menu = [ModelEdgesOptions, ModelPointsOptions, ModelStyleOptions];
91
+
92
+ const menusData: Record<string, Record<string, MenuItems>> = {
93
+ mesh: {
94
+ EdgedCurve2D: EdgedCurve_menu,
95
+ EdgedCurve3D: EdgedCurve_menu,
96
+ HybridSolid3D: Solid_menu,
97
+ LightRegularGrid2D: Grid2D_menu,
98
+ LightRegularGrid3D: Grid3D_menu,
99
+ PointSet2D: PointSet_menu,
100
+ PointSet3D: PointSet_menu,
101
+ PolygonalSurface2D: PolygonalSurface_menu,
102
+ PolygonalSurface3D: PolygonalSurface_menu,
103
+ PolyhedralSolid3D: Solid_menu,
104
+ RegularGrid2D: Grid2D_menu,
105
+ RegularGrid3D: Grid3D_menu,
106
+ TetrahedralSolid3D: TetrahedralSolid_menu,
107
+ TriangulatedSurface2D: TriangulatedSurface_menu,
108
+ TriangulatedSurface3D: TriangulatedSurface_menu,
109
+ },
110
+ model: {
111
+ BRep: BRep_menu,
112
+ CrossSection: CrossSection_menu,
113
+ ImplicitCrossSection: ImplicitCrossSection_menu,
114
+ ImplicitStructuralModel: ImplicitStructuralModel_menu,
115
+ Section: Section_menu,
116
+ StructuralModel: StructuralModel_menu,
117
+ },
118
+ model_component_type: {
119
+ type: ModelComponent_menu,
120
+ },
121
+ model_component: {
122
+ component: ModelComponent_menu,
123
+ },
124
+ };
125
+
126
+ export { menusData };
127
+ export type { MenuItems };
@@ -70,6 +70,15 @@ interface ReadonlyTreeviewSnapshot {
70
70
  selection?: readonly (string | { id: string })[];
71
71
  }
72
72
 
73
+ function snapshotSelectionIds(snapshot: ReadonlyTreeviewSnapshot | undefined): string[] {
74
+ if (snapshot?.selectionIds) {
75
+ return [...snapshot.selectionIds];
76
+ }
77
+ return (snapshot?.selection ?? []).map((selectionItem: string | { id: string }) =>
78
+ typeof selectionItem === "string" ? selectionItem : selectionItem.id,
79
+ );
80
+ }
81
+
73
82
  // oxlint-disable-next-line max-lines-per-function, max-statements
74
83
  export const useTreeviewStore = defineStore("treeview", () => {
75
84
  const items = ref<TreeviewGroup[]>([]);
@@ -241,18 +250,16 @@ export const useTreeviewStore = defineStore("treeview", () => {
241
250
  }
242
251
 
243
252
  function importStores(snapshot: ReadonlyTreeviewSnapshot | undefined): void {
244
- opened_views.value = snapshot?.opened_views
245
- ? // oxlint-disable-next-line no-unsafe-type-assertion -- narrowing the readonly parameter view back to the mutable working type; these objects aren't actually frozen at runtime.
246
- ([...snapshot.opened_views] as OpenedView[])
247
- : defaultOpenedViews();
253
+ if (snapshot?.opened_views) {
254
+ // oxlint-disable-next-line no-unsafe-type-assertion -- narrowing the readonly parameter view back to the mutable working type; these objects aren't actually frozen at runtime.
255
+ opened_views.value = [...snapshot.opened_views] as OpenedView[];
256
+ } else {
257
+ opened_views.value = defaultOpenedViews();
258
+ }
248
259
  panelWidth.value = snapshot?.panelWidth ?? PANEL_WIDTH;
249
260
  additionalPanelWidth.value = snapshot?.additionalPanelWidth ?? PANEL_WIDTH;
250
- rowHeights.value = snapshot?.rowHeights ? [...snapshot.rowHeights] : [];
251
- pendingSelectionIds.value = snapshot?.selectionIds
252
- ? [...snapshot.selectionIds]
253
- : (snapshot?.selection ?? []).map((selectionItem: string | { id: string }) =>
254
- typeof selectionItem === "string" ? selectionItem : selectionItem.id,
255
- );
261
+ rowHeights.value = [...(snapshot?.rowHeights ?? [])];
262
+ pendingSelectionIds.value = snapshotSelectionIds(snapshot);
256
263
  }
257
264
 
258
265
  function finalizeImportSelection(): void {
@@ -4,24 +4,26 @@ import "@kitware/vtk.js/Rendering/OpenGL/Profiles/Geometry";
4
4
  import type { Vector3 } from "@kitware/vtk.js/types";
5
5
  import { connectImageStream } from "@kitware/vtk.js/Rendering/Misc/RemoteView";
6
6
  import { initWebSocketClient } from "@ogw_internal/utils/ws_client";
7
- import opengeodeweb_front_schemas from "@geode/opengeodeweb-front/opengeodeweb_front_typed_schemas.js";
8
7
  import opengeodeweb_viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
9
8
 
10
9
  // Local imports
10
+ import { type ViewerRequestArgs, callViewer } from "./viewer_helpers/request.js";
11
+ import {
12
+ fetchViewerVersion,
13
+ launchViewerMicroservice,
14
+ pickWorldPosition,
15
+ } from "./viewer_helpers/actions.js";
11
16
  import {
12
17
  getWebsocketApiPort,
13
18
  getWebsocketApiProtocol,
14
19
  isCloudMode,
15
20
  } from "@ogw_front/utils/stores.js";
16
21
  import { Status } from "@ogw_front/utils/status";
17
- import { useAppStore } from "@ogw_front/stores/app";
18
22
  import { useInfraStore } from "@ogw_front/stores/infra";
19
- import { viewer_call } from "@ogw_internal/utils/viewer_call";
20
23
 
21
24
  import type {
22
25
  JsonRpcSchema,
23
26
  MicroserviceVersionSchema,
24
- ParamsOf,
25
27
  RequestHandlers,
26
28
  ResponseOf,
27
29
  } from "@ogw_shared/utils/types.js";
@@ -34,9 +36,6 @@ interface PickedPoint {
34
36
  z: number | undefined;
35
37
  }
36
38
 
37
- const MS_PER_SECOND = 1000;
38
- const SECONDS_PER_REQUEST = 10;
39
- const request_timeout = MS_PER_SECOND * SECONDS_PER_REQUEST;
40
39
  export const useViewerStore = defineStore(
41
40
  "viewer",
42
41
  // oxlint-disable-next-line max-lines-per-function, max-statements
@@ -77,15 +76,7 @@ export const useViewerStore = defineStore(
77
76
  }
78
77
  // oxlint-disable-next-line unicorn/consistent-function-scoping
79
78
  async function request<Schema extends JsonRpcSchema>(
80
- {
81
- schema,
82
- params,
83
- timeout = request_timeout,
84
- }: {
85
- schema: Schema;
86
- params?: ParamsOf<Schema>;
87
- timeout?: number;
88
- },
79
+ args: ViewerRequestArgs<Schema>,
89
80
  callbacks: RequestHandlers<ResponseOf<Schema>> = {},
90
81
  ): Promise<ResponseOf<Schema>> {
91
82
  const microservice = {
@@ -95,38 +86,12 @@ export const useViewerStore = defineStore(
95
86
  start_request,
96
87
  stop_request,
97
88
  };
98
- const result = await viewer_call(
99
- microservice,
100
- {
101
- schema,
102
- params: params ?? {},
103
- timeout,
104
- },
105
- {
106
- ...callbacks,
107
- response_function: async (response: unknown) => {
108
- if (callbacks.response_function) {
109
- // The viewer validates its responses against the schema `response` it was generated from.
110
- // oxlint-disable-next-line typescript/no-unsafe-type-assertion
111
- await callbacks.response_function(response as ResponseOf<Schema>);
112
- }
113
- },
114
- },
115
- );
116
- // oxlint-disable-next-line typescript/no-unsafe-type-assertion
117
- return result as ResponseOf<Schema>;
89
+ const result = await callViewer(microservice, args, callbacks);
90
+ return result;
118
91
  }
119
92
  async function pick_world_position(x: number, y: number): Promise<Vector3> {
120
- const schema = opengeodeweb_viewer_schemas.opengeodeweb_viewer.viewer.get_point_position;
121
- const {
122
- x: world_x,
123
- y: world_y,
124
- z: world_z,
125
- } = await request({
126
- schema,
127
- params: { x: Math.round(x), y: Math.round(y) },
128
- });
129
- return [world_x, world_y, world_z];
93
+ const position = await pickWorldPosition(request, x, y);
94
+ return position;
130
95
  }
131
96
  async function set_picked_point(x: number, y: number): Promise<void> {
132
97
  const [world_x, world_y, world_z] = await pick_world_position(x, y);
@@ -166,25 +131,9 @@ export const useViewerStore = defineStore(
166
131
  });
167
132
  }
168
133
  async function launch(args: Readonly<{ projectFolderPath: string }>): Promise<unknown> {
169
- const appStore = useAppStore();
170
- const { COMMAND_VIEWER, NUXT_ROOT_PATH } = useRuntimeConfig().public;
171
- const schema = opengeodeweb_front_schemas.api.local.app.run_viewer;
172
- const params = {
173
- COMMAND_VIEWER,
174
- NUXT_ROOT_PATH,
175
- args,
176
- };
177
- const result = await appStore.request(
178
- {
179
- schema,
180
- params,
181
- },
182
- {
183
- response_function: (response) => {
184
- default_local_port.value = String(response.port);
185
- },
186
- },
187
- );
134
+ const result = await launchViewerMicroservice(args, (new_port) => {
135
+ default_local_port.value = new_port;
136
+ });
188
137
  return result;
189
138
  }
190
139
  async function connect(): Promise<void> {
@@ -193,19 +142,9 @@ export const useViewerStore = defineStore(
193
142
  async function get_version(
194
143
  schema: MicroserviceVersionSchema | undefined,
195
144
  ): Promise<{ microservice_version: string } | undefined> {
196
- if (!schema) {
197
- return undefined;
198
- }
199
- const result = await request(
200
- {
201
- schema,
202
- },
203
- {
204
- response_function: ({ microservice_version }) => {
205
- version.value = microservice_version;
206
- },
207
- },
208
- );
145
+ const result = await fetchViewerVersion(request, schema, (microservice_version) => {
146
+ version.value = microservice_version;
147
+ });
209
148
  return result;
210
149
  }
211
150
  return {
@@ -0,0 +1,68 @@
1
+ import type { MicroserviceVersionSchema } from "@ogw_shared/utils/types.js";
2
+ import type { Vector3 } from "@kitware/vtk.js/types";
3
+ import type { ViewerRequest } from "./request.js";
4
+ import opengeodeweb_front_schemas from "@geode/opengeodeweb-front/opengeodeweb_front_typed_schemas.js";
5
+ import opengeodeweb_viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
6
+ import { useAppStore } from "@ogw_front/stores/app";
7
+
8
+ async function pickWorldPosition(request: ViewerRequest, x: number, y: number): Promise<Vector3> {
9
+ const schema = opengeodeweb_viewer_schemas.opengeodeweb_viewer.viewer.get_point_position;
10
+ const {
11
+ x: world_x,
12
+ y: world_y,
13
+ z: world_z,
14
+ } = await request({
15
+ schema,
16
+ params: { x: Math.round(x), y: Math.round(y) },
17
+ });
18
+ return [world_x, world_y, world_z];
19
+ }
20
+
21
+ async function launchViewerMicroservice(
22
+ args: Readonly<{ projectFolderPath: string }>,
23
+ onPort: (port: string) => void,
24
+ ): Promise<unknown> {
25
+ const appStore = useAppStore();
26
+ const { COMMAND_VIEWER, NUXT_ROOT_PATH } = useRuntimeConfig().public;
27
+ const schema = opengeodeweb_front_schemas.api.local.app.run_viewer;
28
+ const params = {
29
+ COMMAND_VIEWER,
30
+ NUXT_ROOT_PATH,
31
+ args,
32
+ };
33
+ const result = await appStore.request(
34
+ {
35
+ schema,
36
+ params,
37
+ },
38
+ {
39
+ response_function: (response) => {
40
+ onPort(String(response.port));
41
+ },
42
+ },
43
+ );
44
+ return result;
45
+ }
46
+
47
+ async function fetchViewerVersion(
48
+ request: ViewerRequest,
49
+ schema: MicroserviceVersionSchema | undefined,
50
+ onVersion: (version: string) => void,
51
+ ): Promise<{ microservice_version: string } | undefined> {
52
+ if (!schema) {
53
+ return undefined;
54
+ }
55
+ const result = await request(
56
+ {
57
+ schema,
58
+ },
59
+ {
60
+ response_function: ({ microservice_version }) => {
61
+ onVersion(microservice_version);
62
+ },
63
+ },
64
+ );
65
+ return result;
66
+ }
67
+
68
+ export { fetchViewerVersion, launchViewerMicroservice, pickWorldPosition };
@@ -0,0 +1,61 @@
1
+ import type {
2
+ JsonRpcSchema,
3
+ ParamsOf,
4
+ RequestHandlers,
5
+ ResponseOf,
6
+ } from "@ogw_shared/utils/types.js";
7
+ import type { RpcClient } from "@ogw_shared/utils/call_raw.js";
8
+ import { viewer_call } from "@ogw_internal/utils/viewer_call";
9
+
10
+ interface ViewerRequestMicroservice {
11
+ $id: string;
12
+ client: RpcClient;
13
+ base_url: string;
14
+ start_request: () => void;
15
+ stop_request: () => void;
16
+ }
17
+
18
+ interface ViewerRequestArgs<Schema extends JsonRpcSchema> {
19
+ schema: Schema;
20
+ params?: ParamsOf<Schema>;
21
+ timeout?: number;
22
+ }
23
+
24
+ type ViewerRequest = <Schema extends JsonRpcSchema>(
25
+ args: ViewerRequestArgs<Schema>,
26
+ callbacks?: RequestHandlers<ResponseOf<Schema>>,
27
+ ) => Promise<ResponseOf<Schema>>;
28
+
29
+ const MS_PER_SECOND = 1000;
30
+ const SECONDS_PER_REQUEST = 10;
31
+ const request_timeout = MS_PER_SECOND * SECONDS_PER_REQUEST;
32
+
33
+ async function callViewer<Schema extends JsonRpcSchema>(
34
+ microservice: ViewerRequestMicroservice,
35
+ { schema, params, timeout = request_timeout }: ViewerRequestArgs<Schema>,
36
+ callbacks: RequestHandlers<ResponseOf<Schema>> = {},
37
+ ): Promise<ResponseOf<Schema>> {
38
+ const result = await viewer_call(
39
+ microservice,
40
+ {
41
+ schema,
42
+ params: params ?? {},
43
+ timeout,
44
+ },
45
+ {
46
+ ...callbacks,
47
+ response_function: async (response: unknown) => {
48
+ if (callbacks.response_function) {
49
+ // The viewer validates its responses against the schema `response` it was generated from.
50
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion
51
+ await callbacks.response_function(response as ResponseOf<Schema>);
52
+ }
53
+ },
54
+ },
55
+ );
56
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion
57
+ return result as ResponseOf<Schema>;
58
+ }
59
+
60
+ export { callViewer };
61
+ export type { ViewerRequest, ViewerRequestArgs };
@@ -1,7 +1,3 @@
1
- import type { Bounds } from "@kitware/vtk.js/types";
2
- import type vtkActor from "@kitware/vtk.js/Rendering/Core/Actor";
3
- import type { vtkCamera } from "@kitware/vtk.js/Rendering/Core/Camera";
4
-
5
1
  const AXIS_SCALE = 0.45;
6
2
  const SIZE_RATIO = 0.1;
7
3
  const DEBOUNCE_DELAY = 200;
@@ -79,130 +75,6 @@ function getPlaneStyle(rgb: readonly number[]): PlaneStyle {
79
75
  };
80
76
  }
81
77
 
82
- function computeSceneBounds(actors: readonly vtkActor[]): Bounds {
83
- let bounds: Bounds = [Infinity, -Infinity, Infinity, -Infinity, Infinity, -Infinity];
84
- for (const actor of actors) {
85
- const boundsOfActor = actor.getBounds();
86
- bounds = [
87
- Math.min(bounds[0], boundsOfActor[0]),
88
- Math.max(bounds[1], boundsOfActor[1]),
89
- Math.min(bounds[2], boundsOfActor[2]),
90
- Math.max(bounds[3], boundsOfActor[3]),
91
- Math.min(bounds[4], boundsOfActor[4]),
92
- Math.max(bounds[5], boundsOfActor[5]),
93
- ];
94
- }
95
- return bounds;
96
- }
97
-
98
- interface SceneBoundsInfo {
99
- readonly center: readonly number[];
100
- readonly cubicBounds: readonly number[];
101
- }
102
-
103
- function computeSceneBoundsInfo(actors: readonly vtkActor[]): SceneBoundsInfo {
104
- if (actors.length === 0) {
105
- return { center: [0, 0, 0], cubicBounds: [-1, 1, -1, 1, -1, 1] };
106
- }
107
- const [xmin, xmax, ymin, ymax, zmin, zmax] = computeSceneBounds(actors);
108
- const center = [
109
- Number(((xmin + xmax) / 2).toFixed(4)),
110
- Number(((ymin + ymax) / 2).toFixed(4)),
111
- Number(((zmin + zmax) / 2).toFixed(4)),
112
- ];
113
-
114
- const maxActorExtent = Math.max(
115
- ...actors.map((actor: vtkActor) => {
116
- const bounds = actor.getBounds();
117
- return Math.max(bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]);
118
- }),
119
- );
120
- const halfExtent = maxActorExtent / 2;
121
- const [centerX = 0, centerY = 0, centerZ = 0] = center;
122
- const cubicBounds = [
123
- centerX - halfExtent,
124
- centerX + halfExtent,
125
- centerY - halfExtent,
126
- centerY + halfExtent,
127
- centerZ - halfExtent,
128
- centerZ + halfExtent,
129
- ];
130
- return { center, cubicBounds };
131
- }
132
-
133
- interface ActorEntry {
134
- readonly actor: vtkActor;
135
- }
136
-
137
- interface MainCameraOptions {
138
- readonly focal_point?: readonly number[];
139
- readonly position?: readonly number[];
140
- readonly view_up?: readonly number[];
141
- }
142
-
143
- function resolveActiveActors(
144
- targetAllVisible: boolean,
145
- allItems: readonly { readonly id: string }[],
146
- selectedDatasetIds: readonly string[],
147
- hybridDb: Record<string, ActorEntry | undefined>,
148
- ): vtkActor[] {
149
- const targetIds = targetAllVisible
150
- ? allItems.map((item: { id: string }) => item.id)
151
- : selectedDatasetIds;
152
- const targeted = targetIds
153
- .map((id) => hybridDb[id]?.actor)
154
- .filter((actor: vtkActor | undefined): actor is vtkActor => actor !== undefined);
155
- if (targeted.length > 0) {
156
- return targeted;
157
- }
158
- return Object.values(hybridDb)
159
- .filter((entry: ActorEntry | undefined): entry is ActorEntry => entry !== undefined)
160
- .map((entry: ActorEntry) => entry.actor);
161
- }
162
-
163
- function computeNormalizedViewDirection(
164
- focalPoint: readonly number[],
165
- position: readonly number[],
166
- ): readonly number[] | undefined {
167
- const dir = [
168
- (position[0] ?? 0) - (focalPoint[0] ?? 0),
169
- (position[1] ?? 0) - (focalPoint[1] ?? 0),
170
- (position[2] ?? 0) - (focalPoint[2] ?? 0),
171
- ];
172
- const dirLen = Math.hypot(...dir);
173
- if (dirLen === 0) {
174
- return undefined;
175
- }
176
- return dir.map((component) => component / dirLen);
177
- }
178
-
179
- // Aligns the local clipping-plane preview camera onto the same viewing direction as the
180
- // Main viewer camera, re-centered on the clipped scene's bounds.
181
- function alignCameraToMainCamera(
182
- camera: vtkCamera,
183
- mainCam: MainCameraOptions,
184
- center: readonly number[],
185
- ): void {
186
- if (!mainCam.focal_point || !mainCam.position) {
187
- return;
188
- }
189
- const normDir = computeNormalizedViewDirection(mainCam.focal_point, mainCam.position);
190
- if (!normDir) {
191
- return;
192
- }
193
- const distance = camera.getDistance();
194
- camera.setFocalPoint(center[0] ?? 0, center[1] ?? 0, center[2] ?? 0);
195
- camera.setPosition(
196
- (center[0] ?? 0) + (normDir[0] ?? 0) * distance,
197
- (center[1] ?? 0) + (normDir[1] ?? 0) * distance,
198
- (center[2] ?? 0) + (normDir[2] ?? 0) * distance,
199
- );
200
- if (mainCam.view_up) {
201
- const [viewUpX = 0, viewUpY = 0, viewUpZ = 0] = mainCam.view_up;
202
- camera.setViewUp(viewUpX, viewUpY, viewUpZ);
203
- }
204
- }
205
-
206
78
  export {
207
79
  AXIS_SCALE,
208
80
  SIZE_RATIO,
@@ -213,10 +85,11 @@ export {
213
85
  getPlaneCssColor,
214
86
  hasPlaneChanged,
215
87
  getPlaneStyle,
88
+ };
89
+ export {
216
90
  computeSceneBounds,
217
91
  computeSceneBoundsInfo,
218
92
  resolveActiveActors,
219
93
  alignCameraToMainCamera,
220
- };
221
-
222
- export type { SceneBoundsInfo, MainCameraOptions };
94
+ } from "./clipping_planes_scene";
95
+ export type { SceneBoundsInfo, MainCameraOptions } from "./clipping_planes_scene";