@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
@@ -10,14 +10,37 @@ import { useViewerStore } from "@ogw_front/stores/viewer";
10
10
  const meshPointsVertexAttributeSchemas =
11
11
  viewer_schemas.opengeodeweb_viewer.mesh.points.attribute.vertex;
12
12
 
13
+ function isMeshPointsVertexAttributeValid({ 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
- function useMeshPointsVertexAttributeConfig() {
24
+ function useMeshPointsVertexAttributeStyle() {
25
+ const viewerStore = useViewerStore();
15
26
  const meshPointsCommonStyle = useMeshPointsCommonStyle();
16
27
 
17
28
  function meshPointsVertexAttribute(id) {
18
29
  return meshPointsCommonStyle.meshPointsColoring(id).vertex;
19
30
  }
20
31
 
32
+ function meshPointsVertexAttributeStoredConfig(id, name, item) {
33
+ const { storedConfigs } = meshPointsVertexAttribute(id);
34
+ if (storedConfigs && name in storedConfigs && item in storedConfigs[name]) {
35
+ return storedConfigs[name][item];
36
+ }
37
+ return {
38
+ minimum: undefined,
39
+ maximum: undefined,
40
+ colorMap: undefined,
41
+ };
42
+ }
43
+
21
44
  function mutateMeshPointsVertexStyle(id, values) {
22
45
  return meshPointsCommonStyle.mutateMeshPointsStyle(id, {
23
46
  coloring: {
@@ -26,136 +49,110 @@ function useMeshPointsVertexAttributeConfig() {
26
49
  });
27
50
  }
28
51
 
29
- function setMeshPointsVertexAttributeStoredConfig(id, name, config) {
52
+ function setMeshPointsVertexAttributeStoredConfig(id, name, item, config) {
30
53
  return mutateMeshPointsVertexStyle(id, {
31
54
  storedConfigs: {
32
- [name]: config,
55
+ [name]: {
56
+ lastItem: item,
57
+ [item]: config,
58
+ },
33
59
  },
34
60
  });
35
61
  }
36
62
 
37
- function meshPointsVertexAttributeStoredConfig(id, name) {
38
- const { storedConfigs } = meshPointsVertexAttribute(id);
39
- if (name in storedConfigs) {
40
- return storedConfigs[name];
63
+ function applyVertexAttribute(id) {
64
+ const name = meshPointsVertexAttributeName(id);
65
+ const item = meshPointsVertexAttributeItem(id);
66
+ const storedConfig = meshPointsVertexAttributeStoredConfig(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 (isMeshPointsVertexAttributeValid(attribute)) {
75
+ return setMeshPointsVertexAttribute(id, attribute);
41
76
  }
42
- return setMeshPointsVertexAttributeStoredConfig(id, name, {
43
- minimum: undefined,
44
- maximum: undefined,
45
- colorMap: undefined,
46
- });
47
77
  }
48
78
 
49
79
  function meshPointsVertexAttributeName(id) {
50
80
  return meshPointsVertexAttribute(id).name;
51
81
  }
52
82
 
53
- function meshPointsVertexAttributeRange(id) {
54
- const name = meshPointsVertexAttributeName(id);
55
- const storedConfig = meshPointsVertexAttributeStoredConfig(id, name);
56
- const { minimum, maximum } = storedConfig;
57
- return [minimum, maximum];
83
+ function setMeshPointsVertexAttributeName(id, name) {
84
+ const item = meshPointsVertexAttributeLastItem(id, name);
85
+ mutateMeshPointsVertexStyle(id, { name, item });
86
+ return applyVertexAttribute(id);
58
87
  }
59
88
 
60
- function meshPointsVertexAttributeColorMap(id) {
61
- const name = meshPointsVertexAttributeName(id);
62
- const storedConfig = meshPointsVertexAttributeStoredConfig(id, name);
63
- const { colorMap } = storedConfig;
64
- return colorMap;
89
+ function meshPointsVertexAttributeItem(id) {
90
+ const { item, name } = meshPointsVertexAttribute(id);
91
+ return item ?? meshPointsVertexAttributeLastItem(id, name);
65
92
  }
66
93
 
67
- return {
68
- meshPointsVertexAttribute,
69
- meshPointsVertexAttributeStoredConfig,
70
- setMeshPointsVertexAttributeStoredConfig,
71
- mutateMeshPointsVertexStyle,
72
- meshPointsVertexAttributeName,
73
- meshPointsVertexAttributeRange,
74
- meshPointsVertexAttributeColorMap,
75
- };
76
- }
94
+ function setMeshPointsVertexAttributeItem(id, item) {
95
+ mutateMeshPointsVertexStyle(id, { item });
96
+ return applyVertexAttribute(id);
97
+ }
77
98
 
78
- // oxlint-disable-next-line max-lines-per-function
79
- function useMeshPointsVertexAttributeActions() {
80
- const viewerStore = useViewerStore();
81
- const config = useMeshPointsVertexAttributeConfig();
99
+ function meshPointsVertexAttributeLastItem(id, name) {
100
+ const { storedConfigs } = meshPointsVertexAttribute(id);
101
+ if (storedConfigs && name in storedConfigs) {
102
+ return storedConfigs[name].lastItem;
103
+ }
104
+ return 0;
105
+ }
82
106
 
83
- function setMeshPointsVertexAttributeName(id, name) {
84
- const schema = meshPointsVertexAttributeSchemas.name;
85
- const params = { id, name };
86
- return viewerStore.request(
87
- { schema, params },
88
- {
89
- response_function: () => {
90
- const updates = { name };
91
- const vertex = config.meshPointsVertexAttribute(id);
92
- if (!(name in vertex.storedConfigs)) {
93
- updates.storedConfigs = {
94
- [name]: {
95
- minimum: undefined,
96
- maximum: undefined,
97
- colorMap: undefined,
98
- },
99
- };
100
- }
101
- return config.mutateMeshPointsVertexStyle(id, updates);
102
- },
103
- },
104
- );
107
+ function meshPointsVertexAttributeRange(id) {
108
+ const name = meshPointsVertexAttributeName(id);
109
+ const item = meshPointsVertexAttributeItem(id);
110
+ const storedConfig = meshPointsVertexAttributeStoredConfig(id, name, item);
111
+ return [storedConfig.minimum, storedConfig.maximum];
105
112
  }
106
113
 
107
114
  function setMeshPointsVertexAttributeRange(id, minimum, maximum) {
108
- const name = config.meshPointsVertexAttributeName(id);
109
- const points = getRGBPointsFromPreset(config.meshPointsVertexAttributeColorMap(id));
110
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
111
- const schema = meshPointsVertexAttributeSchemas.color_map;
112
- const params = { id, points, minimum, maximum };
113
- return viewerStore.request(
114
- { schema, params },
115
- {
116
- response_function: () =>
117
- config.setMeshPointsVertexAttributeStoredConfig(id, name, { minimum, maximum }),
118
- },
119
- );
120
- }
121
- return config.setMeshPointsVertexAttributeStoredConfig(id, name, {
122
- minimum,
123
- maximum,
124
- });
115
+ const name = meshPointsVertexAttributeName(id);
116
+ const item = meshPointsVertexAttributeItem(id);
117
+ setMeshPointsVertexAttributeStoredConfig(id, name, item, { minimum, maximum });
118
+ return applyVertexAttribute(id);
119
+ }
120
+
121
+ function meshPointsVertexAttributeColorMap(id) {
122
+ const name = meshPointsVertexAttributeName(id);
123
+ const item = meshPointsVertexAttributeItem(id);
124
+ const storedConfig = meshPointsVertexAttributeStoredConfig(id, name, item);
125
+ return storedConfig.colorMap;
125
126
  }
126
127
 
127
128
  function setMeshPointsVertexAttributeColorMap(id, colorMap) {
128
- const name = config.meshPointsVertexAttributeName(id);
129
- const storedConfig = config.meshPointsVertexAttributeStoredConfig(id, name);
129
+ const name = meshPointsVertexAttributeName(id);
130
+ const item = meshPointsVertexAttributeItem(id);
131
+ setMeshPointsVertexAttributeStoredConfig(id, name, item, { colorMap });
132
+ return applyVertexAttribute(id);
133
+ }
134
+
135
+ function setMeshPointsVertexAttribute(id, { name, item, minimum, maximum, colorMap }) {
136
+ mutateMeshPointsVertexStyle(id, { name, item });
137
+ setMeshPointsVertexAttributeStoredConfig(id, name, item, { minimum, maximum, colorMap });
130
138
  const points = getRGBPointsFromPreset(colorMap);
131
- const { minimum, maximum } = storedConfig;
132
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
133
- const schema = meshPointsVertexAttributeSchemas.color_map;
134
- const params = { id, points, minimum, maximum };
135
- return viewerStore.request(
136
- { schema, params },
137
- {
138
- response_function: () =>
139
- config.setMeshPointsVertexAttributeStoredConfig(id, name, { colorMap }),
140
- },
141
- );
142
- }
143
- return config.setMeshPointsVertexAttributeStoredConfig(id, name, { colorMap });
139
+ const schema = meshPointsVertexAttributeSchemas.attribute;
140
+ const params = { id, name, item, points, minimum, maximum };
141
+ return viewerStore.request({ schema, params });
144
142
  }
145
143
 
146
144
  return {
145
+ meshPointsVertexAttributeName,
146
+ meshPointsVertexAttributeItem,
147
+ meshPointsVertexAttributeRange,
148
+ meshPointsVertexAttributeColorMap,
149
+ meshPointsVertexAttributeStoredConfig,
150
+ setMeshPointsVertexAttribute,
147
151
  setMeshPointsVertexAttributeName,
152
+ setMeshPointsVertexAttributeItem,
148
153
  setMeshPointsVertexAttributeRange,
149
154
  setMeshPointsVertexAttributeColorMap,
150
155
  };
151
156
  }
152
157
 
153
- export function useMeshPointsVertexAttributeStyle() {
154
- const config = useMeshPointsVertexAttributeConfig();
155
- const actions = useMeshPointsVertexAttributeActions();
156
-
157
- return {
158
- ...config,
159
- ...actions,
160
- };
161
- }
158
+ export { isMeshPointsVertexAttributeValid, useMeshPointsVertexAttributeStyle };
@@ -1,11 +1,14 @@
1
1
  // Third party imports
2
2
 
3
3
  // Local imports
4
+ import {
5
+ isMeshPolygonsPolygonAttributeValid,
6
+ useMeshPolygonsPolygonAttributeStyle,
7
+ } from "./polygon";
8
+ import { isMeshPolygonsVertexAttributeValid, useMeshPolygonsVertexAttributeStyle } from "./vertex";
4
9
  import { useMeshPolygonsColorStyle } from "./color";
5
10
  import { useMeshPolygonsCommonStyle } from "./common";
6
- import { useMeshPolygonsPolygonAttributeStyle } from "./polygon";
7
11
  import { useMeshPolygonsTexturesStyle } from "./textures";
8
- import { useMeshPolygonsVertexAttributeStyle } from "./vertex";
9
12
  import { useMeshPolygonsVisibilityStyle } from "./visibility";
10
13
 
11
14
  // Local constants
@@ -41,23 +44,30 @@ function useMeshPolygonsColoringStyle() {
41
44
  }
42
45
  if (type === "vertex") {
43
46
  const name = meshPolygonsVertexAttributeStyle.meshPolygonsVertexAttributeName(id);
44
- const { colorMap } = meshPolygonsVertexAttributeStyle.meshPolygonsVertexAttributeStoredConfig(
45
- id,
46
- name,
47
- );
48
- return Promise.all([
49
- meshPolygonsVertexAttributeStyle.setMeshPolygonsVertexAttributeName(id, name),
50
- meshPolygonsVertexAttributeStyle.setMeshPolygonsVertexAttributeColorMap(id, colorMap),
51
- ]);
47
+ const item = meshPolygonsVertexAttributeStyle.meshPolygonsVertexAttributeItem(id);
48
+ const [minimum, maximum] =
49
+ meshPolygonsVertexAttributeStyle.meshPolygonsVertexAttributeRange(id);
50
+ const colorMap = meshPolygonsVertexAttributeStyle.meshPolygonsVertexAttributeColorMap(id);
51
+ const vertex_attribute = { name, item, minimum, maximum, colorMap };
52
+ if (!isMeshPolygonsVertexAttributeValid(vertex_attribute)) {
53
+ return;
54
+ }
55
+ return meshPolygonsVertexAttributeStyle.setMeshPolygonsVertexAttribute(id, vertex_attribute);
52
56
  }
53
57
  if (type === "polygon") {
54
58
  const name = meshPolygonsPolygonAttributeStyle.meshPolygonsPolygonAttributeName(id);
55
- const { colorMap } =
56
- meshPolygonsPolygonAttributeStyle.meshPolygonsPolygonAttributeStoredConfig(id, name);
57
- return Promise.all([
58
- meshPolygonsPolygonAttributeStyle.setMeshPolygonsPolygonAttributeName(id, name),
59
- meshPolygonsPolygonAttributeStyle.setMeshPolygonsPolygonAttributeColorMap(id, colorMap),
60
- ]);
59
+ const item = meshPolygonsPolygonAttributeStyle.meshPolygonsPolygonAttributeItem(id);
60
+ const [minimum, maximum] =
61
+ meshPolygonsPolygonAttributeStyle.meshPolygonsPolygonAttributeRange(id);
62
+ const colorMap = meshPolygonsPolygonAttributeStyle.meshPolygonsPolygonAttributeColorMap(id);
63
+ const polygon_attribute = { name, item, minimum, maximum, colorMap };
64
+ if (!isMeshPolygonsPolygonAttributeValid(polygon_attribute)) {
65
+ return;
66
+ }
67
+ return meshPolygonsPolygonAttributeStyle.setMeshPolygonsPolygonAttribute(
68
+ id,
69
+ polygon_attribute,
70
+ );
61
71
  }
62
72
  throw new Error(`Unknown mesh polygons coloring type: ${type}`);
63
73
  }
@@ -10,25 +10,39 @@ import { useViewerStore } from "@ogw_front/stores/viewer";
10
10
  const meshPolygonsPolygonAttributeSchemas =
11
11
  viewer_schemas.opengeodeweb_viewer.mesh.polygons.attribute.polygon;
12
12
 
13
+ function isMeshPolygonsPolygonAttributeValid({ 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 useMeshPolygonsPolygonAttributeStyle() {
24
+ function useMeshPolygonsPolygonAttributeStyle() {
15
25
  const viewerStore = useViewerStore();
16
26
  const meshPolygonsCommonStyle = useMeshPolygonsCommonStyle();
17
27
 
28
+ function meshPolygonsColoring(id) {
29
+ return meshPolygonsCommonStyle.meshPolygonsStyle(id).coloring;
30
+ }
31
+
18
32
  function meshPolygonsPolygonAttribute(id) {
19
- return meshPolygonsCommonStyle.meshPolygonsColoring(id).polygon;
33
+ return meshPolygonsColoring(id).polygon;
20
34
  }
21
35
 
22
- function meshPolygonsPolygonAttributeStoredConfig(id, name) {
36
+ function meshPolygonsPolygonAttributeStoredConfig(id, name, item) {
23
37
  const { storedConfigs } = meshPolygonsPolygonAttribute(id);
24
- if (name in storedConfigs) {
25
- return storedConfigs[name];
38
+ if (storedConfigs && name in storedConfigs && item in storedConfigs[name]) {
39
+ return storedConfigs[name][item];
26
40
  }
27
- return setMeshPolygonsPolygonAttributeStoredConfig(id, name, {
41
+ return {
28
42
  minimum: undefined,
29
43
  maximum: undefined,
30
44
  colorMap: undefined,
31
- });
45
+ };
32
46
  }
33
47
 
34
48
  function mutateMeshPolygonsPolygonStyle(id, values) {
@@ -39,102 +53,110 @@ export function useMeshPolygonsPolygonAttributeStyle() {
39
53
  });
40
54
  }
41
55
 
42
- function setMeshPolygonsPolygonAttributeStoredConfig(id, name, config) {
56
+ function setMeshPolygonsPolygonAttributeStoredConfig(id, name, item, config) {
43
57
  return mutateMeshPolygonsPolygonStyle(id, {
44
58
  storedConfigs: {
45
- [name]: config,
59
+ [name]: {
60
+ lastItem: item,
61
+ [item]: config,
62
+ },
46
63
  },
47
64
  });
48
65
  }
49
66
 
67
+ function applyPolygonAttribute(id) {
68
+ const name = meshPolygonsPolygonAttributeName(id);
69
+ const item = meshPolygonsPolygonAttributeItem(id);
70
+ const storedConfig = meshPolygonsPolygonAttributeStoredConfig(id, name, item);
71
+ const attribute = {
72
+ name,
73
+ item,
74
+ minimum: storedConfig.minimum,
75
+ maximum: storedConfig.maximum,
76
+ colorMap: storedConfig.colorMap,
77
+ };
78
+ if (isMeshPolygonsPolygonAttributeValid(attribute)) {
79
+ return setMeshPolygonsPolygonAttribute(id, attribute);
80
+ }
81
+ }
82
+
50
83
  function meshPolygonsPolygonAttributeName(id) {
51
84
  return meshPolygonsPolygonAttribute(id).name;
52
85
  }
53
86
 
54
87
  function setMeshPolygonsPolygonAttributeName(id, name) {
55
- const schema = meshPolygonsPolygonAttributeSchemas.name;
56
- const params = { id, name };
57
- return viewerStore.request(
58
- { schema, params },
59
- {
60
- response_function: () => {
61
- const updates = { name };
62
- const polygon = meshPolygonsPolygonAttribute(id);
63
- if (!(name in polygon.storedConfigs)) {
64
- updates.storedConfigs = {
65
- [name]: {
66
- minimum: undefined,
67
- maximum: undefined,
68
- colorMap: undefined,
69
- },
70
- };
71
- }
72
- return mutateMeshPolygonsPolygonStyle(id, updates);
73
- },
74
- },
75
- );
88
+ const item = meshPolygonsPolygonAttributeLastItem(id, name);
89
+ mutateMeshPolygonsPolygonStyle(id, { name, item });
90
+ return applyPolygonAttribute(id);
91
+ }
92
+
93
+ function meshPolygonsPolygonAttributeItem(id) {
94
+ const { item, name } = meshPolygonsPolygonAttribute(id);
95
+ return item ?? meshPolygonsPolygonAttributeLastItem(id, name);
96
+ }
97
+
98
+ function setMeshPolygonsPolygonAttributeItem(id, item) {
99
+ mutateMeshPolygonsPolygonStyle(id, { item });
100
+ return applyPolygonAttribute(id);
101
+ }
102
+
103
+ function meshPolygonsPolygonAttributeLastItem(id, name) {
104
+ const { storedConfigs } = meshPolygonsPolygonAttribute(id);
105
+ if (storedConfigs && name in storedConfigs) {
106
+ return storedConfigs[name].lastItem;
107
+ }
108
+ return 0;
76
109
  }
77
110
 
78
111
  function meshPolygonsPolygonAttributeRange(id) {
79
112
  const name = meshPolygonsPolygonAttributeName(id);
80
- const storedConfig = meshPolygonsPolygonAttributeStoredConfig(id, name);
81
- const { minimum, maximum } = storedConfig;
82
- return [minimum, maximum];
113
+ const item = meshPolygonsPolygonAttributeItem(id);
114
+ const storedConfig = meshPolygonsPolygonAttributeStoredConfig(id, name, item);
115
+ return [storedConfig.minimum, storedConfig.maximum];
83
116
  }
84
117
 
85
118
  function setMeshPolygonsPolygonAttributeRange(id, minimum, maximum) {
86
119
  const name = meshPolygonsPolygonAttributeName(id);
87
- const points = getRGBPointsFromPreset(meshPolygonsPolygonAttributeColorMap(id));
88
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
89
- const schema = meshPolygonsPolygonAttributeSchemas.color_map;
90
- const params = { id, points, minimum, maximum };
91
- return viewerStore.request(
92
- { schema, params },
93
- {
94
- response_function: () =>
95
- setMeshPolygonsPolygonAttributeStoredConfig(id, name, { minimum, maximum }),
96
- },
97
- );
98
- }
99
- return setMeshPolygonsPolygonAttributeStoredConfig(id, name, {
100
- minimum,
101
- maximum,
102
- });
120
+ const item = meshPolygonsPolygonAttributeItem(id);
121
+ setMeshPolygonsPolygonAttributeStoredConfig(id, name, item, { minimum, maximum });
122
+ return applyPolygonAttribute(id);
103
123
  }
104
124
 
105
125
  function meshPolygonsPolygonAttributeColorMap(id) {
106
126
  const name = meshPolygonsPolygonAttributeName(id);
107
- const storedConfig = meshPolygonsPolygonAttributeStoredConfig(id, name);
108
- const { colorMap } = storedConfig;
109
- return colorMap;
127
+ const item = meshPolygonsPolygonAttributeItem(id);
128
+ const storedConfig = meshPolygonsPolygonAttributeStoredConfig(id, name, item);
129
+ return storedConfig.colorMap;
110
130
  }
111
131
 
112
132
  function setMeshPolygonsPolygonAttributeColorMap(id, colorMap) {
113
133
  const name = meshPolygonsPolygonAttributeName(id);
114
- const storedConfig = meshPolygonsPolygonAttributeStoredConfig(id, name);
134
+ const item = meshPolygonsPolygonAttributeItem(id);
135
+ setMeshPolygonsPolygonAttributeStoredConfig(id, name, item, { colorMap });
136
+ return applyPolygonAttribute(id);
137
+ }
138
+
139
+ function setMeshPolygonsPolygonAttribute(id, { name, item, minimum, maximum, colorMap }) {
140
+ mutateMeshPolygonsPolygonStyle(id, { name, item });
141
+ setMeshPolygonsPolygonAttributeStoredConfig(id, name, item, { minimum, maximum, colorMap });
115
142
  const points = getRGBPointsFromPreset(colorMap);
116
- const { minimum, maximum } = storedConfig;
117
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
118
- const schema = meshPolygonsPolygonAttributeSchemas.color_map;
119
- const params = { id, points, minimum, maximum };
120
- return viewerStore.request(
121
- { schema, params },
122
- {
123
- response_function: () =>
124
- setMeshPolygonsPolygonAttributeStoredConfig(id, name, { colorMap }),
125
- },
126
- );
127
- }
128
- return setMeshPolygonsPolygonAttributeStoredConfig(id, name, { colorMap });
143
+ const schema = meshPolygonsPolygonAttributeSchemas.attribute;
144
+ const params = { id, name, item, points, minimum, maximum };
145
+ return viewerStore.request({ schema, params });
129
146
  }
130
147
 
131
148
  return {
132
149
  meshPolygonsPolygonAttributeName,
150
+ meshPolygonsPolygonAttributeItem,
133
151
  meshPolygonsPolygonAttributeRange,
134
152
  meshPolygonsPolygonAttributeColorMap,
135
153
  meshPolygonsPolygonAttributeStoredConfig,
154
+ setMeshPolygonsPolygonAttribute,
136
155
  setMeshPolygonsPolygonAttributeName,
156
+ setMeshPolygonsPolygonAttributeItem,
137
157
  setMeshPolygonsPolygonAttributeRange,
138
158
  setMeshPolygonsPolygonAttributeColorMap,
139
159
  };
140
160
  }
161
+
162
+ export { isMeshPolygonsPolygonAttributeValid, useMeshPolygonsPolygonAttributeStyle };