Skip to content

Commit 6c0cf11

Browse files
test(Integration): front & viewer
1 parent 4b5388b commit 6c0cf11

File tree

13 files changed

+625
-211
lines changed

13 files changed

+625
-211
lines changed

internal_stores/data_style_state.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { reactive, computed } from "vue"
33
export default function useDataStyleState() {
44
const styles = reactive({})
55

6-
const objectVisibility = computed(() => (id) => styles[id]?.visibility)
6+
const objectVisibility = computed(() => (id) => styles[id].visibility)
77
const selectedObjects = computed(() => {
88
const selection = []
99
for (const [id, value] of Object.entries(styles)) {
@@ -14,5 +14,9 @@ export default function useDataStyleState() {
1414
return selection
1515
})
1616

17-
return { styles, objectVisibility, selectedObjects }
17+
function getStyle(id) {
18+
return styles[id]
19+
}
20+
21+
return { getStyle, styles, objectVisibility, selectedObjects }
1822
}

internal_stores/mesh/edges.js

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,31 @@ const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
44
export function useMeshEdgesStyle() {
55
const dataStyleStore = useDataStyleStore()
66

7+
function edgesStyle(id) {
8+
return dataStyleStore.getStyle(id).edges
9+
}
10+
711
function edgesVisibility(id) {
8-
return dataStyleStore.styles[id].edges.visibility
12+
return edgesStyle(id).visibility
913
}
1014
function setEdgesVisibility(id, visibility) {
11-
const edges_style = dataStyleStore.styles[id].edges
15+
const edges_style = edgesStyle(id)
1216
return viewer_call(
13-
{
14-
schema: mesh_edges_schemas.visibility,
15-
params: { id, visibility },
16-
},
17+
{ schema: mesh_edges_schemas.visibility, params: { id, visibility } },
1718
{
1819
response_function: () => {
1920
edges_style.visibility = visibility
20-
console.log(`${setEdgesVisibility.name} ${edges_style.visibility}`)
21+
console.log(`${setEdgesVisibility.name} ${setEdgesVisibility(id)}`)
2122
},
2223
},
2324
)
2425
}
2526

2627
function edgesActiveColoring(id) {
27-
return dataStyleStore.styles[id].edges.coloring.active
28+
return edgesStyle(id).coloring.active
2829
}
2930
async function setEdgesActiveColoring(id, type) {
30-
const coloring = dataStyleStore.styles[id].edges.coloring
31+
const coloring = edgesStyle(id).coloring
3132
if (type == "color") {
3233
setEdgesColor(id, coloring.color)
3334
// else if (type == "vertex") {
@@ -38,44 +39,36 @@ export function useMeshEdgesStyle() {
3839
// if (edges !== null) setEdgesEdgeAttribute(id, edges)
3940
} else throw new Error("Unknown edges coloring type: " + type)
4041
coloring.active = type
41-
console.log(`${setEdgesActiveColoring.name} ${coloring.active}`)
42+
console.log(`${setEdgesActiveColoring.name} ${edgesActiveColoring(id)}`)
4243
}
4344

4445
function edgesColor(id) {
45-
return dataStyleStore.styles[id].edges.coloring.color
46+
return edgesStyle(id).coloring.color
4647
}
4748
function setEdgesColor(id, color) {
48-
const coloring_style = dataStyleStore.styles[id].edges.coloring
49+
const coloring_style = edgesStyle(id).coloring
4950
return viewer_call(
50-
{
51-
schema: mesh_edges_schemas.color,
52-
params: { id, color },
53-
},
51+
{ schema: mesh_edges_schemas.color, params: { id, color } },
5452
{
5553
response_function: () => {
5654
coloring_style.color = color
57-
console.log(
58-
`${setEdgesColor.name} ${JSON.stringify(coloring_style.color)}`,
59-
)
55+
console.log(`${setEdgesColor.name} ${JSON.stringify(edgesColor(id))}`)
6056
},
6157
},
6258
)
6359
}
6460

6561
function edgesWidth(id) {
66-
return dataStyleStore.styles[id].edges.size
62+
return edgesStyle(id).size
6763
}
6864
function setEdgesWidth(id, width) {
69-
const edges_style = dataStyleStore.styles[id].edges
65+
const edges_style = edgesStyle(id)
7066
return viewer_call(
71-
{
72-
schema: mesh_edges_schemas.width,
73-
params: { id, width },
74-
},
67+
{ schema: mesh_edges_schemas.width, params: { id, width } },
7568
{
7669
response_function: () => {
7770
edges_style.width = width
78-
console.log(`${setEdgesWidth.name} ${edges_style.width}`)
71+
console.log(`${setEdgesWidth.name} ${edgesWidth(id)}`)
7972
},
8073
},
8174
)

internal_stores/mesh/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ export default function useMeshStyle() {
2222
response_function: () => {
2323
hybridViewerStore.setVisibility(id, visibility)
2424
dataStyleStore.styles[id].visibility = visibility
25+
console.log(`${setMeshVisibility.name} ${id} ${visibility}`)
2526
},
2627
},
2728
)
2829
}
2930

3031
async function applyMeshDefaultStyle(id) {
3132
return new Promise(async (resolve) => {
32-
const id_style = dataStyleStore.styles[id]
33-
for (const [key, value] of Object.entries(id_style)) {
33+
const style = dataStyleStore.getStyle(id)
34+
for (const [key, value] of Object.entries(style)) {
3435
if (key == "visibility") {
3536
await setMeshVisibility(id, value)
3637
} else if (key == "points") {

internal_stores/mesh/points.js

Lines changed: 45 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,111 +2,96 @@ import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schem
22
const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points
33

44
export function useMeshPointsStyle() {
5-
/** State **/
65
const dataStyleStore = useDataStyleStore()
76

8-
/** Getters **/
9-
function pointsVisibility(id) {
10-
return dataStyleStore.styles[id].points.visibility
11-
}
12-
function pointsActiveColoring(id) {
13-
return dataStyleStore.styles[id].points.coloring.active
14-
}
15-
function pointsColor(id) {
16-
return dataStyleStore.styles[id].points.coloring.color
17-
}
18-
function pointsVertexAttribute(id) {
19-
return dataStyleStore.styles[id].points.coloring.vertex
20-
}
21-
function pointsSize(id) {
22-
return dataStyleStore.styles[id].points.size
7+
function pointsStyle(id) {
8+
return dataStyleStore.getStyle(id).points
239
}
2410

25-
/** Actions **/
11+
function pointsVisibility(id) {
12+
return pointsStyle(id).visibility
13+
}
2614
function setPointsVisibility(id, visibility) {
15+
const points_style = pointsStyle(id)
2716
return viewer_call(
28-
{
29-
schema: mesh_points_schemas.visibility,
30-
params: { id, visibility },
31-
},
17+
{ schema: mesh_points_schemas.visibility, params: { id, visibility } },
3218
{
3319
response_function: () => {
34-
dataStyleStore.styles[id].points.visibility = visibility
35-
console.log(
36-
"setPointsVisibility",
37-
dataStyleStore.styles[id].points.visibility,
38-
)
20+
points_style.visibility = visibility
21+
console.log(`${setPointsVisibility.name} ${pointsVisibility(id)}`)
3922
},
4023
},
4124
)
4225
}
4326

27+
function pointsActiveColoring(id) {
28+
return pointsStyle(id).coloring.active
29+
}
30+
function setPointsActiveColoring(id, type) {
31+
const coloring = pointsStyle(id).coloring
32+
if (type == "color") dataStyleStore.setPointsColor(id, coloring.color)
33+
else if (type == "vertex") {
34+
if (coloring.vertex !== null)
35+
dataStyleStore.setPointsVertexAttribute(id, coloring.vertex)
36+
} else throw new Error("Unknown points coloring type: " + type)
37+
coloring.active = type
38+
console.log(`${setPointsActiveColoring.name} ${pointsActiveColoring(id)}`)
39+
}
40+
41+
function pointsColor(id) {
42+
return pointsStyle(id).coloring.color
43+
}
4444
function setPointsColor(id, color) {
45+
const coloring_style = pointsStyle(id).coloring
4546
return viewer_call(
46-
{
47-
schema: viewer_schemas.opengeodeweb_viewer.mesh.points.color,
48-
params: { id, color },
49-
},
47+
{ schema: mesh_points_schemas.color, params: { id, color } },
5048
{
5149
response_function: () => {
52-
dataStyleStore.styles[id].points.coloring.color = color
50+
coloring_style.color = color
5351
console.log(
54-
"setPointsColor",
55-
dataStyleStore.styles[id].points.coloring.color,
52+
`${setPointsColor.name} ${JSON.stringify(pointsColor(id))}`,
5653
)
5754
},
5855
},
5956
)
6057
}
58+
function pointsVertexAttribute(id) {
59+
return pointsStyle(id).coloring.vertex
60+
}
6161
function setPointsVertexAttribute(id, vertex_attribute) {
62+
const coloring_style = pointsStyle(id).coloring
6263
return viewer_call(
6364
{
64-
schema: viewer_schemas.opengeodeweb_viewer.mesh.points.vertex_attribute,
65+
schema: mesh_points_schemas.vertex_attribute,
6566
params: { id, ...vertex_attribute },
6667
},
6768
{
6869
response_function: () => {
69-
dataStyleStore.styles[id].points.coloring.vertex = vertex_attribute
70+
coloring_style.vertex = vertex_attribute
7071
console.log(
71-
"setPointsVertexAttribute",
72-
dataStyleStore.styles[id].points.coloring.vertex,
72+
`${setPointsVertexAttribute.name} ${pointsVertexAttribute(id)}`,
7373
)
7474
},
7575
},
7676
)
7777
}
78+
79+
function pointsSize(id) {
80+
return pointsStyle(id).size
81+
}
7882
function setPointsSize(id, size) {
83+
const points_style = pointsStyle(id)
7984
return viewer_call(
80-
{
81-
schema: viewer_schemas.opengeodeweb_viewer.mesh.points.size,
82-
params: { id, size },
83-
},
85+
{ schema: mesh_points_schemas.size, params: { id, size } },
8486
{
8587
response_function: () => {
86-
dataStyleStore.styles[id].points.size = size
87-
console.log("setPointsSize", dataStyleStore.styles[id].points.size)
88+
points_style.size = size
89+
console.log(`${setPointsSize.name} ${pointsSize(id)}`)
8890
},
8991
},
9092
)
9193
}
9294

93-
function setPointsActiveColoring(id, type) {
94-
if (type == "color")
95-
dataStyleStore.setPointsColor(
96-
id,
97-
dataStyleStore.styles[id].points.coloring.color,
98-
)
99-
else if (type == "vertex") {
100-
const vertex = dataStyleStore.styles[id].points.coloring.vertex
101-
if (vertex !== null) dataStyleStore.setPointsVertexAttribute(id, vertex)
102-
} else throw new Error("Unknown edges coloring type: " + type)
103-
dataStyleStore.styles[id].points.coloring.active = type
104-
console.log(
105-
"setPointsActiveColoring",
106-
dataStyleStore.styles[id].points.coloring.active,
107-
)
108-
}
109-
11095
function applyPointsStyle(id, style) {
11196
return Promise.all([
11297
setPointsVisibility(id, style.visibility),

0 commit comments

Comments
 (0)