@geode/opengeodeweb-front 10.28.1-rc.4 → 10.29.0-rc.2

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 (57) hide show
  1. package/app/components/Viewer/ContextMenu/InfoCard.vue +56 -21
  2. package/app/components/Viewer/EdgedCurve/SpecificEdgesOptions.vue +21 -0
  3. package/app/components/Viewer/Generic/Mesh/CellsOptions.vue +21 -0
  4. package/app/components/Viewer/Generic/Mesh/EdgesOptions.vue +80 -0
  5. package/app/components/Viewer/Generic/Mesh/PointsOptions.vue +10 -0
  6. package/app/components/Viewer/Generic/Mesh/PolygonsOptions.vue +81 -0
  7. package/app/components/Viewer/Generic/Mesh/PolyhedraOptions.vue +20 -0
  8. package/app/components/Viewer/Generic/Model/BlocksOptions.vue +36 -0
  9. package/app/components/Viewer/Generic/Model/CornersOptions.vue +18 -0
  10. package/app/components/Viewer/Generic/Model/LinesOptions.vue +36 -0
  11. package/app/components/Viewer/Generic/Model/SurfacesOptions.vue +36 -0
  12. package/app/components/Viewer/Options/AttributeSelector.vue +47 -38
  13. package/app/components/Viewer/Options/ColoringTypeSelector.vue +26 -22
  14. package/app/components/Viewer/PointSet/SpecificPointsOptions.vue +10 -0
  15. package/app/components/Viewer/Solid/SpecificPolyhedraOptions.vue +20 -0
  16. package/app/components/Viewer/Surface/PolygonsOptions.vue +20 -0
  17. package/internal/stores/data_style/mesh/cells/cell.js +94 -60
  18. package/internal/stores/data_style/mesh/cells/index.js +21 -22
  19. package/internal/stores/data_style/mesh/cells/vertex.js +83 -64
  20. package/internal/stores/data_style/mesh/edges/edge.js +83 -67
  21. package/internal/stores/data_style/mesh/edges/index.js +22 -19
  22. package/internal/stores/data_style/mesh/edges/vertex.js +87 -65
  23. package/internal/stores/data_style/mesh/points/index.js +9 -9
  24. package/internal/stores/data_style/mesh/points/vertex.js +96 -99
  25. package/internal/stores/data_style/mesh/polygons/index.js +26 -16
  26. package/internal/stores/data_style/mesh/polygons/polygon.js +88 -66
  27. package/internal/stores/data_style/mesh/polygons/vertex.js +88 -66
  28. package/internal/stores/data_style/mesh/polyhedra/index.js +33 -22
  29. package/internal/stores/data_style/mesh/polyhedra/polyhedron.js +101 -103
  30. package/internal/stores/data_style/mesh/polyhedra/vertex.js +101 -103
  31. package/internal/stores/data_style/model/blocks/color.js +27 -28
  32. package/internal/stores/data_style/model/blocks/index.js +140 -72
  33. package/internal/stores/data_style/model/blocks/polyhedron.js +114 -58
  34. package/internal/stores/data_style/model/blocks/vertex.js +107 -57
  35. package/internal/stores/data_style/model/common.js +6 -6
  36. package/internal/stores/data_style/model/corners/color.js +12 -16
  37. package/internal/stores/data_style/model/corners/index.js +95 -63
  38. package/internal/stores/data_style/model/corners/vertex.js +108 -58
  39. package/internal/stores/data_style/model/lines/color.js +18 -23
  40. package/internal/stores/data_style/model/lines/edge.js +106 -54
  41. package/internal/stores/data_style/model/lines/index.js +132 -71
  42. package/internal/stores/data_style/model/lines/vertex.js +107 -54
  43. package/internal/stores/data_style/model/surfaces/color.js +24 -32
  44. package/internal/stores/data_style/model/surfaces/index.js +142 -74
  45. package/internal/stores/data_style/model/surfaces/polygon.js +114 -58
  46. package/internal/stores/data_style/model/surfaces/vertex.js +114 -58
  47. package/internal/stores/data_style/state.js +105 -94
  48. package/package.json +1 -1
  49. package/tests/integration/stores/data_style/mesh/cells.nuxt.test.js +200 -24
  50. package/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +132 -34
  51. package/tests/integration/stores/data_style/mesh/points.nuxt.test.js +60 -11
  52. package/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +116 -22
  53. package/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +145 -34
  54. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +206 -33
  55. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +94 -15
  56. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +187 -30
  57. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +379 -31
@@ -8,9 +8,21 @@ import { useModelBlocksCommonStyle } from "./common";
8
8
  import { useViewerStore } from "@ogw_front/stores/viewer";
9
9
 
10
10
  // Local constants
11
- const schema = viewer_schemas.opengeodeweb_viewer.model.blocks.attribute.polyhedron;
11
+ const modelBlockPolyhedronAttributeSchema =
12
+ viewer_schemas.opengeodeweb_viewer.model.blocks.attribute.polyhedron.attribute;
13
+
14
+ function isModelBlocksPolyhedronAttributeValid({ name, item, minimum, maximum, colorMap }) {
15
+ return (
16
+ name !== undefined &&
17
+ item !== undefined &&
18
+ minimum !== undefined &&
19
+ maximum !== undefined &&
20
+ colorMap !== undefined
21
+ );
22
+ }
12
23
 
13
- export function useModelBlocksPolyhedronAttribute() {
24
+ // oxlint-disable-next-line max-lines-per-function
25
+ function useModelBlocksPolyhedronAttribute() {
14
26
  const dataStore = useDataStore();
15
27
  const modelBlocksCommonStyle = useModelBlocksCommonStyle();
16
28
  const viewerStore = useViewerStore();
@@ -19,16 +31,16 @@ export function useModelBlocksPolyhedronAttribute() {
19
31
  return modelBlocksCommonStyle.modelBlockColoring(modelId, blockId).polyhedron;
20
32
  }
21
33
 
22
- function modelBlocksPolyhedronAttributeStoredConfig(modelId, blockId, name) {
34
+ function modelBlocksPolyhedronAttributeStoredConfig(modelId, blockId, name, item) {
23
35
  const { storedConfigs } = modelBlocksPolyhedronAttribute(modelId, blockId);
24
- if (name in storedConfigs) {
25
- return storedConfigs[name];
36
+ if (storedConfigs && name in storedConfigs && item in storedConfigs[name]) {
37
+ return storedConfigs[name][item];
26
38
  }
27
- return setModelBlocksPolyhedronAttributeStoredConfig(modelId, [blockId], name, {
39
+ return {
28
40
  minimum: undefined,
29
41
  maximum: undefined,
30
42
  colorMap: undefined,
31
- });
43
+ };
32
44
  }
33
45
 
34
46
  function mutateModelBlocksPolyhedronStyle(modelId, blockIds, values) {
@@ -37,10 +49,13 @@ export function useModelBlocksPolyhedronAttribute() {
37
49
  });
38
50
  }
39
51
 
40
- function setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, config) {
52
+ function setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, item, config) {
41
53
  return mutateModelBlocksPolyhedronStyle(modelId, blockIds, {
42
54
  storedConfigs: {
43
- [name]: config,
55
+ [name]: {
56
+ lastItem: item,
57
+ [item]: config,
58
+ },
44
59
  },
45
60
  });
46
61
  }
@@ -49,83 +64,124 @@ export function useModelBlocksPolyhedronAttribute() {
49
64
  return modelBlocksPolyhedronAttribute(modelId, blockId).name;
50
65
  }
51
66
 
52
- async function setModelBlocksPolyhedronAttributeName(modelId, blockIds, name) {
53
- const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, blockIds);
54
- const params = { id: modelId, block_ids: viewer_ids, name };
55
- return viewerStore.request(
56
- { schema: schema.name, params },
57
- {
58
- response_function: () => mutateModelBlocksPolyhedronStyle(modelId, blockIds, { name }),
59
- },
67
+ function modelBlocksPolyhedronAttributeItem(modelId, blockId) {
68
+ const polyhedronAttribute = modelBlocksPolyhedronAttribute(modelId, blockId);
69
+ return (
70
+ polyhedronAttribute.item ??
71
+ modelBlocksPolyhedronAttributeLastItem(modelId, blockId, polyhedronAttribute.name)
60
72
  );
61
73
  }
62
74
 
75
+ function modelBlocksPolyhedronAttributeLastItem(modelId, blockId, name) {
76
+ const { storedConfigs } = modelBlocksPolyhedronAttribute(modelId, blockId);
77
+ if (!(name in storedConfigs)) {
78
+ return 0;
79
+ }
80
+ return storedConfigs[name].lastItem;
81
+ }
82
+
63
83
  function modelBlocksPolyhedronAttributeRange(modelId, blockId) {
64
84
  const name = modelBlocksPolyhedronAttributeName(modelId, blockId);
65
- const storedConfig = modelBlocksPolyhedronAttributeStoredConfig(modelId, blockId, name);
85
+ const item = modelBlocksPolyhedronAttributeItem(modelId, blockId);
86
+ const storedConfig = modelBlocksPolyhedronAttributeStoredConfig(modelId, blockId, name, item);
66
87
  const { minimum, maximum } = storedConfig;
67
88
  return [minimum, maximum];
68
89
  }
69
90
 
70
- async function setModelBlocksPolyhedronAttributeRange(modelId, blockIds, minimum, maximum) {
71
- const name = modelBlocksPolyhedronAttributeName(modelId, blockIds[0]);
72
- const colorMap = modelBlocksPolyhedronAttributeColorMap(modelId, blockIds[0]);
73
- const points = getRGBPointsFromPreset(colorMap);
91
+ function modelBlocksPolyhedronAttributeColorMap(modelId, blockId) {
92
+ const name = modelBlocksPolyhedronAttributeName(modelId, blockId);
93
+ const item = modelBlocksPolyhedronAttributeItem(modelId, blockId);
94
+ const storedConfig = modelBlocksPolyhedronAttributeStoredConfig(modelId, blockId, name, item);
95
+ return storedConfig.colorMap;
96
+ }
74
97
 
75
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
76
- const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, blockIds);
77
- const params = { id: modelId, block_ids: viewer_ids, points, minimum, maximum };
78
- return viewerStore.request(
79
- { schema: schema.color_map, params },
80
- {
81
- response_function: () =>
82
- setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, {
83
- minimum,
84
- maximum,
85
- }),
86
- },
87
- );
98
+ function applyPolyhedronAttribute(modelId, blockIds) {
99
+ const name = modelBlocksPolyhedronAttributeName(modelId, blockIds[0]);
100
+ const item = modelBlocksPolyhedronAttributeItem(modelId, blockIds[0]);
101
+ const storedConfig = modelBlocksPolyhedronAttributeStoredConfig(
102
+ modelId,
103
+ blockIds[0],
104
+ name,
105
+ item,
106
+ );
107
+ const attribute = {
108
+ name,
109
+ item,
110
+ minimum: storedConfig.minimum,
111
+ maximum: storedConfig.maximum,
112
+ colorMap: storedConfig.colorMap,
113
+ };
114
+ if (isModelBlocksPolyhedronAttributeValid(attribute)) {
115
+ return setModelBlocksPolyhedronAttribute(modelId, blockIds, attribute);
88
116
  }
89
- return setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, {
117
+ return Promise.resolve();
118
+ }
119
+
120
+ function setModelBlocksPolyhedronAttributeName(modelId, blockIds, name) {
121
+ const item = modelBlocksPolyhedronAttributeLastItem(modelId, blockIds[0], name);
122
+ mutateModelBlocksPolyhedronStyle(modelId, blockIds, { name, item });
123
+ return applyPolyhedronAttribute(modelId, blockIds);
124
+ }
125
+
126
+ function setModelBlocksPolyhedronAttributeItem(modelId, blockIds, item) {
127
+ mutateModelBlocksPolyhedronStyle(modelId, blockIds, { item });
128
+ return applyPolyhedronAttribute(modelId, blockIds);
129
+ }
130
+
131
+ function setModelBlocksPolyhedronAttributeRange(modelId, blockIds, minimum, maximum) {
132
+ const name = modelBlocksPolyhedronAttributeName(modelId, blockIds[0]);
133
+ const item = modelBlocksPolyhedronAttributeItem(modelId, blockIds[0]);
134
+ setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, item, {
90
135
  minimum,
91
136
  maximum,
92
137
  });
138
+ return applyPolyhedronAttribute(modelId, blockIds);
93
139
  }
94
140
 
95
- function modelBlocksPolyhedronAttributeColorMap(modelId, blockId) {
96
- const name = modelBlocksPolyhedronAttributeName(modelId, blockId);
97
- const storedConfig = modelBlocksPolyhedronAttributeStoredConfig(modelId, blockId, name);
98
- const { colorMap } = storedConfig;
99
- return colorMap;
141
+ function setModelBlocksPolyhedronAttributeColorMap(modelId, blockIds, colorMap) {
142
+ const name = modelBlocksPolyhedronAttributeName(modelId, blockIds[0]);
143
+ const item = modelBlocksPolyhedronAttributeItem(modelId, blockIds[0]);
144
+ setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, item, { colorMap });
145
+ return applyPolyhedronAttribute(modelId, blockIds);
100
146
  }
101
147
 
102
- async function setModelBlocksPolyhedronAttributeColorMap(modelId, blockIds, colorMap) {
103
- const name = modelBlocksPolyhedronAttributeName(modelId, blockIds[0]);
104
- const storedConfig = modelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds[0], name);
148
+ async function setModelBlocksPolyhedronAttribute(
149
+ modelId,
150
+ blockIds,
151
+ { name, item, minimum, maximum, colorMap },
152
+ ) {
153
+ mutateModelBlocksPolyhedronStyle(modelId, blockIds, { name, item });
154
+ setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, item, {
155
+ minimum,
156
+ maximum,
157
+ colorMap,
158
+ });
105
159
  const points = getRGBPointsFromPreset(colorMap);
106
- const { minimum, maximum } = storedConfig;
107
-
108
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
109
- const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, blockIds);
110
- const params = { id: modelId, block_ids: viewer_ids, points, minimum, maximum };
111
- return viewerStore.request(
112
- { schema: schema.color_map, params },
113
- {
114
- response_function: () =>
115
- setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, { colorMap }),
116
- },
117
- );
118
- }
119
- return setModelBlocksPolyhedronAttributeStoredConfig(modelId, blockIds, name, { colorMap });
160
+ const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, blockIds);
161
+ const params = {
162
+ id: modelId,
163
+ block_ids: viewer_ids,
164
+ name,
165
+ item,
166
+ points,
167
+ minimum,
168
+ maximum,
169
+ };
170
+ return viewerStore.request({ schema: modelBlockPolyhedronAttributeSchema, params });
120
171
  }
121
172
 
122
173
  return {
123
174
  modelBlocksPolyhedronAttributeName,
175
+ modelBlocksPolyhedronAttributeItem,
124
176
  modelBlocksPolyhedronAttributeRange,
125
177
  modelBlocksPolyhedronAttributeColorMap,
126
178
  modelBlocksPolyhedronAttributeStoredConfig,
179
+ setModelBlocksPolyhedronAttribute,
127
180
  setModelBlocksPolyhedronAttributeName,
181
+ setModelBlocksPolyhedronAttributeItem,
128
182
  setModelBlocksPolyhedronAttributeRange,
129
183
  setModelBlocksPolyhedronAttributeColorMap,
130
184
  };
131
185
  }
186
+
187
+ export { isModelBlocksPolyhedronAttributeValid, useModelBlocksPolyhedronAttribute };
@@ -8,9 +8,20 @@ import { useModelBlocksCommonStyle } from "./common";
8
8
  import { useViewerStore } from "@ogw_front/stores/viewer";
9
9
 
10
10
  // Local constants
11
- const schema = viewer_schemas.opengeodeweb_viewer.model.blocks.attribute.vertex;
11
+ const attributeSchema = viewer_schemas.opengeodeweb_viewer.model.blocks.attribute.vertex.attribute;
12
+
13
+ function isModelBlocksVertexAttributeValid({ name, item, minimum, maximum, colorMap }) {
14
+ return (
15
+ name !== undefined &&
16
+ item !== undefined &&
17
+ minimum !== undefined &&
18
+ maximum !== undefined &&
19
+ colorMap !== undefined
20
+ );
21
+ }
12
22
 
13
- export function useModelBlocksVertexAttribute() {
23
+ // oxlint-disable-next-line max-lines-per-function
24
+ function useModelBlocksVertexAttribute() {
14
25
  const dataStore = useDataStore();
15
26
  const modelBlocksCommonStyle = useModelBlocksCommonStyle();
16
27
  const viewerStore = useViewerStore();
@@ -19,16 +30,16 @@ export function useModelBlocksVertexAttribute() {
19
30
  return modelBlocksCommonStyle.modelBlockColoring(modelId, blockId).vertex;
20
31
  }
21
32
 
22
- function modelBlocksVertexAttributeStoredConfig(modelId, blockId, name) {
33
+ function modelBlocksVertexAttributeStoredConfig(modelId, blockId, name, item) {
23
34
  const { storedConfigs } = modelBlocksVertexAttribute(modelId, blockId);
24
- if (name in storedConfigs) {
25
- return storedConfigs[name];
35
+ if (storedConfigs && name in storedConfigs && item in storedConfigs[name]) {
36
+ return storedConfigs[name][item];
26
37
  }
27
- return setModelBlocksVertexAttributeStoredConfig(modelId, [blockId], name, {
38
+ return {
28
39
  minimum: undefined,
29
40
  maximum: undefined,
30
41
  colorMap: undefined,
31
- });
42
+ };
32
43
  }
33
44
 
34
45
  function mutateModelBlocksVertexStyle(modelId, blockIds, values) {
@@ -37,10 +48,13 @@ export function useModelBlocksVertexAttribute() {
37
48
  });
38
49
  }
39
50
 
40
- function setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, config) {
51
+ function setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, item, config) {
41
52
  return mutateModelBlocksVertexStyle(modelId, blockIds, {
42
53
  storedConfigs: {
43
- [name]: config,
54
+ [name]: {
55
+ lastItem: item,
56
+ [item]: config,
57
+ },
44
58
  },
45
59
  });
46
60
  }
@@ -49,80 +63,116 @@ export function useModelBlocksVertexAttribute() {
49
63
  return modelBlocksVertexAttribute(modelId, blockId).name;
50
64
  }
51
65
 
52
- async function setModelBlocksVertexAttributeName(modelId, blockIds, name) {
53
- const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, blockIds);
54
- const params = { id: modelId, block_ids: viewer_ids, name };
55
- return viewerStore.request(
56
- { schema: schema.name, params },
57
- {
58
- response_function: () => mutateModelBlocksVertexStyle(modelId, blockIds, { name }),
59
- },
66
+ function modelBlocksVertexAttributeItem(modelId, blockId) {
67
+ const vertexAttribute = modelBlocksVertexAttribute(modelId, blockId);
68
+ return (
69
+ vertexAttribute.item ??
70
+ modelBlocksVertexAttributeLastItem(modelId, blockId, vertexAttribute.name)
60
71
  );
61
72
  }
62
73
 
74
+ function modelBlocksVertexAttributeLastItem(modelId, blockId, name) {
75
+ const { storedConfigs } = modelBlocksVertexAttribute(modelId, blockId);
76
+ if (!(name in storedConfigs)) {
77
+ return 0;
78
+ }
79
+ return storedConfigs[name].lastItem;
80
+ }
81
+
63
82
  function modelBlocksVertexAttributeRange(modelId, blockId) {
64
83
  const name = modelBlocksVertexAttributeName(modelId, blockId);
65
- const storedConfig = modelBlocksVertexAttributeStoredConfig(modelId, blockId, name);
84
+ const item = modelBlocksVertexAttributeItem(modelId, blockId);
85
+ const storedConfig = modelBlocksVertexAttributeStoredConfig(modelId, blockId, name, item);
66
86
  const { minimum, maximum } = storedConfig;
67
87
  return [minimum, maximum];
68
88
  }
69
89
 
70
- async function setModelBlocksVertexAttributeRange(modelId, blockIds, minimum, maximum) {
71
- const name = modelBlocksVertexAttributeName(modelId, blockIds[0]);
72
- const colorMap = modelBlocksVertexAttributeColorMap(modelId, blockIds[0]);
73
- const points = getRGBPointsFromPreset(colorMap);
90
+ function modelBlocksVertexAttributeColorMap(modelId, blockId) {
91
+ const name = modelBlocksVertexAttributeName(modelId, blockId);
92
+ const item = modelBlocksVertexAttributeItem(modelId, blockId);
93
+ const storedConfig = modelBlocksVertexAttributeStoredConfig(modelId, blockId, name, item);
94
+ return storedConfig.colorMap;
95
+ }
74
96
 
75
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
76
- const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, blockIds);
77
- const params = { id: modelId, block_ids: viewer_ids, points, minimum, maximum };
78
- return viewerStore.request(
79
- { schema: schema.color_map, params },
80
- {
81
- response_function: () =>
82
- setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, {
83
- minimum,
84
- maximum,
85
- }),
86
- },
87
- );
97
+ function applyVertexAttribute(modelId, blockIds) {
98
+ const name = modelBlocksVertexAttributeName(modelId, blockIds[0]);
99
+ const item = modelBlocksVertexAttributeItem(modelId, blockIds[0]);
100
+ const storedConfig = modelBlocksVertexAttributeStoredConfig(modelId, blockIds[0], name, item);
101
+ const attribute = {
102
+ name,
103
+ item,
104
+ minimum: storedConfig.minimum,
105
+ maximum: storedConfig.maximum,
106
+ colorMap: storedConfig.colorMap,
107
+ };
108
+ if (isModelBlocksVertexAttributeValid(attribute)) {
109
+ return setModelBlocksVertexAttribute(modelId, blockIds, attribute);
88
110
  }
89
- return setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, { minimum, maximum });
111
+ return Promise.resolve();
90
112
  }
91
113
 
92
- function modelBlocksVertexAttributeColorMap(modelId, blockId) {
93
- const name = modelBlocksVertexAttributeName(modelId, blockId);
94
- const storedConfig = modelBlocksVertexAttributeStoredConfig(modelId, blockId, name);
95
- const { colorMap } = storedConfig;
96
- return colorMap;
114
+ function setModelBlocksVertexAttributeName(modelId, blockIds, name) {
115
+ const item = modelBlocksVertexAttributeLastItem(modelId, blockIds[0], name);
116
+ mutateModelBlocksVertexStyle(modelId, blockIds, { name, item });
117
+ return applyVertexAttribute(modelId, blockIds);
118
+ }
119
+
120
+ function setModelBlocksVertexAttributeItem(modelId, blockIds, item) {
121
+ mutateModelBlocksVertexStyle(modelId, blockIds, { item });
122
+ return applyVertexAttribute(modelId, blockIds);
97
123
  }
98
124
 
99
- async function setModelBlocksVertexAttributeColorMap(modelId, blockIds, colorMap) {
125
+ function setModelBlocksVertexAttributeRange(modelId, blockIds, minimum, maximum) {
100
126
  const name = modelBlocksVertexAttributeName(modelId, blockIds[0]);
101
- const storedConfig = modelBlocksVertexAttributeStoredConfig(modelId, blockIds[0], name);
102
- const points = getRGBPointsFromPreset(colorMap);
103
- const { minimum, maximum } = storedConfig;
127
+ const item = modelBlocksVertexAttributeItem(modelId, blockIds[0]);
128
+ setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, item, { minimum, maximum });
129
+ return applyVertexAttribute(modelId, blockIds);
130
+ }
104
131
 
105
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
106
- const viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, blockIds);
107
- const params = { id: modelId, block_ids: viewer_ids, points, minimum, maximum };
108
- return viewerStore.request(
109
- { schema: schema.color_map, params },
110
- {
111
- response_function: () =>
112
- setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, { colorMap }),
113
- },
114
- );
115
- }
116
- return setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, { colorMap });
132
+ function setModelBlocksVertexAttributeColorMap(modelId, blockIds, colorMap) {
133
+ const name = modelBlocksVertexAttributeName(modelId, blockIds[0]);
134
+ const item = modelBlocksVertexAttributeItem(modelId, blockIds[0]);
135
+ setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, item, { colorMap });
136
+ return applyVertexAttribute(modelId, blockIds);
137
+ }
138
+
139
+ async function setModelBlocksVertexAttribute(
140
+ modelId,
141
+ blockIds,
142
+ { name, item, minimum, maximum, colorMap },
143
+ ) {
144
+ mutateModelBlocksVertexStyle(modelId, blockIds, { name, item });
145
+ setModelBlocksVertexAttributeStoredConfig(modelId, blockIds, name, item, {
146
+ minimum,
147
+ maximum,
148
+ colorMap,
149
+ });
150
+ const points = getRGBPointsFromPreset(colorMap);
151
+ const block_viewer_ids = await dataStore.getMeshComponentsViewerIds(modelId, blockIds);
152
+ const params = {
153
+ id: modelId,
154
+ block_ids: block_viewer_ids,
155
+ name,
156
+ item,
157
+ points,
158
+ minimum,
159
+ maximum,
160
+ };
161
+ return viewerStore.request({ schema: attributeSchema, params });
117
162
  }
118
163
 
119
164
  return {
120
165
  modelBlocksVertexAttributeName,
166
+ modelBlocksVertexAttributeItem,
121
167
  modelBlocksVertexAttributeRange,
122
168
  modelBlocksVertexAttributeColorMap,
123
169
  modelBlocksVertexAttributeStoredConfig,
170
+ setModelBlocksVertexAttribute,
124
171
  setModelBlocksVertexAttributeName,
172
+ setModelBlocksVertexAttributeItem,
125
173
  setModelBlocksVertexAttributeRange,
126
174
  setModelBlocksVertexAttributeColorMap,
127
175
  };
128
176
  }
177
+
178
+ export { isModelBlocksVertexAttributeValid, useModelBlocksVertexAttribute };
@@ -20,9 +20,9 @@ export function useModelCommonStyle() {
20
20
  return model_component_datastyle_db.put(structuredClone(toRaw(entry)));
21
21
  }
22
22
 
23
- function mutateModelComponentTypeStyle(id_model, type, values) {
23
+ async function mutateModelComponentTypeStyle(id_model, type, values) {
24
24
  dataStyleState.updateModelComponentTypeStyleCache(id_model, type, values);
25
- return database.transaction("rw", model_component_type_datastyle_db, async () => {
25
+ await database.transaction("rw", model_component_type_datastyle_db, async () => {
26
26
  const key = [id_model, type];
27
27
  const entry = (await model_component_type_datastyle_db.get(key)) || { id_model, type };
28
28
  merge(entry, values);
@@ -30,9 +30,9 @@ export function useModelCommonStyle() {
30
30
  });
31
31
  }
32
32
 
33
- function mutateComponentStyles(id_model, id_components, values) {
33
+ async function mutateComponentStyles(id_model, id_components, values) {
34
34
  dataStyleState.bulkUpdateComponentStylesCache(id_model, id_components, values);
35
- return database.transaction("rw", model_component_datastyle_db, async () => {
35
+ await database.transaction("rw", model_component_datastyle_db, async () => {
36
36
  const keys = id_components.map((id_component) => [id_model, id_component]);
37
37
  const existing = await model_component_datastyle_db.bulkGet(keys);
38
38
  const updates = id_components.map((id_component, index) => {
@@ -45,9 +45,9 @@ export function useModelCommonStyle() {
45
45
  });
46
46
  }
47
47
 
48
- function bulkMutateComponentStylesPerComponent(id_model, component_updates) {
48
+ async function bulkMutateComponentStylesPerComponent(id_model, component_updates) {
49
49
  dataStyleState.bulkUpdateComponentStyleCache(id_model, component_updates);
50
- return database.transaction("rw", model_component_datastyle_db, async () => {
50
+ await database.transaction("rw", model_component_datastyle_db, async () => {
51
51
  const keys = component_updates.map((update) => [id_model, update.id_component]);
52
52
  const existing = await model_component_datastyle_db.bulkGet(keys);
53
53
  const updates = component_updates.map(({ id_component, values }, index) => {
@@ -1,6 +1,6 @@
1
+ import { isModelCornersVertexAttributeValid, useModelCornersVertexAttribute } from "./vertex";
1
2
  import { useModelCommonStyle } from "@ogw_internal/stores/data_style/model/common";
2
3
  import { useModelCornersCommonStyle } from "./common";
3
- import { useModelCornersVertexAttribute } from "./vertex";
4
4
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json";
5
5
 
6
6
  const schema = viewer_schemas.opengeodeweb_viewer.model.corners.color;
@@ -40,30 +40,26 @@ export function useModelCornersColor() {
40
40
  modelId,
41
41
  corners_ids[0],
42
42
  );
43
- await modelCornersVertexAttribute.setModelCornersVertexAttributeName(
44
- modelId,
45
- corners_ids,
46
- name,
47
- );
48
- const [min, max] = modelCornersVertexAttribute.modelCornersVertexAttributeRange(
43
+ const item = modelCornersVertexAttribute.modelCornersVertexAttributeItem(
49
44
  modelId,
50
45
  corners_ids[0],
51
46
  );
52
- await modelCornersVertexAttribute.setModelCornersVertexAttributeRange(
47
+ const [minimum, maximum] = modelCornersVertexAttribute.modelCornersVertexAttributeRange(
53
48
  modelId,
54
- corners_ids,
55
- min,
56
- max,
49
+ corners_ids[0],
57
50
  );
58
51
  const colorMap = modelCornersVertexAttribute.modelCornersVertexAttributeColorMap(
59
52
  modelId,
60
53
  corners_ids[0],
61
54
  );
62
- await modelCornersVertexAttribute.setModelCornersVertexAttributeColorMap(
63
- modelId,
64
- corners_ids,
65
- colorMap,
66
- );
55
+ const attribute = { name, item, minimum, maximum, colorMap };
56
+ if (isModelCornersVertexAttributeValid(attribute)) {
57
+ return modelCornersVertexAttribute.setModelCornersVertexAttribute(
58
+ modelId,
59
+ corners_ids,
60
+ attribute,
61
+ );
62
+ }
67
63
  }
68
64
  }
69
65