Skip to content

Commit 38e6c53

Browse files
authored
Merge pull request #250 from Geode-solutions/test/integration_model
Test/integration model
2 parents 22237a1 + 9f60ded commit 38e6c53

38 files changed

+1464
-492
lines changed

components/Viewer/TreeComponent.vue

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,42 @@
4040
removed_blocks,
4141
] = sortMeshComponents(removed)
4242
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+
)
4448
if (added_lines.length > 0)
45-
dataStyleStore.setLineVisibility(props.id, added_lines, true)
49+
dataStyleStore.setModelLinesVisibility(props.id, added_lines, true)
4650
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+
)
4856
if (added_blocks.length > 0)
49-
dataStyleStore.setBlockVisibility(props.id, added_blocks, true)
57+
dataStyleStore.setModelBlocksVisibility(props.id, added_blocks, true)
5058
5159
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+
)
5365
if (removed_lines.length > 0)
54-
dataStyleStore.setLineVisibility(props.id, removed_lines, false)
66+
dataStyleStore.setModelLinesVisibility(props.id, removed_lines, false)
5567
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+
)
5773
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+
)
5979
}
6080
},
6181
{ immediate: true, deep: true },

internal_stores/data_style_state.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ 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) => {
7+
if (styles[id]) {
8+
return styles[id].visibility
9+
}
10+
return false
11+
})
712
const selectedObjects = computed(() => {
813
const selection = []
914
for (const [id, value] of Object.entries(styles)) {

internal_stores/mesh/edges.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Third party imports
22
import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json"
3+
4+
// Local constants
35
const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges
46

57
export function useMeshEdgesStyle() {
@@ -13,14 +15,15 @@ export function useMeshEdgesStyle() {
1315
return meshEdgesStyle(id).visibility
1416
}
1517
function setMeshEdgesVisibility(id, visibility) {
16-
const mesh_edges_style = meshEdgesStyle(id)
1718
return viewer_call(
1819
{ schema: mesh_edges_schemas.visibility, params: { id, visibility } },
1920
{
2021
response_function: () => {
21-
mesh_edges_style.visibility = visibility
22+
meshEdgesStyle(id).visibility = visibility
2223
console.log(
23-
`${setMeshEdgesVisibility.name} ${id} ${meshEdgesVisibility(id)}`,
24+
setMeshEdgesVisibility.name,
25+
{ id },
26+
meshEdgesVisibility(id),
2427
)
2528
},
2629
},
@@ -34,15 +37,19 @@ export function useMeshEdgesStyle() {
3437
const coloring = meshEdgesStyle(id).coloring
3538
coloring.active = type
3639
console.log(
37-
`${setMeshEdgesActiveColoring.name} ${id} ${meshEdgesActiveColoring(id)}`,
40+
setMeshEdgesActiveColoring.name,
41+
{ id },
42+
meshEdgesActiveColoring(id),
3843
)
3944
if (type === "color") {
4045
return setMeshEdgesColor(id, coloring.color)
4146
// } else if (type == "vertex" && coloring.vertex !== null) {
4247
// return setEdgesVertexAttribute(id, coloring.vertex)
4348
// } else if (type == "edges" && coloring.edges !== null) {
4449
// 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+
}
4653
}
4754

4855
function meshEdgesColor(id) {
@@ -56,7 +63,9 @@ export function useMeshEdgesStyle() {
5663
response_function: () => {
5764
coloring_style.color = color
5865
console.log(
59-
`${setMeshEdgesColor.name} ${id} ${JSON.stringify(meshEdgesColor(id))}`,
66+
setMeshEdgesColor.name,
67+
{ id },
68+
JSON.stringify(meshEdgesColor(id)),
6069
)
6170
},
6271
},
@@ -73,13 +82,14 @@ export function useMeshEdgesStyle() {
7382
{
7483
response_function: () => {
7584
edges_style.width = width
76-
console.log(`${setMeshEdgesWidth.name} ${id} ${meshEdgesWidth(id)}`)
85+
console.log(setMeshEdgesWidth.name, { id }, meshEdgesWidth(id))
7786
},
7887
},
7988
)
8089
}
8190

82-
function applyMeshEdgesStyle(id, style) {
91+
function applyMeshEdgesStyle(id) {
92+
const style = meshEdgesStyle(id)
8393
return Promise.all([
8494
setMeshEdgesVisibility(id, style.visibility),
8595
setMeshEdgesActiveColoring(id, style.coloring.active),

internal_stores/mesh/index.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { useMeshEdgesStyle } from "./edges.js"
77
import { useMeshPolygonsStyle } from "./polygons.js"
88
import { useMeshPolyhedraStyle } from "./polyhedra.js"
99

10+
// Local constants
11+
const mesh_schemas = viewer_schemas.opengeodeweb_viewer.mesh
12+
1013
export default function useMeshStyle() {
1114
const dataStyleStore = useDataStyleStore()
1215
const pointsStyleStore = useMeshPointsStyle()
@@ -16,51 +19,49 @@ export default function useMeshStyle() {
1619
const hybridViewerStore = useHybridViewerStore()
1720

1821
function meshVisibility(id) {
19-
return dataStyleStore.styles[id].visibility
22+
return dataStyleStore.getStyle(id).visibility
2023
}
2124
function setMeshVisibility(id, visibility) {
2225
return viewer_call(
2326
{
24-
schema: viewer_schemas.opengeodeweb_viewer.mesh.visibility,
27+
schema: mesh_schemas.visibility,
2528
params: { id, visibility },
2629
},
2730
{
2831
response_function: () => {
2932
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))
3235
},
3336
},
3437
)
3538
}
3639

37-
function applyMeshDefaultStyle(id) {
40+
function applyMeshStyle(id) {
3841
const style = dataStyleStore.getStyle(id)
3942
const promise_array = []
4043
for (const [key, value] of Object.entries(style)) {
41-
if (key == "visibility") {
44+
if (key === "visibility") {
4245
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)
5556
}
5657
}
57-
return promise_array
58+
return Promise.all(promise_array)
5859
}
5960

6061
return {
6162
meshVisibility,
6263
setMeshVisibility,
63-
applyMeshDefaultStyle,
64+
applyMeshStyle,
6465
...useMeshPointsStyle(),
6566
...useMeshEdgesStyle(),
6667
...useMeshPolygonsStyle(),

internal_stores/mesh/points.js

Lines changed: 22 additions & 9 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 constants
25
const mesh_points_schemas = viewer_schemas.opengeodeweb_viewer.mesh.points
36

47
export function useMeshPointsStyle() {
@@ -19,7 +22,9 @@ export function useMeshPointsStyle() {
1922
response_function: () => {
2023
points_style.visibility = visibility
2124
console.log(
22-
`${setMeshPointsVisibility.name} ${id} ${meshPointsVisibility(id)}`,
25+
setMeshPointsVisibility.name,
26+
{ id },
27+
meshPointsVisibility(id),
2328
)
2429
},
2530
},
@@ -33,13 +38,17 @@ export function useMeshPointsStyle() {
3338
const coloring = meshPointsStyle(id).coloring
3439
coloring.active = type
3540
console.log(
36-
`${setMeshPointsActiveColoring.name} ${id} ${meshPointsActiveColoring(id)}`,
41+
setMeshPointsActiveColoring.name,
42+
{ id },
43+
meshPointsActiveColoring(id),
3744
)
3845
if (type == "color") {
3946
return dataStyleStore.setMeshPointsColor(id, coloring.color)
4047
} else if (type == "vertex" && coloring.vertex !== null) {
4148
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+
}
4352
}
4453

4554
function meshPointsColor(id) {
@@ -53,7 +62,9 @@ export function useMeshPointsStyle() {
5362
response_function: () => {
5463
coloring_style.color = color
5564
console.log(
56-
`${setMeshPointsColor.name} ${id} ${JSON.stringify(meshPointsColor(id))}`,
65+
setMeshPointsColor.name,
66+
{ id },
67+
JSON.stringify(meshPointsColor(id)),
5768
)
5869
},
5970
},
@@ -73,7 +84,9 @@ export function useMeshPointsStyle() {
7384
response_function: () => {
7485
coloring_style.vertex = vertex_attribute
7586
console.log(
76-
`${setMeshPointsVertexAttribute.name} ${id} ${meshPointsVertexAttribute(id)}`,
87+
setMeshPointsVertexAttribute.name,
88+
{ id },
89+
meshPointsVertexAttribute(id),
7790
)
7891
},
7992
},
@@ -84,19 +97,19 @@ export function useMeshPointsStyle() {
8497
return meshPointsStyle(id).size
8598
}
8699
function setMeshPointsSize(id, size) {
87-
const points_style = meshPointsStyle(id)
88100
return viewer_call(
89101
{ schema: mesh_points_schemas.size, params: { id, size } },
90102
{
91103
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))
94106
},
95107
},
96108
)
97109
}
98110

99-
function applyMeshPointsStyle(id, style) {
111+
function applyMeshPointsStyle(id) {
112+
const style = meshPointsStyle(id)
100113
return Promise.all([
101114
setMeshPointsVisibility(id, style.visibility),
102115
setMeshPointsActiveColoring(id, style.coloring.active),

internal_stores/mesh/polygons.js

Lines changed: 26 additions & 8 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 constants
25
const mesh_polygons_schemas = viewer_schemas.opengeodeweb_viewer.mesh.polygons
36

47
export function useMeshPolygonsStyle() {
@@ -19,7 +22,9 @@ export function useMeshPolygonsStyle() {
1922
response_function: () => {
2023
polygons_style.visibility = visibility
2124
console.log(
22-
`${setMeshPolygonsVisibility.name} ${id} ${meshPolygonsVisibility(id)}`,
25+
setMeshPolygonsVisibility.name,
26+
{ id },
27+
meshPolygonsVisibility(id),
2328
)
2429
},
2530
},
@@ -37,7 +42,9 @@ export function useMeshPolygonsStyle() {
3742
response_function: () => {
3843
coloring_style.color = color
3944
console.log(
40-
`${setMeshPolygonsColor.name} ${id} ${JSON.stringify(meshPolygonsColor(id))}`,
45+
setMeshPolygonsColor.name,
46+
{ id },
47+
JSON.stringify(meshPolygonsColor(id)),
4148
)
4249
},
4350
},
@@ -58,7 +65,9 @@ export function useMeshPolygonsStyle() {
5865
response_function: () => {
5966
coloring_style.textures = textures
6067
console.log(
61-
`${setMeshPolygonsTextures.name} ${id} ${meshPolygonsTextures(id)}`,
68+
setMeshPolygonsTextures.name,
69+
{ id },
70+
meshPolygonsTextures(id),
6271
)
6372
},
6473
},
@@ -80,7 +89,9 @@ export function useMeshPolygonsStyle() {
8089
response_function: () => {
8190
coloring_style.vertex = vertex_attribute
8291
console.log(
83-
`${setMeshPolygonsVertexAttribute.name} ${id} ${meshPolygonsVertexAttribute(id)}`,
92+
setMeshPolygonsVertexAttribute.name,
93+
{ id },
94+
meshPolygonsVertexAttribute(id),
8495
)
8596
},
8697
},
@@ -101,7 +112,9 @@ export function useMeshPolygonsStyle() {
101112
response_function: () => {
102113
coloring_style.polygon = polygon_attribute
103114
console.log(
104-
`${setMeshPolygonsPolygonAttribute.name} ${id} ${meshPolygonsPolygonAttribute(id)}`,
115+
setMeshPolygonsPolygonAttribute.name,
116+
{ id },
117+
meshPolygonsPolygonAttribute(id),
105118
)
106119
},
107120
},
@@ -115,7 +128,9 @@ export function useMeshPolygonsStyle() {
115128
const coloring = meshPolygonsStyle(id).coloring
116129
coloring.active = type
117130
console.log(
118-
`${setMeshPolygonsActiveColoring.name} ${id} ${meshPolygonsActiveColoring(id)}`,
131+
setMeshPolygonsActiveColoring.name,
132+
{ id },
133+
meshPolygonsActiveColoring(id),
119134
)
120135
if (type === "color") {
121136
return setMeshPolygonsColor(id, coloring.color)
@@ -125,10 +140,13 @@ export function useMeshPolygonsStyle() {
125140
return setMeshPolygonsVertexAttribute(id, coloring.vertex)
126141
} else if (type === "polygon" && coloring.polygon !== null) {
127142
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+
}
129146
}
130147

131-
function applyMeshPolygonsStyle(id, style) {
148+
function applyMeshPolygonsStyle(id) {
149+
const style = meshPolygonsStyle(id)
132150
return Promise.all([
133151
setMeshPolygonsVisibility(id, style.visibility),
134152
setMeshPolygonsActiveColoring(id, style.coloring.active),

0 commit comments

Comments
 (0)