@geode/opengeodeweb-front 10.38.0 → 10.39.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.
- package/app/components/ThresholdFilter.vue +33 -5
- package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +28 -0
- package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +28 -0
- package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +28 -0
- package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +14 -0
- package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +28 -0
- package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +30 -0
- package/app/components/Viewer/Generic/Model/BlocksOptions.vue +53 -0
- package/app/components/Viewer/Generic/Model/CornersOptions.vue +24 -0
- package/app/components/Viewer/Generic/Model/LinesOptions.vue +48 -0
- package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +58 -0
- package/app/components/Viewer/Options/AttributeSelector.vue +25 -0
- package/app/components/Viewer/Options/ColoringTypeSelector.vue +10 -0
- package/app/components/Viewer/Options/ColormapQuickPicker.vue +17 -2
- package/app/components/Viewer/Options/TimeStepSlider.vue +120 -0
- package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +14 -0
- package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +30 -0
- package/app/components/Viewer/Surface/PolygonsOptions.vue +28 -0
- package/app/composables/global_attribute_style.ts +94 -0
- package/app/stores/data_style.ts +3 -0
- package/app/utils/attributes.ts +46 -9
- package/internal/stores/data_style/mesh/cells/cell.ts +20 -1
- package/internal/stores/data_style/mesh/cells/index.ts +4 -2
- package/internal/stores/data_style/mesh/cells/vertex.ts +23 -1
- package/internal/stores/data_style/mesh/edges/edge.ts +20 -1
- package/internal/stores/data_style/mesh/edges/index.ts +4 -2
- package/internal/stores/data_style/mesh/edges/vertex.ts +23 -1
- package/internal/stores/data_style/mesh/index.ts +68 -0
- package/internal/stores/data_style/mesh/points/index.ts +2 -1
- package/internal/stores/data_style/mesh/points/vertex.ts +23 -1
- package/internal/stores/data_style/mesh/polygons/index.ts +11 -2
- package/internal/stores/data_style/mesh/polygons/polygon.ts +23 -1
- package/internal/stores/data_style/mesh/polygons/vertex.ts +23 -1
- package/internal/stores/data_style/mesh/polyhedra/index.ts +11 -2
- package/internal/stores/data_style/mesh/polyhedra/polyhedron.ts +27 -1
- package/internal/stores/data_style/mesh/polyhedra/vertex.ts +23 -1
- package/internal/stores/data_style/model/blocks/color.ts +11 -2
- package/internal/stores/data_style/model/blocks/index.ts +36 -6
- package/internal/stores/data_style/model/blocks/polyhedron.ts +61 -7
- package/internal/stores/data_style/model/blocks/vertex.ts +61 -7
- package/internal/stores/data_style/model/corners/color.ts +5 -1
- package/internal/stores/data_style/model/corners/index.ts +18 -3
- package/internal/stores/data_style/model/corners/vertex.ts +68 -8
- package/internal/stores/data_style/model/lines/color.ts +10 -2
- package/internal/stores/data_style/model/lines/edge.ts +58 -7
- package/internal/stores/data_style/model/lines/index.ts +35 -6
- package/internal/stores/data_style/model/lines/vertex.ts +58 -7
- package/internal/stores/data_style/model/surfaces/color.ts +10 -2
- package/internal/stores/data_style/model/surfaces/index.ts +53 -6
- package/internal/stores/data_style/model/surfaces/polygon.ts +76 -15
- package/internal/stores/data_style/model/surfaces/vertex.ts +70 -12
- package/internal/stores/data_style/time_step.ts +75 -0
- package/internal/stores/data_style/types.ts +1 -0
- package/package.json +1 -1
|
@@ -102,7 +102,11 @@ export function useModelSurfacesColor(): {
|
|
|
102
102
|
modelId,
|
|
103
103
|
surfaces_ids[0],
|
|
104
104
|
);
|
|
105
|
-
const
|
|
105
|
+
const no_data_color = modelSurfacesVertexAttribute.modelSurfacesVertexAttributeNoDataColor(
|
|
106
|
+
modelId,
|
|
107
|
+
surfaces_ids[0],
|
|
108
|
+
);
|
|
109
|
+
const attribute = { name, item, minimum, maximum, colorMap, no_data_color };
|
|
106
110
|
if (isModelSurfacesVertexAttributeValid(attribute)) {
|
|
107
111
|
return modelSurfacesVertexAttribute.setModelSurfacesVertexAttribute(
|
|
108
112
|
modelId,
|
|
@@ -127,7 +131,11 @@ export function useModelSurfacesColor(): {
|
|
|
127
131
|
modelId,
|
|
128
132
|
surfaces_ids[0],
|
|
129
133
|
);
|
|
130
|
-
const
|
|
134
|
+
const no_data_color = modelSurfacesPolygonAttribute.modelSurfacesPolygonAttributeNoDataColor(
|
|
135
|
+
modelId,
|
|
136
|
+
surfaces_ids[0],
|
|
137
|
+
);
|
|
138
|
+
const attribute = { name, item, minimum, maximum, colorMap, no_data_color };
|
|
131
139
|
if (isModelSurfacesPolygonAttributeValid(attribute)) {
|
|
132
140
|
return modelSurfacesPolygonAttribute.setModelSurfacesPolygonAttribute(
|
|
133
141
|
modelId,
|
|
@@ -17,6 +17,7 @@ interface AttributeGroup {
|
|
|
17
17
|
minimum: number;
|
|
18
18
|
maximum: number;
|
|
19
19
|
colorMap: string;
|
|
20
|
+
no_data_color?: RGBAColor;
|
|
20
21
|
surfaces_ids: string[];
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -123,17 +124,39 @@ export function useModelSurfacesStyle(): UseModelSurfacesStyleReturn {
|
|
|
123
124
|
modelId,
|
|
124
125
|
surfaces_id,
|
|
125
126
|
);
|
|
126
|
-
const
|
|
127
|
+
const no_data_color =
|
|
128
|
+
modelSurfacesVertexAttribute.modelSurfacesVertexAttributeNoDataColor(
|
|
129
|
+
modelId,
|
|
130
|
+
surfaces_id,
|
|
131
|
+
);
|
|
132
|
+
const attribute = {
|
|
133
|
+
name,
|
|
134
|
+
item,
|
|
135
|
+
minimum,
|
|
136
|
+
maximum,
|
|
137
|
+
colorMap,
|
|
138
|
+
no_data_color,
|
|
139
|
+
};
|
|
127
140
|
if (!isModelSurfacesVertexAttributeValid(attribute)) {
|
|
128
141
|
continue;
|
|
129
142
|
}
|
|
130
|
-
const key =
|
|
143
|
+
const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join(
|
|
144
|
+
"_",
|
|
145
|
+
);
|
|
131
146
|
vertexGroups[key] ??= { ...attribute, surfaces_ids: [] };
|
|
132
147
|
vertexGroups[key].surfaces_ids.push(surfaces_id);
|
|
133
148
|
}
|
|
134
149
|
coloringPromises.push(
|
|
135
150
|
...Object.values(vertexGroups).map(
|
|
136
|
-
async ({
|
|
151
|
+
async ({
|
|
152
|
+
name,
|
|
153
|
+
item,
|
|
154
|
+
minimum,
|
|
155
|
+
maximum,
|
|
156
|
+
colorMap,
|
|
157
|
+
no_data_color,
|
|
158
|
+
surfaces_ids: ids,
|
|
159
|
+
}) => {
|
|
137
160
|
const result = await modelSurfacesVertexAttribute.setModelSurfacesVertexAttribute(
|
|
138
161
|
modelId,
|
|
139
162
|
ids,
|
|
@@ -143,6 +166,7 @@ export function useModelSurfacesStyle(): UseModelSurfacesStyleReturn {
|
|
|
143
166
|
minimum,
|
|
144
167
|
maximum,
|
|
145
168
|
colorMap,
|
|
169
|
+
no_data_color,
|
|
146
170
|
},
|
|
147
171
|
);
|
|
148
172
|
return result;
|
|
@@ -166,17 +190,39 @@ export function useModelSurfacesStyle(): UseModelSurfacesStyleReturn {
|
|
|
166
190
|
modelId,
|
|
167
191
|
surfaces_id,
|
|
168
192
|
);
|
|
169
|
-
const
|
|
193
|
+
const no_data_color =
|
|
194
|
+
modelSurfacesPolygonAttribute.modelSurfacesPolygonAttributeNoDataColor(
|
|
195
|
+
modelId,
|
|
196
|
+
surfaces_id,
|
|
197
|
+
);
|
|
198
|
+
const attribute = {
|
|
199
|
+
name,
|
|
200
|
+
item,
|
|
201
|
+
minimum,
|
|
202
|
+
maximum,
|
|
203
|
+
colorMap,
|
|
204
|
+
no_data_color,
|
|
205
|
+
};
|
|
170
206
|
if (!isModelSurfacesPolygonAttributeValid(attribute)) {
|
|
171
207
|
continue;
|
|
172
208
|
}
|
|
173
|
-
const key =
|
|
209
|
+
const key = [name, item, colorMap, minimum, maximum, JSON.stringify(no_data_color)].join(
|
|
210
|
+
"_",
|
|
211
|
+
);
|
|
174
212
|
polygonGroups[key] ??= { ...attribute, surfaces_ids: [] };
|
|
175
213
|
polygonGroups[key].surfaces_ids.push(surfaces_id);
|
|
176
214
|
}
|
|
177
215
|
coloringPromises.push(
|
|
178
216
|
...Object.values(polygonGroups).map(
|
|
179
|
-
async ({
|
|
217
|
+
async ({
|
|
218
|
+
name,
|
|
219
|
+
item,
|
|
220
|
+
minimum,
|
|
221
|
+
maximum,
|
|
222
|
+
colorMap,
|
|
223
|
+
no_data_color,
|
|
224
|
+
surfaces_ids: ids,
|
|
225
|
+
}) => {
|
|
180
226
|
const result = await modelSurfacesPolygonAttribute.setModelSurfacesPolygonAttribute(
|
|
181
227
|
modelId,
|
|
182
228
|
ids,
|
|
@@ -186,6 +232,7 @@ export function useModelSurfacesStyle(): UseModelSurfacesStyleReturn {
|
|
|
186
232
|
minimum,
|
|
187
233
|
maximum,
|
|
188
234
|
colorMap,
|
|
235
|
+
no_data_color,
|
|
189
236
|
},
|
|
190
237
|
);
|
|
191
238
|
return result;
|
|
@@ -4,6 +4,10 @@ import { DEFAULT_NO_DATA_COLOR, type RGBAColor } from "@ogw_front/utils/default_
|
|
|
4
4
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
5
5
|
|
|
6
6
|
// Local imports
|
|
7
|
+
import {
|
|
8
|
+
reapplySameSeries,
|
|
9
|
+
useAttributeTimeStepStyle,
|
|
10
|
+
} from "@ogw_internal/stores/data_style/time_step";
|
|
7
11
|
import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap";
|
|
8
12
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
9
13
|
import { useModelSurfacesCommonStyle } from "./common";
|
|
@@ -61,6 +65,15 @@ interface UseModelSurfacesPolygonAttributeReturn {
|
|
|
61
65
|
modelId: string,
|
|
62
66
|
surfaceId?: string,
|
|
63
67
|
) => [number | undefined, number | undefined];
|
|
68
|
+
modelSurfacesPolygonAttributeTimeStep: (
|
|
69
|
+
modelId: string,
|
|
70
|
+
surfaceId?: string,
|
|
71
|
+
) => number | undefined;
|
|
72
|
+
setModelSurfacesPolygonAttributeTimeStep: (
|
|
73
|
+
modelId: string,
|
|
74
|
+
surfaceIds: string[],
|
|
75
|
+
timeStep: number,
|
|
76
|
+
) => Promise<void>;
|
|
64
77
|
modelSurfacesPolygonAttributeColorMap: (
|
|
65
78
|
modelId: string,
|
|
66
79
|
surfaceId?: string,
|
|
@@ -107,14 +120,14 @@ interface UseModelSurfacesPolygonAttributeReturn {
|
|
|
107
120
|
|
|
108
121
|
// oxlint-disable-next-line max-lines-per-function
|
|
109
122
|
function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeReturn {
|
|
123
|
+
const { attributeTimeStep, setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
|
|
110
124
|
const dataStore = useDataStore();
|
|
111
125
|
const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
|
|
112
126
|
const viewerStore = useViewerStore();
|
|
113
127
|
function modelSurfacesPolygonAttribute(modelId: string, surfaceId?: string): AttributeState {
|
|
114
128
|
return (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
.polygon as AttributeState
|
|
129
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring.polygon shape is defined by the data style schema.
|
|
130
|
+
modelSurfacesCommonStyle.modelSurfaceColoring(modelId, surfaceId).polygon as AttributeState
|
|
118
131
|
);
|
|
119
132
|
}
|
|
120
133
|
function modelSurfacesPolygonAttributeStoredConfig(
|
|
@@ -149,7 +162,9 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
149
162
|
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
150
163
|
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
151
164
|
tasks.push(
|
|
152
|
-
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
165
|
+
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
166
|
+
polygon: values,
|
|
167
|
+
}),
|
|
153
168
|
);
|
|
154
169
|
}
|
|
155
170
|
await Promise.all(tasks);
|
|
@@ -209,6 +224,25 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
209
224
|
const storedConfig = modelSurfacesPolygonAttributeStoredConfig(modelId, surfaceId, name, item);
|
|
210
225
|
return storedConfig.colorMap;
|
|
211
226
|
}
|
|
227
|
+
function modelSurfacesPolygonAttributeNoDataColor(
|
|
228
|
+
modelId: string,
|
|
229
|
+
surfaceId?: string,
|
|
230
|
+
): RGBAColor {
|
|
231
|
+
const name = modelSurfacesPolygonAttributeName(modelId, surfaceId);
|
|
232
|
+
const item = modelSurfacesPolygonAttributeItem(modelId, surfaceId);
|
|
233
|
+
const storedConfig = modelSurfacesPolygonAttributeStoredConfig(modelId, surfaceId, name, item);
|
|
234
|
+
return storedConfig.no_data_color;
|
|
235
|
+
}
|
|
236
|
+
function modelSurfacesPolygonAttributeTimeStep(
|
|
237
|
+
modelId: string,
|
|
238
|
+
surfaceId?: string,
|
|
239
|
+
): number | undefined {
|
|
240
|
+
return attributeTimeStep(
|
|
241
|
+
modelId,
|
|
242
|
+
attributeSchema.$id,
|
|
243
|
+
modelSurfacesPolygonAttribute(modelId, surfaceId).name,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
212
246
|
async function setModelSurfacesPolygonAttribute(
|
|
213
247
|
modelId: string,
|
|
214
248
|
surfaceIds: string[],
|
|
@@ -233,14 +267,17 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
233
267
|
const params = {
|
|
234
268
|
id: modelId,
|
|
235
269
|
block_ids: surface_viewer_ids,
|
|
236
|
-
name,
|
|
270
|
+
name: seriesArrayName(modelId, attributeSchema.$id, name),
|
|
237
271
|
item,
|
|
238
272
|
points,
|
|
239
273
|
minimum,
|
|
240
274
|
maximum,
|
|
241
275
|
no_data_color,
|
|
242
276
|
};
|
|
243
|
-
const result = await viewerStore.request({
|
|
277
|
+
const result = await viewerStore.request({
|
|
278
|
+
schema: attributeSchema,
|
|
279
|
+
params,
|
|
280
|
+
});
|
|
244
281
|
return result;
|
|
245
282
|
}
|
|
246
283
|
async function applyPolygonAttribute(modelId: string, surfaceIds: string[]): Promise<void> {
|
|
@@ -281,6 +318,37 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
281
318
|
await mutateModelSurfacesPolygonStyle(modelId, surfaceIds, { item });
|
|
282
319
|
await applyPolygonAttribute(modelId, surfaceIds);
|
|
283
320
|
}
|
|
321
|
+
async function setModelSurfacesPolygonAttributeTimeStep(
|
|
322
|
+
modelId: string,
|
|
323
|
+
surfaceIds: string[],
|
|
324
|
+
timeStep: number,
|
|
325
|
+
): Promise<void> {
|
|
326
|
+
const name = modelSurfacesPolygonAttributeName(modelId, surfaceIds[0]);
|
|
327
|
+
if (name === undefined) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
await setAttributeTimeStep(modelId, attributeSchema.$id, name, timeStep);
|
|
331
|
+
await Promise.all([
|
|
332
|
+
applyPolygonAttribute(modelId, surfaceIds),
|
|
333
|
+
reapplySameSeries(
|
|
334
|
+
await dataStore.getSurfacesGeodeIds(modelId),
|
|
335
|
+
surfaceIds,
|
|
336
|
+
(id) =>
|
|
337
|
+
modelSurfacesCommonStyle.modelSurfaceColoring(modelId, id).active === "polygon" &&
|
|
338
|
+
modelSurfacesPolygonAttributeName(modelId, id) === name
|
|
339
|
+
? [
|
|
340
|
+
modelSurfacesPolygonAttributeItem(modelId, id),
|
|
341
|
+
modelSurfacesPolygonAttributeRange(modelId, id),
|
|
342
|
+
modelSurfacesPolygonAttributeColorMap(modelId, id),
|
|
343
|
+
JSON.stringify(modelSurfacesPolygonAttributeNoDataColor(modelId, id)),
|
|
344
|
+
].join("|")
|
|
345
|
+
: undefined,
|
|
346
|
+
async (ids) => {
|
|
347
|
+
await applyPolygonAttribute(modelId, ids);
|
|
348
|
+
},
|
|
349
|
+
),
|
|
350
|
+
]);
|
|
351
|
+
}
|
|
284
352
|
async function setModelSurfacesPolygonAttributeRange(
|
|
285
353
|
modelId: string,
|
|
286
354
|
surfaceIds: string[],
|
|
@@ -307,15 +375,6 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
307
375
|
});
|
|
308
376
|
await applyPolygonAttribute(modelId, surfaceIds);
|
|
309
377
|
}
|
|
310
|
-
function modelSurfacesPolygonAttributeNoDataColor(
|
|
311
|
-
modelId: string,
|
|
312
|
-
surfaceId?: string,
|
|
313
|
-
): RGBAColor {
|
|
314
|
-
const name = modelSurfacesPolygonAttributeName(modelId, surfaceId);
|
|
315
|
-
const item = modelSurfacesPolygonAttributeItem(modelId, surfaceId);
|
|
316
|
-
const storedConfig = modelSurfacesPolygonAttributeStoredConfig(modelId, surfaceId, name, item);
|
|
317
|
-
return storedConfig.no_data_color;
|
|
318
|
-
}
|
|
319
378
|
async function setModelSurfacesPolygonAttributeNoDataColor(
|
|
320
379
|
modelId: string,
|
|
321
380
|
surfaceIds: string[],
|
|
@@ -337,6 +396,8 @@ function useModelSurfacesPolygonAttribute(): UseModelSurfacesPolygonAttributeRet
|
|
|
337
396
|
}
|
|
338
397
|
return {
|
|
339
398
|
modelSurfacesPolygonAttributeName,
|
|
399
|
+
modelSurfacesPolygonAttributeTimeStep,
|
|
400
|
+
setModelSurfacesPolygonAttributeTimeStep,
|
|
340
401
|
modelSurfacesPolygonAttributeItem,
|
|
341
402
|
modelSurfacesPolygonAttributeRange,
|
|
342
403
|
modelSurfacesPolygonAttributeColorMap,
|
|
@@ -4,6 +4,10 @@ import { DEFAULT_NO_DATA_COLOR, type RGBAColor } from "@ogw_front/utils/default_
|
|
|
4
4
|
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_typed_schemas.js";
|
|
5
5
|
|
|
6
6
|
// Local imports
|
|
7
|
+
import {
|
|
8
|
+
reapplySameSeries,
|
|
9
|
+
useAttributeTimeStepStyle,
|
|
10
|
+
} from "@ogw_internal/stores/data_style/time_step";
|
|
7
11
|
import { getRGBPointsFromPreset } from "@ogw_front/utils/colormap";
|
|
8
12
|
import { useDataStore } from "@ogw_front/stores/data";
|
|
9
13
|
import { useModelSurfacesCommonStyle } from "./common";
|
|
@@ -61,6 +65,12 @@ interface UseModelSurfacesVertexAttributeReturn {
|
|
|
61
65
|
modelId: string,
|
|
62
66
|
surfaceId?: string,
|
|
63
67
|
) => [number | undefined, number | undefined];
|
|
68
|
+
modelSurfacesVertexAttributeTimeStep: (modelId: string, surfaceId?: string) => number | undefined;
|
|
69
|
+
setModelSurfacesVertexAttributeTimeStep: (
|
|
70
|
+
modelId: string,
|
|
71
|
+
surfaceIds: string[],
|
|
72
|
+
timeStep: number,
|
|
73
|
+
) => Promise<void>;
|
|
64
74
|
modelSurfacesVertexAttributeColorMap: (modelId: string, surfaceId?: string) => string | undefined;
|
|
65
75
|
modelSurfacesVertexAttributeStoredConfig: (
|
|
66
76
|
modelId: string,
|
|
@@ -104,14 +114,14 @@ interface UseModelSurfacesVertexAttributeReturn {
|
|
|
104
114
|
|
|
105
115
|
// oxlint-disable-next-line max-lines-per-function
|
|
106
116
|
function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeReturn {
|
|
117
|
+
const { attributeTimeStep, setAttributeTimeStep, seriesArrayName } = useAttributeTimeStepStyle();
|
|
107
118
|
const dataStore = useDataStore();
|
|
108
119
|
const modelSurfacesCommonStyle = useModelSurfacesCommonStyle();
|
|
109
120
|
const viewerStore = useViewerStore();
|
|
110
121
|
function modelSurfacesVertexAttribute(modelId: string, surfaceId?: string): AttributeState {
|
|
111
122
|
return (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
.vertex as AttributeState
|
|
123
|
+
// oxlint-disable-next-line no-unsafe-type-assertion -- coloring.vertex shape is defined by the data style schema.
|
|
124
|
+
modelSurfacesCommonStyle.modelSurfaceColoring(modelId, surfaceId).vertex as AttributeState
|
|
115
125
|
);
|
|
116
126
|
}
|
|
117
127
|
function modelSurfacesVertexAttributeStoredConfig(
|
|
@@ -146,7 +156,9 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
146
156
|
const totalSurfaceIds = await dataStore.getSurfacesGeodeIds(modelId);
|
|
147
157
|
if (surfaceIds.length === totalSurfaceIds.length) {
|
|
148
158
|
tasks.push(
|
|
149
|
-
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
159
|
+
modelSurfacesCommonStyle.mutateModelSurfacesTypeColoring(modelId, {
|
|
160
|
+
vertex: values,
|
|
161
|
+
}),
|
|
150
162
|
);
|
|
151
163
|
}
|
|
152
164
|
await Promise.all(tasks);
|
|
@@ -206,6 +218,22 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
206
218
|
const storedConfig = modelSurfacesVertexAttributeStoredConfig(modelId, surfaceId, name, item);
|
|
207
219
|
return storedConfig.colorMap;
|
|
208
220
|
}
|
|
221
|
+
function modelSurfacesVertexAttributeNoDataColor(modelId: string, surfaceId?: string): RGBAColor {
|
|
222
|
+
const name = modelSurfacesVertexAttributeName(modelId, surfaceId);
|
|
223
|
+
const item = modelSurfacesVertexAttributeItem(modelId, surfaceId);
|
|
224
|
+
const storedConfig = modelSurfacesVertexAttributeStoredConfig(modelId, surfaceId, name, item);
|
|
225
|
+
return storedConfig.no_data_color;
|
|
226
|
+
}
|
|
227
|
+
function modelSurfacesVertexAttributeTimeStep(
|
|
228
|
+
modelId: string,
|
|
229
|
+
surfaceId?: string,
|
|
230
|
+
): number | undefined {
|
|
231
|
+
return attributeTimeStep(
|
|
232
|
+
modelId,
|
|
233
|
+
attributeSchema.$id,
|
|
234
|
+
modelSurfacesVertexAttribute(modelId, surfaceId).name,
|
|
235
|
+
);
|
|
236
|
+
}
|
|
209
237
|
async function setModelSurfacesVertexAttribute(
|
|
210
238
|
modelId: string,
|
|
211
239
|
surfaceIds: string[],
|
|
@@ -230,14 +258,17 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
230
258
|
const params = {
|
|
231
259
|
id: modelId,
|
|
232
260
|
block_ids: surface_viewer_ids,
|
|
233
|
-
name,
|
|
261
|
+
name: seriesArrayName(modelId, attributeSchema.$id, name),
|
|
234
262
|
item,
|
|
235
263
|
points,
|
|
236
264
|
minimum,
|
|
237
265
|
maximum,
|
|
238
266
|
no_data_color,
|
|
239
267
|
};
|
|
240
|
-
const result = await viewerStore.request({
|
|
268
|
+
const result = await viewerStore.request({
|
|
269
|
+
schema: attributeSchema,
|
|
270
|
+
params,
|
|
271
|
+
});
|
|
241
272
|
return result;
|
|
242
273
|
}
|
|
243
274
|
async function applyVertexAttribute(modelId: string, surfaceIds: string[]): Promise<unknown> {
|
|
@@ -282,6 +313,37 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
282
313
|
const result = await applyVertexAttribute(modelId, surfaceIds);
|
|
283
314
|
return result;
|
|
284
315
|
}
|
|
316
|
+
async function setModelSurfacesVertexAttributeTimeStep(
|
|
317
|
+
modelId: string,
|
|
318
|
+
surfaceIds: string[],
|
|
319
|
+
timeStep: number,
|
|
320
|
+
): Promise<void> {
|
|
321
|
+
const name = modelSurfacesVertexAttributeName(modelId, surfaceIds[0]);
|
|
322
|
+
if (name === undefined) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
await setAttributeTimeStep(modelId, attributeSchema.$id, name, timeStep);
|
|
326
|
+
await Promise.all([
|
|
327
|
+
applyVertexAttribute(modelId, surfaceIds),
|
|
328
|
+
reapplySameSeries(
|
|
329
|
+
await dataStore.getSurfacesGeodeIds(modelId),
|
|
330
|
+
surfaceIds,
|
|
331
|
+
(id) =>
|
|
332
|
+
modelSurfacesCommonStyle.modelSurfaceColoring(modelId, id).active === "vertex" &&
|
|
333
|
+
modelSurfacesVertexAttributeName(modelId, id) === name
|
|
334
|
+
? [
|
|
335
|
+
modelSurfacesVertexAttributeItem(modelId, id),
|
|
336
|
+
modelSurfacesVertexAttributeRange(modelId, id),
|
|
337
|
+
modelSurfacesVertexAttributeColorMap(modelId, id),
|
|
338
|
+
JSON.stringify(modelSurfacesVertexAttributeNoDataColor(modelId, id)),
|
|
339
|
+
].join("|")
|
|
340
|
+
: undefined,
|
|
341
|
+
async (ids) => {
|
|
342
|
+
await applyVertexAttribute(modelId, ids);
|
|
343
|
+
},
|
|
344
|
+
),
|
|
345
|
+
]);
|
|
346
|
+
}
|
|
285
347
|
async function setModelSurfacesVertexAttributeRange(
|
|
286
348
|
modelId: string,
|
|
287
349
|
surfaceIds: string[],
|
|
@@ -310,12 +372,6 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
310
372
|
const result = await applyVertexAttribute(modelId, surfaceIds);
|
|
311
373
|
return result;
|
|
312
374
|
}
|
|
313
|
-
function modelSurfacesVertexAttributeNoDataColor(modelId: string, surfaceId?: string): RGBAColor {
|
|
314
|
-
const name = modelSurfacesVertexAttributeName(modelId, surfaceId);
|
|
315
|
-
const item = modelSurfacesVertexAttributeItem(modelId, surfaceId);
|
|
316
|
-
const storedConfig = modelSurfacesVertexAttributeStoredConfig(modelId, surfaceId, name, item);
|
|
317
|
-
return storedConfig.no_data_color;
|
|
318
|
-
}
|
|
319
375
|
async function setModelSurfacesVertexAttributeNoDataColor(
|
|
320
376
|
modelId: string,
|
|
321
377
|
surfaceIds: string[],
|
|
@@ -338,6 +394,8 @@ function useModelSurfacesVertexAttribute(): UseModelSurfacesVertexAttributeRetur
|
|
|
338
394
|
}
|
|
339
395
|
return {
|
|
340
396
|
modelSurfacesVertexAttributeName,
|
|
397
|
+
modelSurfacesVertexAttributeTimeStep,
|
|
398
|
+
setModelSurfacesVertexAttributeTimeStep,
|
|
341
399
|
modelSurfacesVertexAttributeItem,
|
|
342
400
|
modelSurfacesVertexAttributeRange,
|
|
343
401
|
modelSurfacesVertexAttributeColorMap,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { attributeArrayName } from "@ogw_front/utils/attributes";
|
|
2
|
+
import { useDataStyleState } from "./state";
|
|
3
|
+
|
|
4
|
+
interface UseAttributeTimeStepStyleReturn {
|
|
5
|
+
attributeTimeStep: (id: string, key: string, name: string | undefined) => number | undefined;
|
|
6
|
+
setAttributeTimeStep: (
|
|
7
|
+
id: string,
|
|
8
|
+
key: string,
|
|
9
|
+
name: string,
|
|
10
|
+
timeStep: number,
|
|
11
|
+
) => Promise<unknown>;
|
|
12
|
+
seriesArrayName: (id: string, key: string, name: string) => string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Re-render the other components showing the same series, one request per group.
|
|
16
|
+
// Identical config means same name, item, range, colormap and no data color.
|
|
17
|
+
// The group key is undefined for a component not showing the series.
|
|
18
|
+
async function reapplySameSeries(
|
|
19
|
+
allIds: string[],
|
|
20
|
+
targetIds: string[],
|
|
21
|
+
groupKey: (componentId: string) => string | undefined,
|
|
22
|
+
apply: (componentIds: string[]) => Promise<unknown>,
|
|
23
|
+
): Promise<void> {
|
|
24
|
+
const groups: Record<string, string[]> = {};
|
|
25
|
+
for (const componentId of allIds) {
|
|
26
|
+
const key = groupKey(componentId);
|
|
27
|
+
if (key !== undefined && !targetIds.includes(componentId)) {
|
|
28
|
+
groups[key] ??= [];
|
|
29
|
+
groups[key].push(componentId);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
await Promise.all(
|
|
33
|
+
Object.values(groups).map(async (componentIds) => {
|
|
34
|
+
await apply(componentIds);
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The key of a series is a schema $id: the back attribute names schema for meshes
|
|
40
|
+
// (cards share a step), the viewer attribute schema for models (one step per component type)
|
|
41
|
+
function useAttributeTimeStepStyle(): UseAttributeTimeStepStyleReturn {
|
|
42
|
+
const dataStyleState = useDataStyleState();
|
|
43
|
+
|
|
44
|
+
function attributeTimeStep(
|
|
45
|
+
id: string,
|
|
46
|
+
key: string,
|
|
47
|
+
name: string | undefined,
|
|
48
|
+
): number | undefined {
|
|
49
|
+
if (name === undefined) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return dataStyleState.getStyle(id).timeSteps?.[key]?.[name];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function setAttributeTimeStep(
|
|
56
|
+
id: string,
|
|
57
|
+
key: string,
|
|
58
|
+
name: string,
|
|
59
|
+
timeStep: number,
|
|
60
|
+
): Promise<unknown> {
|
|
61
|
+
const result = await dataStyleState.mutateStyle(id, {
|
|
62
|
+
timeSteps: { [key]: { [name]: timeStep } },
|
|
63
|
+
});
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// VTK array name of the series at its current time step
|
|
68
|
+
function seriesArrayName(id: string, key: string, name: string): string {
|
|
69
|
+
return attributeArrayName(name, attributeTimeStep(id, key, name));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return { attributeTimeStep, setAttributeTimeStep, seriesArrayName };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { reapplySameSeries, useAttributeTimeStepStyle };
|
package/package.json
CHANGED