Skip to content

Commit 8e64ed0

Browse files
color methods harmonization
1 parent 15b35fc commit 8e64ed0

File tree

7 files changed

+22
-53
lines changed

7 files changed

+22
-53
lines changed

src/opengeodeweb_viewer/object/object_methods.py

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def applyTextures(self, id, textures):
8888

8989
self.render()
9090

91-
9291
def SetVisibility(self, id, visibility):
9392
actor = self.get_object(id)["actor"]
9493
actor.SetVisibility(visibility)
@@ -103,7 +102,7 @@ def SetColor(self, id, red, green, blue):
103102
mapper = self.get_object(id)["mapper"]
104103
mapper.ScalarVisibilityOff()
105104
actor = self.get_object(id)["actor"]
106-
actor.GetProperty().SetColor([red, green, blue])
105+
actor.GetProperty().SetColor([red/255, green/255, blue/255])
107106
self.render()
108107

109108
def SetEdgesVisibility(self, id, visibility):
@@ -116,10 +115,11 @@ def SetEdgesSize(self, id, size):
116115
actor.GetProperty().SetEdgeWidth(size)
117116
self.render()
118117

119-
def SetEdgesColor(self, id, color):
118+
def SetEdgesColor(self, id, red, green, blue):
120119
actor = self.get_object(id)["actor"]
121-
actor.GetProperty().SetEdgeColor(color)
120+
actor.GetProperty().SetEdgeColor([red/255, green/255, blue/255])
122121
self.render()
122+
123123
def SetPointsVisibility(self, id, visibility):
124124
actor = self.get_object(id)["actor"]
125125
actor.GetProperty().SetVertexVisibility(visibility)
@@ -131,35 +131,11 @@ def SetPointsSize(self, id, size):
131131
actor.GetProperty().SetPointSize(size)
132132
self.render()
133133

134-
def SetPointsColor(self, id, color):
134+
def SetPointsColor(self, id, red, green, blue):
135135
actor = self.get_object(id)["actor"]
136-
actor.GetProperty().SetVertexColor(color)
136+
actor.GetProperty().SetVertexColor([red/255, green/255, blue/255])
137137
self.render()
138138

139-
def SetPolygonsVisibility(self, id, visibility):
140-
actor = self.get_object(id)["actor"]
141-
actor.SetVisibility(visibility)
142-
self.render()
143-
144-
145-
def SetPolygonsColor(self, id, color):
146-
actor = self.get_object(id)["actor"]
147-
actor.GetProperty().SetColor(color)
148-
self.render()
149-
150-
def SetPolyhedronsVisibility(self, id, visibility):
151-
actor = self.get_object(id)["actor"]
152-
actor.SetVisibility(visibility)
153-
self.render()
154-
155-
def SetPolyhedronsColor(self, id, color):
156-
reader = self.get_object(id)["reader"]
157-
cells = reader.GetOutput().GetCellData()
158-
mapper = self.get_object(id)["mapper"]
159-
mapper.ScalarVisibilityOff()
160-
cells.SetColor(color)
161-
162-
163139
def clearColors(self, id):
164140
db = self.get_object(id)
165141
mapper = db["mapper"]

src/opengeodeweb_viewer/rpc/mesh/edges/edges_protocols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def setMeshEdgesColor(self, params):
2828
print(self.mesh_edges_prefix + self.mesh_edges_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
2929
validate_schema(params, self.mesh_edges_schemas_dict["color"])
3030
id = params["id"]
31-
red, green, blue = params["color"]["r"]/255, params["color"]["g"]/255, params["color"]["b"]/255
32-
self.SetEdgesColor(id, [red, green, blue])
31+
red, green, blue = params["color"]["r"], params["color"]["g"], params["color"]["b"]
32+
self.SetEdgesColor(id, red, green, blue)
3333

3434
@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["size"]["rpc"])
3535
def setMeshEdgesSize(self, params):

src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def setMeshColor(self, params):
5959
print(self.mesh_prefix + self.mesh_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
6060
validate_schema(params, self.mesh_schemas_dict["color"])
6161
id = params["id"]
62-
red, green, blue = params["color"]["r"]/255, params["color"]["g"]/255, params["color"]["b"]/255
62+
red, green, blue = params["color"]["r"], params["color"]["g"], params["color"]["b"]
6363
self.SetColor(id, red, green, blue)
6464

6565
def setMeshVertexAttribute(self, id, name):

src/opengeodeweb_viewer/rpc/mesh/points/points_protocols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def setMeshPointsColor(self, params):
2828
print(self.mesh_points_prefix + self.mesh_points_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
2929
validate_schema(params, self.mesh_points_schemas_dict["color"])
3030
id = str(params["id"])
31-
red, green, blue = params["color"]["r"]/255, params["color"]["g"]/255, params["color"]["b"]/255
32-
self.SetPointsColor(id, [red, green, blue])
31+
red, green, blue = params["color"]["r"], params["color"]["g"], params["color"]["b"]
32+
self.SetPointsColor(id, red, green, blue)
3333

3434
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["size"]["rpc"])
3535
def setMeshPointsSize(self, params):

src/opengeodeweb_viewer/rpc/mesh/polygons/polygons_protocols.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def setMeshPolygonsVisibility(self, params):
2121
validate_schema(params, self.mesh_polygons_schemas_dict["visibility"])
2222
id = params["id"]
2323
visibility = bool(params["visibility"])
24-
self.SetPolygonsVisibility(id, visibility)
24+
self.SetVisibility(id, visibility)
2525

2626
@exportRpc(mesh_polygons_prefix + mesh_polygons_schemas_dict["color"]["rpc"])
2727
def setMeshPolygonsColor(self, params):
2828
print(self.mesh_polygons_prefix + self.mesh_polygons_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
2929
validate_schema(params, self.mesh_polygons_schemas_dict["color"])
3030
id = params["id"]
31-
red, green, blue = params["color"]["r"]/255, params["color"]["g"]/255, params["color"]["b"]/255
32-
self.SetPolygonsColor(id, [red, green, blue])
31+
red, green, blue = params["color"]["r"], params["color"]["g"], params["color"]["b"]
32+
self.SetColor(id, red, green, blue)
3333

3434
@exportRpc(mesh_polygons_prefix + mesh_polygons_schemas_dict["vertex_attribute"]["rpc"])
3535
def setMeshPolygonsVertexAttribute(self, params):

src/opengeodeweb_viewer/rpc/mesh/polyhedrons/polyhedrons_protocols.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class VtkMeshPolyhedronsView(VtkMeshView):
1515
def __init__(self):
1616
super().__init__()
1717

18-
# @exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["visibility"]["rpc"])
19-
# def setMeshPolyhedronsVisibility(self, params):
20-
# print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
21-
# validate_schema(params, self.mesh_polyhedrons_schemas_dict["visibility"])
22-
# id = params["id"]
23-
# visibility = bool(params["visibility"])
24-
# self.SetPolyhedronsVisibility(id, visibility)
18+
@exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["visibility"]["rpc"])
19+
def setMeshPolyhedronsVisibility(self, params):
20+
print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
21+
validate_schema(params, self.mesh_polyhedrons_schemas_dict["visibility"])
22+
id = params["id"]
23+
visibility = bool(params["visibility"])
24+
self.SetVisibility(id, visibility)
2525

2626
@exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["color"]["rpc"])
2727
def setMeshPolyhedronsColor(self, params):
@@ -30,7 +30,7 @@ def setMeshPolyhedronsColor(self, params):
3030
print("id", params["id"], flush=True)
3131
id = params["id"]
3232
print("color", params["color"], flush=True)
33-
red, green, blue = params["color"]["r"]/255, params["color"]["g"]/255, params["color"]["b"]/255
33+
red, green, blue = params["color"]["r"], params["color"]["g"], params["color"]["b"]
3434
self.SetColor(id, red, green, blue)
3535

3636
# @exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["vertex_attribute"]["rpc"])
@@ -41,10 +41,3 @@ def setMeshPolyhedronsColor(self, params):
4141
# name = str(params["name"])
4242
# self.setMeshVertexAttribute(id, name)
4343

44-
# @exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["polygon_attribute"]["rpc"])
45-
# def setMeshPolyhedronsPolygonAttribute(self, params):
46-
# print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["polygon_attribute"]["rpc"], f"{params=}", flush=True)
47-
# validate_schema(params, self.mesh_polyhedrons_schemas_dict["polygon_attribute"])
48-
# id = params["id"]
49-
# name = str(params["name"])
50-
# self.setMeshPolygonAttribute(id, name)

src/tests/tests_output/test.jpeg

3.65 KB
Loading

0 commit comments

Comments
 (0)