|
| 1 | +// Third party imports |
1 | 2 | import viewer_schemas from "@geode/opengeodeweb-viewer/opengeodeweb_viewer_schemas.json" |
2 | 3 | const mesh_edges_schemas = viewer_schemas.opengeodeweb_viewer.mesh.edges |
3 | 4 |
|
4 | 5 | export function useMeshEdgesStyle() { |
5 | 6 | const dataStyleStore = useDataStyleStore() |
6 | 7 |
|
7 | | - function edgesStyle(id) { |
| 8 | + function meshEdgesStyle(id) { |
8 | 9 | return dataStyleStore.getStyle(id).edges |
9 | 10 | } |
10 | 11 |
|
11 | | - function edgesVisibility(id) { |
12 | | - return edgesStyle(id).visibility |
| 12 | + function meshEdgesVisibility(id) { |
| 13 | + return meshEdgesStyle(id).visibility |
13 | 14 | } |
14 | | - function setEdgesVisibility(id, visibility) { |
15 | | - const edges_style = edgesStyle(id) |
| 15 | + function setMeshEdgesVisibility(id, visibility) { |
| 16 | + const mesh_edges_style = meshEdgesStyle(id) |
16 | 17 | return viewer_call( |
17 | 18 | { schema: mesh_edges_schemas.visibility, params: { id, visibility } }, |
18 | 19 | { |
19 | 20 | response_function: () => { |
20 | | - edges_style.visibility = visibility |
| 21 | + mesh_edges_style.visibility = visibility |
21 | 22 | console.log( |
22 | | - `${setEdgesVisibility.name} ${id} ${setEdgesVisibility(id)}`, |
| 23 | + `${setMeshEdgesVisibility.name} ${id} ${meshEdgesVisibility(id)}`, |
23 | 24 | ) |
24 | 25 | }, |
25 | 26 | }, |
26 | 27 | ) |
27 | 28 | } |
28 | 29 |
|
29 | | - function edgesActiveColoring(id) { |
| 30 | + function meshEdgesActiveColoring(id) { |
30 | 31 | return edgesStyle(id).coloring.active |
31 | 32 | } |
32 | | - function setEdgesActiveColoring(id, type) { |
| 33 | + function setMeshEdgesActiveColoring(id, type) { |
33 | 34 | const coloring = edgesStyle(id).coloring |
34 | 35 | coloring.active = type |
35 | 36 | console.log( |
36 | | - `${setEdgesActiveColoring.name} ${id} ${edgesActiveColoring(id)}`, |
| 37 | + `${setMeshEdgesActiveColoring.name} ${id} ${meshEdgesActiveColoring(id)}`, |
37 | 38 | ) |
38 | 39 | if (type === "color") { |
39 | | - return setEdgesColor(id, coloring.color) |
| 40 | + return setMeshEdgesColor(id, coloring.color) |
40 | 41 | // } else if (type == "vertex" && coloring.vertex !== null) { |
41 | 42 | // return setEdgesVertexAttribute(id, coloring.vertex) |
42 | 43 | // } else if (type == "edges" && coloring.edges !== null) { |
43 | 44 | // return setEdgesEdgeAttribute(id, coloring.edges) |
44 | 45 | } else throw new Error("Unknown edges coloring type: " + type) |
45 | 46 | } |
46 | 47 |
|
47 | | - function edgesColor(id) { |
48 | | - return edgesStyle(id).coloring.color |
| 48 | + function meshEdgesColor(id) { |
| 49 | + return meshEdgesStyle(id).coloring.color |
49 | 50 | } |
50 | | - function setEdgesColor(id, color) { |
51 | | - const coloring_style = edgesStyle(id).coloring |
| 51 | + function setMeshEdgesColor(id, color) { |
| 52 | + const coloring_style = meshEdgesStyle(id).coloring |
52 | 53 | return viewer_call( |
53 | 54 | { schema: mesh_edges_schemas.color, params: { id, color } }, |
54 | 55 | { |
55 | 56 | response_function: () => { |
56 | 57 | coloring_style.color = color |
57 | 58 | console.log( |
58 | | - `${setEdgesColor.name} ${id} ${JSON.stringify(edgesColor(id))}`, |
| 59 | + `${setMeshEdgesColor.name} ${id} ${JSON.stringify(meshEdgesColor(id))}`, |
59 | 60 | ) |
60 | 61 | }, |
61 | 62 | }, |
62 | 63 | ) |
63 | 64 | } |
64 | 65 |
|
65 | | - function edgesWidth(id) { |
66 | | - return edgesStyle(id).size |
| 66 | + function meshEdgesWidth(id) { |
| 67 | + return meshEdgesStyle(id).size |
67 | 68 | } |
68 | | - function setEdgesWidth(id, width) { |
69 | | - const edges_style = edgesStyle(id) |
| 69 | + function setMeshEdgesWidth(id, width) { |
| 70 | + const edges_style = meshEdgesStyle(id) |
70 | 71 | return viewer_call( |
71 | 72 | { schema: mesh_edges_schemas.width, params: { id, width } }, |
72 | 73 | { |
73 | 74 | response_function: () => { |
74 | 75 | edges_style.width = width |
75 | | - console.log(`${setEdgesWidth.name} ${id} ${edgesWidth(id)}`) |
| 76 | + console.log(`${setMeshEdgesWidth.name} ${id} ${meshEdgesWidth(id)}`) |
76 | 77 | }, |
77 | 78 | }, |
78 | 79 | ) |
79 | 80 | } |
80 | 81 |
|
81 | | - function applyEdgesStyle(id, style) { |
| 82 | + function applyMeshEdgesStyle(id, style) { |
82 | 83 | 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); |
86 | 87 | ]) |
87 | 88 | } |
88 | 89 |
|
89 | 90 | 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, |
99 | 100 | } |
100 | 101 | } |
0 commit comments