Skip to content

Commit 66836bc

Browse files
feat(rpc): set_opacity
1 parent 06992c6 commit 66836bc

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"rpc": "set_opacity",
3+
"type": "object",
4+
"properties": {
5+
"id": {
6+
"type": "string"
7+
},
8+
"opacity": {
9+
"type": "number",
10+
"min": 0,
11+
"max": 1
12+
}
13+
},
14+
"required": [
15+
"id",
16+
"opacity"
17+
],
18+
"additionalProperties": false
19+
}

src/opengeodeweb_viewer/vtk_protocol.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@
3636
get_point_position_json = json.load(file)
3737
with open(os.path.join(schemas, "reset.json"), "r") as file:
3838
reset_json = json.load(file)
39+
with open(os.path.join(schemas, "set_opacity.json"), "r") as file:
40+
set_opacity_json = json.load(file)
3941
with open(os.path.join(schemas, "toggle_edge_visibility.json"), "r") as file:
4042
toggle_edge_visibility_json = json.load(file)
41-
with open(os.path.join(schemas, "point_size.json"), "r") as file:
42-
point_size_json = json.load(file)
43+
with open(os.path.join(schemas, "set_point_size.json"), "r") as file:
44+
set_point_size_json = json.load(file)
4345
with open(os.path.join(schemas, "toggle_point_visibility.json"), "r") as file:
4446
toggle_point_visibility_json = json.load(file)
4547
with open(os.path.join(schemas, "set_color.json"), "r") as file:
@@ -246,11 +248,20 @@ def reset(self, params):
246248
renderWindow = self.getView("-1")
247249
renderWindow.GetRenderers().GetFirstRenderer().RemoveAllViewProps()
248250

251+
@exportRpc(set_opacity_json["rpc"])
252+
def set_opacity(self, params):
253+
validate_schemas(params, set_opacity_json)
254+
id = params["id"]
255+
opacity = float(params["opacity"])
256+
actor = self.get_object(id)["actor"]
257+
actor.GetProperty().SetOpacity(opacity)
258+
self.render()
259+
249260
@exportRpc(toggle_edge_visibility_json["rpc"])
250261
def setEdgeVisibility(self, params):
251262
validate_schemas(params, toggle_edge_visibility_json)
252263
print(f"{params=}", flush=True)
253-
id = params["id"]
264+
id = str(params["id"])
254265
visibility = bool(params["visibility"])
255266
actor = self.get_object(id)["actor"]
256267
actor.GetProperty().SetEdgeVisibility(visibility)
@@ -265,9 +276,9 @@ def setPointVisibility(self, params):
265276
actor.GetProperty().SetVertexVisibility(visibility)
266277
self.render()
267278

268-
@exportRpc(point_size_json["rpc"])
279+
@exportRpc(set_point_size_json["rpc"])
269280
def setPointSize(self, params):
270-
validate_schemas(params, point_size_json)
281+
validate_schemas(params, set_point_size_json)
271282
id = params["id"]
272283
size = float(params["size"])
273284
actor = self.get_object(id)["actor"]
8.2 KB
Loading

0 commit comments

Comments
 (0)