@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,25 +10,39 @@ import { useViewerStore } from "@ogw_front/stores/viewer";
10
10
  const meshPolygonsVertexAttributeSchemas =
11
11
  viewer_schemas.opengeodeweb_viewer.mesh.polygons.attribute.vertex;
12
12
 
13
+ function isMeshPolygonsVertexAttributeValid({ 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 useMeshPolygonsVertexAttributeStyle() {
24
+ function useMeshPolygonsVertexAttributeStyle() {
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 meshPolygonsVertexAttribute(id) {
19
- return meshPolygonsCommonStyle.meshPolygonsColoring(id).vertex;
33
+ return meshPolygonsColoring(id).vertex;
20
34
  }
21
35
 
22
- function meshPolygonsVertexAttributeStoredConfig(id, name) {
36
+ function meshPolygonsVertexAttributeStoredConfig(id, name, item) {
23
37
  const { storedConfigs } = meshPolygonsVertexAttribute(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 setMeshPolygonsVertexAttributeStoredConfig(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 mutateMeshPolygonsVertexStyle(id, values) {
@@ -39,102 +53,110 @@ export function useMeshPolygonsVertexAttributeStyle() {
39
53
  });
40
54
  }
41
55
 
42
- function setMeshPolygonsVertexAttributeStoredConfig(id, name, config) {
56
+ function setMeshPolygonsVertexAttributeStoredConfig(id, name, item, config) {
43
57
  return mutateMeshPolygonsVertexStyle(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 applyVertexAttribute(id) {
68
+ const name = meshPolygonsVertexAttributeName(id);
69
+ const item = meshPolygonsVertexAttributeItem(id);
70
+ const storedConfig = meshPolygonsVertexAttributeStoredConfig(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 (isMeshPolygonsVertexAttributeValid(attribute)) {
79
+ return setMeshPolygonsVertexAttribute(id, attribute);
80
+ }
81
+ }
82
+
50
83
  function meshPolygonsVertexAttributeName(id) {
51
84
  return meshPolygonsVertexAttribute(id).name;
52
85
  }
53
86
 
54
87
  function setMeshPolygonsVertexAttributeName(id, name) {
55
- const schema = meshPolygonsVertexAttributeSchemas.name;
56
- const params = { id, name };
57
- return viewerStore.request(
58
- { schema, params },
59
- {
60
- response_function: () => {
61
- const updates = { name };
62
- const vertex = meshPolygonsVertexAttribute(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 mutateMeshPolygonsVertexStyle(id, updates);
73
- },
74
- },
75
- );
88
+ const item = meshPolygonsVertexAttributeLastItem(id, name);
89
+ mutateMeshPolygonsVertexStyle(id, { name, item });
90
+ return applyVertexAttribute(id);
91
+ }
92
+
93
+ function meshPolygonsVertexAttributeItem(id) {
94
+ const { item, name } = meshPolygonsVertexAttribute(id);
95
+ return item ?? meshPolygonsVertexAttributeLastItem(id, name);
96
+ }
97
+
98
+ function setMeshPolygonsVertexAttributeItem(id, item) {
99
+ mutateMeshPolygonsVertexStyle(id, { item });
100
+ return applyVertexAttribute(id);
101
+ }
102
+
103
+ function meshPolygonsVertexAttributeLastItem(id, name) {
104
+ const { storedConfigs } = meshPolygonsVertexAttribute(id);
105
+ if (storedConfigs && name in storedConfigs) {
106
+ return storedConfigs[name].lastItem;
107
+ }
108
+ return 0;
76
109
  }
77
110
 
78
111
  function meshPolygonsVertexAttributeRange(id) {
79
112
  const name = meshPolygonsVertexAttributeName(id);
80
- const storedConfig = meshPolygonsVertexAttributeStoredConfig(id, name);
81
- const { minimum, maximum } = storedConfig;
82
- return [minimum, maximum];
113
+ const item = meshPolygonsVertexAttributeItem(id);
114
+ const storedConfig = meshPolygonsVertexAttributeStoredConfig(id, name, item);
115
+ return [storedConfig.minimum, storedConfig.maximum];
83
116
  }
84
117
 
85
118
  function setMeshPolygonsVertexAttributeRange(id, minimum, maximum) {
86
119
  const name = meshPolygonsVertexAttributeName(id);
87
- const points = getRGBPointsFromPreset(meshPolygonsVertexAttributeColorMap(id));
88
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
89
- const schema = meshPolygonsVertexAttributeSchemas.color_map;
90
- const params = { id, points, minimum, maximum };
91
- return viewerStore.request(
92
- { schema, params },
93
- {
94
- response_function: () =>
95
- setMeshPolygonsVertexAttributeStoredConfig(id, name, { minimum, maximum }),
96
- },
97
- );
98
- }
99
- return setMeshPolygonsVertexAttributeStoredConfig(id, name, {
100
- minimum,
101
- maximum,
102
- });
120
+ const item = meshPolygonsVertexAttributeItem(id);
121
+ setMeshPolygonsVertexAttributeStoredConfig(id, name, item, { minimum, maximum });
122
+ return applyVertexAttribute(id);
103
123
  }
104
124
 
105
125
  function meshPolygonsVertexAttributeColorMap(id) {
106
126
  const name = meshPolygonsVertexAttributeName(id);
107
- const storedConfig = meshPolygonsVertexAttributeStoredConfig(id, name);
108
- const { colorMap } = storedConfig;
109
- return colorMap;
127
+ const item = meshPolygonsVertexAttributeItem(id);
128
+ const storedConfig = meshPolygonsVertexAttributeStoredConfig(id, name, item);
129
+ return storedConfig.colorMap;
110
130
  }
111
131
 
112
132
  function setMeshPolygonsVertexAttributeColorMap(id, colorMap) {
113
133
  const name = meshPolygonsVertexAttributeName(id);
114
- const storedConfig = meshPolygonsVertexAttributeStoredConfig(id, name);
134
+ const item = meshPolygonsVertexAttributeItem(id);
135
+ setMeshPolygonsVertexAttributeStoredConfig(id, name, item, { colorMap });
136
+ return applyVertexAttribute(id);
137
+ }
138
+
139
+ function setMeshPolygonsVertexAttribute(id, { name, item, minimum, maximum, colorMap }) {
140
+ mutateMeshPolygonsVertexStyle(id, { name, item });
141
+ setMeshPolygonsVertexAttributeStoredConfig(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 = meshPolygonsVertexAttributeSchemas.color_map;
119
- const params = { id, points, minimum, maximum };
120
- return viewerStore.request(
121
- { schema, params },
122
- {
123
- response_function: () =>
124
- setMeshPolygonsVertexAttributeStoredConfig(id, name, { colorMap }),
125
- },
126
- );
127
- }
128
- return setMeshPolygonsVertexAttributeStoredConfig(id, name, { colorMap });
143
+ const schema = meshPolygonsVertexAttributeSchemas.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
  meshPolygonsVertexAttributeName,
150
+ meshPolygonsVertexAttributeItem,
133
151
  meshPolygonsVertexAttributeRange,
134
152
  meshPolygonsVertexAttributeColorMap,
135
153
  meshPolygonsVertexAttributeStoredConfig,
154
+ setMeshPolygonsVertexAttribute,
136
155
  setMeshPolygonsVertexAttributeName,
156
+ setMeshPolygonsVertexAttributeItem,
137
157
  setMeshPolygonsVertexAttributeRange,
138
158
  setMeshPolygonsVertexAttributeColorMap,
139
159
  };
140
160
  }
161
+
162
+ export { isMeshPolygonsVertexAttributeValid, useMeshPolygonsVertexAttributeStyle };
@@ -1,11 +1,16 @@
1
1
  // Third party imports
2
2
 
3
3
  // Local imports
4
-
4
+ import {
5
+ isMeshPolyhedraPolyhedronAttributeValid,
6
+ useMeshPolyhedraPolyhedronAttributeStyle,
7
+ } from "./polyhedron";
8
+ import {
9
+ isMeshPolyhedraVertexAttributeValid,
10
+ useMeshPolyhedraVertexAttributeStyle,
11
+ } from "./vertex";
5
12
  import { useMeshPolyhedraColorStyle } from "./color";
6
13
  import { useMeshPolyhedraCommonStyle } from "./common";
7
- import { useMeshPolyhedraPolyhedronAttributeStyle } from "./polyhedron";
8
- import { useMeshPolyhedraVertexAttributeStyle } from "./vertex";
9
14
  import { useMeshPolyhedraVisibilityStyle } from "./visibility";
10
15
 
11
16
  // Local constants
@@ -29,7 +34,6 @@ export function useMeshPolyhedraStyle() {
29
34
  await meshPolyhedraCommonStyle.mutateMeshPolyhedraStyle(id, {
30
35
  coloring: { active: type },
31
36
  });
32
- console.log(setMeshPolyhedraActiveColoring.name, { id }, type);
33
37
  if (type === "constant") {
34
38
  return meshPolyhedraColorStyle.setMeshPolyhedraColor(
35
39
  id,
@@ -38,27 +42,34 @@ export function useMeshPolyhedraStyle() {
38
42
  }
39
43
  if (type === "vertex") {
40
44
  const name = meshPolyhedraVertexAttributeStyle.meshPolyhedraVertexAttributeName(id);
41
- const { colorMap } =
42
- meshPolyhedraVertexAttributeStyle.meshPolyhedraVertexAttributeStoredConfig(id, name);
43
- return Promise.all([
44
- meshPolyhedraVertexAttributeStyle.setMeshPolyhedraVertexAttributeName(id, name),
45
- meshPolyhedraVertexAttributeStyle.setMeshPolyhedraVertexAttributeColorMap(id, colorMap),
46
- ]);
45
+ const item = meshPolyhedraVertexAttributeStyle.meshPolyhedraVertexAttributeItem(id);
46
+ const [minimum, maximum] =
47
+ meshPolyhedraVertexAttributeStyle.meshPolyhedraVertexAttributeRange(id);
48
+ const colorMap = meshPolyhedraVertexAttributeStyle.meshPolyhedraVertexAttributeColorMap(id);
49
+ const vertex_attribute = { name, item, minimum, maximum, colorMap };
50
+ if (!isMeshPolyhedraVertexAttributeValid(vertex_attribute)) {
51
+ return;
52
+ }
53
+ return meshPolyhedraVertexAttributeStyle.setMeshPolyhedraVertexAttribute(
54
+ id,
55
+ vertex_attribute,
56
+ );
47
57
  }
48
58
  if (type === "polyhedron") {
49
59
  const name = meshPolyhedraPolyhedronAttributeStyle.meshPolyhedraPolyhedronAttributeName(id);
50
- const { colorMap } =
51
- meshPolyhedraPolyhedronAttributeStyle.meshPolyhedraPolyhedronAttributeStoredConfig(
52
- id,
53
- name,
54
- );
55
- return Promise.all([
56
- meshPolyhedraPolyhedronAttributeStyle.setMeshPolyhedraPolyhedronAttributeName(id, name),
57
- meshPolyhedraPolyhedronAttributeStyle.setMeshPolyhedraPolyhedronAttributeColorMap(
58
- id,
59
- colorMap,
60
- ),
61
- ]);
60
+ const item = meshPolyhedraPolyhedronAttributeStyle.meshPolyhedraPolyhedronAttributeItem(id);
61
+ const [minimum, maximum] =
62
+ meshPolyhedraPolyhedronAttributeStyle.meshPolyhedraPolyhedronAttributeRange(id);
63
+ const colorMap =
64
+ meshPolyhedraPolyhedronAttributeStyle.meshPolyhedraPolyhedronAttributeColorMap(id);
65
+ const polyhedron_attribute = { name, item, minimum, maximum, colorMap };
66
+ if (!isMeshPolyhedraPolyhedronAttributeValid(polyhedron_attribute)) {
67
+ return;
68
+ }
69
+ return meshPolyhedraPolyhedronAttributeStyle.setMeshPolyhedraPolyhedronAttribute(
70
+ id,
71
+ polyhedron_attribute,
72
+ );
62
73
  }
63
74
  throw new Error(`Unknown mesh polyhedra coloring type: ${type}`);
64
75
  }
@@ -10,12 +10,39 @@ import { useViewerStore } from "@ogw_front/stores/viewer";
10
10
  const meshPolyhedraPolyhedronAttributeSchemas =
11
11
  viewer_schemas.opengeodeweb_viewer.mesh.polyhedra.attribute.polyhedron;
12
12
 
13
+ function isMeshPolyhedraPolyhedronAttributeValid({ 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 useMeshPolyhedraPolyhedronAttributeConfig() {
24
+ function useMeshPolyhedraPolyhedronAttributeStyle() {
25
+ const viewerStore = useViewerStore();
15
26
  const meshPolyhedraCommonStyle = useMeshPolyhedraCommonStyle();
16
27
 
28
+ function meshPolyhedraColoring(id) {
29
+ return meshPolyhedraCommonStyle.meshPolyhedraStyle(id).coloring;
30
+ }
31
+
17
32
  function meshPolyhedraPolyhedronAttribute(id) {
18
- return meshPolyhedraCommonStyle.meshPolyhedraColoring(id).polyhedron;
33
+ return meshPolyhedraColoring(id).polyhedron;
34
+ }
35
+
36
+ function meshPolyhedraPolyhedronAttributeStoredConfig(id, name, item) {
37
+ const { storedConfigs } = meshPolyhedraPolyhedronAttribute(id);
38
+ if (storedConfigs && name in storedConfigs && item in storedConfigs[name]) {
39
+ return storedConfigs[name][item];
40
+ }
41
+ return {
42
+ minimum: undefined,
43
+ maximum: undefined,
44
+ colorMap: undefined,
45
+ };
19
46
  }
20
47
 
21
48
  function mutateMeshPolyhedraPolyhedronStyle(id, values) {
@@ -26,139 +53,110 @@ function useMeshPolyhedraPolyhedronAttributeConfig() {
26
53
  });
27
54
  }
28
55
 
29
- function setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, config) {
56
+ function setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, item, config) {
30
57
  return mutateMeshPolyhedraPolyhedronStyle(id, {
31
58
  storedConfigs: {
32
- [name]: config,
59
+ [name]: {
60
+ lastItem: item,
61
+ [item]: config,
62
+ },
33
63
  },
34
64
  });
35
65
  }
36
66
 
37
- function meshPolyhedraPolyhedronAttributeStoredConfig(id, name) {
38
- const { storedConfigs } = meshPolyhedraPolyhedronAttribute(id);
39
- if (name in storedConfigs) {
40
- return storedConfigs[name];
67
+ function applyPolyhedronAttribute(id) {
68
+ const name = meshPolyhedraPolyhedronAttributeName(id);
69
+ const item = meshPolyhedraPolyhedronAttributeItem(id);
70
+ const storedConfig = meshPolyhedraPolyhedronAttributeStoredConfig(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 (isMeshPolyhedraPolyhedronAttributeValid(attribute)) {
79
+ return setMeshPolyhedraPolyhedronAttribute(id, attribute);
41
80
  }
42
- return setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, {
43
- minimum: undefined,
44
- maximum: undefined,
45
- colorMap: undefined,
46
- });
47
81
  }
48
82
 
49
83
  function meshPolyhedraPolyhedronAttributeName(id) {
50
84
  return meshPolyhedraPolyhedronAttribute(id).name;
51
85
  }
52
86
 
53
- function meshPolyhedraPolyhedronAttributeRange(id) {
54
- const name = meshPolyhedraPolyhedronAttributeName(id);
55
- const storedConfig = meshPolyhedraPolyhedronAttributeStoredConfig(id, name);
56
- const { minimum, maximum } = storedConfig;
57
- return [minimum, maximum];
87
+ function setMeshPolyhedraPolyhedronAttributeName(id, name) {
88
+ const item = meshPolyhedraPolyhedronAttributeLastItem(id, name);
89
+ mutateMeshPolyhedraPolyhedronStyle(id, { name, item });
90
+ return applyPolyhedronAttribute(id);
58
91
  }
59
92
 
60
- function meshPolyhedraPolyhedronAttributeColorMap(id) {
61
- const name = meshPolyhedraPolyhedronAttributeName(id);
62
- const storedConfig = meshPolyhedraPolyhedronAttributeStoredConfig(id, name);
63
- const { colorMap } = storedConfig;
64
- return colorMap;
93
+ function meshPolyhedraPolyhedronAttributeItem(id) {
94
+ const { item, name } = meshPolyhedraPolyhedronAttribute(id);
95
+ return item ?? meshPolyhedraPolyhedronAttributeLastItem(id, name);
65
96
  }
66
97
 
67
- return {
68
- meshPolyhedraPolyhedronAttribute,
69
- meshPolyhedraPolyhedronAttributeStoredConfig,
70
- setMeshPolyhedraPolyhedronAttributeStoredConfig,
71
- mutateMeshPolyhedraPolyhedronStyle,
72
- meshPolyhedraPolyhedronAttributeName,
73
- meshPolyhedraPolyhedronAttributeRange,
74
- meshPolyhedraPolyhedronAttributeColorMap,
75
- };
76
- }
98
+ function setMeshPolyhedraPolyhedronAttributeItem(id, item) {
99
+ mutateMeshPolyhedraPolyhedronStyle(id, { item });
100
+ return applyPolyhedronAttribute(id);
101
+ }
77
102
 
78
- // oxlint-disable-next-line max-lines-per-function
79
- function useMeshPolyhedraPolyhedronAttributeActions() {
80
- const viewerStore = useViewerStore();
81
- const config = useMeshPolyhedraPolyhedronAttributeConfig();
103
+ function meshPolyhedraPolyhedronAttributeLastItem(id, name) {
104
+ const { storedConfigs } = meshPolyhedraPolyhedronAttribute(id);
105
+ if (storedConfigs && name in storedConfigs) {
106
+ return storedConfigs[name].lastItem;
107
+ }
108
+ return 0;
109
+ }
82
110
 
83
- function setMeshPolyhedraPolyhedronAttributeName(id, name) {
84
- const schema = meshPolyhedraPolyhedronAttributeSchemas.name;
85
- const params = { id, name };
86
- return viewerStore.request(
87
- {
88
- schema,
89
- params,
90
- },
91
- {
92
- response_function: () => {
93
- const updates = { name };
94
- const polyhedron = config.meshPolyhedraPolyhedronAttribute(id);
95
- if (!(name in polyhedron.storedConfigs)) {
96
- updates.storedConfigs = {
97
- [name]: {
98
- minimum: undefined,
99
- maximum: undefined,
100
- colorMap: undefined,
101
- },
102
- };
103
- }
104
- return config.mutateMeshPolyhedraPolyhedronStyle(id, updates);
105
- },
106
- },
107
- );
111
+ function meshPolyhedraPolyhedronAttributeRange(id) {
112
+ const name = meshPolyhedraPolyhedronAttributeName(id);
113
+ const item = meshPolyhedraPolyhedronAttributeItem(id);
114
+ const storedConfig = meshPolyhedraPolyhedronAttributeStoredConfig(id, name, item);
115
+ return [storedConfig.minimum, storedConfig.maximum];
108
116
  }
109
117
 
110
118
  function setMeshPolyhedraPolyhedronAttributeRange(id, minimum, maximum) {
111
- const name = config.meshPolyhedraPolyhedronAttributeName(id);
112
- const points = getRGBPointsFromPreset(config.meshPolyhedraPolyhedronAttributeColorMap(id));
113
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
114
- const schema = meshPolyhedraPolyhedronAttributeSchemas.color_map;
115
- const params = { id, points, minimum, maximum };
116
- return viewerStore.request(
117
- { schema, params },
118
- {
119
- response_function: () =>
120
- config.setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, { minimum, maximum }),
121
- },
122
- );
123
- }
124
- return config.setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, {
125
- minimum,
126
- maximum,
127
- });
119
+ const name = meshPolyhedraPolyhedronAttributeName(id);
120
+ const item = meshPolyhedraPolyhedronAttributeItem(id);
121
+ setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, item, { minimum, maximum });
122
+ return applyPolyhedronAttribute(id);
123
+ }
124
+
125
+ function meshPolyhedraPolyhedronAttributeColorMap(id) {
126
+ const name = meshPolyhedraPolyhedronAttributeName(id);
127
+ const item = meshPolyhedraPolyhedronAttributeItem(id);
128
+ const storedConfig = meshPolyhedraPolyhedronAttributeStoredConfig(id, name, item);
129
+ return storedConfig.colorMap;
128
130
  }
129
131
 
130
132
  function setMeshPolyhedraPolyhedronAttributeColorMap(id, colorMap) {
131
- const name = config.meshPolyhedraPolyhedronAttributeName(id);
132
- const storedConfig = config.meshPolyhedraPolyhedronAttributeStoredConfig(id, name);
133
+ const name = meshPolyhedraPolyhedronAttributeName(id);
134
+ const item = meshPolyhedraPolyhedronAttributeItem(id);
135
+ setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, item, { colorMap });
136
+ return applyPolyhedronAttribute(id);
137
+ }
138
+
139
+ function setMeshPolyhedraPolyhedronAttribute(id, { name, item, minimum, maximum, colorMap }) {
140
+ mutateMeshPolyhedraPolyhedronStyle(id, { name, item });
141
+ setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, item, { minimum, maximum, colorMap });
133
142
  const points = getRGBPointsFromPreset(colorMap);
134
- const { minimum, maximum } = storedConfig;
135
- if (points.length > 0 && minimum !== undefined && maximum !== undefined) {
136
- const schema = meshPolyhedraPolyhedronAttributeSchemas.color_map;
137
- const params = { id, points, minimum, maximum };
138
- return viewerStore.request(
139
- { schema, params },
140
- {
141
- response_function: () =>
142
- config.setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, { colorMap }),
143
- },
144
- );
145
- }
146
- return config.setMeshPolyhedraPolyhedronAttributeStoredConfig(id, name, { colorMap });
143
+ const schema = meshPolyhedraPolyhedronAttributeSchemas.attribute;
144
+ const params = { id, name, item, points, minimum, maximum };
145
+ return viewerStore.request({ schema, params });
147
146
  }
148
147
 
149
148
  return {
149
+ meshPolyhedraPolyhedronAttributeName,
150
+ meshPolyhedraPolyhedronAttributeItem,
151
+ meshPolyhedraPolyhedronAttributeRange,
152
+ meshPolyhedraPolyhedronAttributeColorMap,
153
+ meshPolyhedraPolyhedronAttributeStoredConfig,
154
+ setMeshPolyhedraPolyhedronAttribute,
150
155
  setMeshPolyhedraPolyhedronAttributeName,
156
+ setMeshPolyhedraPolyhedronAttributeItem,
151
157
  setMeshPolyhedraPolyhedronAttributeRange,
152
158
  setMeshPolyhedraPolyhedronAttributeColorMap,
153
159
  };
154
160
  }
155
161
 
156
- export function useMeshPolyhedraPolyhedronAttributeStyle() {
157
- const config = useMeshPolyhedraPolyhedronAttributeConfig();
158
- const actions = useMeshPolyhedraPolyhedronAttributeActions();
159
-
160
- return {
161
- ...config,
162
- ...actions,
163
- };
164
- }
162
+ export { isMeshPolyhedraPolyhedronAttributeValid, useMeshPolyhedraPolyhedronAttributeStyle };