Skip to content

Commit 8bca026

Browse files
tidy
1 parent 608a816 commit 8bca026

19 files changed

+148
-163
lines changed

src/opengeodeweb_viewer/object/methods.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
from opengeodeweb_viewer.utils_functions import get_schemas_dict, validate_schema
99
from opengeodeweb_viewer.vtk_protocol import VtkView
1010

11-
12-
schemas_dir = os.path.join(os.path.dirname(__file__), "schemas")
13-
schemas_dict = get_schemas_dict(schemas_dir)
14-
15-
1611
class VtkObjectView(VtkView):
1712
def __init__(self):
1813
super().__init__()
@@ -108,7 +103,9 @@ def SetOpacity(self, id, opacity):
108103
actor.GetProperty().SetOpacity(opacity)
109104
self.render()
110105

111-
def SetColor(self, id, color):
106+
def SetColor(self, id, red, green, blue):
107+
color = [red, green, blue]
108+
print(f"{color=}", flush=True)
112109
mapper = self.get_object(id)["mapper"]
113110
mapper.ScalarVisibilityOff()
114111
actor = self.get_object(id)["actor"]
@@ -126,7 +123,6 @@ def SetVertexVisibility(self, id, visibility):
126123
self.render()
127124

128125
def SetPointSize(self, id, size):
129-
validate_schema(params, schemas_dict["set_point_size"])
130126
actor = self.get_object(id)["actor"]
131127
actor.GetProperty().SetPointSize(size)
132128
self.render()

src/opengeodeweb_viewer/object/schemas/set_vertex_visility.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/opengeodeweb_viewer/rpc/mesh/protocols.py

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def register(self, params):
3535
except Exception as e:
3636
print("error : ", str(e), flush=True)
3737

38-
@exportRpc(schemas_dict["register"]["rpc"])
38+
@exportRpc(schemas_dict["deregister"]["rpc"])
3939
def deregisterMesh(self, params):
4040
validate_schema(params, schemas_dict["deregister"])
4141
id = params["id"]
@@ -45,67 +45,74 @@ def deregisterMesh(self, params):
4545
def SetVisibility(self, params):
4646
print(schemas_dict["set_visibility"]["rpc"], flush=True)
4747
validate_schema(params, schemas_dict["set_visibility"])
48-
super().SetVisibility(params)
48+
id = params["id"]
49+
visibility = bool(params["visibility"])
50+
super().SetVisibility(id, visibility)
4951

5052
@exportRpc(schemas_dict["set_opacity"]["rpc"])
5153
def SetOpacity(self, params):
5254
print(schemas_dict["set_opacity"]["rpc"], flush=True)
5355
validate_schema(params, schemas_dict["set_opacity"])
54-
super().SetOpacity(params)
56+
id = params["id"]
57+
opacity = float(params["opacity"])
58+
super().SetOpacity(id, opacity)
5559

5660
@exportRpc(schemas_dict["set_edge_visibility"]["rpc"])
5761
def setEdgeVisibility(self, params):
5862
print(schemas_dict["set_edge_visibility"]["rpc"], flush=True)
5963
validate_schema(params, schemas_dict["set_edge_visibility"])
6064
print(f"{params=}", flush=True)
61-
super().SetEdgeVisibility(params)
65+
id = params["id"]
66+
visibility = bool(params["visibility"])
67+
super().SetEdgeVisibility(id, visibility)
6268

6369
@exportRpc(schemas_dict["set_point_visibility"]["rpc"])
6470
def setPointVisibility(self, params):
6571
print(schemas_dict["set_point_visibility"]["rpc"], flush=True)
6672
validate_schema(params, schemas_dict["set_point_visibility"])
67-
super().SetVertexVisibility(params)
73+
id = params["id"]
74+
visibility = bool(params["visibility"])
75+
super().SetVertexVisibility(id, visibility)
6876

6977
@exportRpc(schemas_dict["set_point_size"]["rpc"])
7078
def setPointSize(self, params):
7179
print(schemas_dict["set_point_size"]["rpc"], flush=True)
7280
validate_schema(params, schemas_dict["set_point_size"])
73-
super().SetPointSize(params)
81+
id = params["id"]
82+
size = float(params["size"])
83+
super().SetPointSize(id, size)
7484

7585
@exportRpc(schemas_dict["set_color"]["rpc"])
7686
def setColor(self, params):
7787
print(schemas_dict["set_color"]["rpc"], flush=True)
7888
validate_schema(params, schemas_dict["set_color"])
79-
super().SetColor(params)
89+
id = params["id"]
90+
red = params["red"]
91+
green = params["green"]
92+
blue = params["blue"]
93+
super().SetColor(id, red, green, blue)
8094

8195
@exportRpc(schemas_dict["display_vertex_attribute"]["rpc"])
8296
def setVertexAttribute(self, params):
8397
validate_schema(params, schemas_dict["display_vertex_attribute"])
8498
print(f"{params=}", flush=True)
8599
id = params["id"]
86100
name = params["name"]
87-
mapper = self.get_object(id)["mapper"]
101+
mapper = super().get_object(id)["mapper"]
88102
mapper.SelectColorArray(name)
89103
mapper.ScalarVisibilityOn()
90104
mapper.SetScalarModeToUsePointFieldData()
91-
self.render()
105+
super().render()
92106

93107
@exportRpc(schemas_dict["display_polygon_attribute"]["rpc"])
94-
def setPolygonAttribute(self, id, name):
108+
def setPolygonAttribute(self, params):
95109
validate_schema(params, schemas_dict["display_polygon_attribute"])
96-
cpp = store["cpp"]
97-
print(cpp.nb_polygons())
98-
cells = store["vtk"].GetCellData()
99-
print(store["vtk"].GetNumberOfCells())
100-
manager = cpp.polygon_attribute_manager()
101-
if not manager.attribute_exists(name):
102-
return
103-
if not cells.HasArray(name):
104-
data = self.computeAttributeData(manager, name)
105-
cells.AddArray(data)
106-
cells.SetActiveScalars(name)
107-
mapper = self.get_object(id)["mapper"]
110+
id = params["id"]
111+
name = params["name"]
112+
print(f"{id=}", flush=True)
113+
print(f"{name=}", flush=True)
114+
mapper = super().get_object(id)["mapper"]
115+
mapper.SelectColorArray(name)
108116
mapper.ScalarVisibilityOn()
109-
mapper.SetScalarModeToUseCellData()
110-
mapper.SetScalarRange(cells.GetScalars().GetRange())
111-
self.render()
117+
mapper.SetScalarModeToUseCellFieldData()
118+
super().render()

src/opengeodeweb_viewer/rpc/mesh/schemas/display_polygon_attribute.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"rpc": "display_polygon_attribute",
2+
"rpc": "mesh.display_polygon_attribute",
33
"type": "object",
44
"properties": {
55
"id": {

src/opengeodeweb_viewer/rpc/mesh/schemas/display_vertex_attribute.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"rpc": "display_vertex_attribute",
2+
"rpc": "mesh.display_vertex_attribute",
33
"type": "object",
44
"properties": {
55
"id": {

src/opengeodeweb_viewer/rpc/mesh/schemas/set_color.json

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,27 @@
55
"id": {
66
"type": "string"
77
},
8-
"color": {
9-
"type": "object",
10-
"properties": {
11-
"red": {
12-
"type": "integer",
13-
"minimum": 0,
14-
"maximum": 255
15-
},
16-
"green": {
17-
"type": "integer",
18-
"minimum": 0,
19-
"maximum": 255
20-
},
21-
"blue": {
22-
"type": "integer",
23-
"minimum": 0,
24-
"maximum": 255
25-
}
26-
},
27-
"required": [
28-
"red",
29-
"green",
30-
"blue"
31-
],
32-
"additionalProperties": false
8+
"red": {
9+
"type": "integer",
10+
"minimum": 0,
11+
"maximum": 255
12+
},
13+
"green": {
14+
"type": "integer",
15+
"minimum": 0,
16+
"maximum": 255
17+
},
18+
"blue": {
19+
"type": "integer",
20+
"minimum": 0,
21+
"maximum": 255
3322
}
3423
},
3524
"required": [
3625
"id",
37-
"color"
26+
"red",
27+
"green",
28+
"blue"
3829
],
3930
"additionalProperties": false
4031
}

src/opengeodeweb_viewer/rpc/model/protocols.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ def SetComponentsVisibility(self, params):
5757
def SetComponentsColor(self, params):
5858
validate_schema(params, schemas_dict["set_components_color"])
5959
id = params["id"]
60-
color = params["color"]
61-
super().SetColor(id, color)
60+
red = params["red"]
61+
green = params["green"]
62+
blue = params["blue"]
63+
super().SetColor(id, red, green, blue)
6264

6365
@exportRpc(schemas_dict["set_corners_size"]["rpc"])
6466
def setCornersSize(self, params):

src/opengeodeweb_viewer/rpc/model/schemas/set_components_color.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,27 @@
55
"id": {
66
"type": "string"
77
},
8-
"color": {
9-
"type": "string"
8+
"red": {
9+
"type": "integer",
10+
"minimum": 0,
11+
"maximum": 255
12+
},
13+
"green": {
14+
"type": "integer",
15+
"minimum": 0,
16+
"maximum": 255
17+
},
18+
"blue": {
19+
"type": "integer",
20+
"minimum": 0,
21+
"maximum": 255
1022
}
1123
},
1224
"required": [
1325
"id",
14-
"color"
26+
"red",
27+
"green",
28+
"blue"
1529
],
1630
"additionalProperties": false
1731
}
7.02 KB
Loading
7.02 KB
Loading

0 commit comments

Comments
 (0)