@geode/opengeodeweb-front 10.44.0-rc.6 → 10.44.0-rc.8

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 (59) hide show
  1. package/.build/server/utils/scripts.js +34 -23
  2. package/app/components/BasemapAttribution.vue +28 -0
  3. package/app/components/MissingFilesSelector.vue +30 -17
  4. package/app/components/ObjectSelector.vue +34 -23
  5. package/app/components/Viewer/Basemap/CropOptions.vue +50 -0
  6. package/app/components/Viewer/Basemap/OpacityOptions.vue +52 -0
  7. package/app/components/Viewer/ContextMenu/ContextMenu.vue +5 -1
  8. package/app/components/Viewer/ContextMenu/ContextMenuItem.vue +6 -2
  9. package/app/components/Viewer/ObjectTree/Views/GlobalObjects.vue +49 -10
  10. package/app/components/Viewer/Ui.vue +6 -0
  11. package/app/composables/overlapping_picker_menu.ts +43 -0
  12. package/app/composables/project_manager_helpers/reset.ts +3 -0
  13. package/app/composables/project_manager_helpers/restore.ts +22 -10
  14. package/app/composables/project_manager_helpers/types.ts +2 -0
  15. package/app/composables/use_overlapping_picker.ts +23 -37
  16. package/app/composables/viewer_context_menu.ts +10 -0
  17. package/app/composables/virtual_tree_flatten.ts +66 -43
  18. package/app/stores/app_helpers/extension.ts +90 -51
  19. package/app/stores/basemap.ts +52 -0
  20. package/app/stores/basemap_detail.ts +51 -0
  21. package/app/stores/basemap_helpers/builds.ts +158 -0
  22. package/app/stores/basemap_helpers/detail_layers.ts +72 -0
  23. package/app/stores/basemap_helpers/detail_map.ts +62 -0
  24. package/app/stores/basemap_helpers/detail_refresh.ts +134 -0
  25. package/app/stores/basemap_helpers/detail_view.ts +94 -0
  26. package/app/stores/basemap_helpers/extent.ts +40 -0
  27. package/app/stores/basemap_helpers/georeferenced.ts +50 -0
  28. package/app/stores/basemap_helpers/layers.ts +66 -0
  29. package/app/stores/basemap_helpers/settings.ts +87 -0
  30. package/app/stores/basemap_helpers/viewer.ts +114 -0
  31. package/app/stores/infra.ts +26 -21
  32. package/app/stores/menu_helpers/basemap.ts +10 -0
  33. package/app/stores/menu_helpers/menus_data.ts +2 -0
  34. package/app/utils/basemap_tree.ts +76 -0
  35. package/app/utils/color_picker.ts +18 -15
  36. package/app/utils/treeview.ts +12 -1
  37. package/app/utils/visible_map_area.ts +129 -0
  38. package/internal/database/database.ts +47 -32
  39. package/internal/stores/data_style/mesh/base_style.ts +74 -0
  40. package/internal/stores/data_style/mesh/index.ts +2 -57
  41. package/internal/stores/data_style/model/blocks/color.ts +58 -57
  42. package/internal/stores/data_style/model/blocks/polyhedron.ts +88 -44
  43. package/internal/stores/data_style/model/blocks/vertex.ts +88 -44
  44. package/internal/stores/data_style/model/color.ts +25 -26
  45. package/internal/stores/data_style/model/corners/index.ts +85 -78
  46. package/internal/stores/data_style/model/corners/vertex.ts +83 -39
  47. package/internal/stores/data_style/model/lines/color.ts +53 -40
  48. package/internal/stores/data_style/model/lines/edge.ts +88 -44
  49. package/internal/stores/data_style/model/lines/vertex.ts +88 -44
  50. package/internal/stores/data_style/model/surfaces/color.ts +68 -56
  51. package/internal/stores/data_style/model/surfaces/polygon.ts +80 -36
  52. package/internal/stores/data_style/model/surfaces/vertex.ts +80 -36
  53. package/internal/stores/data_style/model/visibility_dispatch.ts +49 -99
  54. package/internal/stores/hybrid_viewer/highlight.ts +70 -54
  55. package/internal/stores/hybrid_viewer/scene.ts +31 -25
  56. package/internal/stores/hybrid_viewer/vtk_types.ts +2 -1
  57. package/package.json +1 -1
  58. package/server/api/local/extensions/upload.put.ts +47 -20
  59. package/server/utils/scripts.ts +35 -30
@@ -63,102 +63,109 @@ export function useModelCornersStyle(): ModelCornersStyleApi {
63
63
  return results;
64
64
  }
65
65
 
66
- async function applyModelCornersColoringStyle(
66
+ function groupCornersByActiveColoring(
67
67
  modelId: string,
68
68
  corners_ids: string[],
69
- ): Promise<unknown[]> {
69
+ ): Record<string, string[]> {
70
70
  const activeColoringGroups: Record<string, string[]> = {};
71
71
  for (const corner_id of corners_ids) {
72
72
  const activeColoring = String(modelColorStyle.modelCornerActiveColoring(modelId, corner_id));
73
73
  activeColoringGroups[activeColoring] ??= [];
74
74
  activeColoringGroups[activeColoring].push(corner_id);
75
75
  }
76
+ return activeColoringGroups;
77
+ }
76
78
 
77
- const coloringPromises: Promise<unknown>[] = [];
79
+ function applyConstantColoring(modelId: string, corners_ids: string[]): Promise<unknown>[] {
80
+ const colorGroups: Record<string, ColorGroup> = {};
81
+ for (const corner_id of corners_ids) {
82
+ const color = modelColorStyle.modelCornerColor(modelId, corner_id);
83
+ const color_key = JSON.stringify(color);
84
+ colorGroups[color_key] ??= { color, corners_ids: [] };
85
+ colorGroups[color_key].corners_ids.push(corner_id);
86
+ }
87
+ return Object.values(colorGroups).map(async ({ color, corners_ids: ids }) => {
88
+ const result = await modelColorStyle.setModelCornersColor(modelId, ids, color, "constant");
89
+ return result;
90
+ });
91
+ }
78
92
 
79
- for (const [type, type_corners_ids] of Object.entries(activeColoringGroups)) {
80
- if (type === "constant") {
81
- const colorGroups: Record<string, ColorGroup> = {};
82
- for (const corner_id of type_corners_ids) {
83
- const color = modelColorStyle.modelCornerColor(modelId, corner_id);
84
- const color_key = JSON.stringify(color);
85
- colorGroups[color_key] ??= { color, corners_ids: [] };
86
- colorGroups[color_key].corners_ids.push(corner_id);
87
- }
88
- coloringPromises.push(
89
- ...Object.values(colorGroups).map(async ({ color, corners_ids: ids }) => {
90
- const result = await modelColorStyle.setModelCornersColor(
91
- modelId,
92
- ids,
93
- color,
94
- "constant",
95
- );
96
- return result;
97
- }),
98
- );
99
- } else if (type === "random") {
100
- coloringPromises.push(
101
- modelColorStyle.setModelCornersColor(modelId, type_corners_ids, undefined, "random"),
102
- );
103
- } else if (type === "vertex") {
104
- const vertexGroups: Record<string, AttributeGroup> = {};
105
- for (const corner_id of type_corners_ids) {
106
- const name = modelCornersVertexAttribute.modelCornersVertexAttributeName(
107
- modelId,
108
- corner_id,
109
- );
110
- const item = modelCornersVertexAttribute.modelCornersVertexAttributeItem(
111
- modelId,
112
- corner_id,
113
- );
114
- const [minimum, maximum] = modelCornersVertexAttribute.modelCornersVertexAttributeRange(
115
- modelId,
116
- corner_id,
117
- );
118
- const colorMap = modelCornersVertexAttribute.modelCornersVertexAttributeColorMap(
119
- modelId,
120
- corner_id,
121
- );
122
- const no_data_color = modelCornersVertexAttribute.modelCornersVertexAttributeNoDataColor(
123
- modelId,
124
- corner_id,
125
- );
126
- const attribute = {
93
+ function groupCornersByVertexAttribute(
94
+ modelId: string,
95
+ corners_ids: string[],
96
+ ): Record<string, AttributeGroup> {
97
+ const vertexGroups: Record<string, AttributeGroup> = {};
98
+ for (const corner_id of corners_ids) {
99
+ const name = modelCornersVertexAttribute.modelCornersVertexAttributeName(modelId, corner_id);
100
+ const item = modelCornersVertexAttribute.modelCornersVertexAttributeItem(modelId, corner_id);
101
+ const [minimum, maximum] = modelCornersVertexAttribute.modelCornersVertexAttributeRange(
102
+ modelId,
103
+ corner_id,
104
+ );
105
+ const colorMap = modelCornersVertexAttribute.modelCornersVertexAttributeColorMap(
106
+ modelId,
107
+ corner_id,
108
+ );
109
+ const no_data_color = modelCornersVertexAttribute.modelCornersVertexAttributeNoDataColor(
110
+ modelId,
111
+ corner_id,
112
+ );
113
+ const attribute = {
114
+ name,
115
+ item,
116
+ minimum,
117
+ maximum,
118
+ colorMap,
119
+ no_data_color,
120
+ };
121
+ if (!isModelCornersVertexAttributeValid(attribute)) {
122
+ continue;
123
+ }
124
+ const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join("_");
125
+ vertexGroups[key] ??= { ...attribute, corners_ids: [] };
126
+ vertexGroups[key].corners_ids.push(corner_id);
127
+ }
128
+ return vertexGroups;
129
+ }
130
+
131
+ function applyVertexColoring(modelId: string, corners_ids: string[]): Promise<unknown>[] {
132
+ const vertexGroups = groupCornersByVertexAttribute(modelId, corners_ids);
133
+ return Object.values(vertexGroups).map(
134
+ async ({ name, item, minimum, maximum, colorMap, no_data_color, corners_ids: ids }) => {
135
+ const result = await modelCornersVertexAttribute.setModelCornersVertexAttribute(
136
+ modelId,
137
+ ids,
138
+ {
127
139
  name,
128
140
  item,
129
141
  minimum,
130
142
  maximum,
131
143
  colorMap,
132
144
  no_data_color,
133
- };
134
- if (!isModelCornersVertexAttributeValid(attribute)) {
135
- continue;
136
- }
137
- const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join(
138
- "_",
139
- );
140
- vertexGroups[key] ??= { ...attribute, corners_ids: [] };
141
- vertexGroups[key].corners_ids.push(corner_id);
142
- }
145
+ },
146
+ );
147
+ return result;
148
+ },
149
+ );
150
+ }
151
+
152
+ async function applyModelCornersColoringStyle(
153
+ modelId: string,
154
+ corners_ids: string[],
155
+ ): Promise<unknown[]> {
156
+ const activeColoringGroups = groupCornersByActiveColoring(modelId, corners_ids);
157
+
158
+ const coloringPromises: Promise<unknown>[] = [];
159
+
160
+ for (const [type, type_corners_ids] of Object.entries(activeColoringGroups)) {
161
+ if (type === "constant") {
162
+ coloringPromises.push(...applyConstantColoring(modelId, type_corners_ids));
163
+ } else if (type === "random") {
143
164
  coloringPromises.push(
144
- ...Object.values(vertexGroups).map(
145
- async ({ name, item, minimum, maximum, colorMap, no_data_color, corners_ids: ids }) => {
146
- const result = await modelCornersVertexAttribute.setModelCornersVertexAttribute(
147
- modelId,
148
- ids,
149
- {
150
- name,
151
- item,
152
- minimum,
153
- maximum,
154
- colorMap,
155
- no_data_color,
156
- },
157
- );
158
- return result;
159
- },
160
- ),
165
+ modelColorStyle.setModelCornersColor(modelId, type_corners_ids, undefined, "random"),
161
166
  );
167
+ } else if (type === "vertex") {
168
+ coloringPromises.push(...applyVertexColoring(modelId, type_corners_ids));
162
169
  }
163
170
  }
164
171
 
@@ -97,12 +97,28 @@ function isModelCornersVertexAttributeValid(input: AttributeInput): input is Val
97
97
  );
98
98
  }
99
99
 
100
+ type ModelCornersVertexAttributeGetters = Pick<
101
+ ModelCornersVertexAttributeApi,
102
+ | "modelCornersVertexAttributeStoredConfig"
103
+ | "modelCornersVertexAttributeName"
104
+ | "modelCornersVertexAttributeItem"
105
+ | "modelCornersVertexAttributeRange"
106
+ | "modelCornersVertexAttributeColorMap"
107
+ | "modelCornersVertexAttributeNoDataColor"
108
+ | "modelCornersVertexAttributeTimeStep"
109
+ > & {
110
+ modelCornersVertexAttributeLastItem: (
111
+ modelId: string,
112
+ componentId: string | undefined,
113
+ name: string | undefined,
114
+ ) => number;
115
+ };
116
+
100
117
  // oxlint-disable-next-line max-lines-per-function
101
- function useModelCornersVertexAttribute(): ModelCornersVertexAttributeApi {
102
- const { attributeTimeStep, setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
103
- const dataStore = useDataStore();
104
- const modelCornersCommonStyle = useModelCornersCommonStyle();
105
- const viewerStore = useViewerStore();
118
+ function useModelCornersVertexAttributeGetters(
119
+ modelCornersCommonStyle: ReturnType<typeof useModelCornersCommonStyle>,
120
+ ): ModelCornersVertexAttributeGetters {
121
+ const { attributeTimeStep } = useAttributeTimeStepStyle();
106
122
  function modelCornersVertexAttribute(modelId: string, cornerId?: string): AttributeState {
107
123
  // oxlint-disable-next-line no-unsafe-type-assertion -- vertex is a StyleValues sub-object stored under a StyleValues index signature.
108
124
  return modelCornersCommonStyle.modelCornerColoring(modelId, cornerId).vertex as AttributeState;
@@ -127,40 +143,6 @@ function useModelCornersVertexAttribute(): ModelCornersVertexAttributeApi {
127
143
  no_data_color: DEFAULT_NO_DATA_COLOR,
128
144
  };
129
145
  }
130
- async function mutateModelCornersVertexStyle(
131
- modelId: string,
132
- cornerIds: string[],
133
- values: Record<string, unknown>,
134
- ): Promise<void> {
135
- const tasks: Promise<void>[] = [
136
- modelCornersCommonStyle.mutateModelCornersColoring(modelId, cornerIds, {
137
- vertex: values,
138
- }),
139
- ];
140
- const totalCornerIds = await dataStore.getCornersGeodeIds(modelId);
141
- if (cornerIds.length === totalCornerIds.length) {
142
- tasks.push(
143
- modelCornersCommonStyle.mutateModelCornersTypeColoring(modelId, {
144
- vertex: values,
145
- }),
146
- );
147
- }
148
- await Promise.all(tasks);
149
- }
150
- async function setModelCornersVertexAttributeStoredConfig(
151
- modelId: string,
152
- cornerIds: string[],
153
- name: string | undefined,
154
- item: number | undefined,
155
- config: Partial<AttributeStoredConfig>,
156
- ): Promise<void> {
157
- if (name === undefined || item === undefined) {
158
- return;
159
- }
160
- await mutateModelCornersVertexStyle(modelId, cornerIds, {
161
- storedConfigs: { [name]: { lastItem: item, [item]: config } },
162
- });
163
- }
164
146
  function modelCornersVertexAttributeName(modelId: string, cornerId?: string): string | undefined {
165
147
  return modelCornersVertexAttribute(modelId, cornerId).name;
166
148
  }
@@ -219,6 +201,68 @@ function useModelCornersVertexAttribute(): ModelCornersVertexAttributeApi {
219
201
  modelCornersVertexAttribute(modelId, cornerId).name,
220
202
  );
221
203
  }
204
+ return {
205
+ modelCornersVertexAttributeStoredConfig,
206
+ modelCornersVertexAttributeName,
207
+ modelCornersVertexAttributeLastItem,
208
+ modelCornersVertexAttributeItem,
209
+ modelCornersVertexAttributeRange,
210
+ modelCornersVertexAttributeColorMap,
211
+ modelCornersVertexAttributeNoDataColor,
212
+ modelCornersVertexAttributeTimeStep,
213
+ };
214
+ }
215
+
216
+ // oxlint-disable-next-line max-lines-per-function
217
+ function useModelCornersVertexAttribute(): ModelCornersVertexAttributeApi {
218
+ const { setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
219
+ const dataStore = useDataStore();
220
+ const modelCornersCommonStyle = useModelCornersCommonStyle();
221
+ const {
222
+ modelCornersVertexAttributeStoredConfig,
223
+ modelCornersVertexAttributeName,
224
+ modelCornersVertexAttributeLastItem,
225
+ modelCornersVertexAttributeItem,
226
+ modelCornersVertexAttributeRange,
227
+ modelCornersVertexAttributeColorMap,
228
+ modelCornersVertexAttributeNoDataColor,
229
+ modelCornersVertexAttributeTimeStep,
230
+ } = useModelCornersVertexAttributeGetters(modelCornersCommonStyle);
231
+ const viewerStore = useViewerStore();
232
+ async function mutateModelCornersVertexStyle(
233
+ modelId: string,
234
+ cornerIds: string[],
235
+ values: Record<string, unknown>,
236
+ ): Promise<void> {
237
+ const tasks: Promise<void>[] = [
238
+ modelCornersCommonStyle.mutateModelCornersColoring(modelId, cornerIds, {
239
+ vertex: values,
240
+ }),
241
+ ];
242
+ const totalCornerIds = await dataStore.getCornersGeodeIds(modelId);
243
+ if (cornerIds.length === totalCornerIds.length) {
244
+ tasks.push(
245
+ modelCornersCommonStyle.mutateModelCornersTypeColoring(modelId, {
246
+ vertex: values,
247
+ }),
248
+ );
249
+ }
250
+ await Promise.all(tasks);
251
+ }
252
+ async function setModelCornersVertexAttributeStoredConfig(
253
+ modelId: string,
254
+ cornerIds: string[],
255
+ name: string | undefined,
256
+ item: number | undefined,
257
+ config: Partial<AttributeStoredConfig>,
258
+ ): Promise<void> {
259
+ if (name === undefined || item === undefined) {
260
+ return;
261
+ }
262
+ await mutateModelCornersVertexStyle(modelId, cornerIds, {
263
+ storedConfigs: { [name]: { lastItem: item, [item]: config } },
264
+ });
265
+ }
222
266
  async function setModelCornersVertexAttribute(
223
267
  modelId: string,
224
268
  cornerIds: string[],
@@ -65,6 +65,57 @@ export function useModelLinesColor(): {
65
65
  return modelLineColoring(id, line_id).active;
66
66
  }
67
67
 
68
+ async function applyVertexColoring(modelId: string, lines_ids: string[]): Promise<unknown> {
69
+ const name = modelLinesVertexAttribute.modelLinesVertexAttributeName(modelId, lines_ids[0]);
70
+ const item = modelLinesVertexAttribute.modelLinesVertexAttributeItem(modelId, lines_ids[0]);
71
+ const [minimum, maximum] = modelLinesVertexAttribute.modelLinesVertexAttributeRange(
72
+ modelId,
73
+ lines_ids[0],
74
+ );
75
+ const colorMap = modelLinesVertexAttribute.modelLinesVertexAttributeColorMap(
76
+ modelId,
77
+ lines_ids[0],
78
+ );
79
+ const no_data_color = modelLinesVertexAttribute.modelLinesVertexAttributeNoDataColor(
80
+ modelId,
81
+ lines_ids[0],
82
+ );
83
+ const attribute = { name, item, minimum, maximum, colorMap, no_data_color };
84
+ if (isModelLinesVertexAttributeValid(attribute)) {
85
+ const result = await modelLinesVertexAttribute.setModelLinesVertexAttribute(
86
+ modelId,
87
+ lines_ids,
88
+ attribute,
89
+ );
90
+ return result;
91
+ }
92
+ return undefined;
93
+ }
94
+
95
+ async function applyEdgeColoring(modelId: string, lines_ids: string[]): Promise<unknown> {
96
+ const name = modelLinesEdgeAttribute.modelLinesEdgeAttributeName(modelId, lines_ids[0]);
97
+ const item = modelLinesEdgeAttribute.modelLinesEdgeAttributeItem(modelId, lines_ids[0]);
98
+ const [minimum, maximum] = modelLinesEdgeAttribute.modelLinesEdgeAttributeRange(
99
+ modelId,
100
+ lines_ids[0],
101
+ );
102
+ const colorMap = modelLinesEdgeAttribute.modelLinesEdgeAttributeColorMap(modelId, lines_ids[0]);
103
+ const no_data_color = modelLinesEdgeAttribute.modelLinesEdgeAttributeNoDataColor(
104
+ modelId,
105
+ lines_ids[0],
106
+ );
107
+ const attribute = { name, item, minimum, maximum, colorMap, no_data_color };
108
+ if (isModelLinesEdgeAttributeValid(attribute)) {
109
+ const result = await modelLinesEdgeAttribute.setModelLinesEdgeAttribute(
110
+ modelId,
111
+ lines_ids,
112
+ attribute,
113
+ );
114
+ return result;
115
+ }
116
+ return undefined;
117
+ }
118
+
68
119
  async function setModelLinesActiveColoring(
69
120
  modelId: string,
70
121
  lines_ids: string[],
@@ -86,47 +137,9 @@ export function useModelLinesColor(): {
86
137
  }
87
138
 
88
139
  if (activeColoring === "vertex") {
89
- const name = modelLinesVertexAttribute.modelLinesVertexAttributeName(modelId, lines_ids[0]);
90
- const item = modelLinesVertexAttribute.modelLinesVertexAttributeItem(modelId, lines_ids[0]);
91
- const [minimum, maximum] = modelLinesVertexAttribute.modelLinesVertexAttributeRange(
92
- modelId,
93
- lines_ids[0],
94
- );
95
- const colorMap = modelLinesVertexAttribute.modelLinesVertexAttributeColorMap(
96
- modelId,
97
- lines_ids[0],
98
- );
99
- const no_data_color = modelLinesVertexAttribute.modelLinesVertexAttributeNoDataColor(
100
- modelId,
101
- lines_ids[0],
102
- );
103
- const attribute = { name, item, minimum, maximum, colorMap, no_data_color };
104
- if (isModelLinesVertexAttributeValid(attribute)) {
105
- return modelLinesVertexAttribute.setModelLinesVertexAttribute(
106
- modelId,
107
- lines_ids,
108
- attribute,
109
- );
110
- }
140
+ return applyVertexColoring(modelId, lines_ids);
111
141
  } else if (activeColoring === "edge") {
112
- const name = modelLinesEdgeAttribute.modelLinesEdgeAttributeName(modelId, lines_ids[0]);
113
- const item = modelLinesEdgeAttribute.modelLinesEdgeAttributeItem(modelId, lines_ids[0]);
114
- const [minimum, maximum] = modelLinesEdgeAttribute.modelLinesEdgeAttributeRange(
115
- modelId,
116
- lines_ids[0],
117
- );
118
- const colorMap = modelLinesEdgeAttribute.modelLinesEdgeAttributeColorMap(
119
- modelId,
120
- lines_ids[0],
121
- );
122
- const no_data_color = modelLinesEdgeAttribute.modelLinesEdgeAttributeNoDataColor(
123
- modelId,
124
- lines_ids[0],
125
- );
126
- const attribute = { name, item, minimum, maximum, colorMap, no_data_color };
127
- if (isModelLinesEdgeAttributeValid(attribute)) {
128
- return modelLinesEdgeAttribute.setModelLinesEdgeAttribute(modelId, lines_ids, attribute);
129
- }
142
+ return applyEdgeColoring(modelId, lines_ids);
130
143
  }
131
144
  return undefined;
132
145
  }
@@ -111,12 +111,28 @@ interface UseModelLinesEdgeAttributeReturn {
111
111
  ) => Promise<unknown>;
112
112
  }
113
113
 
114
+ type ModelLinesEdgeAttributeGetters = Pick<
115
+ UseModelLinesEdgeAttributeReturn,
116
+ | "modelLinesEdgeAttributeStoredConfig"
117
+ | "modelLinesEdgeAttributeName"
118
+ | "modelLinesEdgeAttributeItem"
119
+ | "modelLinesEdgeAttributeRange"
120
+ | "modelLinesEdgeAttributeColorMap"
121
+ | "modelLinesEdgeAttributeNoDataColor"
122
+ | "modelLinesEdgeAttributeTimeStep"
123
+ > & {
124
+ modelLinesEdgeAttributeLastItem: (
125
+ modelId: string,
126
+ componentId: string | undefined,
127
+ name: string | undefined,
128
+ ) => number;
129
+ };
130
+
114
131
  // oxlint-disable-next-line max-lines-per-function
115
- function useModelLinesEdgeAttribute(): UseModelLinesEdgeAttributeReturn {
116
- const { attributeTimeStep, setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
117
- const dataStore = useDataStore();
118
- const modelLinesCommonStyle = useModelLinesCommonStyle();
119
- const viewerStore = useViewerStore();
132
+ function useModelLinesEdgeAttributeGetters(
133
+ modelLinesCommonStyle: ReturnType<typeof useModelLinesCommonStyle>,
134
+ ): ModelLinesEdgeAttributeGetters {
135
+ const { attributeTimeStep } = useAttributeTimeStepStyle();
120
136
  function modelLinesEdgeAttribute(modelId: string, lineId?: string): AttributeState {
121
137
  // oxlint-disable-next-line no-unsafe-type-assertion -- coloring.edge shape is defined by the data style schema.
122
138
  return modelLinesCommonStyle.modelLineColoring(modelId, lineId).edge as AttributeState;
@@ -140,45 +156,6 @@ function useModelLinesEdgeAttribute(): UseModelLinesEdgeAttributeReturn {
140
156
  no_data_color: DEFAULT_NO_DATA_COLOR,
141
157
  };
142
158
  }
143
- async function mutateModelLinesEdgeStyle(
144
- modelId: string,
145
- lineIds: string[],
146
- values: Record<string, unknown>,
147
- ): Promise<void> {
148
- const tasks: Promise<void>[] = [
149
- modelLinesCommonStyle.mutateModelLinesColoring(modelId, lineIds, {
150
- edge: values,
151
- }),
152
- ];
153
- const totalLineIds = await dataStore.getLinesGeodeIds(modelId);
154
- if (lineIds.length === totalLineIds.length) {
155
- tasks.push(
156
- modelLinesCommonStyle.mutateModelLinesTypeColoring(modelId, {
157
- edge: values,
158
- }),
159
- );
160
- }
161
- await Promise.all(tasks);
162
- }
163
- async function setModelLinesEdgeAttributeStoredConfig(
164
- modelId: string,
165
- lineIds: string[],
166
- name: string | undefined,
167
- item: number | undefined,
168
- config: Partial<AttributeStoredConfig>,
169
- ): Promise<void> {
170
- if (name === undefined || item === undefined) {
171
- return;
172
- }
173
- await mutateModelLinesEdgeStyle(modelId, lineIds, {
174
- storedConfigs: {
175
- [name]: {
176
- lastItem: item,
177
- [item]: config,
178
- },
179
- },
180
- });
181
- }
182
159
  function modelLinesEdgeAttributeName(modelId: string, lineId?: string): string | undefined {
183
160
  return modelLinesEdgeAttribute(modelId, lineId).name;
184
161
  }
@@ -229,6 +206,73 @@ function useModelLinesEdgeAttribute(): UseModelLinesEdgeAttributeReturn {
229
206
  modelLinesEdgeAttribute(modelId, lineId).name,
230
207
  );
231
208
  }
209
+ return {
210
+ modelLinesEdgeAttributeStoredConfig,
211
+ modelLinesEdgeAttributeName,
212
+ modelLinesEdgeAttributeLastItem,
213
+ modelLinesEdgeAttributeItem,
214
+ modelLinesEdgeAttributeRange,
215
+ modelLinesEdgeAttributeColorMap,
216
+ modelLinesEdgeAttributeNoDataColor,
217
+ modelLinesEdgeAttributeTimeStep,
218
+ };
219
+ }
220
+
221
+ // oxlint-disable-next-line max-lines-per-function
222
+ function useModelLinesEdgeAttribute(): UseModelLinesEdgeAttributeReturn {
223
+ const { setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
224
+ const dataStore = useDataStore();
225
+ const modelLinesCommonStyle = useModelLinesCommonStyle();
226
+ const {
227
+ modelLinesEdgeAttributeStoredConfig,
228
+ modelLinesEdgeAttributeName,
229
+ modelLinesEdgeAttributeLastItem,
230
+ modelLinesEdgeAttributeItem,
231
+ modelLinesEdgeAttributeRange,
232
+ modelLinesEdgeAttributeColorMap,
233
+ modelLinesEdgeAttributeNoDataColor,
234
+ modelLinesEdgeAttributeTimeStep,
235
+ } = useModelLinesEdgeAttributeGetters(modelLinesCommonStyle);
236
+ const viewerStore = useViewerStore();
237
+ async function mutateModelLinesEdgeStyle(
238
+ modelId: string,
239
+ lineIds: string[],
240
+ values: Record<string, unknown>,
241
+ ): Promise<void> {
242
+ const tasks: Promise<void>[] = [
243
+ modelLinesCommonStyle.mutateModelLinesColoring(modelId, lineIds, {
244
+ edge: values,
245
+ }),
246
+ ];
247
+ const totalLineIds = await dataStore.getLinesGeodeIds(modelId);
248
+ if (lineIds.length === totalLineIds.length) {
249
+ tasks.push(
250
+ modelLinesCommonStyle.mutateModelLinesTypeColoring(modelId, {
251
+ edge: values,
252
+ }),
253
+ );
254
+ }
255
+ await Promise.all(tasks);
256
+ }
257
+ async function setModelLinesEdgeAttributeStoredConfig(
258
+ modelId: string,
259
+ lineIds: string[],
260
+ name: string | undefined,
261
+ item: number | undefined,
262
+ config: Partial<AttributeStoredConfig>,
263
+ ): Promise<void> {
264
+ if (name === undefined || item === undefined) {
265
+ return;
266
+ }
267
+ await mutateModelLinesEdgeStyle(modelId, lineIds, {
268
+ storedConfigs: {
269
+ [name]: {
270
+ lastItem: item,
271
+ [item]: config,
272
+ },
273
+ },
274
+ });
275
+ }
232
276
  async function setModelLinesEdgeAttribute(
233
277
  modelId: string,
234
278
  lineIds: string[],