@geode/opengeodeweb-front 9.12.2-rc.1 → 9.12.2-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 (38) hide show
  1. package/components/Viewer/TreeComponent.vue +28 -8
  2. package/internal_stores/data_style_state.js +6 -1
  3. package/internal_stores/mesh/edges.js +18 -8
  4. package/internal_stores/mesh/index.js +21 -20
  5. package/internal_stores/mesh/points.js +22 -9
  6. package/internal_stores/mesh/polygons.js +26 -8
  7. package/internal_stores/mesh/polyhedra.js +19 -8
  8. package/internal_stores/model/blocks.js +71 -31
  9. package/internal_stores/model/corners.js +69 -32
  10. package/internal_stores/model/edges.js +16 -10
  11. package/internal_stores/model/index.js +117 -77
  12. package/internal_stores/model/lines.js +53 -36
  13. package/internal_stores/model/points.js +23 -16
  14. package/internal_stores/model/surfaces.js +63 -29
  15. package/package.json +1 -1
  16. package/stores/data_base.js +18 -32
  17. package/stores/data_style.js +18 -30
  18. package/stores/hybrid_viewer.js +12 -6
  19. package/stores/treeview.js +2 -3
  20. package/tests/integration/data/uploads/test.og_brep +0 -0
  21. package/tests/integration/microservices/viewer/requirements.txt +1 -1
  22. package/tests/integration/setup.js +16 -31
  23. package/tests/integration/stores/data_style/mesh/edges.nuxt.test.js +27 -13
  24. package/tests/integration/stores/data_style/mesh/index.nuxt.test.js +66 -0
  25. package/tests/integration/stores/data_style/mesh/points.nuxt.test.js +47 -13
  26. package/tests/integration/stores/data_style/mesh/polygons.nuxt.test.js +27 -13
  27. package/tests/integration/stores/data_style/mesh/polyhedra.nuxt.test.js +26 -13
  28. package/tests/integration/stores/data_style/model/blocks.nuxt.test.js +92 -0
  29. package/tests/integration/stores/data_style/model/corners.nuxt.test.js +92 -0
  30. package/tests/integration/stores/data_style/model/edges.nuxt.test.js +57 -0
  31. package/tests/integration/stores/data_style/model/index.nuxt.test.js +57 -0
  32. package/tests/integration/stores/data_style/model/lines.nuxt.test.js +83 -0
  33. package/tests/integration/stores/data_style/model/points.nuxt.test.js +73 -0
  34. package/tests/integration/stores/data_style/model/surfaces.nuxt.test.js +96 -0
  35. package/tests/vitest.config.js +2 -1
  36. package/utils/default_styles.js +19 -7
  37. package/utils/file_import_workflow.js +82 -0
  38. package/tests/integration/utils.js +0 -35
@@ -40,22 +40,42 @@
40
40
  removed_blocks,
41
41
  ] = sortMeshComponents(removed)
42
42
  if (added_corners.length > 0)
43
- dataStyleStore.setCornerVisibility(props.id, added_corners, true)
43
+ dataStyleStore.setModelCornersVisibility(
44
+ props.id,
45
+ added_corners,
46
+ true,
47
+ )
44
48
  if (added_lines.length > 0)
45
- dataStyleStore.setLineVisibility(props.id, added_lines, true)
49
+ dataStyleStore.setModelLinesVisibility(props.id, added_lines, true)
46
50
  if (added_surfaces.length > 0)
47
- dataStyleStore.setSurfaceVisibility(props.id, added_surfaces, true)
51
+ dataStyleStore.setModelSurfacesVisibility(
52
+ props.id,
53
+ added_surfaces,
54
+ true,
55
+ )
48
56
  if (added_blocks.length > 0)
49
- dataStyleStore.setBlockVisibility(props.id, added_blocks, true)
57
+ dataStyleStore.setModelBlocksVisibility(props.id, added_blocks, true)
50
58
 
51
59
  if (removed_corners.length > 0)
52
- dataStyleStore.setCornerVisibility(props.id, removed_corners, false)
60
+ dataStyleStore.setModelCornersVisibility(
61
+ props.id,
62
+ removed_corners,
63
+ false,
64
+ )
53
65
  if (removed_lines.length > 0)
54
- dataStyleStore.setLineVisibility(props.id, removed_lines, false)
66
+ dataStyleStore.setModelLinesVisibility(props.id, removed_lines, false)
55
67
  if (removed_surfaces.length > 0)
56
- dataStyleStore.setSurfaceVisibility(props.id, removed_surfaces, false)
68
+ dataStyleStore.setModelSurfacesVisibility(
69
+ props.id,
70
+ removed_surfaces,
71
+ false,
72
+ )
57
73
  if (removed_blocks.length > 0)
58
- dataStyleStore.setBlockVisibility(props.id, removed_blocks, false)
74
+ dataStyleStore.setModelBlocksVisibility(
75
+ props.id,
76
+ removed_blocks,
77
+ false,
78
+ )
59
79
  }
60
80
  },
61
81
  { immediate: true, deep: true },
@@ -3,7 +3,12 @@ import { reactive, computed } from "vue"
3
3
  export default function useDataStyleState() {
4
4
  const styles = reactive({})
5
5
 
6
- const objectVisibility = computed(() => (id) => styles[id].visibility)
6
+ const objectVisibility = computed(() => (id) => {
7
+ if (styles[id]) {
8
+ return styles[id].visibility
9
+ }
10
+ return false
11
+ })
7
12
  const selectedObjects = computed(() => {
8
13
  const selection = []
9
14
  for (const [id, value] of Object.entries(styles)) {
@@ -1,5 +1,7 @@
1
1
  // Third party imports
2
2
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local constants
3
5
  const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
4
6
 
5
7
  export function useMeshEdgesStyle() {
@@ -13,14 +15,15 @@ export function useMeshEdgesStyle() {
13
15
  return meshEdgesStyle(id).visibility
14
16
  }
15
17
  function setMeshEdgesVisibility(id, visibility) {
16
- const mesh_edges_style = meshEdgesStyle(id)
17
18
  return viewer_call(
18
19
  { schema: mesh_edges_schemas.visibility, params: { id, visibility } },
19
20
  {
20
21
  response_function: () => {
21
- mesh_edges_style.visibility = visibility
22
+ meshEdgesStyle(id).visibility = visibility
22
23
  console.log(
23
- `${setMeshEdgesVisibility.name} ${id} ${meshEdgesVisibility(id)}`,
24
+ setMeshEdgesVisibility.name,
25
+ { id },
26
+ meshEdgesVisibility(id),
24
27
  )
25
28
  },
26
29
  },
@@ -34,7 +37,9 @@ export function useMeshEdgesStyle() {
34
37
  const coloring = meshEdgesStyle(id).coloring
35
38
  coloring.active = type
36
39
  console.log(
37
- `${setMeshEdgesActiveColoring.name} ${id} ${meshEdgesActiveColoring(id)}`,
40
+ setMeshEdgesActiveColoring.name,
41
+ { id },
42
+ meshEdgesActiveColoring(id),
38
43
  )
39
44
  if (type === "color") {
40
45
  return setMeshEdgesColor(id, coloring.color)
@@ -42,7 +47,9 @@ export function useMeshEdgesStyle() {
42
47
  // return setEdgesVertexAttribute(id, coloring.vertex)
43
48
  // } else if (type == "edges" && coloring.edges !== null) {
44
49
  // return setEdgesEdgeAttribute(id, coloring.edges)
45
- } else throw new Error("Unknown edges coloring type: " + type)
50
+ } else {
51
+ throw new Error("Unknown mesh edges coloring type: " + type)
52
+ }
46
53
  }
47
54
 
48
55
  function meshEdgesColor(id) {
@@ -56,7 +63,9 @@ export function useMeshEdgesStyle() {
56
63
  response_function: () => {
57
64
  coloring_style.color = color
58
65
  console.log(
59
- `${setMeshEdgesColor.name} ${id} ${JSON.stringify(meshEdgesColor(id))}`,
66
+ setMeshEdgesColor.name,
67
+ { id },
68
+ JSON.stringify(meshEdgesColor(id)),
60
69
  )
61
70
  },
62
71
  },
@@ -73,13 +82,14 @@ export function useMeshEdgesStyle() {
73
82
  {
74
83
  response_function: () => {
75
84
  edges_style.width = width
76
- console.log(`${setMeshEdgesWidth.name} ${id} ${meshEdgesWidth(id)}`)
85
+ console.log(setMeshEdgesWidth.name, { id }, meshEdgesWidth(id))
77
86
  },
78
87
  },
79
88
  )
80
89
  }
81
90
 
82
- function applyMeshEdgesStyle(id, style) {
91
+ function applyMeshEdgesStyle(id) {
92
+ const style = meshEdgesStyle(id)
83
93
  return Promise.all([
84
94
  setMeshEdgesVisibility(id, style.visibility),
85
95
  setMeshEdgesActiveColoring(id, style.coloring.active),
@@ -7,6 +7,9 @@ import { useMeshEdgesStyle } from "./edges.js"
7
7
  import { useMeshPolygonsStyle } from "./polygons.js"
8
8
  import { useMeshPolyhedraStyle } from "./polyhedra.js"
9
9
 
10
+ // Local constants
11
+ const mesh_schemas = viewer_schemas.opengeodeweb_viewer.mesh
12
+
10
13
  export default function useMeshStyle() {
11
14
  const dataStyleStore = useDataStyleStore()
12
15
  const pointsStyleStore = useMeshPointsStyle()
@@ -16,51 +19,49 @@ export default function useMeshStyle() {
16
19
  const hybridViewerStore = useHybridViewerStore()
17
20
 
18
21
  function meshVisibility(id) {
19
- return dataStyleStore.styles[id].visibility
22
+ return dataStyleStore.getStyle(id).visibility
20
23
  }
21
24
  function setMeshVisibility(id, visibility) {
22
25
  return viewer_call(
23
26
  {
24
- schema: viewer_schemas.opengeodeweb_viewer.mesh.visibility,
27
+ schema: mesh_schemas.visibility,
25
28
  params: { id, visibility },
26
29
  },
27
30
  {
28
31
  response_function: () => {
29
32
  hybridViewerStore.setVisibility(id, visibility)
30
- dataStyleStore.styles[id].visibility = visibility
31
- console.log(`${setMeshVisibility.name} ${id} ${meshVisibility(id)}`)
33
+ dataStyleStore.getStyle(id).visibility = visibility
34
+ console.log(setMeshVisibility.name, { id }, meshVisibility(id))
32
35
  },
33
36
  },
34
37
  )
35
38
  }
36
39
 
37
- function applyMeshDefaultStyle(id) {
40
+ function applyMeshStyle(id) {
38
41
  const style = dataStyleStore.getStyle(id)
39
42
  const promise_array = []
40
43
  for (const [key, value] of Object.entries(style)) {
41
- if (key == "visibility") {
44
+ if (key === "visibility") {
42
45
  promise_array.push(setMeshVisibility(id, value))
43
- } else if (key == "points") {
44
- promise_array.push(pointsStyleStore.applyMeshPointsStyle(id, value))
45
- } else if (key == "edges") {
46
- promise_array.push(edgesStyleStore.applyMeshEdgesStyle(id, value))
47
- } else if (key == "polygons") {
48
- promise_array.push(
49
- meshPolygonsStyleStore.applyMeshPolygonsStyle(id, value),
50
- )
51
- } else if (key == "polyhedra") {
52
- promise_array.push(
53
- meshPolyhedraStyleStore.applyMeshPolyhedraStyle(id, value),
54
- )
46
+ } else if (key === "points") {
47
+ promise_array.push(pointsStyleStore.applyMeshPointsStyle(id))
48
+ } else if (key === "edges") {
49
+ promise_array.push(edgesStyleStore.applyMeshEdgesStyle(id))
50
+ } else if (key === "polygons") {
51
+ promise_array.push(meshPolygonsStyleStore.applyMeshPolygonsStyle(id))
52
+ } else if (key === "polyhedra") {
53
+ promise_array.push(meshPolyhedraStyleStore.applyMeshPolyhedraStyle(id))
54
+ } else {
55
+ throw new Error("Unknown mesh key: " + key)
55
56
  }
56
57
  }
57
- return promise_array
58
+ return Promise.all(promise_array)
58
59
  }
59
60
 
60
61
  return {
61
62
  meshVisibility,
62
63
  setMeshVisibility,
63
- applyMeshDefaultStyle,
64
+ applyMeshStyle,
64
65
  ...useMeshPointsStyle(),
65
66
  ...useMeshEdgesStyle(),
66
67
  ...useMeshPolygonsStyle(),
@@ -1,4 +1,7 @@
1
+ // Third party imports
1
2
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local constants
2
5
  const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points
3
6
 
4
7
  export function useMeshPointsStyle() {
@@ -19,7 +22,9 @@ export function useMeshPointsStyle() {
19
22
  response_function: () => {
20
23
  points_style.visibility = visibility
21
24
  console.log(
22
- `${setMeshPointsVisibility.name} ${id} ${meshPointsVisibility(id)}`,
25
+ setMeshPointsVisibility.name,
26
+ { id },
27
+ meshPointsVisibility(id),
23
28
  )
24
29
  },
25
30
  },
@@ -33,13 +38,17 @@ export function useMeshPointsStyle() {
33
38
  const coloring = meshPointsStyle(id).coloring
34
39
  coloring.active = type
35
40
  console.log(
36
- `${setMeshPointsActiveColoring.name} ${id} ${meshPointsActiveColoring(id)}`,
41
+ setMeshPointsActiveColoring.name,
42
+ { id },
43
+ meshPointsActiveColoring(id),
37
44
  )
38
45
  if (type == "color") {
39
46
  return dataStyleStore.setMeshPointsColor(id, coloring.color)
40
47
  } else if (type == "vertex" && coloring.vertex !== null) {
41
48
  return dataStyleStore.setMeshPointsVertexAttribute(id, coloring.vertex)
42
- } else throw new Error("Unknown points coloring type: " + type)
49
+ } else {
50
+ throw new Error("Unknown mesh points coloring type: " + type)
51
+ }
43
52
  }
44
53
 
45
54
  function meshPointsColor(id) {
@@ -53,7 +62,9 @@ export function useMeshPointsStyle() {
53
62
  response_function: () => {
54
63
  coloring_style.color = color
55
64
  console.log(
56
- `${setMeshPointsColor.name} ${id} ${JSON.stringify(meshPointsColor(id))}`,
65
+ setMeshPointsColor.name,
66
+ { id },
67
+ JSON.stringify(meshPointsColor(id)),
57
68
  )
58
69
  },
59
70
  },
@@ -73,7 +84,9 @@ export function useMeshPointsStyle() {
73
84
  response_function: () => {
74
85
  coloring_style.vertex = vertex_attribute
75
86
  console.log(
76
- `${setMeshPointsVertexAttribute.name} ${id} ${meshPointsVertexAttribute(id)}`,
87
+ setMeshPointsVertexAttribute.name,
88
+ { id },
89
+ meshPointsVertexAttribute(id),
77
90
  )
78
91
  },
79
92
  },
@@ -84,19 +97,19 @@ export function useMeshPointsStyle() {
84
97
  return meshPointsStyle(id).size
85
98
  }
86
99
  function setMeshPointsSize(id, size) {
87
- const points_style = meshPointsStyle(id)
88
100
  return viewer_call(
89
101
  { schema: mesh_points_schemas.size, params: { id, size } },
90
102
  {
91
103
  response_function: () => {
92
- points_style.size = size
93
- console.log(`${setMeshPointsSize.name} ${id} ${meshPointsSize(id)}`)
104
+ meshPointsStyle(id).size = size
105
+ console.log(setMeshPointsSize.name, { id }, meshPointsSize(id))
94
106
  },
95
107
  },
96
108
  )
97
109
  }
98
110
 
99
- function applyMeshPointsStyle(id, style) {
111
+ function applyMeshPointsStyle(id) {
112
+ const style = meshPointsStyle(id)
100
113
  return Promise.all([
101
114
  setMeshPointsVisibility(id, style.visibility),
102
115
  setMeshPointsActiveColoring(id, style.coloring.active),
@@ -1,4 +1,7 @@
1
+ // Third party imports
1
2
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local constants
2
5
  const mesh_polygons_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polygons
3
6
 
4
7
  export function useMeshPolygonsStyle() {
@@ -19,7 +22,9 @@ export function useMeshPolygonsStyle() {
19
22
  response_function: () => {
20
23
  polygons_style.visibility = visibility
21
24
  console.log(
22
- `${setMeshPolygonsVisibility.name} ${id} ${meshPolygonsVisibility(id)}`,
25
+ setMeshPolygonsVisibility.name,
26
+ { id },
27
+ meshPolygonsVisibility(id),
23
28
  )
24
29
  },
25
30
  },
@@ -37,7 +42,9 @@ export function useMeshPolygonsStyle() {
37
42
  response_function: () => {
38
43
  coloring_style.color = color
39
44
  console.log(
40
- `${setMeshPolygonsColor.name} ${id} ${JSON.stringify(meshPolygonsColor(id))}`,
45
+ setMeshPolygonsColor.name,
46
+ { id },
47
+ JSON.stringify(meshPolygonsColor(id)),
41
48
  )
42
49
  },
43
50
  },
@@ -58,7 +65,9 @@ export function useMeshPolygonsStyle() {
58
65
  response_function: () => {
59
66
  coloring_style.textures = textures
60
67
  console.log(
61
- `${setMeshPolygonsTextures.name} ${id} ${meshPolygonsTextures(id)}`,
68
+ setMeshPolygonsTextures.name,
69
+ { id },
70
+ meshPolygonsTextures(id),
62
71
  )
63
72
  },
64
73
  },
@@ -80,7 +89,9 @@ export function useMeshPolygonsStyle() {
80
89
  response_function: () => {
81
90
  coloring_style.vertex = vertex_attribute
82
91
  console.log(
83
- `${setMeshPolygonsVertexAttribute.name} ${id} ${meshPolygonsVertexAttribute(id)}`,
92
+ setMeshPolygonsVertexAttribute.name,
93
+ { id },
94
+ meshPolygonsVertexAttribute(id),
84
95
  )
85
96
  },
86
97
  },
@@ -101,7 +112,9 @@ export function useMeshPolygonsStyle() {
101
112
  response_function: () => {
102
113
  coloring_style.polygon = polygon_attribute
103
114
  console.log(
104
- `${setMeshPolygonsPolygonAttribute.name} ${id} ${meshPolygonsPolygonAttribute(id)}`,
115
+ setMeshPolygonsPolygonAttribute.name,
116
+ { id },
117
+ meshPolygonsPolygonAttribute(id),
105
118
  )
106
119
  },
107
120
  },
@@ -115,7 +128,9 @@ export function useMeshPolygonsStyle() {
115
128
  const coloring = meshPolygonsStyle(id).coloring
116
129
  coloring.active = type
117
130
  console.log(
118
- `${setMeshPolygonsActiveColoring.name} ${id} ${meshPolygonsActiveColoring(id)}`,
131
+ setMeshPolygonsActiveColoring.name,
132
+ { id },
133
+ meshPolygonsActiveColoring(id),
119
134
  )
120
135
  if (type === "color") {
121
136
  return setMeshPolygonsColor(id, coloring.color)
@@ -125,10 +140,13 @@ export function useMeshPolygonsStyle() {
125
140
  return setMeshPolygonsVertexAttribute(id, coloring.vertex)
126
141
  } else if (type === "polygon" && coloring.polygon !== null) {
127
142
  return setMeshPolygonsPolygonAttribute(id, coloring.polygon)
128
- } else throw new Error("Unknown polygons coloring type: " + type)
143
+ } else {
144
+ throw new Error("Unknown mesh polygons coloring type: " + type)
145
+ }
129
146
  }
130
147
 
131
- function applyMeshPolygonsStyle(id, style) {
148
+ function applyMeshPolygonsStyle(id) {
149
+ const style = meshPolygonsStyle(id)
132
150
  return Promise.all([
133
151
  setMeshPolygonsVisibility(id, style.visibility),
134
152
  setMeshPolygonsActiveColoring(id, style.coloring.active),
@@ -1,5 +1,7 @@
1
1
  // Third party imports
2
2
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3
+
4
+ // Local constants
3
5
  const mesh_polyhedra_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polyhedra
4
6
 
5
7
  export function useMeshPolyhedraStyle() {
@@ -20,7 +22,9 @@ export function useMeshPolyhedraStyle() {
20
22
  response_function: () => {
21
23
  polyhedra_style.visibility = visibility
22
24
  console.log(
23
- `${setMeshPolyhedraVisibility.name} ${id} ${meshPolyhedraVisibility(id)}`,
25
+ setMeshPolyhedraVisibility.name,
26
+ { id },
27
+ meshPolyhedraVisibility(id),
24
28
  )
25
29
  },
26
30
  },
@@ -33,7 +37,9 @@ export function useMeshPolyhedraStyle() {
33
37
  const coloring = meshPolyhedraStyle(id).coloring
34
38
  coloring.active = type
35
39
  console.log(
36
- `${setMeshPolyhedraActiveColoring.name} ${id} ${meshPolyhedraActiveColoring(id)}`,
40
+ setMeshPolyhedraActiveColoring.name,
41
+ { id },
42
+ meshPolyhedraActiveColoring(id),
37
43
  )
38
44
  if (type === "color") {
39
45
  return setMeshPolyhedraColor(id, coloring.color)
@@ -41,7 +47,9 @@ export function useMeshPolyhedraStyle() {
41
47
  // return setPolyhedraVertexAttribute(id, coloring.vertex)
42
48
  // } else if (type === "polyhedron" && coloring.polyhedron !== null) {
43
49
  // return setPolyhedraPolyhedronAttribute(id, coloring.polyhedron)
44
- } else throw new Error("Unknown mesh polyhedra coloring type: " + type)
50
+ } else {
51
+ throw new Error("Unknown mesh polyhedra coloring type: " + type)
52
+ }
45
53
  }
46
54
 
47
55
  function meshPolyhedraColor(id) {
@@ -55,7 +63,9 @@ export function useMeshPolyhedraStyle() {
55
63
  response_function: () => {
56
64
  coloring.color = color
57
65
  console.log(
58
- `${setMeshPolyhedraColor.name} ${id} ${JSON.stringify(meshPolyhedraColor(id))}`,
66
+ setMeshPolyhedraColor.name,
67
+ { id },
68
+ JSON.stringify(meshPolyhedraColor(id)),
59
69
  )
60
70
  },
61
71
  },
@@ -76,7 +86,7 @@ export function useMeshPolyhedraStyle() {
76
86
  // response_function: () => {
77
87
  // coloring_style.vertex = vertex_attribute
78
88
  // console.log(
79
- // `${setPolyhedraVertexAttribute.name} ${polyhedraVertexAttribute(id)}`,
89
+ // setPolyhedraVertexAttribute.name} ${polyhedraVertexAttribute(id),
80
90
  // )
81
91
  // },
82
92
  // },
@@ -97,7 +107,7 @@ export function useMeshPolyhedraStyle() {
97
107
  // response_function: () => {
98
108
  // coloring_style.polygon = polygon_attribute
99
109
  // console.log(
100
- // `${setPolyhedraPolygonAttribute.name} ${polyhedraPolygonAttribute(id)}`,
110
+ // setPolyhedraPolygonAttribute.name} ${polyhedraPolygonAttribute(id),
101
111
  // )
102
112
  // },
103
113
  // },
@@ -118,14 +128,15 @@ export function useMeshPolyhedraStyle() {
118
128
  // response_function: () => {
119
129
  // coloring.polyhedron = polyhedron_attribute
120
130
  // console.log(
121
- // `${setPolyhedraPolyhedronAttribute.name} ${polyhedraPolyhedronAttribute(id)}`,
131
+ // setPolyhedraPolyhedronAttribute.name} ${polyhedraPolyhedronAttribute(id),
122
132
  // )
123
133
  // },
124
134
  // },
125
135
  // )
126
136
  // }
127
137
 
128
- function applyMeshPolyhedraStyle(id, style) {
138
+ function applyMeshPolyhedraStyle(id) {
139
+ const style = meshPolyhedraStyle(id)
129
140
  return Promise.all([
130
141
  setMeshPolyhedraVisibility(id, style.visibility),
131
142
  setMeshPolyhedraActiveColoring(id, style.coloring.active),
@@ -1,58 +1,98 @@
1
+ // Third party imports
1
2
  import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
2
- import _ from "lodash"
3
- const blocks_schemas = viewer_schemas.opengeodeweb_viewer.model.blocks
4
3
 
5
- export function useBlocksStyle() {
6
- /** State **/
4
+ // Local constants
5
+ const model_blocks_schemas = viewer_schemas.opengeodeweb_viewer.model.blocks
6
+
7
+ export function useModelBlocksStyle() {
7
8
  const dataStyleStore = useDataStyleStore()
8
9
  const dataBaseStore = useDataBaseStore()
9
10
 
10
- /** Getters **/
11
- function blockVisibility(id, block_id) {
12
- return dataStyleStore.styles[id].blocks[block_id].visibility
11
+ function modelBlocksStyle(id) {
12
+ return dataStyleStore.getStyle(id).blocks
13
+ }
14
+ function modelBlockStyle(id, block_id) {
15
+ if (!modelBlocksStyle(id)[block_id]) {
16
+ modelBlocksStyle(id)[block_id] = {}
17
+ }
18
+ return modelBlocksStyle(id)[block_id]
19
+ }
20
+
21
+ function modelBlockVisibility(id, block_id) {
22
+ return modelBlockStyle(id, block_id).visibility
13
23
  }
14
24
 
15
- /** Actions **/
16
- function setBlockVisibility(id, block_ids, visibility) {
17
- const block_flat_indexes = dataBaseStore.getFlatIndexes(id, block_ids)
25
+ function saveModelBlockVisibility(id, block_id, visibility) {
26
+ modelBlockStyle(id, block_id).visibility = visibility
27
+ }
28
+ function setModelBlocksVisibility(id, block_ids, visibility) {
29
+ const blocks_flat_indexes = dataBaseStore.getFlatIndexes(id, block_ids)
18
30
  return viewer_call(
19
31
  {
20
- schema: blocks_schemas.visibility,
21
- params: { id, block_ids: block_flat_indexes, visibility },
32
+ schema: model_blocks_schemas.visibility,
33
+ params: { id, block_ids: blocks_flat_indexes, visibility },
22
34
  },
23
35
  {
24
36
  response_function: () => {
25
37
  for (const block_id of block_ids) {
26
- if (!dataStyleStore.styles[id].blocks[block_id])
27
- dataStyleStore.styles[id].blocks[block_id] = {}
28
- dataStyleStore.styles[id].blocks[block_id].visibility = visibility
38
+ saveModelBlockVisibility(id, block_id, visibility)
29
39
  }
30
- console.log("setBlockVisibility", block_ids, visibility)
40
+ console.log(
41
+ setModelBlocksVisibility.name,
42
+ { id },
43
+ { block_ids },
44
+ modelBlockVisibility(id, block_ids[0]),
45
+ )
31
46
  },
32
47
  },
33
48
  )
34
49
  }
50
+ function modelBlockColor(id, block_id) {
51
+ return modelBlockStyle(id, block_id).color
52
+ }
53
+
54
+ function saveModelBlockColor(id, block_id, color) {
55
+ modelBlockStyle(id, block_id).color = color
56
+ }
57
+
58
+ function setModelBlocksColor(id, block_ids, color) {
59
+ const blocks_flat_indexes = dataBaseStore.getFlatIndexes(id, block_ids)
60
+ return viewer_call(
61
+ {
62
+ schema: model_blocks_schemas.color,
63
+ params: { id, block_ids: blocks_flat_indexes, color },
64
+ },
65
+ {
66
+ response_function: () => {
67
+ for (const block_id of block_ids) {
68
+ saveModelBlockColor(id, block_id, color)
69
+ }
35
70
 
36
- function setBlocksDefaultStyle(id) {
37
- const block_ids = dataBaseStore.getBlocksUuids(id)
38
- setBlockVisibility(
39
- id,
40
- block_ids,
41
- dataStyleStore.styles[id].blocks.visibility,
71
+ console.log(
72
+ setModelBlocksColor.name,
73
+ { id },
74
+ { block_ids },
75
+ JSON.stringify(modelBlockColor(id, block_ids[0])),
76
+ )
77
+ },
78
+ },
42
79
  )
43
80
  }
44
81
 
45
- function applyBlocksStyle(id) {
46
- const blocks = dataStyleStore.styles[id].blocks
47
- for (const [block_id, style] of Object.entries(blocks)) {
48
- setBlockVisibility(id, [block_id], style.visibility)
49
- }
82
+ function applyModelBlocksStyle(id) {
83
+ const style = modelBlocksStyle(id)
84
+ const blocks_ids = dataBaseStore.getBlocksUuids(id)
85
+ return Promise.all([
86
+ setModelBlocksVisibility(id, blocks_ids, style.visibility),
87
+ setModelBlocksColor(id, blocks_ids, style.color),
88
+ ])
50
89
  }
51
90
 
52
91
  return {
53
- blockVisibility,
54
- setBlocksDefaultStyle,
55
- setBlockVisibility,
56
- applyBlocksStyle,
92
+ modelBlockVisibility,
93
+ modelBlockColor,
94
+ setModelBlocksVisibility,
95
+ setModelBlocksColor,
96
+ applyModelBlocksStyle,
57
97
  }
58
98
  }