@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
@@ -9,8 +9,18 @@ import { useViewerStore } from "@ogw_front/stores/viewer";
9
9
  // Local constants
10
10
  const meshCellsCellAttributeSchemas = viewer_schemas.opengeodeweb_viewer.mesh.cells.attribute.cell;
11
11
 
12
+ function isMeshCellsCellAttributeValid({ name, item, minimum, maximum, colorMap }) {
13
+ return (
14
+ name !== undefined &&
15
+ item !== undefined &&
16
+ minimum !== undefined &&
17
+ maximum !== undefined &&
18
+ colorMap !== undefined
19
+ );
20
+ }
21
+
12
22
  // oxlint-disable-next-line max-lines-per-function
13
- export function useMeshCellsCellAttributeStyle() {
23
+ function useMeshCellsCellAttributeStyle() {
14
24
  const viewerStore = useViewerStore();
15
25
  const meshCellsCommonStyle = useMeshCellsCommonStyle();
16
26
 
@@ -18,106 +28,130 @@ export function useMeshCellsCellAttributeStyle() {
18
28
  return meshCellsCommonStyle.meshCellsColoring(id).cell;
19
29
  }
20
30
 
21
- function meshCellsCellAttributeStoredConfig(id, name) {
31
+ function meshCellsCellAttributeStoredConfig(id, name, item) {
22
32
  const { storedConfigs } = meshCellsCellAttribute(id);
23
- if (name in storedConfigs) {
24
- return storedConfigs[name];
33
+ if (storedConfigs && name in storedConfigs && item in storedConfigs[name]) {
34
+ return storedConfigs[name][item];
25
35
  }
26
- return setMeshCellsCellAttributeStoredConfig(id, name, {
36
+ return {
27
37
  minimum: undefined,
28
38
  maximum: undefined,
29
39
  colorMap: undefined,
40
+ };
41
+ }
42
+
43
+ function mutateMeshCellsCellStyle(id, values) {
44
+ return meshCellsCommonStyle.mutateMeshCellsStyle(id, {
45
+ coloring: {
46
+ cell: values,
47
+ },
30
48
  });
31
49
  }
32
50
 
33
- function setMeshCellsCellAttributeStoredConfig(id, name, config) {
34
- return meshCellsCommonStyle.mutateMeshCellsCellStyle(id, {
51
+ function setMeshCellsCellAttributeStoredConfig(id, name, item, config) {
52
+ return mutateMeshCellsCellStyle(id, {
35
53
  storedConfigs: {
36
- [name]: config,
54
+ [name]: {
55
+ lastItem: item,
56
+ [item]: config,
57
+ },
37
58
  },
38
59
  });
39
60
  }
40
61
 
62
+ function applyCellAttribute(id) {
63
+ const name = meshCellsCellAttributeName(id);
64
+ const item = meshCellsCellAttributeItem(id);
65
+ const storedConfig = meshCellsCellAttributeStoredConfig(id, name, item);
66
+ const attribute = {
67
+ name,
68
+ item,
69
+ minimum: storedConfig.minimum,
70
+ maximum: storedConfig.maximum,
71
+ colorMap: storedConfig.colorMap,
72
+ };
73
+ if (isMeshCellsCellAttributeValid(attribute)) {
74
+ return setMeshCellsCellAttribute(id, attribute);
75
+ }
76
+ }
77
+
41
78
  function meshCellsCellAttributeName(id) {
42
79
  return meshCellsCellAttribute(id).name;
43
80
  }
44
81
 
45
- function setMeshCellsCellAttributeName(id, name) {
46
- const schema = meshCellsCellAttributeSchemas.name;
47
- const params = { id, name };
48
- return viewerStore.request(
49
- {
50
- schema,
51
- params,
52
- },
53
- {
54
- response_function: () => meshCellsCommonStyle.mutateMeshCellsCellStyle(id, { name }),
55
- },
56
- );
82
+ async function setMeshCellsCellAttributeName(id, name) {
83
+ const item = meshCellsCellAttributeLastItem(id, name);
84
+ await mutateMeshCellsCellStyle(id, { name, item });
85
+ return applyCellAttribute(id);
86
+ }
87
+
88
+ function meshCellsCellAttributeItem(id) {
89
+ const { item, name } = meshCellsCellAttribute(id);
90
+ return item ?? meshCellsCellAttributeLastItem(id, name);
91
+ }
92
+
93
+ async function setMeshCellsCellAttributeItem(id, item) {
94
+ await mutateMeshCellsCellStyle(id, { item });
95
+ return applyCellAttribute(id);
96
+ }
97
+
98
+ function meshCellsCellAttributeLastItem(id, name) {
99
+ const { storedConfigs } = meshCellsCellAttribute(id);
100
+ if (storedConfigs && name in storedConfigs) {
101
+ return storedConfigs[name].lastItem;
102
+ }
103
+ return 0;
57
104
  }
58
105
 
59
106
  function meshCellsCellAttributeRange(id) {
60
107
  const name = meshCellsCellAttributeName(id);
61
- const storedConfig = meshCellsCellAttributeStoredConfig(id, name);
62
- const { minimum, maximum } = storedConfig;
63
- return [minimum, maximum];
108
+ const item = meshCellsCellAttributeItem(id);
109
+ const storedConfig = meshCellsCellAttributeStoredConfig(id, name, item);
110
+ return [storedConfig.minimum, storedConfig.maximum];
64
111
  }
65
112
 
66
- function setMeshCellsCellAttributeRange(id, minimum, maximum) {
113
+ async function setMeshCellsCellAttributeRange(id, minimum, maximum) {
67
114
  const name = meshCellsCellAttributeName(id);
68
- const points = getRGBPointsFromPreset(meshCellsCellAttributeColorMap(id));
69
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
70
- const schema = meshCellsCellAttributeSchemas.color_map;
71
- const params = { id, points, minimum, maximum };
72
- return viewerStore.request(
73
- {
74
- schema,
75
- params,
76
- },
77
- {
78
- response_function: () =>
79
- setMeshCellsCellAttributeStoredConfig(id, name, { minimum, maximum }),
80
- },
81
- );
82
- }
83
- return setMeshCellsCellAttributeStoredConfig(id, name, { minimum, maximum });
115
+ const item = meshCellsCellAttributeItem(id);
116
+ await setMeshCellsCellAttributeStoredConfig(id, name, item, { minimum, maximum });
117
+ return applyCellAttribute(id);
84
118
  }
85
119
 
86
120
  function meshCellsCellAttributeColorMap(id) {
87
121
  const name = meshCellsCellAttributeName(id);
88
- const storedConfig = meshCellsCellAttributeStoredConfig(id, name);
89
- const { colorMap } = storedConfig;
90
- return colorMap;
122
+ const item = meshCellsCellAttributeItem(id);
123
+ const storedConfig = meshCellsCellAttributeStoredConfig(id, name, item);
124
+ return storedConfig.colorMap;
91
125
  }
92
126
 
93
- function setMeshCellsCellAttributeColorMap(id, colorMap) {
127
+ async function setMeshCellsCellAttributeColorMap(id, colorMap) {
94
128
  const name = meshCellsCellAttributeName(id);
95
- const storedConfig = meshCellsCellAttributeStoredConfig(id, name);
129
+ const item = meshCellsCellAttributeItem(id);
130
+ await setMeshCellsCellAttributeStoredConfig(id, name, item, { colorMap });
131
+ return applyCellAttribute(id);
132
+ }
133
+
134
+ function setMeshCellsCellAttribute(id, { name, item, minimum, maximum, colorMap }) {
135
+ mutateMeshCellsCellStyle(id, { name, item });
136
+ setMeshCellsCellAttributeStoredConfig(id, name, item, { minimum, maximum, colorMap });
96
137
  const points = getRGBPointsFromPreset(colorMap);
97
- const { minimum, maximum } = storedConfig;
98
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
99
- const schema = meshCellsCellAttributeSchemas.color_map;
100
- const params = { id, points, minimum, maximum };
101
- return viewerStore.request(
102
- {
103
- schema,
104
- params,
105
- },
106
- {
107
- response_function: () => setMeshCellsCellAttributeStoredConfig(id, name, { colorMap }),
108
- },
109
- );
110
- }
111
- return setMeshCellsCellAttributeStoredConfig(id, name, { colorMap });
138
+ const schema = meshCellsCellAttributeSchemas.attribute;
139
+ const params = { id, name, item, points, minimum, maximum };
140
+ return viewerStore.request({ schema, params });
112
141
  }
113
142
 
114
143
  return {
115
144
  meshCellsCellAttributeName,
145
+ meshCellsCellAttributeItem,
116
146
  meshCellsCellAttributeRange,
117
147
  meshCellsCellAttributeColorMap,
118
148
  meshCellsCellAttributeStoredConfig,
149
+ setMeshCellsCellAttribute,
119
150
  setMeshCellsCellAttributeName,
151
+ setMeshCellsCellAttributeItem,
120
152
  setMeshCellsCellAttributeRange,
121
153
  setMeshCellsCellAttributeColorMap,
122
154
  };
123
155
  }
156
+
157
+ export { isMeshCellsCellAttributeValid, useMeshCellsCellAttributeStyle };
@@ -1,11 +1,11 @@
1
1
  // Third party imports
2
2
 
3
3
  // Local imports
4
- import { useMeshCellsCellAttributeStyle } from "./cell";
4
+ import { isMeshCellsCellAttributeValid, useMeshCellsCellAttributeStyle } from "./cell";
5
+ import { isMeshCellsVertexAttributeValid, useMeshCellsVertexAttributeStyle } from "./vertex";
5
6
  import { useMeshCellsColorStyle } from "./color";
6
7
  import { useMeshCellsCommonStyle } from "./common";
7
8
  import { useMeshCellsTexturesStyle } from "./textures";
8
- import { useMeshCellsVertexAttributeStyle } from "./vertex";
9
9
  import { useMeshCellsVisibilityStyle } from "./visibility";
10
10
 
11
11
  // Local constants
@@ -30,32 +30,31 @@ export function useMeshCellsStyle() {
30
30
  await meshCellsCommonStyle.mutateMeshCellsStyle(id, {
31
31
  coloring: { active: type },
32
32
  });
33
- console.log(setMeshCellsActiveColoring.name, { id }, type);
34
33
  if (type === "constant") {
35
34
  return meshCellsColorStyle.setMeshCellsColor(id, meshCellsColorStyle.meshCellsColor(id));
36
- }
37
- if (type === "textures") {
35
+ } else if (type === "textures") {
38
36
  const textures = meshCellsTexturesStore.meshCellsTextures(id);
39
37
  return meshCellsTexturesStore.setMeshCellsTextures(id, textures);
40
- }
41
- if (type === "vertex") {
38
+ } else if (type === "vertex") {
42
39
  const name = meshCellsVertexAttributeStyle.meshCellsVertexAttributeName(id);
43
- const { colorMap } = meshCellsVertexAttributeStyle.meshCellsVertexAttributeStoredConfig(
44
- id,
45
- name,
46
- );
47
- return Promise.all([
48
- meshCellsVertexAttributeStyle.setMeshCellsVertexAttributeName(id, name),
49
- meshCellsVertexAttributeStyle.setMeshCellsVertexAttributeColorMap(id, colorMap),
50
- ]);
51
- }
52
- if (type === "cell") {
40
+ const item = meshCellsVertexAttributeStyle.meshCellsVertexAttributeItem(id);
41
+ const [minimum, maximum] = meshCellsVertexAttributeStyle.meshCellsVertexAttributeRange(id);
42
+ const colorMap = meshCellsVertexAttributeStyle.meshCellsVertexAttributeColorMap(id);
43
+ const vertex_attribute = { name, item, minimum, maximum, colorMap };
44
+ if (!isMeshCellsVertexAttributeValid(vertex_attribute)) {
45
+ return;
46
+ }
47
+ return meshCellsVertexAttributeStyle.setMeshCellsVertexAttribute(id, vertex_attribute);
48
+ } else if (type === "cell") {
53
49
  const name = meshCellsCellAttributeStyle.meshCellsCellAttributeName(id);
54
- const { colorMap } = meshCellsCellAttributeStyle.meshCellsCellAttributeStoredConfig(id, name);
55
- return Promise.all([
56
- meshCellsCellAttributeStyle.setMeshCellsCellAttributeName(id, name),
57
- meshCellsCellAttributeStyle.setMeshCellsCellAttributeColorMap(id, colorMap),
58
- ]);
50
+ const item = meshCellsCellAttributeStyle.meshCellsCellAttributeItem(id);
51
+ const [minimum, maximum] = meshCellsCellAttributeStyle.meshCellsCellAttributeRange(id);
52
+ const colorMap = meshCellsCellAttributeStyle.meshCellsCellAttributeColorMap(id);
53
+ const cell_attribute = { name, item, minimum, maximum, colorMap };
54
+ if (!isMeshCellsCellAttributeValid(cell_attribute)) {
55
+ return;
56
+ }
57
+ return meshCellsCellAttributeStyle.setMeshCellsCellAttribute(id, cell_attribute);
59
58
  }
60
59
  throw new Error(`Unknown mesh cells coloring type: ${type}`);
61
60
  }
@@ -10,8 +10,18 @@ import { useViewerStore } from "@ogw_front/stores/viewer";
10
10
  const meshCellsVertexAttributeSchemas =
11
11
  viewer_schemas.opengeodeweb_viewer.mesh.cells.attribute.vertex;
12
12
 
13
+ function isMeshCellsVertexAttributeValid({ name, item, minimum, maximum, colorMap }) {
14
+ return (
15
+ name !== undefined &&
16
+ item !== undefined &&
17
+ minimum !== undefined &&
18
+ maximum !== undefined &&
19
+ colorMap !== undefined
20
+ );
21
+ }
22
+
13
23
  // oxlint-disable-next-line max-lines-per-function
14
- export function useMeshCellsVertexAttributeStyle() {
24
+ function useMeshCellsVertexAttributeStyle() {
15
25
  const viewerStore = useViewerStore();
16
26
  const meshCellsCommonStyle = useMeshCellsCommonStyle();
17
27
 
@@ -19,16 +29,16 @@ export function useMeshCellsVertexAttributeStyle() {
19
29
  return meshCellsCommonStyle.meshCellsColoring(id).vertex;
20
30
  }
21
31
 
22
- function meshCellsVertexAttributeStoredConfig(id, name) {
32
+ function meshCellsVertexAttributeStoredConfig(id, name, item) {
23
33
  const { storedConfigs } = meshCellsVertexAttribute(id);
24
- if (name in storedConfigs) {
25
- return storedConfigs[name];
34
+ if (storedConfigs && name in storedConfigs && item in storedConfigs[name]) {
35
+ return storedConfigs[name][item];
26
36
  }
27
- return setMeshCellsVertexAttributeStoredConfig(id, name, {
37
+ return {
28
38
  minimum: undefined,
29
39
  maximum: undefined,
30
40
  colorMap: undefined,
31
- });
41
+ };
32
42
  }
33
43
 
34
44
  function mutateMeshCellsVertexStyle(id, values) {
@@ -39,101 +49,110 @@ export function useMeshCellsVertexAttributeStyle() {
39
49
  });
40
50
  }
41
51
 
42
- function setMeshCellsVertexAttributeStoredConfig(id, name, config) {
52
+ function setMeshCellsVertexAttributeStoredConfig(id, name, item, config) {
43
53
  return mutateMeshCellsVertexStyle(id, {
44
54
  storedConfigs: {
45
- [name]: config,
55
+ [name]: {
56
+ lastItem: item,
57
+ [item]: config,
58
+ },
46
59
  },
47
60
  });
48
61
  }
49
62
 
63
+ function applyVertexAttribute(id) {
64
+ const name = meshCellsVertexAttributeName(id);
65
+ const item = meshCellsVertexAttributeItem(id);
66
+ const storedConfig = meshCellsVertexAttributeStoredConfig(id, name, item);
67
+ const attribute = {
68
+ name,
69
+ item,
70
+ minimum: storedConfig.minimum,
71
+ maximum: storedConfig.maximum,
72
+ colorMap: storedConfig.colorMap,
73
+ };
74
+ if (isMeshCellsVertexAttributeValid(attribute)) {
75
+ return setMeshCellsVertexAttribute(id, attribute);
76
+ }
77
+ }
78
+
50
79
  function meshCellsVertexAttributeName(id) {
51
80
  return meshCellsVertexAttribute(id).name;
52
81
  }
53
82
 
54
83
  function setMeshCellsVertexAttributeName(id, name) {
55
- const schema = meshCellsVertexAttributeSchemas.name;
56
- const params = { id, name };
57
- return viewerStore.request(
58
- { schema, params },
59
- {
60
- response_function: () => {
61
- const updates = { name };
62
- const vertex = meshCellsVertexAttribute(id);
63
- if (!(name in vertex.storedConfigs)) {
64
- updates.storedConfigs = {
65
- [name]: {
66
- minimum: undefined,
67
- maximum: undefined,
68
- colorMap: undefined,
69
- },
70
- };
71
- }
72
- return mutateMeshCellsVertexStyle(id, updates);
73
- },
74
- },
75
- );
84
+ const item = meshCellsVertexAttributeLastItem(id, name);
85
+ mutateMeshCellsVertexStyle(id, { name, item });
86
+ return applyVertexAttribute(id);
87
+ }
88
+
89
+ function meshCellsVertexAttributeItem(id) {
90
+ const { item, name } = meshCellsVertexAttribute(id);
91
+ return item ?? meshCellsVertexAttributeLastItem(id, name);
92
+ }
93
+
94
+ function setMeshCellsVertexAttributeItem(id, item) {
95
+ mutateMeshCellsVertexStyle(id, { item });
96
+ return applyVertexAttribute(id);
97
+ }
98
+
99
+ function meshCellsVertexAttributeLastItem(id, name) {
100
+ const { storedConfigs } = meshCellsVertexAttribute(id);
101
+ if (storedConfigs && name in storedConfigs) {
102
+ return storedConfigs[name].lastItem;
103
+ }
104
+ return 0;
76
105
  }
77
106
 
78
107
  function meshCellsVertexAttributeRange(id) {
79
108
  const name = meshCellsVertexAttributeName(id);
80
- const storedConfig = meshCellsVertexAttributeStoredConfig(id, name);
81
- const { minimum, maximum } = storedConfig;
82
- return [minimum, maximum];
109
+ const item = meshCellsVertexAttributeItem(id);
110
+ const storedConfig = meshCellsVertexAttributeStoredConfig(id, name, item);
111
+ return [storedConfig.minimum, storedConfig.maximum];
83
112
  }
84
113
 
85
114
  function setMeshCellsVertexAttributeRange(id, minimum, maximum) {
86
115
  const name = meshCellsVertexAttributeName(id);
87
- const points = getRGBPointsFromPreset(meshCellsVertexAttributeColorMap(id));
88
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
89
- const schema = meshCellsVertexAttributeSchemas.color_map;
90
- const params = { id, points, minimum, maximum };
91
- return viewerStore.request(
92
- { schema, params },
93
- {
94
- response_function: () =>
95
- setMeshCellsVertexAttributeStoredConfig(id, name, { minimum, maximum }),
96
- },
97
- );
98
- }
99
- return setMeshCellsVertexAttributeStoredConfig(id, name, {
100
- minimum,
101
- maximum,
102
- });
116
+ const item = meshCellsVertexAttributeItem(id);
117
+ setMeshCellsVertexAttributeStoredConfig(id, name, item, { minimum, maximum });
118
+ return applyVertexAttribute(id);
103
119
  }
104
120
 
105
121
  function meshCellsVertexAttributeColorMap(id) {
106
122
  const name = meshCellsVertexAttributeName(id);
107
- const storedConfig = meshCellsVertexAttributeStoredConfig(id, name);
108
- const { colorMap } = storedConfig;
109
- return colorMap;
123
+ const item = meshCellsVertexAttributeItem(id);
124
+ const storedConfig = meshCellsVertexAttributeStoredConfig(id, name, item);
125
+ return storedConfig.colorMap;
110
126
  }
111
127
 
112
128
  function setMeshCellsVertexAttributeColorMap(id, colorMap) {
113
129
  const name = meshCellsVertexAttributeName(id);
114
- const storedConfig = meshCellsVertexAttributeStoredConfig(id, name);
130
+ const item = meshCellsVertexAttributeItem(id);
131
+ setMeshCellsVertexAttributeStoredConfig(id, name, item, { colorMap });
132
+ return applyVertexAttribute(id);
133
+ }
134
+
135
+ function setMeshCellsVertexAttribute(id, { name, item, minimum, maximum, colorMap }) {
136
+ mutateMeshCellsVertexStyle(id, { name, item });
137
+ setMeshCellsVertexAttributeStoredConfig(id, name, item, { minimum, maximum, colorMap });
115
138
  const points = getRGBPointsFromPreset(colorMap);
116
- const { minimum, maximum } = storedConfig;
117
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
118
- const schema = meshCellsVertexAttributeSchemas.color_map;
119
- const params = { id, points, minimum, maximum };
120
- return viewerStore.request(
121
- { schema, params },
122
- {
123
- response_function: () => setMeshCellsVertexAttributeStoredConfig(id, name, { colorMap }),
124
- },
125
- );
126
- }
127
- return setMeshCellsVertexAttributeStoredConfig(id, name, { colorMap });
139
+ const schema = meshCellsVertexAttributeSchemas.attribute;
140
+ const params = { id, name, item, points, minimum, maximum };
141
+ return viewerStore.request({ schema, params });
128
142
  }
129
143
 
130
144
  return {
131
145
  meshCellsVertexAttributeName,
146
+ meshCellsVertexAttributeItem,
132
147
  meshCellsVertexAttributeRange,
133
148
  meshCellsVertexAttributeColorMap,
134
149
  meshCellsVertexAttributeStoredConfig,
150
+ setMeshCellsVertexAttribute,
135
151
  setMeshCellsVertexAttributeName,
152
+ setMeshCellsVertexAttributeItem,
136
153
  setMeshCellsVertexAttributeRange,
137
154
  setMeshCellsVertexAttributeColorMap,
138
155
  };
139
156
  }
157
+
158
+ export { isMeshCellsVertexAttributeValid, useMeshCellsVertexAttributeStyle };