@geode/opengeodeweb-front 10.36.0 → 10.37.0

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 (93) hide show
  1. package/app/components/Screenshot.vue +6 -4
  2. package/app/components/ViewToolbar.vue +4 -2
  3. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +7 -4
  4. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +10 -4
  5. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +7 -4
  6. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +5 -2
  7. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +10 -6
  8. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +7 -6
  9. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +9 -18
  10. package/app/components/Viewer/Generic/Model/CornersOptions.vue +5 -10
  11. package/app/components/Viewer/Generic/Model/EdgesOptions.vue +3 -0
  12. package/app/components/Viewer/Generic/Model/LinesOptions.vue +9 -17
  13. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +8 -18
  14. package/app/components/Viewer/ObjectTree/Views/ModelTree.vue +1 -5
  15. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +11 -2
  16. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +7 -6
  17. package/app/components/Viewer/Surface/PolygonsOptions.vue +10 -6
  18. package/app/composables/hover_highlight.ts +5 -4
  19. package/app/composables/project_manager.ts +1 -1
  20. package/app/composables/use_overlapping_picker.ts +4 -73
  21. package/app/composables/use_quick_colormap.ts +4 -14
  22. package/app/stores/back.ts +4 -10
  23. package/app/stores/camera_manager.ts +1 -1
  24. package/app/stores/data.ts +1 -1
  25. package/app/stores/viewer.ts +33 -19
  26. package/internal/stores/data_style/mesh/cells/cell.ts +26 -23
  27. package/internal/stores/data_style/mesh/cells/color.ts +8 -6
  28. package/internal/stores/data_style/mesh/cells/index.ts +13 -6
  29. package/internal/stores/data_style/mesh/cells/textures.ts +17 -6
  30. package/internal/stores/data_style/mesh/cells/vertex.ts +29 -23
  31. package/internal/stores/data_style/mesh/cells/visibility.ts +3 -6
  32. package/internal/stores/data_style/mesh/edges/color.ts +8 -6
  33. package/internal/stores/data_style/mesh/edges/edge.ts +26 -23
  34. package/internal/stores/data_style/mesh/edges/index.ts +13 -3
  35. package/internal/stores/data_style/mesh/edges/vertex.ts +29 -23
  36. package/internal/stores/data_style/mesh/edges/visibility.ts +3 -6
  37. package/internal/stores/data_style/mesh/edges/width.ts +3 -3
  38. package/internal/stores/data_style/mesh/index.ts +24 -11
  39. package/internal/stores/data_style/mesh/points/color.ts +8 -6
  40. package/internal/stores/data_style/mesh/points/index.ts +13 -6
  41. package/internal/stores/data_style/mesh/points/size.ts +3 -3
  42. package/internal/stores/data_style/mesh/points/vertex.ts +29 -23
  43. package/internal/stores/data_style/mesh/points/visibility.ts +5 -11
  44. package/internal/stores/data_style/mesh/polygons/color.ts +8 -6
  45. package/internal/stores/data_style/mesh/polygons/index.ts +13 -9
  46. package/internal/stores/data_style/mesh/polygons/polygon.ts +26 -23
  47. package/internal/stores/data_style/mesh/polygons/textures.ts +17 -6
  48. package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -23
  49. package/internal/stores/data_style/mesh/polygons/visibility.ts +3 -6
  50. package/internal/stores/data_style/mesh/polyhedra/color.ts +8 -6
  51. package/internal/stores/data_style/mesh/polyhedra/index.ts +9 -5
  52. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +28 -23
  53. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -23
  54. package/internal/stores/data_style/mesh/polyhedra/visibility.ts +3 -6
  55. package/internal/stores/data_style/model/blocks/color.ts +8 -6
  56. package/internal/stores/data_style/model/blocks/index.ts +9 -22
  57. package/internal/stores/data_style/model/blocks/polyhedron.ts +28 -23
  58. package/internal/stores/data_style/model/blocks/vertex.ts +26 -23
  59. package/internal/stores/data_style/model/blocks/visibility.ts +3 -3
  60. package/internal/stores/data_style/model/color.ts +10 -7
  61. package/internal/stores/data_style/model/common.ts +36 -20
  62. package/internal/stores/data_style/model/corners/color.ts +8 -6
  63. package/internal/stores/data_style/model/corners/index.ts +8 -14
  64. package/internal/stores/data_style/model/corners/vertex.ts +26 -23
  65. package/internal/stores/data_style/model/corners/visibility.ts +3 -3
  66. package/internal/stores/data_style/model/edges/visibility.ts +8 -8
  67. package/internal/stores/data_style/model/lines/color.ts +8 -6
  68. package/internal/stores/data_style/model/lines/edge.ts +26 -23
  69. package/internal/stores/data_style/model/lines/index.ts +9 -22
  70. package/internal/stores/data_style/model/lines/vertex.ts +26 -23
  71. package/internal/stores/data_style/model/lines/visibility.ts +3 -3
  72. package/internal/stores/data_style/model/points/index.ts +14 -4
  73. package/internal/stores/data_style/model/points/size.ts +3 -3
  74. package/internal/stores/data_style/model/points/visibility.ts +3 -6
  75. package/internal/stores/data_style/model/surfaces/color.ts +8 -6
  76. package/internal/stores/data_style/model/surfaces/index.ts +9 -22
  77. package/internal/stores/data_style/model/surfaces/polygon.ts +29 -23
  78. package/internal/stores/data_style/model/surfaces/vertex.ts +26 -23
  79. package/internal/stores/data_style/model/surfaces/visibility.ts +3 -3
  80. package/internal/stores/data_style/model/visibility.ts +1 -1
  81. package/internal/stores/data_style/when_defined.ts +13 -0
  82. package/internal/stores/hybrid_viewer/camera.ts +14 -15
  83. package/internal/stores/hybrid_viewer/core.ts +1 -1
  84. package/internal/stores/hybrid_viewer/filters.ts +12 -6
  85. package/internal/stores/hybrid_viewer/highlight.ts +9 -18
  86. package/internal/stores/hybrid_viewer/ruler.ts +10 -13
  87. package/internal/stores/hybrid_viewer/scene.ts +1 -1
  88. package/internal/utils/viewer_call.ts +1 -1
  89. package/package.json +1 -1
  90. package/server/utils/ws_client.ts +4 -4
  91. package/shared/utils/call_raw.ts +3 -3
  92. package/shared/utils/call_schema.ts +10 -8
  93. package/shared/utils/types.ts +6 -0
@@ -4,12 +4,14 @@ import type {
4
4
  ModelComponentTypeStyle,
5
5
  StyleValues,
6
6
  } from "@ogw_internal/stores/data_style/types.js";
7
- import type { JsonRpcSchema } from "@ogw_shared/utils/types.js";
7
+ import type { ParamsOf } from "@ogw_shared/utils/types.js";
8
+ import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
8
9
  import { database } from "@ogw_internal/database/database";
9
10
  import merge from "lodash/merge";
10
11
  import { useDataStore } from "@ogw_front/stores/data";
11
12
  import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
12
13
  import { useViewerStore } from "@ogw_front/stores/viewer";
14
+ import type viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
13
15
 
14
16
  // The underlying dexie tables use compound array keys ([id_model, id_component] /
15
17
  // [id_model, type]) but the shared `database` proxy types every table as
@@ -17,6 +19,19 @@ import { useViewerStore } from "@ogw_front/stores/viewer";
17
19
  type ComponentTable = Table<ModelComponentStyle, [string, string]>;
18
20
  type ComponentTypeTable = Table<ModelComponentTypeStyle, [string, string]>;
19
21
 
22
+ type ModelComponentSchemas = (typeof viewer_schemas)["opengeodeweb_viewer"]["model"][
23
+ | "corners"
24
+ | "lines"
25
+ | "surfaces"
26
+ | "blocks"];
27
+ type ModelColorSchema = ModelComponentSchemas["color"];
28
+ type ModelVisibilitySchema = ModelComponentSchemas["visibility"];
29
+ type ModelColorMode = ParamsOf<ModelColorSchema>["color_mode"];
30
+
31
+ function isModelColorMode(value: string): value is ModelColorMode {
32
+ return value === "constant" || value === "random";
33
+ }
34
+
20
35
  interface ComponentStyleUpdate {
21
36
  id_component: string;
22
37
  values: StyleValues;
@@ -45,16 +60,16 @@ interface UseModelCommonStyleReturn {
45
60
  setModelTypeColor: (
46
61
  id: string,
47
62
  component_ids: string[],
48
- color: unknown,
49
- schema: JsonRpcSchema,
63
+ color: RGBAColor | undefined,
64
+ schema: ModelColorSchema,
50
65
  activeColoring?: string,
51
66
  collectionId?: string,
52
67
  ) => Promise<unknown>;
53
68
  setModelTypeVisibility: (
54
69
  id: string,
55
70
  component_ids: string[],
56
- visibility: boolean | undefined,
57
- schema: JsonRpcSchema,
71
+ visibility: boolean,
72
+ schema: ModelVisibilitySchema,
58
73
  ) => Promise<unknown>;
59
74
  }
60
75
 
@@ -164,8 +179,8 @@ export function useModelCommonStyle(): UseModelCommonStyleReturn {
164
179
  async function setModelTypeColor(
165
180
  id: string,
166
181
  component_ids: string[],
167
- color: unknown,
168
- schema: JsonRpcSchema,
182
+ color: RGBAColor | undefined,
183
+ schema: ModelColorSchema,
169
184
  activeColoring = "constant",
170
185
  collectionId?: string,
171
186
  ): Promise<unknown> {
@@ -178,27 +193,28 @@ export function useModelCommonStyle(): UseModelCommonStyleReturn {
178
193
  return undefined;
179
194
  }
180
195
 
181
- const params: Record<string, unknown> = {
182
- id,
183
- block_ids: viewer_ids,
184
- color_mode: activeColoring,
185
- collection_id: collectionId,
186
- };
187
196
  if (activeColoring === "constant") {
188
197
  await mutateComponentStyles(id, component_ids, {
189
198
  coloring: {
190
199
  constant: color,
191
200
  },
192
201
  });
193
- params.color = color;
194
202
  }
203
+ if (!isModelColorMode(activeColoring)) {
204
+ throw new Error(`Unknown model color mode: ${activeColoring}`);
205
+ }
206
+ const params = {
207
+ id,
208
+ block_ids: viewer_ids,
209
+ color_mode: activeColoring,
210
+ collection_id: collectionId,
211
+ ...(activeColoring === "constant" && { color }),
212
+ };
195
213
 
196
214
  return viewerStore.request(
197
215
  { schema, params },
198
216
  {
199
- response_function: async (response: unknown) => {
200
- // oxlint-disable-next-line no-unsafe-type-assertion -- response shape is defined by the color-set schema.
201
- const colors = response as { geode_id: string; color: unknown }[] | undefined;
217
+ response_function: async ({ colors }) => {
202
218
  if (activeColoring === "constant") {
203
219
  await mutateComponentStyles(id, component_ids, {
204
220
  coloring: {
@@ -208,7 +224,7 @@ export function useModelCommonStyle(): UseModelCommonStyleReturn {
208
224
  return;
209
225
  }
210
226
 
211
- if (colors === undefined || colors.length === 0) {
227
+ if (colors.length === 0) {
212
228
  return;
213
229
  }
214
230
 
@@ -231,8 +247,8 @@ export function useModelCommonStyle(): UseModelCommonStyleReturn {
231
247
  async function setModelTypeVisibility(
232
248
  id: string,
233
249
  component_ids: string[],
234
- visibility: boolean | undefined,
235
- schema: JsonRpcSchema,
250
+ visibility: boolean,
251
+ schema: ModelVisibilitySchema,
236
252
  ): Promise<unknown> {
237
253
  if (!component_ids?.length) {
238
254
  return undefined;
@@ -1,9 +1,10 @@
1
1
  import { isModelCornersVertexAttributeValid, useModelCornersVertexAttribute } from "./vertex";
2
+ import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
2
3
  import type { StyleValues } from "@ogw_internal/stores/data_style/types.js";
3
4
  import { useDataStore } from "@ogw_front/stores/data";
4
5
  import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
5
6
  import { useModelCornersCommonStyle } from "./common";
6
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
7
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
7
8
 
8
9
  const schema = viewer_schemas.opengeodeweb_viewer.model.corners.color;
9
10
 
@@ -11,12 +12,12 @@ interface ModelCornersColorApi {
11
12
  setModelCornersColor: (
12
13
  modelId: string,
13
14
  corners_ids: string[],
14
- color: unknown,
15
+ color: RGBAColor | undefined,
15
16
  activeColoring?: string,
16
17
  collectionId?: string,
17
18
  ) => Promise<unknown>;
18
19
  modelCornerColoring: (id: string, corner_id?: string) => StyleValues;
19
- modelCornerColor: (id: string, corner_id?: string) => unknown;
20
+ modelCornerColor: (id: string, corner_id?: string) => RGBAColor | undefined;
20
21
  modelCornerActiveColoring: (id: string, corner_id?: string) => unknown;
21
22
  setModelCornersActiveColoring: (
22
23
  modelId: string,
@@ -37,14 +38,15 @@ export function useModelCornersColor(): ModelCornersColorApi {
37
38
  return modelCornersCommonStyle.modelCornerStyle(id, corner_id).coloring as StyleValues;
38
39
  }
39
40
 
40
- function modelCornerColor(id: string, corner_id?: string): unknown {
41
- return modelCornerColoring(id, corner_id).constant;
41
+ function modelCornerColor(id: string, corner_id?: string): RGBAColor | undefined {
42
+ // oxlint-disable-next-line no-unsafe-type-assertion -- coloring.constant shape is defined by the data style schema.
43
+ return modelCornerColoring(id, corner_id).constant as RGBAColor | undefined;
42
44
  }
43
45
 
44
46
  async function setModelCornersColor(
45
47
  modelId: string,
46
48
  corners_ids: string[],
47
- color: unknown,
49
+ color: RGBAColor | undefined,
48
50
  activeColoring = "constant",
49
51
  collectionId?: string,
50
52
  ): Promise<unknown> {
@@ -1,20 +1,21 @@
1
1
  import { isModelCornersVertexAttributeValid, useModelCornersVertexAttribute } from "./vertex";
2
+ import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
2
3
  import { useDataStore } from "@ogw_front/stores/data";
3
4
  import { useModelCornersColor } from "./color";
4
5
  import { useModelCornersCommonStyle } from "./common";
5
6
  import { useModelCornersVisibility } from "./visibility";
6
7
 
7
8
  interface ColorGroup {
8
- color: unknown;
9
+ color: RGBAColor | undefined;
9
10
  corners_ids: string[];
10
11
  }
11
12
 
12
13
  interface AttributeGroup {
13
- name: string | undefined;
14
- item: number | undefined;
15
- minimum: number | undefined;
16
- maximum: number | undefined;
17
- colorMap: string | undefined;
14
+ name: string;
15
+ item: number;
16
+ minimum: number;
17
+ maximum: number;
18
+ colorMap: string;
18
19
  corners_ids: string[];
19
20
  }
20
21
 
@@ -122,14 +123,7 @@ export function useModelCornersStyle(): ModelCornersStyleApi {
122
123
  continue;
123
124
  }
124
125
  const key = `${name}_${item}_${colorMap}_${minimum}_${maximum}`;
125
- vertexGroups[key] ??= {
126
- name,
127
- item,
128
- minimum,
129
- maximum,
130
- colorMap,
131
- corners_ids: [],
132
- };
126
+ vertexGroups[key] ??= { ...attribute, corners_ids: [] };
133
127
  vertexGroups[key].corners_ids.push(corner_id);
134
128
  }
135
129
  coloringPromises.push(
@@ -1,6 +1,6 @@
1
- import { DEFAULT_NO_DATA_COLOR } from "@ogw_front/utils/default_styles/constants";
1
+ import { DEFAULT_NO_DATA_COLOR, type RGBAColor } from "@ogw_front/utils/default_styles/constants";
2
2
  // Third party imports
3
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
4
4
 
5
5
  // Local imports
6
6
  import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap";
@@ -15,7 +15,7 @@ interface AttributeStoredConfig {
15
15
  minimum: number | undefined;
16
16
  maximum: number | undefined;
17
17
  colorMap: string | undefined;
18
- no_data_color: unknown;
18
+ no_data_color: RGBAColor;
19
19
  }
20
20
 
21
21
  interface AttributeState {
@@ -30,7 +30,16 @@ interface AttributeInput {
30
30
  minimum: number | undefined;
31
31
  maximum: number | undefined;
32
32
  colorMap: string | undefined;
33
- no_data_color?: unknown;
33
+ no_data_color?: RGBAColor;
34
+ }
35
+
36
+ interface ValidAttributeInput {
37
+ name: string;
38
+ item: number;
39
+ minimum: number;
40
+ maximum: number;
41
+ colorMap: string;
42
+ no_data_color?: RGBAColor;
34
43
  }
35
44
 
36
45
  type IdsFn<Value> = (modelId: string, cornerIds: string[], value: Value) => Promise<void>;
@@ -52,7 +61,7 @@ interface ModelCornersVertexAttributeApi {
52
61
  setModelCornersVertexAttribute: (
53
62
  modelId: string,
54
63
  cornerIds: string[],
55
- attribute: AttributeInput,
64
+ attribute: ValidAttributeInput,
56
65
  ) => Promise<unknown>;
57
66
  setModelCornersVertexAttributeName: IdsFn<string>;
58
67
  setModelCornersVertexAttributeItem: IdsFn<number>;
@@ -63,23 +72,17 @@ interface ModelCornersVertexAttributeApi {
63
72
  maximum: number,
64
73
  ) => Promise<void>;
65
74
  setModelCornersVertexAttributeColorMap: IdsFn<string | undefined>;
66
- modelCornersVertexAttributeNoDataColor: (modelId: string, cornerId?: string) => unknown;
67
- setModelCornersVertexAttributeNoDataColor: IdsFn<unknown>;
75
+ modelCornersVertexAttributeNoDataColor: (modelId: string, cornerId?: string) => RGBAColor;
76
+ setModelCornersVertexAttributeNoDataColor: IdsFn<RGBAColor>;
68
77
  }
69
78
 
70
- function isModelCornersVertexAttributeValid({
71
- name,
72
- item,
73
- minimum,
74
- maximum,
75
- colorMap,
76
- }: AttributeInput): boolean {
79
+ function isModelCornersVertexAttributeValid(input: AttributeInput): input is ValidAttributeInput {
77
80
  return (
78
- name !== undefined &&
79
- item !== undefined &&
80
- minimum !== undefined &&
81
- maximum !== undefined &&
82
- colorMap !== undefined
81
+ input.name !== undefined &&
82
+ input.item !== undefined &&
83
+ input.minimum !== undefined &&
84
+ input.maximum !== undefined &&
85
+ input.colorMap !== undefined
83
86
  );
84
87
  }
85
88
 
@@ -197,7 +200,7 @@ function useModelCornersVertexAttribute(): ModelCornersVertexAttributeApi {
197
200
  maximum,
198
201
  colorMap,
199
202
  no_data_color = DEFAULT_NO_DATA_COLOR,
200
- }: AttributeInput,
203
+ }: ValidAttributeInput,
201
204
  ): Promise<unknown> {
202
205
  await mutateModelCornersVertexStyle(modelId, cornerIds, { name, item });
203
206
  await setModelCornersVertexAttributeStoredConfig(modelId, cornerIds, name, item, {
@@ -206,7 +209,7 @@ function useModelCornersVertexAttribute(): ModelCornersVertexAttributeApi {
206
209
  colorMap,
207
210
  no_data_color,
208
211
  });
209
- const points = getRGBPointsFromPreset(colorMap ?? "");
212
+ const points = [...getRGBPointsFromPreset(colorMap)];
210
213
  const corner_viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, cornerIds);
211
214
  const params = {
212
215
  id: modelId,
@@ -278,7 +281,7 @@ function useModelCornersVertexAttribute(): ModelCornersVertexAttributeApi {
278
281
  await setModelCornersVertexAttributeStoredConfig(modelId, cornerIds, name, item, { colorMap });
279
282
  await applyVertexAttribute(modelId, cornerIds);
280
283
  }
281
- function modelCornersVertexAttributeNoDataColor(modelId: string, cornerId?: string): unknown {
284
+ function modelCornersVertexAttributeNoDataColor(modelId: string, cornerId?: string): RGBAColor {
282
285
  const name = modelCornersVertexAttributeName(modelId, cornerId);
283
286
  const item = modelCornersVertexAttributeItem(modelId, cornerId);
284
287
  return modelCornersVertexAttributeStoredConfig(modelId, cornerId, name, item).no_data_color;
@@ -286,7 +289,7 @@ function useModelCornersVertexAttribute(): ModelCornersVertexAttributeApi {
286
289
  async function setModelCornersVertexAttributeNoDataColor(
287
290
  modelId: string,
288
291
  cornerIds: string[],
289
- no_data_color: unknown,
292
+ no_data_color: RGBAColor,
290
293
  ): Promise<void> {
291
294
  const name = modelCornersVertexAttributeName(modelId, cornerIds[0]);
292
295
  const item = modelCornersVertexAttributeItem(modelId, cornerIds[0]);
@@ -1,6 +1,6 @@
1
1
  import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
2
2
  import { useModelCornersCommonStyle } from "./common";
3
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
3
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
4
4
 
5
5
  const schema = viewer_schemas.opengeodeweb_viewer.model.corners.visibility;
6
6
 
@@ -8,7 +8,7 @@ interface ModelCornersVisibilityApi {
8
8
  setModelCornersVisibility: (
9
9
  modelId: string,
10
10
  corners_ids: string[],
11
- visibility: boolean | undefined,
11
+ visibility: boolean,
12
12
  ) => Promise<unknown>;
13
13
  modelCornerVisibility: (id: string, corner_id?: string) => unknown;
14
14
  }
@@ -24,7 +24,7 @@ export function useModelCornersVisibility(): ModelCornersVisibilityApi {
24
24
  async function setModelCornersVisibility(
25
25
  modelId: string,
26
26
  corners_ids: string[],
27
- visibility: boolean | undefined,
27
+ visibility: boolean,
28
28
  ): Promise<unknown> {
29
29
  const result = await modelCommonStyle.setModelTypeVisibility(
30
30
  modelId,
@@ -1,15 +1,16 @@
1
1
  // Third party imports
2
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
2
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
3
3
 
4
4
  import { useModelEdgesCommonStyle } from "./common";
5
5
  import { useViewerStore } from "@ogw_front/stores/viewer";
6
+ import { whenDefined } from "@ogw_internal/stores/data_style/when_defined";
6
7
 
7
8
  // Local constants
8
9
  const schema = viewer_schemas.opengeodeweb_viewer.model.edges.visibility;
9
10
 
10
11
  interface ModelEdgesVisibilityStyleApi {
11
12
  modelEdgesVisibility: (id: string) => boolean | undefined;
12
- setModelEdgesVisibility: (id: string, visibility: boolean | undefined) => Promise<unknown>;
13
+ setModelEdgesVisibility: (id: string, visibility: boolean) => Promise<unknown>;
13
14
  applyModelEdgesStyle: (id: string) => Promise<unknown[]>;
14
15
  }
15
16
 
@@ -25,10 +26,7 @@ export function useModelEdgesVisibilityStyle(): ModelEdgesVisibilityStyleApi {
25
26
  return undefined;
26
27
  }
27
28
 
28
- async function setModelEdgesVisibility(
29
- id: string,
30
- visibility: boolean | undefined,
31
- ): Promise<unknown> {
29
+ async function setModelEdgesVisibility(id: string, visibility: boolean): Promise<unknown> {
32
30
  const params = { id, visibility };
33
31
  const result = await viewerStore.request(
34
32
  { schema, params },
@@ -42,8 +40,10 @@ export function useModelEdgesVisibilityStyle(): ModelEdgesVisibilityStyleApi {
42
40
  }
43
41
 
44
42
  async function applyModelEdgesStyle(id: string): Promise<unknown[]> {
45
- const visibility = modelEdgesVisibility(id);
46
- const result = await setModelEdgesVisibility(id, visibility);
43
+ const result = await whenDefined(modelEdgesVisibility(id), async (visibility) => {
44
+ const applied = await setModelEdgesVisibility(id, visibility);
45
+ return applied;
46
+ });
47
47
  return [result];
48
48
  }
49
49
 
@@ -1,10 +1,11 @@
1
1
  import { isModelLinesEdgeAttributeValid, useModelLinesEdgeAttribute } from "./edge";
2
2
  import { isModelLinesVertexAttributeValid, useModelLinesVertexAttribute } from "./vertex";
3
+ import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
3
4
  import type { StyleValues } from "@ogw_internal/stores/data_style/types.js";
4
5
  import { useDataStore } from "@ogw_front/stores/data";
5
6
  import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
6
7
  import { useModelLinesCommonStyle } from "./common";
7
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
8
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
8
9
 
9
10
  const schema = viewer_schemas.opengeodeweb_viewer.model.lines.color;
10
11
 
@@ -12,12 +13,12 @@ export function useModelLinesColor(): {
12
13
  setModelLinesColor: (
13
14
  modelId: string,
14
15
  lines_ids: string[],
15
- color: unknown,
16
+ color: RGBAColor | undefined,
16
17
  activeColoring?: string,
17
18
  collectionId?: string,
18
19
  ) => Promise<unknown>;
19
20
  modelLineColoring: (id: string, line_id?: string) => StyleValues;
20
- modelLineColor: (id: string, line_id?: string) => unknown;
21
+ modelLineColor: (id: string, line_id?: string) => RGBAColor | undefined;
21
22
  modelLineActiveColoring: (id: string, line_id?: string) => unknown;
22
23
  setModelLinesActiveColoring: (
23
24
  modelId: string,
@@ -37,14 +38,15 @@ export function useModelLinesColor(): {
37
38
  return modelLinesCommonStyle.modelLineStyle(id, line_id).coloring as StyleValues;
38
39
  }
39
40
 
40
- function modelLineColor(id: string, line_id?: string): unknown {
41
- return modelLineColoring(id, line_id).constant;
41
+ function modelLineColor(id: string, line_id?: string): RGBAColor | undefined {
42
+ // oxlint-disable-next-line no-unsafe-type-assertion -- coloring.constant shape is defined by the data style schema.
43
+ return modelLineColoring(id, line_id).constant as RGBAColor | undefined;
42
44
  }
43
45
 
44
46
  async function setModelLinesColor(
45
47
  modelId: string,
46
48
  lines_ids: string[],
47
- color: unknown,
49
+ color: RGBAColor | undefined,
48
50
  activeColoring = "constant",
49
51
  collectionId?: string,
50
52
  ): Promise<unknown> {
@@ -1,7 +1,7 @@
1
1
  // oxlint-disable eslint/max-lines
2
- import { DEFAULT_NO_DATA_COLOR } from "@ogw_front/utils/default_styles/constants";
2
+ import { DEFAULT_NO_DATA_COLOR, type RGBAColor } from "@ogw_front/utils/default_styles/constants";
3
3
  // Third party imports
4
- import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
4
+ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
5
5
 
6
6
  // Local imports
7
7
  import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap";
@@ -16,7 +16,7 @@ interface AttributeStoredConfig {
16
16
  minimum: number | undefined;
17
17
  maximum: number | undefined;
18
18
  colorMap: string | undefined;
19
- no_data_color: unknown;
19
+ no_data_color: RGBAColor;
20
20
  }
21
21
 
22
22
  interface AttributeState {
@@ -31,22 +31,25 @@ interface AttributeInput {
31
31
  minimum: number | undefined;
32
32
  maximum: number | undefined;
33
33
  colorMap: string | undefined;
34
- no_data_color?: unknown;
34
+ no_data_color?: RGBAColor;
35
35
  }
36
36
 
37
- function isModelLinesEdgeAttributeValid({
38
- name,
39
- item,
40
- minimum,
41
- maximum,
42
- colorMap,
43
- }: AttributeInput): boolean {
37
+ interface ValidAttributeInput {
38
+ name: string;
39
+ item: number;
40
+ minimum: number;
41
+ maximum: number;
42
+ colorMap: string;
43
+ no_data_color?: RGBAColor;
44
+ }
45
+
46
+ function isModelLinesEdgeAttributeValid(input: AttributeInput): input is ValidAttributeInput {
44
47
  return (
45
- name !== undefined &&
46
- item !== undefined &&
47
- minimum !== undefined &&
48
- maximum !== undefined &&
49
- colorMap !== undefined
48
+ input.name !== undefined &&
49
+ input.item !== undefined &&
50
+ input.minimum !== undefined &&
51
+ input.maximum !== undefined &&
52
+ input.colorMap !== undefined
50
53
  );
51
54
  }
52
55
 
@@ -67,7 +70,7 @@ interface UseModelLinesEdgeAttributeReturn {
67
70
  setModelLinesEdgeAttribute: (
68
71
  modelId: string,
69
72
  lineIds: string[],
70
- input: AttributeInput,
73
+ input: ValidAttributeInput,
71
74
  ) => Promise<unknown>;
72
75
  setModelLinesEdgeAttributeName: (
73
76
  modelId: string,
@@ -90,11 +93,11 @@ interface UseModelLinesEdgeAttributeReturn {
90
93
  lineIds: string[],
91
94
  colorMap: string | undefined,
92
95
  ) => Promise<unknown>;
93
- modelLinesEdgeAttributeNoDataColor: (modelId: string, lineId?: string) => unknown;
96
+ modelLinesEdgeAttributeNoDataColor: (modelId: string, lineId?: string) => RGBAColor;
94
97
  setModelLinesEdgeAttributeNoDataColor: (
95
98
  modelId: string,
96
99
  lineIds: string[],
97
- no_data_color: unknown,
100
+ no_data_color: RGBAColor,
98
101
  ) => Promise<unknown>;
99
102
  }
100
103
 
@@ -212,7 +215,7 @@ function useModelLinesEdgeAttribute(): UseModelLinesEdgeAttributeReturn {
212
215
  maximum,
213
216
  colorMap,
214
217
  no_data_color = DEFAULT_NO_DATA_COLOR,
215
- }: AttributeInput,
218
+ }: ValidAttributeInput,
216
219
  ): Promise<unknown> {
217
220
  await mutateModelLinesEdgeStyle(modelId, lineIds, {
218
221
  name,
@@ -224,7 +227,7 @@ function useModelLinesEdgeAttribute(): UseModelLinesEdgeAttributeReturn {
224
227
  colorMap,
225
228
  no_data_color,
226
229
  });
227
- const points = getRGBPointsFromPreset(colorMap ?? "");
230
+ const points = [...getRGBPointsFromPreset(colorMap)];
228
231
  const line_viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, lineIds);
229
232
  const params = {
230
233
  id: modelId,
@@ -305,7 +308,7 @@ function useModelLinesEdgeAttribute(): UseModelLinesEdgeAttributeReturn {
305
308
  });
306
309
  return applyEdgeAttribute(modelId, lineIds);
307
310
  }
308
- function modelLinesEdgeAttributeNoDataColor(modelId: string, lineId?: string): unknown {
311
+ function modelLinesEdgeAttributeNoDataColor(modelId: string, lineId?: string): RGBAColor {
309
312
  const name = modelLinesEdgeAttributeName(modelId, lineId);
310
313
  const item = modelLinesEdgeAttributeItem(modelId, lineId);
311
314
  const storedConfig = modelLinesEdgeAttributeStoredConfig(modelId, lineId, name, item);
@@ -314,7 +317,7 @@ function useModelLinesEdgeAttribute(): UseModelLinesEdgeAttributeReturn {
314
317
  async function setModelLinesEdgeAttributeNoDataColor(
315
318
  modelId: string,
316
319
  lineIds: string[],
317
- no_data_color: unknown,
320
+ no_data_color: RGBAColor,
318
321
  ): Promise<unknown> {
319
322
  const name = modelLinesEdgeAttributeName(modelId, lineIds[0]);
320
323
  const item = modelLinesEdgeAttributeItem(modelId, lineIds[0]);
@@ -1,21 +1,22 @@
1
1
  import { isModelLinesEdgeAttributeValid, useModelLinesEdgeAttribute } from "./edge";
2
2
  import { isModelLinesVertexAttributeValid, useModelLinesVertexAttribute } from "./vertex";
3
+ import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
3
4
  import { useDataStore } from "@ogw_front/stores/data";
4
5
  import { useModelLinesColor } from "./color";
5
6
  import { useModelLinesCommonStyle } from "./common";
6
7
  import { useModelLinesVisibility } from "./visibility";
7
8
 
8
9
  interface ColorGroup {
9
- color: unknown;
10
+ color: RGBAColor | undefined;
10
11
  lines_ids: string[];
11
12
  }
12
13
 
13
14
  interface AttributeGroup {
14
- name: string | undefined;
15
- item: number | undefined;
16
- minimum: number | undefined;
17
- maximum: number | undefined;
18
- colorMap: string | undefined;
15
+ name: string;
16
+ item: number;
17
+ minimum: number;
18
+ maximum: number;
19
+ colorMap: string;
19
20
  lines_ids: string[];
20
21
  }
21
22
 
@@ -117,14 +118,7 @@ export function useModelLinesStyle(): ReturnType<typeof useModelLinesCommonStyle
117
118
  continue;
118
119
  }
119
120
  const key = `${name}_${item}_${colorMap}_${minimum}_${maximum}`;
120
- vertexGroups[key] ??= {
121
- name,
122
- item,
123
- minimum,
124
- maximum,
125
- colorMap,
126
- lines_ids: [],
127
- };
121
+ vertexGroups[key] ??= { ...attribute, lines_ids: [] };
128
122
  vertexGroups[key].lines_ids.push(line_id);
129
123
  }
130
124
  coloringPromises.push(
@@ -163,14 +157,7 @@ export function useModelLinesStyle(): ReturnType<typeof useModelLinesCommonStyle
163
157
  continue;
164
158
  }
165
159
  const key = `${name}_${item}_${colorMap}_${minimum}_${maximum}`;
166
- edgeGroups[key] ??= {
167
- name,
168
- item,
169
- minimum,
170
- maximum,
171
- colorMap,
172
- lines_ids: [],
173
- };
160
+ edgeGroups[key] ??= { ...attribute, lines_ids: [] };
174
161
  edgeGroups[key].lines_ids.push(line_id);
175
162
  }
176
163
  coloringPromises.push(