| 
 | 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 |  | -          console.log(`${setEdgesVisibility.name} ${id} ${edgesVisibility(id)}`)  | 
 | 21 | +          mesh_edges_style.visibility = visibility  | 
 | 22 | +          console.log(  | 
 | 23 | +            `${setMeshEdgesVisibility.name} ${id} ${meshEdgesVisibility(id)}`,  | 
 | 24 | +          )  | 
22 | 25 |         },  | 
23 | 26 |       },  | 
24 | 27 |     )  | 
25 | 28 |   }  | 
26 | 29 | 
 
  | 
27 |  | -  function edgesActiveColoring(id) {  | 
28 |  | -    return edgesStyle(id).coloring.active  | 
 | 30 | +  function meshEdgesActiveColoring(id) {  | 
 | 31 | +    return meshEdgesStyle(id).coloring.active  | 
29 | 32 |   }  | 
30 |  | -  function setEdgesActiveColoring(id, type) {  | 
31 |  | -    const coloring = edgesStyle(id).coloring  | 
 | 33 | +  function setMeshEdgesActiveColoring(id, type) {  | 
 | 34 | +    const coloring = meshEdgesStyle(id).coloring  | 
32 | 35 |     coloring.active = type  | 
33 | 36 |     console.log(  | 
34 |  | -      `${setEdgesActiveColoring.name} ${id} ${edgesActiveColoring(id)}`,  | 
 | 37 | +      `${setMeshEdgesActiveColoring.name} ${id} ${meshEdgesActiveColoring(id)}`,  | 
35 | 38 |     )  | 
36 | 39 |     if (type === "color") {  | 
37 |  | -      return setEdgesColor(id, coloring.color)  | 
 | 40 | +      return setMeshEdgesColor(id, coloring.color)  | 
38 | 41 |       // } else if (type == "vertex" && coloring.vertex !== null) {  | 
39 | 42 |       //   return setEdgesVertexAttribute(id, coloring.vertex)  | 
40 | 43 |       // } else if (type == "edges" && coloring.edges !== null) {  | 
41 | 44 |       //   return setEdgesEdgeAttribute(id, coloring.edges)  | 
42 | 45 |     } else throw new Error("Unknown edges coloring type: " + type)  | 
43 | 46 |   }  | 
44 | 47 | 
 
  | 
45 |  | -  function edgesColor(id) {  | 
46 |  | -    return edgesStyle(id).coloring.color  | 
 | 48 | +  function meshEdgesColor(id) {  | 
 | 49 | +    return meshEdgesStyle(id).coloring.color  | 
47 | 50 |   }  | 
48 |  | -  function setEdgesColor(id, color) {  | 
49 |  | -    const coloring_style = edgesStyle(id).coloring  | 
 | 51 | +  function setMeshEdgesColor(id, color) {  | 
 | 52 | +    const coloring_style = meshEdgesStyle(id).coloring  | 
50 | 53 |     return viewer_call(  | 
51 | 54 |       { schema: mesh_edges_schemas.color, params: { id, color } },  | 
52 | 55 |       {  | 
53 | 56 |         response_function: () => {  | 
54 | 57 |           coloring_style.color = color  | 
55 | 58 |           console.log(  | 
56 |  | -            `${setEdgesColor.name} ${id} ${JSON.stringify(edgesColor(id))}`,  | 
 | 59 | +            `${setMeshEdgesColor.name} ${id} ${JSON.stringify(meshEdgesColor(id))}`,  | 
57 | 60 |           )  | 
58 | 61 |         },  | 
59 | 62 |       },  | 
60 | 63 |     )  | 
61 | 64 |   }  | 
62 | 65 | 
 
  | 
63 |  | -  function edgesWidth(id) {  | 
64 |  | -    return edgesStyle(id).size  | 
 | 66 | +  function meshEdgesWidth(id) {  | 
 | 67 | +    return meshEdgesStyle(id).size  | 
65 | 68 |   }  | 
66 |  | -  function setEdgesWidth(id, width) {  | 
67 |  | -    const edges_style = edgesStyle(id)  | 
 | 69 | +  function setMeshEdgesWidth(id, width) {  | 
 | 70 | +    const edges_style = meshEdgesStyle(id)  | 
68 | 71 |     return viewer_call(  | 
69 | 72 |       { schema: mesh_edges_schemas.width, params: { id, width } },  | 
70 | 73 |       {  | 
71 | 74 |         response_function: () => {  | 
72 | 75 |           edges_style.width = width  | 
73 |  | -          console.log(`${setEdgesWidth.name} ${id} ${edgesWidth(id)}`)  | 
 | 76 | +          console.log(`${setMeshEdgesWidth.name} ${id} ${meshEdgesWidth(id)}`)  | 
74 | 77 |         },  | 
75 | 78 |       },  | 
76 | 79 |     )  | 
77 | 80 |   }  | 
78 | 81 | 
 
  | 
79 |  | -  function applyEdgesStyle(id, style) {  | 
 | 82 | +  function applyMeshEdgesStyle(id, style) {  | 
80 | 83 |     return Promise.all([  | 
81 |  | -      setEdgesVisibility(id, style.visibility),  | 
82 |  | -      setEdgesActiveColoring(id, style.coloring.active),  | 
83 |  | -      // setEdgesWidth(id, style.width);  | 
 | 84 | +      setMeshEdgesVisibility(id, style.visibility),  | 
 | 85 | +      setMeshEdgesActiveColoring(id, style.coloring.active),  | 
 | 86 | +      // setMeshEdgesWidth(id, style.width);  | 
84 | 87 |     ])  | 
85 | 88 |   }  | 
86 | 89 | 
 
  | 
87 | 90 |   return {  | 
88 |  | -    applyEdgesStyle,  | 
89 |  | -    edgesActiveColoring,  | 
90 |  | -    edgesColor,  | 
91 |  | -    edgesVisibility,  | 
92 |  | -    edgesWidth,  | 
93 |  | -    setEdgesActiveColoring,  | 
94 |  | -    setEdgesColor,  | 
95 |  | -    setEdgesVisibility,  | 
96 |  | -    setEdgesWidth,  | 
 | 91 | +    applyMeshEdgesStyle,  | 
 | 92 | +    meshEdgesActiveColoring,  | 
 | 93 | +    meshEdgesColor,  | 
 | 94 | +    meshEdgesVisibility,  | 
 | 95 | +    meshEdgesWidth,  | 
 | 96 | +    setMeshEdgesActiveColoring,  | 
 | 97 | +    setMeshEdgesColor,  | 
 | 98 | +    setMeshEdgesVisibility,  | 
 | 99 | +    setMeshEdgesWidth,  | 
97 | 100 |   }  | 
98 | 101 | }  | 
0 commit comments