@geode/opengeodeweb-front 10.41.0-rc.1 → 10.41.0-rc.3

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 (26) hide show
  1. package/app/components/HybridRenderingView.vue +2 -0
  2. package/app/components/RemoteRenderingView.vue +2 -0
  3. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +0 -1
  4. package/app/components/Viewer/Generic/Model/ComponentPointsOptions.vue +245 -0
  5. package/app/components/Viewer/Generic/Model/ModelPointsCard.vue +141 -0
  6. package/app/components/Viewer/Generic/Model/ModelStyleCard.vue +7 -67
  7. package/app/components/Viewer/Generic/Model/PointsOptions.vue +2 -40
  8. package/app/components/Viewer/Options/ColormapQuickPicker.vue +11 -2
  9. package/app/composables/attribute_coloring_style.ts +182 -0
  10. package/app/composables/global_attribute_style.ts +55 -366
  11. package/app/composables/model_attribute_style.ts +79 -0
  12. package/app/composables/model_menu_context.ts +101 -0
  13. package/app/composables/use_quick_colormap.ts +4 -1
  14. package/app/stores/data.ts +12 -0
  15. package/app/utils/attribute_range.ts +15 -15
  16. package/internal/stores/data_style/model/blocks/index.ts +4 -0
  17. package/internal/stores/data_style/model/blocks/points.ts +51 -0
  18. package/internal/stores/data_style/model/index.ts +6 -0
  19. package/internal/stores/data_style/model/lines/index.ts +4 -0
  20. package/internal/stores/data_style/model/lines/points.ts +51 -0
  21. package/internal/stores/data_style/model/points/component.ts +423 -0
  22. package/internal/stores/data_style/model/points/size.ts +13 -1
  23. package/internal/stores/data_style/model/points/visibility.ts +13 -3
  24. package/internal/stores/data_style/model/surfaces/index.ts +4 -0
  25. package/internal/stores/data_style/model/surfaces/points.ts +51 -0
  26. package/package.json +1 -1
@@ -0,0 +1,182 @@
1
+ import { type AttributeSchemas, fetchAttributeRange } from "@ogw_front/utils/attribute_range";
2
+ import type { JsonRpcSchema } from "@ogw_shared/utils/types";
3
+ import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
4
+ import { getAttributeRange } from "@ogw_front/utils/attributes";
5
+ import { useBackStore } from "@ogw_front/stores/back";
6
+ import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
7
+
8
+ // Elements colored by the same attribute, with the store and back accesses of their data
9
+ interface AttributeColoring {
10
+ // Reads a style property ("Name", "Range", ...) of the attribute coloring
11
+ read: (property: string) => unknown;
12
+ write: (property: string, ...values: unknown[]) => Promise<void>;
13
+ schemas: AttributeSchemas;
14
+ params: { id: string; component_ids?: string[] };
15
+ }
16
+
17
+ interface AttributeNamesResponse {
18
+ attributes: { attribute_name: string; time_steps?: number[] }[];
19
+ }
20
+
21
+ interface AttributeColoringStyle {
22
+ currentColormap: ComputedRef<string>;
23
+ currentRange: WritableComputedRef<readonly [number, number]>;
24
+ applyGlobalColormap: (colorMap: string) => Promise<void>;
25
+ resetGlobalRange: () => Promise<void>;
26
+ currentTimeSteps: Ref<number[]>;
27
+ currentTimeStep: WritableComputedRef<number>;
28
+ loadTimeSteps: () => Promise<void>;
29
+ }
30
+
31
+ type StoreMethod = (...args: readonly unknown[]) => unknown;
32
+
33
+ // The data style store methods are named after the element and attribute types, e.g. "meshPointsVertexAttributeRange"
34
+ function storeMethod(store: object, name: string): StoreMethod {
35
+ const method: unknown = Reflect.get(store, name);
36
+ // oxlint-disable-next-line no-unsafe-type-assertion -- the style methods exist for every element type and attribute coloring
37
+ return method as StoreMethod;
38
+ }
39
+
40
+ // "Polyhedron" in the store method names of the "polyhedron" coloring
41
+ function attributeType(activeColoring: string): string {
42
+ return `${activeColoring.charAt(0).toUpperCase()}${activeColoring.slice(1)}Attribute`;
43
+ }
44
+
45
+ function attributeSchema(prefix: string, activeColoring: string, route: string): JsonRpcSchema {
46
+ const schema: unknown = Reflect.get(
47
+ back_schemas.opengeodeweb_back,
48
+ `${prefix}${activeColoring}_attribute_${route}`,
49
+ );
50
+ // oxlint-disable-next-line no-unsafe-type-assertion -- these schemas exist for every attribute coloring
51
+ return schema as JsonRpcSchema;
52
+ }
53
+
54
+ // The `${prefix}${activeColoring}_attribute_names` and `_attribute_range` schemas
55
+ function attributeSchemas(prefix: string, activeColoring: string): AttributeSchemas {
56
+ return {
57
+ names: attributeSchema(prefix, activeColoring, "names"),
58
+ range: attributeSchema(prefix, activeColoring, "range"),
59
+ };
60
+ }
61
+
62
+ // Colormap, range and time step of the attributes colored by a scalar bar
63
+ function useAttributeColoringStyle(colorings: Ref<AttributeColoring[]>): AttributeColoringStyle {
64
+ const backStore = useBackStore();
65
+ const hybridViewerStore = useHybridViewerStore();
66
+
67
+ const currentTimeSteps = ref<number[]>([]);
68
+ const temporalColoring = shallowRef<AttributeColoring | undefined>(undefined);
69
+
70
+ async function writeAll(property: string, ...values: unknown[]): Promise<void> {
71
+ await Promise.all(
72
+ colorings.value.map(async (coloring) => {
73
+ await coloring.write(property, ...values);
74
+ }),
75
+ );
76
+ await hybridViewerStore.remoteRender();
77
+ }
78
+
79
+ const currentColormap = computed((): string => {
80
+ const [coloring] = colorings.value;
81
+ return coloring ? String(coloring.read("ColorMap")) : "batlow";
82
+ });
83
+
84
+ async function applyGlobalColormap(colorMap: string): Promise<void> {
85
+ await writeAll("ColorMap", colorMap);
86
+ }
87
+
88
+ const currentRange = computed<readonly [number, number]>({
89
+ get(): readonly [number, number] {
90
+ const [coloring] = colorings.value;
91
+ if (!coloring) {
92
+ return [0, 1];
93
+ }
94
+ // oxlint-disable-next-line no-unsafe-type-assertion -- the range getters return [minimum, maximum].
95
+ const [minimum = 0, maximum = 1] = coloring.read("Range") as (number | undefined)[];
96
+ return [minimum, maximum];
97
+ },
98
+ // Vue's WritableComputedOptions setter is strictly `(v: T) => void`: the async write is delegated.
99
+ set: (range: readonly [number, number]): void => {
100
+ /* oxlint-disable-next-line promise/prefer-await-to-then -- setter cannot be async; see comment above. */
101
+ writeAll("Range", range[0], range[1]).catch(() => undefined);
102
+ },
103
+ });
104
+
105
+ async function resetGlobalRange(): Promise<void> {
106
+ await Promise.all(
107
+ colorings.value.map(async (coloring) => {
108
+ const range = await fetchAttributeRange(
109
+ coloring.schemas.range,
110
+ coloring.params,
111
+ String(coloring.read("Name")),
112
+ );
113
+ const { min, max } = getAttributeRange(range, Number(coloring.read("Item") ?? 0));
114
+ await coloring.write("Range", min, max);
115
+ }),
116
+ );
117
+ await hybridViewerStore.remoteRender();
118
+ }
119
+
120
+ async function requestTimeSteps(coloring: AttributeColoring): Promise<number[]> {
121
+ const name = coloring.read("Name");
122
+ const response = await backStore.request({
123
+ schema: coloring.schemas.names,
124
+ params: coloring.params,
125
+ });
126
+ // oxlint-disable-next-line no-unsafe-type-assertion -- every *_attribute_names schema shares this response.
127
+ const { attributes } = response as AttributeNamesResponse;
128
+ return attributes.find((attribute) => attribute.attribute_name === name)?.time_steps ?? [];
129
+ }
130
+
131
+ async function loadTimeSteps(): Promise<void> {
132
+ temporalColoring.value = undefined;
133
+ currentTimeSteps.value = [];
134
+ for (const coloring of colorings.value) {
135
+ // oxlint-disable-next-line no-await-in-loop -- first temporal coloring wins, in order.
136
+ const timeSteps = await requestTimeSteps(coloring);
137
+ if (timeSteps.length > 0) {
138
+ temporalColoring.value = coloring;
139
+ currentTimeSteps.value = timeSteps;
140
+ return;
141
+ }
142
+ }
143
+ }
144
+
145
+ async function applyTimeStep(step: number): Promise<void> {
146
+ if (temporalColoring.value) {
147
+ await temporalColoring.value.write("TimeStep", step);
148
+ await hybridViewerStore.remoteRender();
149
+ }
150
+ }
151
+
152
+ const currentTimeStep = computed<number>({
153
+ get(): number {
154
+ const coloring = temporalColoring.value;
155
+ return coloring ? Number(coloring.read("TimeStep") ?? 0) : 0;
156
+ },
157
+ // Setter cannot be async (see `currentRange`), so the write is delegated.
158
+ set: (step: number): void => {
159
+ /* oxlint-disable-next-line promise/prefer-await-to-then -- setter cannot be async; see comment above. */
160
+ applyTimeStep(step).catch(() => undefined);
161
+ },
162
+ });
163
+
164
+ return {
165
+ currentColormap,
166
+ currentRange,
167
+ applyGlobalColormap,
168
+ resetGlobalRange,
169
+ currentTimeSteps,
170
+ currentTimeStep,
171
+ loadTimeSteps,
172
+ };
173
+ }
174
+
175
+ export {
176
+ type AttributeColoring,
177
+ type AttributeColoringStyle,
178
+ attributeSchemas,
179
+ attributeType,
180
+ storeMethod,
181
+ useAttributeColoringStyle,
182
+ };
@@ -1,384 +1,73 @@
1
- import type { JsonRpcSchema } from "@ogw_shared/utils/types";
2
- import back_schemas from "@geode/opengeodeweb-back/opengeodeweb_back_typed_schemas.js";
3
- import { fetchAttributeRange } from "@ogw_front/utils/attribute_range";
4
- import { getAttributeRange } from "@ogw_front/utils/attributes";
5
- import { useBackStore } from "@ogw_front/stores/back";
1
+ import {
2
+ type AttributeColoring,
3
+ type AttributeColoringStyle,
4
+ attributeSchemas,
5
+ attributeType,
6
+ storeMethod,
7
+ useAttributeColoringStyle,
8
+ } from "@ogw_front/composables/attribute_coloring_style";
6
9
  import { useDataStyleStore } from "@ogw_front/stores/data_style";
7
- import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
8
10
 
9
- interface ComponentNameEntry {
10
- getterKey: string;
11
- setterKey: string;
12
- key: string;
11
+ interface MeshElement {
12
+ // Element type of the store methods, e.g. "MeshPoints" for "setMeshPointsVertexAttributeRange"
13
+ storeName: string;
14
+ styleKey: "points" | "edges" | "polygons" | "cells" | "polyhedra";
13
15
  }
14
16
 
15
- interface ActiveComponent extends ComponentNameEntry {
16
- activeColoring: string;
17
- attributeType: string;
18
- }
19
-
20
- // This composable resolves a batch of dynamically-named getter/setter methods on the data style store (e.g. "meshPointsVertexAttributeRange", "setMeshPointsVertexAttributeRange", ...) - the store's real, fully-typed surface has no index signature for this, so dynamic lookups go through this type guard instead of an unsafe cast of the whole store (which mixes these methods with state refs and other members), matching how these methods are actually shaped (getters take an id and return a value, setters take an id plus arbitrary arguments).
21
- type DynamicStoreMethod = (...args: readonly unknown[]) => unknown;
22
-
23
- function isDynamicStoreMethod(value: unknown): value is DynamicStoreMethod {
24
- return typeof value === "function";
25
- }
26
-
27
- function getDynamicStoreMethod(store: object, key: string): DynamicStoreMethod | undefined {
28
- const value: unknown = Reflect.get(store, key);
29
- return isDynamicStoreMethod(value) ? value : undefined;
30
- }
17
+ const MESH_ELEMENTS: MeshElement[] = [
18
+ { storeName: "MeshPoints", styleKey: "points" },
19
+ { storeName: "MeshEdges", styleKey: "edges" },
20
+ { storeName: "MeshPolygons", styleKey: "polygons" },
21
+ { storeName: "MeshCells", styleKey: "cells" },
22
+ { storeName: "MeshPolyhedra", styleKey: "polyhedra" },
23
+ ];
31
24
 
32
- interface AttributeStyleComponent {
33
- coloring?: { active?: string };
34
- }
25
+ const ATTRIBUTE_COLORINGS = new Set(["vertex", "edge", "polygon", "cell", "polyhedron"]);
35
26
 
36
- interface AttributeResponse {
37
- readonly attributes?: readonly {
38
- readonly attribute_name?: string;
39
- readonly time_steps?: readonly number[];
40
- }[];
41
- }
42
-
43
- function isColoringValue(
44
- value: unknown,
45
- ): value is NonNullable<AttributeStyleComponent["coloring"]> {
27
+ function isColoring(value: unknown): value is { active?: string } {
46
28
  return typeof value === "object" && value !== null;
47
29
  }
48
30
 
49
- function isJsonRpcSchema(value: unknown): value is JsonRpcSchema {
50
- return (
51
- typeof value === "object" && value !== null && "$id" in value && typeof value.$id === "string"
52
- );
53
- }
54
-
55
- function isAttributeResponse(value: unknown): value is AttributeResponse {
56
- return typeof value === "object" && value !== null;
57
- }
58
-
59
- function isNumberArray(value: unknown): value is number[] {
60
- return Array.isArray(value) && value.every((item) => typeof item === "number");
61
- }
62
-
63
- function isStringOrUndefined(value: unknown): value is string | undefined {
64
- return value === undefined || typeof value === "string";
65
- }
66
-
67
- function isNumberOrUndefined(value: unknown): value is number | undefined {
68
- return value === undefined || typeof value === "number";
69
- }
70
-
71
- export function useGlobalAttributeStyle(dataIdRef: Ref<string | undefined>): {
72
- currentColormap: typeof currentColormap;
73
- currentRange: typeof currentRange;
74
- applyGlobalColormap: typeof applyGlobalColormap;
75
- resetGlobalRange: typeof resetGlobalRange;
76
- currentTimeSteps: typeof currentTimeSteps;
77
- currentTimeStep: typeof currentTimeStep;
78
- loadTimeSteps: typeof loadTimeSteps;
79
- } {
31
+ // Styles the mesh elements colored by an attribute
32
+ export function useGlobalAttributeStyle(
33
+ dataIdRef: Ref<string | undefined>,
34
+ ): AttributeColoringStyle {
80
35
  const dataStyleStore = useDataStyleStore();
81
- const hybridViewerStore = useHybridViewerStore();
82
- const backStore = useBackStore();
83
-
84
- const componentNames: ComponentNameEntry[] = [
85
- { getterKey: "meshPoints", setterKey: "MeshPoints", key: "points" },
86
- { getterKey: "meshEdges", setterKey: "MeshEdges", key: "edges" },
87
- { getterKey: "meshPolygons", setterKey: "MeshPolygons", key: "polygons" },
88
- { getterKey: "meshCells", setterKey: "MeshCells", key: "cells" },
89
- { getterKey: "meshPolyhedra", setterKey: "MeshPolyhedra", key: "polyhedra" },
90
- ];
91
-
92
- function getActiveComponents(targetId: string): ActiveComponent[] {
93
- const style = dataStyleStore.getStyle(targetId);
94
- const activeComponents: ActiveComponent[] = [];
95
- for (const { key, getterKey, setterKey } of componentNames) {
96
- let componentStyle: Record<string, unknown> | undefined = undefined;
97
- switch (key) {
98
- case "points": {
99
- componentStyle = style.points;
100
- break;
101
- }
102
- case "edges": {
103
- componentStyle = style.edges;
104
- break;
105
- }
106
- case "polygons": {
107
- componentStyle = style.polygons;
108
- break;
109
- }
110
- case "cells": {
111
- componentStyle = style.cells;
112
- break;
113
- }
114
- case "polyhedra": {
115
- componentStyle = style.polyhedra;
116
- break;
117
- }
118
- default: {
119
- componentStyle = undefined;
120
- }
121
- }
122
- if (componentStyle === undefined) {
123
- continue;
124
- }
125
-
126
- const { coloring } = componentStyle;
127
- if (!isColoringValue(coloring)) {
128
- continue;
129
- }
130
-
131
- const { active: activeColoring } = coloring;
132
- if (
133
- activeColoring === undefined ||
134
- !["vertex", "edge", "polygon", "cell", "polyhedron"].includes(activeColoring)
135
- ) {
136
- continue;
137
- }
138
-
139
- const attributeType = `${activeColoring.charAt(0).toUpperCase()}${activeColoring.slice(1)}Attribute`;
140
- activeComponents.push({ activeColoring, attributeType, getterKey, setterKey, key });
141
- }
142
- return activeComponents;
143
- }
144
-
145
- const currentColormap = computed((): string => {
146
- const targetId = dataIdRef.value;
147
- if (targetId === undefined || targetId === "") {
148
- return "batlow";
149
- }
150
-
151
- for (const comp of getActiveComponents(targetId)) {
152
- const getterName = `${comp.getterKey}${comp.attributeType}ColorMap`;
153
- const getter = getDynamicStoreMethod(dataStyleStore, getterName);
154
- if (getter) {
155
- const colorMap = getter(targetId);
156
- if (typeof colorMap === "string" && colorMap.length > 0) {
157
- return colorMap;
158
- }
159
- }
160
- }
161
-
162
- return "batlow";
163
- });
164
-
165
- async function applyCurrentRange(newValue: readonly [number, number]): Promise<void> {
166
- const targetId = dataIdRef.value;
167
- if (targetId === undefined || targetId === "") {
168
- return;
169
- }
170
-
171
- let updated = false;
172
- for (const comp of getActiveComponents(targetId)) {
173
- const setterName = `set${comp.setterKey}${comp.attributeType}Range`;
174
- const setter = getDynamicStoreMethod(dataStyleStore, setterName);
175
- if (setter) {
176
- setter(targetId, newValue[0], newValue[1]);
177
- updated = true;
178
- }
179
- }
180
- if (updated) {
181
- await hybridViewerStore.remoteRender();
182
- }
183
- }
184
-
185
- const currentRange = computed<readonly [number, number]>({
186
- get(): readonly [number, number] {
187
- const targetId = dataIdRef.value;
188
- if (targetId === undefined || targetId === "") {
189
- return [0, 1];
190
- }
191
-
192
- for (const comp of getActiveComponents(targetId)) {
193
- const getterName = `${comp.getterKey}${comp.attributeType}Range`;
194
- const getter = getDynamicStoreMethod(dataStyleStore, getterName);
195
- if (getter) {
196
- const rawRange = getter(targetId);
197
- const range = isNumberArray(rawRange) ? rawRange : undefined;
198
- if (range && range.length === 2) {
199
- return [range[0] ?? 0, range[1] ?? 1];
200
- }
201
- }
202
- }
203
- return [0, 1];
204
- },
205
- // Vue's WritableComputedOptions setter is strictly `(v: T) => void`, so the async render call is delegated to a helper (see the same trade-off in `app/composables/hover_highlight.ts`'s `onHoverEnter`).
206
- set: (newValue: readonly [number, number]): void => {
207
- /* oxlint-disable-next-line promise/prefer-await-to-then -- setter cannot be async; see comment above. */
208
- applyCurrentRange(newValue).catch(() => undefined);
209
- },
210
- });
211
-
212
- async function applyGlobalColormap(newMap: string): Promise<void> {
213
- const targetId = dataIdRef.value;
214
- if (targetId === undefined || targetId === "") {
215
- return;
216
- }
217
-
218
- const promises: Promise<unknown>[] = [];
219
-
220
- for (const comp of getActiveComponents(targetId)) {
221
- const setterName = `set${comp.setterKey}${comp.attributeType}ColorMap`;
222
- const setter = getDynamicStoreMethod(dataStyleStore, setterName);
223
-
224
- if (setter) {
225
- promises.push(Promise.resolve(setter(targetId, newMap)));
226
- }
227
- }
228
-
229
- await Promise.all(promises);
230
- await hybridViewerStore.remoteRender();
231
- }
232
-
233
- async function resetGlobalRange(): Promise<void> {
234
- const targetId = dataIdRef.value;
235
- if (targetId === undefined || targetId === "") {
236
- return;
237
- }
238
-
239
- const requestPromises: Promise<unknown>[] = [];
240
-
241
- for (const comp of getActiveComponents(targetId)) {
242
- const { activeColoring, attributeType, getterKey, setterKey } = comp;
243
-
244
- const nameGetter = getDynamicStoreMethod(dataStyleStore, `${getterKey}${attributeType}Name`);
245
- const itemGetter = getDynamicStoreMethod(dataStyleStore, `${getterKey}${attributeType}Item`);
246
- if (!nameGetter || !itemGetter) {
247
- continue;
248
- }
249
-
250
- const rawAttrName = nameGetter(targetId);
251
- const attrName = isStringOrUndefined(rawAttrName) ? rawAttrName : undefined;
252
- const rawAttrItem = itemGetter(targetId);
253
- const attrItem = (isNumberOrUndefined(rawAttrItem) ? rawAttrItem : undefined) ?? 0;
254
36
 
255
- if (attrName === undefined || attrName === "") {
256
- continue;
257
- }
258
-
259
- const rangeSchema = (back_schemas.opengeodeweb_back as Record<string, unknown>)[
260
- `${activeColoring}_attribute_range`
261
- ];
262
- if (!isJsonRpcSchema(rangeSchema)) {
263
- continue;
264
- }
265
-
266
- requestPromises.push(
267
- (async (): Promise<void> => {
268
- const range = await fetchAttributeRange(rangeSchema, { id: targetId }, attrName);
269
- if (!range) {
270
- return;
271
- }
272
- const { min, max } = getAttributeRange(range, attrItem);
273
- const setter = getDynamicStoreMethod(
274
- dataStyleStore,
275
- `set${setterKey}${attributeType}Range`,
276
- );
277
- if (setter) {
278
- setter(targetId, min, max);
279
- await hybridViewerStore.remoteRender();
280
- }
281
- })(),
282
- );
283
- }
284
-
285
- await Promise.all(requestPromises);
286
- }
287
-
288
- const currentTimeSteps = ref<number[]>([]);
289
- const temporalComponent = shallowRef<ActiveComponent | undefined>(undefined);
290
-
291
- async function requestTimeSteps(targetId: string, comp: ActiveComponent): Promise<number[]> {
292
- const { activeColoring, attributeType, getterKey } = comp;
293
- const nameGetter = getDynamicStoreMethod(dataStyleStore, `${getterKey}${attributeType}Name`);
294
- const rawAttrName = nameGetter?.(targetId);
295
- const schema = (back_schemas.opengeodeweb_back as Record<string, unknown>)[
296
- `${activeColoring}_attribute_names`
297
- ];
298
- if (
299
- !isStringOrUndefined(rawAttrName) ||
300
- rawAttrName === undefined ||
301
- rawAttrName === "" ||
302
- !isJsonRpcSchema(schema)
303
- ) {
304
- return [];
305
- }
306
- let timeSteps: number[] = [];
307
- await backStore.request(
308
- { schema, params: { id: targetId } },
309
- {
310
- response_function: (response: unknown): void => {
311
- if (!isAttributeResponse(response)) {
312
- return;
313
- }
314
- const found = response.attributes?.find((attr) => attr.attribute_name === rawAttrName);
315
- timeSteps = [...(found?.time_steps ?? [])];
316
- },
37
+ function meshColoring(
38
+ dataId: string,
39
+ { storeName }: MeshElement,
40
+ activeColoring: string,
41
+ ): AttributeColoring {
42
+ const methodName = `${storeName}${attributeType(activeColoring)}`;
43
+ const getterName = `${methodName.charAt(0).toLowerCase()}${methodName.slice(1)}`;
44
+ return {
45
+ read: (property): unknown => storeMethod(dataStyleStore, `${getterName}${property}`)(dataId),
46
+ write: async (property, ...values): Promise<void> => {
47
+ await storeMethod(dataStyleStore, `set${methodName}${property}`)(dataId, ...values);
317
48
  },
318
- );
319
- return timeSteps;
49
+ schemas: attributeSchemas("", activeColoring),
50
+ params: { id: dataId },
51
+ };
320
52
  }
321
53
 
322
- async function loadTimeSteps(): Promise<void> {
323
- const targetId = dataIdRef.value;
324
- temporalComponent.value = undefined;
325
- currentTimeSteps.value = [];
326
- if (targetId === undefined || targetId === "") {
327
- return;
328
- }
329
- for (const comp of getActiveComponents(targetId)) {
330
- // oxlint-disable-next-line no-await-in-loop -- first temporal component wins, in order.
331
- const timeSteps = await requestTimeSteps(targetId, comp);
332
- if (timeSteps.length > 0) {
333
- temporalComponent.value = comp;
334
- currentTimeSteps.value = timeSteps;
335
- return;
336
- }
337
- }
338
- }
339
-
340
- watch(dataIdRef, loadTimeSteps, { immediate: true });
341
-
342
- async function applyCurrentTimeStep(step: number): Promise<void> {
343
- const targetId = dataIdRef.value;
344
- const comp = temporalComponent.value;
345
- if (targetId === undefined || targetId === "" || !comp) {
346
- return;
347
- }
348
- const { attributeType, setterKey } = comp;
349
- const setter = getDynamicStoreMethod(dataStyleStore, `set${setterKey}${attributeType}TimeStep`);
350
- if (setter) {
351
- await setter(targetId, step);
352
- await hybridViewerStore.remoteRender();
54
+ const colorings = computed<AttributeColoring[]>(() => {
55
+ const dataId = dataIdRef.value;
56
+ // The picker exists before any scalar bar is picked
57
+ if (dataId === undefined) {
58
+ return [];
353
59
  }
354
- }
355
-
356
- const currentTimeStep = computed<number>({
357
- get(): number {
358
- const targetId = dataIdRef.value;
359
- const comp = temporalComponent.value;
360
- if (targetId === undefined || targetId === "" || !comp) {
361
- return 0;
362
- }
363
- const { attributeType, getterKey } = comp;
364
- const getter = getDynamicStoreMethod(dataStyleStore, `${getterKey}${attributeType}TimeStep`);
365
- const rawStep = getter?.(targetId);
366
- return typeof rawStep === "number" ? rawStep : 0;
367
- },
368
- // Setter cannot be async (see `currentRange`), so the work is delegated to a helper.
369
- set: (step: number): void => {
370
- /* oxlint-disable-next-line promise/prefer-await-to-then -- setter cannot be async; see comment above. */
371
- applyCurrentTimeStep(step).catch(() => undefined);
372
- },
60
+ const style = dataStyleStore.getStyle(dataId);
61
+ return MESH_ELEMENTS.flatMap((element) => {
62
+ const coloring: unknown = style[element.styleKey]?.coloring;
63
+ const activeColoring = isColoring(coloring) ? coloring.active : undefined;
64
+ return activeColoring !== undefined && ATTRIBUTE_COLORINGS.has(activeColoring)
65
+ ? [meshColoring(dataId, element, activeColoring)]
66
+ : [];
67
+ });
373
68
  });
374
69
 
375
- return {
376
- currentColormap,
377
- currentRange,
378
- applyGlobalColormap,
379
- resetGlobalRange,
380
- currentTimeSteps,
381
- currentTimeStep,
382
- loadTimeSteps,
383
- };
70
+ const style = useAttributeColoringStyle(colorings);
71
+ watch(dataIdRef, style.loadTimeSteps, { immediate: true });
72
+ return style;
384
73
  }