Skip to content

Commit 3aa1331

Browse files
wip refactor tests & data style stores
1 parent b58ef13 commit 3aa1331

32 files changed

+988
-840
lines changed

components/Viewer/Generic/Mesh/EdgesOptions.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,22 @@
2828
const dataStyleStore = useDataStyleStore()
2929
3030
const visibility = computed({
31-
get: () => dataStyleStore.edgesVisibility(id.value),
32-
set: (newValue) => dataStyleStore.setEdgesVisibility(id.value, newValue),
31+
get: () => dataStyleStore.meshEdgesVisibility(id.value),
32+
set: (newValue) =>
33+
dataStyleStore.setMeshEdgesVisibility(id.value, newValue),
3334
})
3435
const size = computed({
3536
get: () => dataStyleStore.edgesSize(id.value),
3637
set: (newValue) => dataStyleStore.setEdgesSize(id.value, newValue),
3738
})
3839
const coloring_style_key = computed({
39-
get: () => dataStyleStore.edgesActiveColoring(id.value),
40+
get: () => dataStyleStore.meshEdgesActiveColoring(id.value),
4041
set: (newValue) => {
41-
dataStyleStore.setEdgesActiveColoring(id.value, newValue)
42+
dataStyleStore.setMeshEdgesActiveColoring(id.value, newValue)
4243
},
4344
})
4445
const color = computed({
45-
get: () => dataStyleStore.edgesColor(id.value),
46-
set: (newValue) => dataStyleStore.setEdgesColor(id.value, newValue),
46+
get: () => dataStyleStore.meshEdgesColor(id.value),
47+
set: (newValue) => dataStyleStore.setMeshEdgesColor(id.value, newValue),
4748
})
4849
</script>

components/Viewer/Generic/Mesh/PolygonsOptions.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,34 @@
3232
const id = toRef(() => props.itemProps.id)
3333
3434
const visibility = computed({
35-
get: () => dataStyleStore.polygonsVisibility(id.value),
36-
set: (newValue) => dataStyleStore.setPolygonsVisibility(id.value, newValue),
35+
get: () => dataStyleStore.meshPolygonsVisibility(id.value),
36+
set: (newValue) =>
37+
dataStyleStore.setMeshPolygonsVisibility(id.value, newValue),
3738
})
3839
const coloring_style_key = computed({
39-
get: () => dataStyleStore.polygonsActiveColoring(id.value),
40+
get: () => dataStyleStore.meshPolygonsActiveColoring(id.value),
4041
set: (newValue) =>
41-
dataStyleStore.setPolygonsActiveColoring(id.value, newValue),
42+
dataStyleStore.setMeshPolygonsActiveColoring(id.value, newValue),
4243
})
4344
const color = computed({
44-
get: () => dataStyleStore.polygonsColor(id.value),
45-
set: (newValue) => dataStyleStore.setPolygonsColor(id.value, newValue),
45+
get: () => dataStyleStore.meshPolygonsColor(id.value),
46+
set: (newValue) => dataStyleStore.setMeshPolygonsColor(id.value, newValue),
4647
})
4748
const textures = computed({
48-
get: () => dataStyleStore.polygonsTextures(id.value),
49-
set: (newValue) => dataStyleStore.setPolygonsTextures(id.value, newValue),
49+
get: () => dataStyleStore.meshPolygonsTextures(id.value),
50+
set: (newValue) =>
51+
dataStyleStore.setMeshPolygonsTextures(id.value, newValue),
5052
})
5153
const vertex_attribute = computed({
52-
get: () => dataStyleStore.polygonsVertexAttribute(id.value),
54+
get: () => dataStyleStore.meshPolygonsVertexAttribute(id.value),
5355
set: (newValue) => {
54-
console.log("setPolygonsVertexAttribute", id.value, newValue)
55-
dataStyleStore.setPolygonsVertexAttribute(id.value, newValue)
56+
dataStyleStore.setMeshPolygonsVertexAttribute(id.value, newValue)
5657
},
5758
})
5859
const polygon_attribute = computed({
59-
get: () => dataStyleStore.polygonsPolygonAttribute(id.value),
60+
get: () => dataStyleStore.meshPolygonsPolygonAttribute(id.value),
6061
set: (newValue) => {
61-
console.log("setPolygonsPolygonAttribute", id.value, newValue)
62-
dataStyleStore.setPolygonsPolygonAttribute(id.value, newValue)
62+
dataStyleStore.setMeshPolygonsPolygonAttribute(id.value, newValue)
6363
},
6464
})
6565
</script>

components/Viewer/Generic/Mesh/PolyhedraOptions.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@
3232
const id = toRef(() => props.itemProps.id)
3333
3434
const visibility = computed({
35-
get: () => dataStyleStore.polyhedraVisibility(id.value),
35+
get: () => dataStyleStore.meshPolyhedraVisibility(id.value),
3636
set: (newValue) =>
37-
dataStyleStore.setPolyhedraVisibility(id.value, newValue),
37+
dataStyleStore.setMeshPolyhedraVisibility(id.value, newValue),
3838
})
3939
const coloring_style_key = computed({
40-
get: () => dataStyleStore.polyhedraActiveColoring(id.value),
40+
get: () => dataStyleStore.meshPolyhedraActiveColoring(id.value),
4141
set: (newValue) =>
42-
dataStyleStore.setPolyhedraActiveColoring(id.value, newValue),
42+
dataStyleStore.setMeshPolyhedraActiveColoring(id.value, newValue),
4343
})
4444
const color = computed({
45-
get: () => dataStyleStore.polyhedraColor(id.value),
46-
set: (newValue) => dataStyleStore.setPolyhedraColor(id.value, newValue),
45+
get: () => dataStyleStore.meshPolyhedraColor(id.value),
46+
set: (newValue) => dataStyleStore.setMeshPolyhedraColor(id.value, newValue),
4747
})
4848
const vertex_attribute = computed({
4949
get: () => dataStyleStore.polyhedraVertexAttribute(id.value),

internal_stores/mesh/edges.js

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,101 @@
1+
// Third party imports
12
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
23
const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
34

45
export function useMeshEdgesStyle() {
56
const dataStyleStore = useDataStyleStore()
67

7-
function edgesStyle(id) {
8+
function meshEdgesStyle(id) {
89
return dataStyleStore.getStyle(id).edges
910
}
1011

11-
function edgesVisibility(id) {
12-
return edgesStyle(id).visibility
12+
function meshEdgesVisibility(id) {
13+
return meshEdgesStyle(id).visibility
1314
}
14-
function setEdgesVisibility(id, visibility) {
15-
const edges_style = edgesStyle(id)
15+
function setMeshEdgesVisibility(id, visibility) {
16+
const mesh_edges_style = meshEdgesStyle(id)
1617
return viewer_call(
1718
{ schema: mesh_edges_schemas.visibility, params: { id, visibility } },
1819
{
1920
response_function: () => {
20-
edges_style.visibility = visibility
21+
mesh_edges_style.visibility = visibility
2122
console.log(
22-
`${setEdgesVisibility.name} ${id} ${setEdgesVisibility(id)}`,
23+
`${setMeshEdgesVisibility.name} ${id} ${meshEdgesVisibility(id)}`,
2324
)
2425
},
2526
},
2627
)
2728
}
2829

29-
function edgesActiveColoring(id) {
30+
function meshEdgesActiveColoring(id) {
3031
return edgesStyle(id).coloring.active
3132
}
32-
function setEdgesActiveColoring(id, type) {
33+
function setMeshEdgesActiveColoring(id, type) {
3334
const coloring = edgesStyle(id).coloring
3435
coloring.active = type
3536
console.log(
36-
`${setEdgesActiveColoring.name} ${id} ${edgesActiveColoring(id)}`,
37+
`${setMeshEdgesActiveColoring.name} ${id} ${meshEdgesActiveColoring(id)}`,
3738
)
3839
if (type === "color") {
39-
return setEdgesColor(id, coloring.color)
40+
return setMeshEdgesColor(id, coloring.color)
4041
// } else if (type == "vertex" && coloring.vertex !== null) {
4142
// return setEdgesVertexAttribute(id, coloring.vertex)
4243
// } else if (type == "edges" && coloring.edges !== null) {
4344
// return setEdgesEdgeAttribute(id, coloring.edges)
4445
} else throw new Error("Unknown edges coloring type: " + type)
4546
}
4647

47-
function edgesColor(id) {
48-
return edgesStyle(id).coloring.color
48+
function meshEdgesColor(id) {
49+
return meshEdgesStyle(id).coloring.color
4950
}
50-
function setEdgesColor(id, color) {
51-
const coloring_style = edgesStyle(id).coloring
51+
function setMeshEdgesColor(id, color) {
52+
const coloring_style = meshEdgesStyle(id).coloring
5253
return viewer_call(
5354
{ schema: mesh_edges_schemas.color, params: { id, color } },
5455
{
5556
response_function: () => {
5657
coloring_style.color = color
5758
console.log(
58-
`${setEdgesColor.name} ${id} ${JSON.stringify(edgesColor(id))}`,
59+
`${setMeshEdgesColor.name} ${id} ${JSON.stringify(meshEdgesColor(id))}`,
5960
)
6061
},
6162
},
6263
)
6364
}
6465

65-
function edgesWidth(id) {
66-
return edgesStyle(id).size
66+
function meshEdgesWidth(id) {
67+
return meshEdgesStyle(id).size
6768
}
68-
function setEdgesWidth(id, width) {
69-
const edges_style = edgesStyle(id)
69+
function setMeshEdgesWidth(id, width) {
70+
const edges_style = meshEdgesStyle(id)
7071
return viewer_call(
7172
{ schema: mesh_edges_schemas.width, params: { id, width } },
7273
{
7374
response_function: () => {
7475
edges_style.width = width
75-
console.log(`${setEdgesWidth.name} ${id} ${edgesWidth(id)}`)
76+
console.log(`${setMeshEdgesWidth.name} ${id} ${meshEdgesWidth(id)}`)
7677
},
7778
},
7879
)
7980
}
8081

81-
function applyEdgesStyle(id, style) {
82+
function applyMeshEdgesStyle(id, style) {
8283
return Promise.all([
83-
setEdgesVisibility(id, style.visibility),
84-
setEdgesActiveColoring(id, style.coloring.active),
85-
// setEdgesWidth(id, style.width);
84+
setMeshEdgesVisibility(id, style.visibility),
85+
setMeshEdgesActiveColoring(id, style.coloring.active),
86+
// setMeshEdgesWidth(id, style.width);
8687
])
8788
}
8889

8990
return {
90-
applyEdgesStyle,
91-
edgesActiveColoring,
92-
edgesColor,
93-
edgesVisibility,
94-
edgesWidth,
95-
setEdgesActiveColoring,
96-
setEdgesColor,
97-
setEdgesVisibility,
98-
setEdgesWidth,
91+
applyMeshEdgesStyle,
92+
meshEdgesActiveColoring,
93+
meshEdgesColor,
94+
meshEdgesVisibility,
95+
meshEdgesWidth,
96+
setMeshEdgesActiveColoring,
97+
setMeshEdgesColor,
98+
setMeshEdgesVisibility,
99+
setMeshEdgesWidth,
99100
}
100101
}

internal_stores/mesh/index.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// Third party imports
12
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3+
4+
// Local imports
25
import { useMeshPointsStyle } from "./points.js"
36
import { useMeshEdgesStyle } from "./edges.js"
47
import { useMeshPolygonsStyle } from "./polygons.js"
@@ -8,8 +11,8 @@ export default function useMeshStyle() {
811
const dataStyleStore = useDataStyleStore()
912
const pointsStyleStore = useMeshPointsStyle()
1013
const edgesStyleStore = useMeshEdgesStyle()
11-
const polygonsStyleStore = useMeshPolygonsStyle()
12-
const polyhedraStyleStore = useMeshPolyhedraStyle()
14+
const meshPolygonsStyleStore = useMeshPolygonsStyle()
15+
const meshPolyhedraStyleStore = useMeshPolyhedraStyle()
1316
const hybridViewerStore = useHybridViewerStore()
1417

1518
function setMeshVisibility(id, visibility) {
@@ -37,11 +40,15 @@ export default function useMeshStyle() {
3740
} else if (key == "points") {
3841
promise_array.push(pointsStyleStore.applyPointsStyle(id, value))
3942
} else if (key == "edges") {
40-
promise_array.push(edgesStyleStore.applyEdgesStyle(id, value))
43+
promise_array.push(edgesStyleStore.applyMeshEdgesStyle(id, value))
4144
} else if (key == "polygons") {
42-
promise_array.push(polygonsStyleStore.applyPolygonsStyle(id, value))
45+
promise_array.push(
46+
meshPolygonsStyleStore.applyMeshPolygonsStyle(id, value),
47+
)
4348
} else if (key == "polyhedra") {
44-
promise_array.push(polyhedraStyleStore.applyPolyhedraStyle(id, value))
49+
promise_array.push(
50+
meshPolyhedraStyleStore.applyMeshPolyhedraStyle(id, value),
51+
)
4552
}
4653
}
4754
return promise_array

0 commit comments

Comments
 (0)