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

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 (125) hide show
  1. package/.build/server/utils/microservices.js +9 -85
  2. package/.build/server/utils/microservices_process.js +85 -0
  3. package/app/components/ClippingPlanes.vue +16 -82
  4. package/app/components/DragAndDrop.vue +1 -74
  5. package/app/components/ThresholdCard.vue +205 -0
  6. package/app/components/ThresholdFilter.vue +77 -216
  7. package/app/components/ViewToolbar.vue +15 -231
  8. package/app/components/Viewer/EdgedCurve/SpecificEdgesColoring.vue +209 -0
  9. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +3 -191
  10. package/app/components/Viewer/Generic/Mesh/CellsColoring.vue +221 -0
  11. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +3 -210
  12. package/app/components/Viewer/Generic/Mesh/EdgesColoring.vue +211 -0
  13. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +3 -192
  14. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +13 -0
  15. package/app/components/Viewer/Generic/Mesh/PolygonsColoring.vue +227 -0
  16. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +3 -215
  17. package/app/components/Viewer/Generic/Mesh/PolyhedraColoring.vue +221 -0
  18. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +3 -203
  19. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +2 -18
  20. package/app/components/Viewer/Generic/Model/CornerComponentOptions.vue +145 -0
  21. package/app/components/Viewer/Generic/Model/CornersOptions.vue +13 -294
  22. package/app/components/Viewer/Generic/Model/CornersTypeOptions.vue +173 -0
  23. package/app/components/Viewer/Generic/Model/LineComponentOptions.vue +218 -0
  24. package/app/components/Viewer/Generic/Model/LinesOptions.vue +13 -425
  25. package/app/components/Viewer/Generic/Model/LinesTypeOptions.vue +229 -0
  26. package/app/components/Viewer/Options/AttributeSelector.vue +26 -133
  27. package/app/components/Viewer/Options/ColoringTypeSelector.vue +48 -74
  28. package/app/components/Viewer/Options/NoDataColorInfo.vue +56 -0
  29. package/app/components/Viewer/Options/Sliders/Opacity.vue +22 -0
  30. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +13 -0
  31. package/app/components/Viewer/Solid/SpecificPolyhedraColoring.vue +217 -0
  32. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +4 -199
  33. package/app/components/Viewer/Surface/PolygonsColoring.vue +224 -0
  34. package/app/components/Viewer/Surface/PolygonsOptions.vue +3 -213
  35. package/app/composables/attribute_selector.ts +126 -0
  36. package/app/composables/batch_style_model.ts +34 -0
  37. package/app/composables/clipping_slices.ts +166 -0
  38. package/app/composables/view_toolbar_options.ts +126 -0
  39. package/app/composables/view_toolbar_tool_options.ts +115 -0
  40. package/app/composables/view_toolbar_tools.ts +108 -0
  41. package/app/composables/virtual_tree.ts +20 -138
  42. package/app/composables/virtual_tree_flatten.ts +86 -0
  43. package/app/composables/virtual_tree_types.ts +81 -0
  44. package/app/stores/app.ts +8 -55
  45. package/app/stores/app_helpers/registry.ts +69 -0
  46. package/app/stores/menu.ts +1 -124
  47. package/app/stores/menu_helpers/menus_data.ts +127 -0
  48. package/app/stores/viewer.ts +17 -78
  49. package/app/stores/viewer_helpers/actions.ts +68 -0
  50. package/app/stores/viewer_helpers/request.ts +61 -0
  51. package/app/utils/clipping_planes.ts +4 -132
  52. package/app/utils/clipping_planes_scene.ts +131 -0
  53. package/app/utils/coloring_styles.ts +101 -0
  54. package/app/utils/default_styles/mesh_components.ts +168 -0
  55. package/app/utils/default_styles/meshes.ts +13 -153
  56. package/app/utils/default_styles/model_components.ts +170 -0
  57. package/app/utils/default_styles/models.ts +16 -153
  58. package/app/utils/drag_and_drop.ts +80 -0
  59. package/app/utils/model_component_coloring.ts +46 -0
  60. package/app/utils/threshold.ts +33 -0
  61. package/app/utils/threshold_sources.ts +51 -0
  62. package/internal/stores/data_style/mesh/cells/cell.ts +27 -150
  63. package/internal/stores/data_style/mesh/cells/cell_attribute.ts +74 -0
  64. package/internal/stores/data_style/mesh/cells/cell_config.ts +152 -0
  65. package/internal/stores/data_style/mesh/cells/color.ts +3 -1
  66. package/internal/stores/data_style/mesh/cells/index.ts +17 -1
  67. package/internal/stores/data_style/mesh/cells/opacity.ts +54 -0
  68. package/internal/stores/data_style/mesh/cells/vertex.ts +26 -157
  69. package/internal/stores/data_style/mesh/cells/vertex_attribute.ts +80 -0
  70. package/internal/stores/data_style/mesh/cells/vertex_config.ts +152 -0
  71. package/internal/stores/data_style/mesh/edges/color.ts +3 -1
  72. package/internal/stores/data_style/mesh/edges/edge.ts +27 -150
  73. package/internal/stores/data_style/mesh/edges/edge_attribute.ts +74 -0
  74. package/internal/stores/data_style/mesh/edges/edge_config.ts +152 -0
  75. package/internal/stores/data_style/mesh/edges/index.ts +17 -1
  76. package/internal/stores/data_style/mesh/edges/opacity.ts +54 -0
  77. package/internal/stores/data_style/mesh/edges/vertex.ts +26 -157
  78. package/internal/stores/data_style/mesh/edges/vertex_attribute.ts +80 -0
  79. package/internal/stores/data_style/mesh/edges/vertex_config.ts +152 -0
  80. package/internal/stores/data_style/mesh/points/color.ts +3 -1
  81. package/internal/stores/data_style/mesh/points/index.ts +17 -1
  82. package/internal/stores/data_style/mesh/points/opacity.ts +54 -0
  83. package/internal/stores/data_style/mesh/points/vertex.ts +26 -157
  84. package/internal/stores/data_style/mesh/points/vertex_attribute.ts +80 -0
  85. package/internal/stores/data_style/mesh/points/vertex_config.ts +152 -0
  86. package/internal/stores/data_style/mesh/polygons/color.ts +3 -1
  87. package/internal/stores/data_style/mesh/polygons/index.ts +17 -1
  88. package/internal/stores/data_style/mesh/polygons/opacity.ts +54 -0
  89. package/internal/stores/data_style/mesh/polygons/polygon.ts +27 -152
  90. package/internal/stores/data_style/mesh/polygons/polygon_attribute.ts +80 -0
  91. package/internal/stores/data_style/mesh/polygons/polygon_config.ts +148 -0
  92. package/internal/stores/data_style/mesh/polygons/vertex.ts +26 -157
  93. package/internal/stores/data_style/mesh/polygons/vertex_attribute.ts +80 -0
  94. package/internal/stores/data_style/mesh/polygons/vertex_config.ts +152 -0
  95. package/internal/stores/data_style/mesh/polyhedra/color.ts +3 -1
  96. package/internal/stores/data_style/mesh/polyhedra/index.ts +17 -1
  97. package/internal/stores/data_style/mesh/polyhedra/opacity.ts +54 -0
  98. package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -160
  99. package/internal/stores/data_style/mesh/polyhedra/polyhedron_attribute.ts +82 -0
  100. package/internal/stores/data_style/mesh/polyhedra/polyhedron_config.ts +157 -0
  101. package/internal/stores/data_style/mesh/polyhedra/vertex.ts +26 -157
  102. package/internal/stores/data_style/mesh/polyhedra/vertex_attribute.ts +80 -0
  103. package/internal/stores/data_style/mesh/polyhedra/vertex_config.ts +152 -0
  104. package/internal/stores/data_style/model/blocks/apply_coloring.ts +173 -0
  105. package/internal/stores/data_style/model/blocks/coloring_groups.ts +18 -0
  106. package/internal/stores/data_style/model/blocks/index.ts +12 -140
  107. package/internal/stores/data_style/model/common.ts +10 -119
  108. package/internal/stores/data_style/model/common_mutations.ts +184 -0
  109. package/internal/stores/data_style/model/lines/apply_coloring.ts +154 -0
  110. package/internal/stores/data_style/model/lines/coloring_groups.ts +18 -0
  111. package/internal/stores/data_style/model/lines/index.ts +10 -134
  112. package/internal/stores/data_style/model/surfaces/apply_coloring.ts +186 -0
  113. package/internal/stores/data_style/model/surfaces/coloring_groups.ts +18 -0
  114. package/internal/stores/data_style/model/surfaces/index.ts +16 -160
  115. package/internal/stores/data_style/model/visibility.ts +3 -156
  116. package/internal/stores/data_style/model/visibility_dispatch.ts +160 -0
  117. package/internal/stores/data_style/state.ts +1 -181
  118. package/internal/stores/data_style/state_shared.ts +191 -0
  119. package/internal/stores/hybrid_viewer/camera.ts +7 -161
  120. package/internal/stores/hybrid_viewer/camera_helpers.ts +120 -0
  121. package/internal/stores/hybrid_viewer/camera_orientation.ts +60 -0
  122. package/internal/stores/hybrid_viewer/filters.ts +54 -11
  123. package/package.json +1 -1
  124. package/server/utils/microservices.ts +10 -109
  125. package/server/utils/microservices_process.ts +127 -0
@@ -0,0 +1,184 @@
1
+ import type { Dexie, Table } from "dexie";
2
+ import type {
3
+ ModelComponentStyle,
4
+ ModelComponentTypeStyle,
5
+ StyleValues,
6
+ } from "@ogw_internal/stores/data_style/types.js";
7
+ import { database } from "@ogw_internal/database/database";
8
+ import merge from "lodash/merge";
9
+ import { useDataStyleState } from "@ogw_internal/stores/data_style/state";
10
+
11
+ // The underlying dexie tables use compound array keys ([id_model, id_component] /
12
+ // [id_model, type]) but the shared `database` proxy types every table as
13
+ // Table<Record<string, unknown>, string>. Cast locally to the real key shape.
14
+ type ComponentTable = Table<ModelComponentStyle, [string, string]>;
15
+ type ComponentTypeTable = Table<ModelComponentTypeStyle, [string, string]>;
16
+
17
+ interface ComponentStyleUpdate {
18
+ id_component: string;
19
+ values: StyleValues;
20
+ }
21
+
22
+ function componentDatastyleTable(): ComponentTable {
23
+ // oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
24
+ return database.model_component_datastyle as unknown as ComponentTable;
25
+ }
26
+
27
+ function componentTypeDatastyleTable(): ComponentTypeTable {
28
+ // oxlint-disable-next-line no-unsafe-type-assertion -- compound-key table cast; see comment above.
29
+ return database.model_component_type_datastyle as unknown as ComponentTypeTable;
30
+ }
31
+
32
+ interface UseModelComponentStyleMutationsReturn {
33
+ mutateComponentStyle: (
34
+ id_model: string,
35
+ id_component: string,
36
+ values: StyleValues,
37
+ ) => Promise<unknown>;
38
+ mutateModelComponentTypeStyle: (
39
+ id_model: string,
40
+ type: string,
41
+ values: StyleValues,
42
+ ) => Promise<void>;
43
+ }
44
+
45
+ interface UseModelComponentsStyleMutationReturn {
46
+ mutateComponentStyles: (
47
+ id_model: string,
48
+ id_components: string[],
49
+ values: StyleValues,
50
+ ) => Promise<void>;
51
+ }
52
+
53
+ interface UseModelComponentsPerComponentStyleMutationReturn {
54
+ bulkMutateComponentStylesPerComponent: (
55
+ id_model: string,
56
+ component_updates: ComponentStyleUpdate[],
57
+ ) => Promise<void>;
58
+ }
59
+
60
+ function useModelComponentStyleMutations(): UseModelComponentStyleMutationsReturn {
61
+ const dataStyleState = useDataStyleState();
62
+ const model_component_datastyle_db = componentDatastyleTable();
63
+ const model_component_type_datastyle_db = componentTypeDatastyleTable();
64
+
65
+ async function mutateComponentStyle(
66
+ id_model: string,
67
+ id_component: string,
68
+ values: StyleValues,
69
+ ): Promise<unknown> {
70
+ dataStyleState.updateComponentStyleCache(id_model, id_component, values);
71
+ const key: [string, string] = [id_model, id_component];
72
+ const entry: ModelComponentStyle = (await model_component_datastyle_db.get(key)) ?? {
73
+ id_model,
74
+ id_component,
75
+ };
76
+ merge(entry, values);
77
+ return model_component_datastyle_db.put(structuredClone(toRaw(entry)));
78
+ }
79
+
80
+ async function mutateModelComponentTypeStyle(
81
+ id_model: string,
82
+ type: string,
83
+ values: StyleValues,
84
+ ): Promise<void> {
85
+ dataStyleState.updateModelComponentTypeStyleCache(id_model, type, values);
86
+ // oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
87
+ await (database as unknown as Dexie).transaction(
88
+ "rw",
89
+ model_component_type_datastyle_db,
90
+ async () => {
91
+ const key: [string, string] = [id_model, type];
92
+ const entry: ModelComponentTypeStyle = (await model_component_type_datastyle_db.get(
93
+ key,
94
+ )) ?? {
95
+ id_model,
96
+ type,
97
+ };
98
+ merge(entry, values);
99
+ return model_component_type_datastyle_db.put(structuredClone(toRaw(entry)));
100
+ },
101
+ );
102
+ }
103
+
104
+ return {
105
+ mutateComponentStyle,
106
+ mutateModelComponentTypeStyle,
107
+ };
108
+ }
109
+
110
+ function useModelComponentsStyleMutation(): UseModelComponentsStyleMutationReturn {
111
+ const dataStyleState = useDataStyleState();
112
+ const model_component_datastyle_db = componentDatastyleTable();
113
+
114
+ async function mutateComponentStyles(
115
+ id_model: string,
116
+ id_components: string[],
117
+ values: StyleValues,
118
+ ): Promise<void> {
119
+ dataStyleState.bulkUpdateComponentStylesCache(id_model, id_components, values);
120
+ // oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
121
+ await (database as unknown as Dexie).transaction(
122
+ "rw",
123
+ model_component_datastyle_db,
124
+ async () => {
125
+ const keys: [string, string][] = id_components.map((id_component) => [
126
+ id_model,
127
+ id_component,
128
+ ]);
129
+ const existing = await model_component_datastyle_db.bulkGet(keys);
130
+ const updates = id_components.map((id_component, index) => {
131
+ const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
132
+ merge(style, values);
133
+ return toRaw(style);
134
+ });
135
+
136
+ return model_component_datastyle_db.bulkPut(structuredClone(updates));
137
+ },
138
+ );
139
+ }
140
+
141
+ return {
142
+ mutateComponentStyles,
143
+ };
144
+ }
145
+
146
+ function useModelComponentsPerComponentStyleMutation(): UseModelComponentsPerComponentStyleMutationReturn {
147
+ const dataStyleState = useDataStyleState();
148
+ const model_component_datastyle_db = componentDatastyleTable();
149
+
150
+ async function bulkMutateComponentStylesPerComponent(
151
+ id_model: string,
152
+ component_updates: ComponentStyleUpdate[],
153
+ ): Promise<void> {
154
+ dataStyleState.bulkUpdateComponentStyleCache(id_model, component_updates);
155
+ // oxlint-disable-next-line no-unsafe-type-assertion -- the shared database proxy types every table as Dexie; see comment above.
156
+ await (database as unknown as Dexie).transaction(
157
+ "rw",
158
+ model_component_datastyle_db,
159
+ async () => {
160
+ const keys: [string, string][] = component_updates.map((update) => [
161
+ id_model,
162
+ update.id_component,
163
+ ]);
164
+ const existing = await model_component_datastyle_db.bulkGet(keys);
165
+ const updates = component_updates.map(({ id_component, values }, index) => {
166
+ const style: ModelComponentStyle = existing[index] ?? { id_model, id_component };
167
+ merge(style, values);
168
+ return toRaw(style);
169
+ });
170
+ return model_component_datastyle_db.bulkPut(structuredClone(updates));
171
+ },
172
+ );
173
+ }
174
+
175
+ return {
176
+ bulkMutateComponentStylesPerComponent,
177
+ };
178
+ }
179
+ export {
180
+ useModelComponentStyleMutations,
181
+ useModelComponentsStyleMutation,
182
+ useModelComponentsPerComponentStyleMutation,
183
+ };
184
+ export type { ComponentStyleUpdate };
@@ -0,0 +1,154 @@
1
+ import type { AttributeGroup, ColorGroup } from "./coloring_groups";
2
+ import { isModelLinesEdgeAttributeValid, type useModelLinesEdgeAttribute } from "./edge";
3
+ import { isModelLinesVertexAttributeValid, type useModelLinesVertexAttribute } from "./vertex";
4
+ import type { useModelLinesColor } from "./color";
5
+
6
+ type ColorStyle = ReturnType<typeof useModelLinesColor>;
7
+ type VertexAttributeStyle = ReturnType<typeof useModelLinesVertexAttribute>;
8
+ type EdgeAttributeStyle = ReturnType<typeof useModelLinesEdgeAttribute>;
9
+
10
+ function applyModelLinesConstantColoring(
11
+ modelId: string,
12
+ type_lines_ids: string[],
13
+ modelColorStyle: ColorStyle,
14
+ ): Promise<unknown>[] {
15
+ const colorGroups: Record<string, ColorGroup> = {};
16
+ for (const line_id of type_lines_ids) {
17
+ const color = modelColorStyle.modelLineColor(modelId, line_id);
18
+ const color_key = JSON.stringify(color);
19
+ colorGroups[color_key] ??= { color, lines_ids: [] };
20
+ colorGroups[color_key].lines_ids.push(line_id);
21
+ }
22
+ return Object.values(colorGroups).map(async ({ color, lines_ids: ids }) => {
23
+ const result = await modelColorStyle.setModelLinesColor(modelId, ids, color, "constant");
24
+ return result;
25
+ });
26
+ }
27
+
28
+ function groupModelLinesVertexAttributes(
29
+ modelId: string,
30
+ type_lines_ids: string[],
31
+ modelLinesVertexAttribute: VertexAttributeStyle,
32
+ ): Record<string, AttributeGroup> {
33
+ const vertexGroups: Record<string, AttributeGroup> = {};
34
+ for (const line_id of type_lines_ids) {
35
+ const name = modelLinesVertexAttribute.modelLinesVertexAttributeName(modelId, line_id);
36
+ const item = modelLinesVertexAttribute.modelLinesVertexAttributeItem(modelId, line_id);
37
+ const [minimum, maximum] = modelLinesVertexAttribute.modelLinesVertexAttributeRange(
38
+ modelId,
39
+ line_id,
40
+ );
41
+ const colorMap = modelLinesVertexAttribute.modelLinesVertexAttributeColorMap(modelId, line_id);
42
+ const no_data_color = modelLinesVertexAttribute.modelLinesVertexAttributeNoDataColor(
43
+ modelId,
44
+ line_id,
45
+ );
46
+ const attribute = {
47
+ name,
48
+ item,
49
+ minimum,
50
+ maximum,
51
+ colorMap,
52
+ no_data_color,
53
+ };
54
+ if (!isModelLinesVertexAttributeValid(attribute)) {
55
+ continue;
56
+ }
57
+ const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join("_");
58
+ vertexGroups[key] ??= { ...attribute, lines_ids: [] };
59
+ vertexGroups[key].lines_ids.push(line_id);
60
+ }
61
+ return vertexGroups;
62
+ }
63
+
64
+ function applyModelLinesVertexColoring(
65
+ modelId: string,
66
+ type_lines_ids: string[],
67
+ modelLinesVertexAttribute: VertexAttributeStyle,
68
+ ): Promise<unknown>[] {
69
+ const vertexGroups = groupModelLinesVertexAttributes(
70
+ modelId,
71
+ type_lines_ids,
72
+ modelLinesVertexAttribute,
73
+ );
74
+ return Object.values(vertexGroups).map(
75
+ async ({ name, item, minimum, maximum, colorMap, no_data_color, lines_ids: ids }) => {
76
+ const result = await modelLinesVertexAttribute.setModelLinesVertexAttribute(modelId, ids, {
77
+ name,
78
+ item,
79
+ minimum,
80
+ maximum,
81
+ colorMap,
82
+ no_data_color,
83
+ });
84
+ return result;
85
+ },
86
+ );
87
+ }
88
+
89
+ function groupModelLinesEdgeAttributes(
90
+ modelId: string,
91
+ type_lines_ids: string[],
92
+ modelLinesEdgeAttribute: EdgeAttributeStyle,
93
+ ): Record<string, AttributeGroup> {
94
+ const edgeGroups: Record<string, AttributeGroup> = {};
95
+ for (const line_id of type_lines_ids) {
96
+ const name = modelLinesEdgeAttribute.modelLinesEdgeAttributeName(modelId, line_id);
97
+ const item = modelLinesEdgeAttribute.modelLinesEdgeAttributeItem(modelId, line_id);
98
+ const [minimum, maximum] = modelLinesEdgeAttribute.modelLinesEdgeAttributeRange(
99
+ modelId,
100
+ line_id,
101
+ );
102
+ const colorMap = modelLinesEdgeAttribute.modelLinesEdgeAttributeColorMap(modelId, line_id);
103
+ const no_data_color = modelLinesEdgeAttribute.modelLinesEdgeAttributeNoDataColor(
104
+ modelId,
105
+ line_id,
106
+ );
107
+ const attribute = {
108
+ name,
109
+ item,
110
+ minimum,
111
+ maximum,
112
+ colorMap,
113
+ no_data_color,
114
+ };
115
+ if (!isModelLinesEdgeAttributeValid(attribute)) {
116
+ continue;
117
+ }
118
+ const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join("_");
119
+ edgeGroups[key] ??= { ...attribute, lines_ids: [] };
120
+ edgeGroups[key].lines_ids.push(line_id);
121
+ }
122
+ return edgeGroups;
123
+ }
124
+
125
+ function applyModelLinesEdgeColoring(
126
+ modelId: string,
127
+ type_lines_ids: string[],
128
+ modelLinesEdgeAttribute: EdgeAttributeStyle,
129
+ ): Promise<unknown>[] {
130
+ const edgeGroups = groupModelLinesEdgeAttributes(
131
+ modelId,
132
+ type_lines_ids,
133
+ modelLinesEdgeAttribute,
134
+ );
135
+ return Object.values(edgeGroups).map(
136
+ async ({ name, item, minimum, maximum, colorMap, no_data_color, lines_ids: ids }) => {
137
+ const result = await modelLinesEdgeAttribute.setModelLinesEdgeAttribute(modelId, ids, {
138
+ name,
139
+ item,
140
+ minimum,
141
+ maximum,
142
+ colorMap,
143
+ no_data_color,
144
+ });
145
+ return result;
146
+ },
147
+ );
148
+ }
149
+
150
+ export {
151
+ applyModelLinesConstantColoring,
152
+ applyModelLinesVertexColoring,
153
+ applyModelLinesEdgeColoring,
154
+ };
@@ -0,0 +1,18 @@
1
+ import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
2
+
3
+ interface ColorGroup {
4
+ color: RGBAColor | undefined;
5
+ lines_ids: string[];
6
+ }
7
+
8
+ interface AttributeGroup {
9
+ name: string;
10
+ item: number;
11
+ minimum: number;
12
+ maximum: number;
13
+ colorMap: string;
14
+ no_data_color?: RGBAColor;
15
+ lines_ids: string[];
16
+ }
17
+
18
+ export type { AttributeGroup, ColorGroup };
@@ -1,27 +1,16 @@
1
- import { isModelLinesEdgeAttributeValid, useModelLinesEdgeAttribute } from "./edge";
2
- import { isModelLinesVertexAttributeValid, useModelLinesVertexAttribute } from "./vertex";
3
- import type { RGBAColor } from "@ogw_front/utils/default_styles/constants";
1
+ import {
2
+ applyModelLinesConstantColoring,
3
+ applyModelLinesEdgeColoring,
4
+ applyModelLinesVertexColoring,
5
+ } from "./apply_coloring";
4
6
  import { useDataStore } from "@ogw_front/stores/data";
5
7
  import { useModelLinesColor } from "./color";
6
8
  import { useModelLinesCommonStyle } from "./common";
9
+ import { useModelLinesEdgeAttribute } from "./edge";
7
10
  import { useModelLinesPointsStyle } from "./points";
11
+ import { useModelLinesVertexAttribute } from "./vertex";
8
12
  import { useModelLinesVisibility } from "./visibility";
9
13
 
10
- interface ColorGroup {
11
- color: RGBAColor | undefined;
12
- lines_ids: string[];
13
- }
14
-
15
- interface AttributeGroup {
16
- name: string;
17
- item: number;
18
- minimum: number;
19
- maximum: number;
20
- colorMap: string;
21
- no_data_color?: RGBAColor;
22
- lines_ids: string[];
23
- }
24
-
25
14
  async function setModelLinesDefaultStyle(_id: string): Promise<void> {
26
15
  // Placeholder
27
16
  }
@@ -82,133 +71,20 @@ export function useModelLinesStyle(): ReturnType<typeof useModelLinesCommonStyle
82
71
 
83
72
  for (const [type, type_lines_ids] of Object.entries(activeColoringGroups)) {
84
73
  if (type === "constant") {
85
- const colorGroups: Record<string, ColorGroup> = {};
86
- for (const line_id of type_lines_ids) {
87
- const color = modelColorStyle.modelLineColor(modelId, line_id);
88
- const color_key = JSON.stringify(color);
89
- colorGroups[color_key] ??= { color, lines_ids: [] };
90
- colorGroups[color_key].lines_ids.push(line_id);
91
- }
92
74
  coloringPromises.push(
93
- ...Object.values(colorGroups).map(async ({ color, lines_ids: ids }) => {
94
- const result = await modelColorStyle.setModelLinesColor(
95
- modelId,
96
- ids,
97
- color,
98
- "constant",
99
- );
100
- return result;
101
- }),
75
+ ...applyModelLinesConstantColoring(modelId, type_lines_ids, modelColorStyle),
102
76
  );
103
77
  } else if (type === "random") {
104
78
  coloringPromises.push(
105
79
  modelColorStyle.setModelLinesColor(modelId, type_lines_ids, undefined, "random"),
106
80
  );
107
81
  } else if (type === "vertex") {
108
- const vertexGroups: Record<string, AttributeGroup> = {};
109
- for (const line_id of type_lines_ids) {
110
- const name = modelLinesVertexAttribute.modelLinesVertexAttributeName(modelId, line_id);
111
- const item = modelLinesVertexAttribute.modelLinesVertexAttributeItem(modelId, line_id);
112
- const [minimum, maximum] = modelLinesVertexAttribute.modelLinesVertexAttributeRange(
113
- modelId,
114
- line_id,
115
- );
116
- const colorMap = modelLinesVertexAttribute.modelLinesVertexAttributeColorMap(
117
- modelId,
118
- line_id,
119
- );
120
- const no_data_color = modelLinesVertexAttribute.modelLinesVertexAttributeNoDataColor(
121
- modelId,
122
- line_id,
123
- );
124
- const attribute = {
125
- name,
126
- item,
127
- minimum,
128
- maximum,
129
- colorMap,
130
- no_data_color,
131
- };
132
- if (!isModelLinesVertexAttributeValid(attribute)) {
133
- continue;
134
- }
135
- const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join(
136
- "_",
137
- );
138
- vertexGroups[key] ??= { ...attribute, lines_ids: [] };
139
- vertexGroups[key].lines_ids.push(line_id);
140
- }
141
82
  coloringPromises.push(
142
- ...Object.values(vertexGroups).map(
143
- async ({ name, item, minimum, maximum, colorMap, no_data_color, lines_ids: ids }) => {
144
- const result = await modelLinesVertexAttribute.setModelLinesVertexAttribute(
145
- modelId,
146
- ids,
147
- {
148
- name,
149
- item,
150
- minimum,
151
- maximum,
152
- colorMap,
153
- no_data_color,
154
- },
155
- );
156
- return result;
157
- },
158
- ),
83
+ ...applyModelLinesVertexColoring(modelId, type_lines_ids, modelLinesVertexAttribute),
159
84
  );
160
85
  } else if (type === "edge") {
161
- const edgeGroups: Record<string, AttributeGroup> = {};
162
- for (const line_id of type_lines_ids) {
163
- const name = modelLinesEdgeAttribute.modelLinesEdgeAttributeName(modelId, line_id);
164
- const item = modelLinesEdgeAttribute.modelLinesEdgeAttributeItem(modelId, line_id);
165
- const [minimum, maximum] = modelLinesEdgeAttribute.modelLinesEdgeAttributeRange(
166
- modelId,
167
- line_id,
168
- );
169
- const colorMap = modelLinesEdgeAttribute.modelLinesEdgeAttributeColorMap(
170
- modelId,
171
- line_id,
172
- );
173
- const no_data_color = modelLinesEdgeAttribute.modelLinesEdgeAttributeNoDataColor(
174
- modelId,
175
- line_id,
176
- );
177
- const attribute = {
178
- name,
179
- item,
180
- minimum,
181
- maximum,
182
- colorMap,
183
- no_data_color,
184
- };
185
- if (!isModelLinesEdgeAttributeValid(attribute)) {
186
- continue;
187
- }
188
- const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join(
189
- "_",
190
- );
191
- edgeGroups[key] ??= { ...attribute, lines_ids: [] };
192
- edgeGroups[key].lines_ids.push(line_id);
193
- }
194
86
  coloringPromises.push(
195
- ...Object.values(edgeGroups).map(
196
- async ({ name, item, minimum, maximum, colorMap, no_data_color, lines_ids: ids }) => {
197
- const result = await modelLinesEdgeAttribute.setModelLinesEdgeAttribute(
198
- modelId,
199
- ids,
200
- {
201
- name,
202
- item,
203
- minimum,
204
- maximum,
205
- colorMap,
206
- no_data_color,
207
- },
208
- );
209
- return result;
210
- },
211
- ),
87
+ ...applyModelLinesEdgeColoring(modelId, type_lines_ids, modelLinesEdgeAttribute),
212
88
  );
213
89
  }
214
90
  }