Skip to content

Commit 9c19564

Browse files
wip test new protocols
1 parent 732afbe commit 9c19564

File tree

21 files changed

+199
-125
lines changed

21 files changed

+199
-125
lines changed

src/opengeodeweb_viewer/object/object_methods.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def SetPointsColor(self, id, color):
141141

142142
def SetPolygonsVisibility(self, id, visibility):
143143
actor = self.get_object(id)["actor"]
144-
actor.GetProperty().SetPolygonVisibility(visibility)
144+
actor.SetVisibility(visibility)
145+
# actor.GetProperty().SetVisibility(visibility)
145146
self.render()
146147

147148
def SetPolygonsColor(self, id, color):

src/opengeodeweb_viewer/rpc/generic/generic_protocols.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
# Local application imports
1111
from opengeodeweb_viewer.vtk_protocol import VtkView
12-
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
13-
from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView
1412
from opengeodeweb_viewer.utils_functions import get_schemas_dict, validate_schema
1513

1614
class VtkGenericView(VtkView):

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@
99
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
1010

1111
class VtkMeshEdgesView(VtkMeshView):
12-
prefix = "opengeodeweb_viewer.mesh.edges."
13-
schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
12+
mesh_edges_prefix = "opengeodeweb_viewer.mesh.edges."
13+
mesh_edges_schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
1414

1515
def __init__(self):
1616
super().__init__()
1717

18-
@exportRpc(prefix + schemas_dict["visibility"]["rpc"])
18+
@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["visibility"]["rpc"])
1919
def setMeshEdgesVisibility(self, params):
20-
print(self.prefix + self.schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
21-
validate_schema(params, self.schemas_dict["visibility"])
20+
print(self.mesh_edges_prefix + self.mesh_edges_schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
21+
validate_schema(params, self.mesh_edges_schemas_dict["visibility"])
2222
id = params["id"]
2323
visibility = bool(params["visibility"])
2424
self.SetEdgesVisibility(id, visibility)
2525

26-
@exportRpc(prefix + schemas_dict["color"]["rpc"])
26+
@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["color"]["rpc"])
2727
def setMeshEdgesColor(self, params):
28-
print(self.prefix + self.schemas_dict["color"]["rpc"], f"{params=}", flush=True)
29-
validate_schema(params, self.schemas_dict["color"])
28+
print(self.mesh_edges_prefix + self.mesh_edges_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
29+
validate_schema(params, self.mesh_edges_schemas_dict["color"])
3030
id = params["id"]
3131
red = 1.0 * params["color"]["r"]
3232
green = 1.0 * params["color"]["g"]
3333
blue = 1.0 * params["color"]["b"]
3434
self.SetEdgesColor(id, [red, green, blue])
3535

36-
@exportRpc(prefix + schemas_dict["size"]["rpc"])
36+
@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["size"]["rpc"])
3737
def setMeshEdgesSize(self, params):
38-
print(self.prefix + self.schemas_dict["size"]["rpc"], f"{params=}", flush=True)
39-
validate_schema(params, self.schemas_dict["size"])
38+
print(self.mesh_edges_prefix + self.mesh_edges_schemas_dict["size"]["rpc"], f"{params=}", flush=True)
39+
validate_schema(params, self.mesh_edges_schemas_dict["size"])
4040
id = params["id"]
4141
size = bool(params["size"])
4242
self.SetEdgesSize(id, size)

src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
from opengeodeweb_viewer.object.object_methods import VtkObjectView
1111

1212
class VtkMeshView(VtkObjectView):
13-
prefix = "opengeodeweb_viewer.mesh."
14-
schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
13+
mesh_prefix = "opengeodeweb_viewer.mesh."
14+
mesh_schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
1515

1616
def __init__(self):
1717
super().__init__()
1818

19-
@exportRpc(prefix + schemas_dict["register"]["rpc"])
19+
@exportRpc(mesh_prefix + mesh_schemas_dict["register"]["rpc"])
2020
def registerMesh(self, params):
21-
print(self.prefix + self.schemas_dict["register"]["rpc"], f"{params=}", flush=True)
22-
validate_schema(params, self.schemas_dict["register"])
21+
print(self.mesh_prefix + self.mesh_schemas_dict["register"]["rpc"], f"{params=}", flush=True)
22+
validate_schema(params, self.mesh_schemas_dict["register"])
2323
id = params["id"]
2424
file_name = params["file_name"]
2525
try:
@@ -31,33 +31,33 @@ def registerMesh(self, params):
3131
except Exception as e:
3232
print("error : ", str(e), flush=True)
3333

34-
@exportRpc(prefix + schemas_dict["deregister"]["rpc"])
34+
@exportRpc(mesh_prefix + mesh_schemas_dict["deregister"]["rpc"])
3535
def deregisterMesh(self, params):
36-
print(self.prefix + self.schemas_dict["deregister"]["rpc"], f"{params=}", flush=True)
37-
validate_schema(params, self.schemas_dict["deregister"])
36+
print(self.mesh_prefix + self.mesh_schemas_dict["deregister"]["rpc"], f"{params=}", flush=True)
37+
validate_schema(params, self.mesh_schemas_dict["deregister"])
3838
id = params["id"]
3939
self.deregisterObject(id)
4040

41-
@exportRpc(prefix + schemas_dict["visibility"]["rpc"])
41+
@exportRpc(mesh_prefix + mesh_schemas_dict["visibility"]["rpc"])
4242
def SetMeshVisibility(self, params):
43-
print(self.prefix + self.schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
44-
validate_schema(params, self.schemas_dict["visibility"])
43+
print(self.mesh_prefix + self.mesh_schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
44+
validate_schema(params, self.mesh_schemas_dict["visibility"])
4545
id = params["id"]
4646
visibility = bool(params["visibility"])
4747
self.SetVisibility(id, visibility)
4848

49-
@exportRpc(prefix + schemas_dict["set_opacity"]["rpc"])
49+
@exportRpc(mesh_prefix + mesh_schemas_dict["opacity"]["rpc"])
5050
def setMeshOpacity(self, params):
51-
print(self.prefix + self.schemas_dict["set_opacity"]["rpc"], f"{params=}", flush=True)
52-
validate_schema(params, self.schemas_dict["set_opacity"])
51+
print(self.mesh_prefix + self.mesh_schemas_dict["opacity"]["rpc"], f"{params=}", flush=True)
52+
validate_schema(params, self.mesh_schemas_dict["opacity"])
5353
id = params["id"]
5454
opacity = float(params["opacity"])
5555
self.SetOpacity(id, opacity)
5656

57-
@exportRpc(prefix + schemas_dict["set_color"]["rpc"])
57+
@exportRpc(mesh_prefix + mesh_schemas_dict["color"]["rpc"])
5858
def setMeshColor(self, params):
59-
print(self.prefix + self.schemas_dict["set_color"]["rpc"], f"{params=}", flush=True)
60-
validate_schema(params, self.schemas_dict["set_color"])
59+
print(self.mesh_prefix + self.mesh_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
60+
validate_schema(params, self.mesh_schemas_dict["color"])
6161
id = params["id"]
6262
red = params["red"]
6363
green = params["green"]

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,42 @@
99
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
1010

1111
class VtkMeshPointsView(VtkMeshView):
12-
prefix = "opengeodeweb_viewer.mesh.points."
13-
schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
12+
mesh_points_prefix = "opengeodeweb_viewer.mesh.points."
13+
mesh_points_schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
1414

1515
def __init__(self):
1616
super().__init__()
1717

18-
@exportRpc(prefix + schemas_dict["visibility"]["rpc"])
18+
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["visibility"]["rpc"])
1919
def setMeshPointsVisibility(self, params):
20-
print(self.prefix + self.schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
21-
validate_schema(params, self.schemas_dict["visibility"])
20+
print(self.mesh_points_prefix + self.mesh_points_schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
21+
validate_schema(params, self.mesh_points_schemas_dict["visibility"])
2222
id = str(params["id"])
2323
visibility = bool(params["visibility"])
2424
self.SetPointsVisibility(id, visibility)
2525

26-
@exportRpc(prefix + schemas_dict["color"]["rpc"])
26+
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["color"]["rpc"])
2727
def setMeshPointsColor(self, params):
28-
print(self.prefix + self.schemas_dict["color"]["rpc"], f"{params=}", flush=True)
29-
validate_schema(params, self.schemas_dict["color"])
28+
print(self.mesh_points_prefix + self.mesh_points_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
29+
validate_schema(params, self.mesh_points_schemas_dict["color"])
3030
id = str(params["id"])
3131
red = params["color"]["r"]
3232
green = params["color"]["g"]
3333
blue = params["color"]["b"]
3434
self.SetPointsColor(id, [red, green, blue])
3535

36-
@exportRpc(prefix + schemas_dict["size"]["rpc"])
36+
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["size"]["rpc"])
3737
def setMeshPointsSize(self, params):
38-
print(self.prefix + self.schemas_dict["size"]["rpc"], f"{params=}", flush=True)
39-
validate_schema(params, self.schemas_dict["size"])
38+
print(self.mesh_points_prefix + self.mesh_points_schemas_dict["size"]["rpc"], f"{params=}", flush=True)
39+
validate_schema(params, self.mesh_points_schemas_dict["size"])
4040
id = str(params["id"])
4141
size = float(params["size"])
4242
self.SetPointsSize(id, size)
4343

44-
@exportRpc(prefix + schemas_dict["vertex_attribute"]["rpc"])
44+
@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["vertex_attribute"]["rpc"])
4545
def setMeshPointsVertexAttribute(self, params):
46-
print(self.prefix + self.schemas_dict["vertex_attribute"]["rpc"], f"{params=}", flush=True)
47-
validate_schema(params, self.schemas_dict["vertex_attribute"])
46+
print(self.mesh_points_prefix + self.mesh_points_schemas_dict["vertex_attribute"]["rpc"], f"{params=}", flush=True)
47+
validate_schema(params, self.mesh_points_schemas_dict["vertex_attribute"])
4848
id = str(params["id"])
4949
name = str(params["name"])
5050
self.setMeshVertexAttribute(id, name)

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,42 @@
99
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
1010

1111
class VtkMeshPolygonsView(VtkMeshView):
12-
prefix = "opengeodeweb_viewer.mesh.polygons."
13-
schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
12+
mesh_polygons_prefix = "opengeodeweb_viewer.mesh.polygons."
13+
mesh_polygons_schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
1414

1515
def __init__(self):
1616
super().__init__()
1717

18-
@exportRpc(prefix + schemas_dict["visibility"]["rpc"])
18+
@exportRpc(mesh_polygons_prefix + mesh_polygons_schemas_dict["visibility"]["rpc"])
1919
def setMeshPolygonsVisibility(self, params):
20-
print(self.prefix + self.schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
21-
validate_schema(params, self.schemas_dict["visibility"])
20+
print(self.mesh_polygons_prefix + self.mesh_polygons_schemas_dict["visibility"]["rpc"], f"{params=}", flush=True)
21+
validate_schema(params, self.mesh_polygons_schemas_dict["visibility"])
2222
id = params["id"]
2323
visibility = bool(params["visibility"])
2424
self.SetPolygonsVisibility(id, visibility)
2525

26-
@exportRpc(prefix + schemas_dict["color"]["rpc"])
26+
@exportRpc(mesh_polygons_prefix + mesh_polygons_schemas_dict["color"]["rpc"])
2727
def setMeshPolygonsColor(self, params):
28-
print(self.prefix + self.schemas_dict["color"]["rpc"], f"{params=}", flush=True)
29-
validate_schema(params, self.schemas_dict["color"])
28+
print(self.mesh_polygons_prefix + self.mesh_polygons_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
29+
validate_schema(params, self.mesh_polygons_schemas_dict["color"])
3030
id = params["id"]
3131
red = params["color"]["r"]
3232
green = params["color"]["g"]
3333
blue = params["color"]["b"]
3434
self.SetPolygonsColor(id, [red, green, blue])
3535

36-
@exportRpc(prefix + schemas_dict["vertex_attribute"]["rpc"])
36+
@exportRpc(mesh_polygons_prefix + mesh_polygons_schemas_dict["vertex_attribute"]["rpc"])
3737
def setMeshPolygonsVertexAttribute(self, params):
38-
print(self.prefix + self.schemas_dict["vertex_attribute"]["rpc"], f"{params=}", flush=True)
39-
validate_schema(params, self.schemas_dict["vertex_attribute"])
38+
print(self.mesh_polygons_prefix + self.mesh_polygons_schemas_dict["vertex_attribute"]["rpc"], f"{params=}", flush=True)
39+
validate_schema(params, self.mesh_polygons_schemas_dict["vertex_attribute"])
4040
id = params["id"]
4141
name = str(params["name"])
4242
self.setMeshVertexAttribute(id, name)
4343

44-
@exportRpc(prefix + schemas_dict["polygon_attribute"]["rpc"])
44+
@exportRpc(mesh_polygons_prefix + mesh_polygons_schemas_dict["polygon_attribute"]["rpc"])
4545
def setMeshPolygonsPolygonAttribute(self, params):
46-
print(self.prefix + self.schemas_dict["polygon_attribute"]["rpc"], f"{params=}", flush=True)
47-
validate_schema(params, self.schemas_dict["polygon_attribute"])
46+
print(self.mesh_polygons_prefix + self.mesh_polygons_schemas_dict["polygon_attribute"]["rpc"], f"{params=}", flush=True)
47+
validate_schema(params, self.mesh_polygons_schemas_dict["polygon_attribute"])
4848
id = params["id"]
4949
name = str(params["name"])
5050
self.setMeshPolygonAttribute(id, name)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"rpc": "color",
3+
"type": "object",
4+
"properties": {
5+
"id": {
6+
"type": "string"
7+
},
8+
"color": {
9+
"type": "object",
10+
"properties": {
11+
"r": {
12+
"type": "integer",
13+
"minimum": 0,
14+
"maximum": 255
15+
},
16+
"g": {
17+
"type": "integer",
18+
"minimum": 0,
19+
"maximum": 255
20+
},
21+
"b": {
22+
"type": "integer",
23+
"minimum": 0,
24+
"maximum": 255
25+
}
26+
},
27+
"required": [
28+
"r",
29+
"g",
30+
"b"
31+
],
32+
"additionalProperties": false
33+
}
34+
},
35+
"required": [
36+
"id",
37+
"color"
38+
],
39+
"additionalProperties": false
40+
}

src/opengeodeweb_viewer/rpc/mesh/schemas/set_opacity.json renamed to src/opengeodeweb_viewer/rpc/mesh/schemas/opacity.json

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

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

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

src/opengeodeweb_viewer/vtkw_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def initialize(self):
6262
self.registerVtkWebProtocol(VtkMeshEdgesView())
6363
self.registerVtkWebProtocol(VtkMeshPolygonsView())
6464
self.registerVtkWebProtocol(model_protocols)
65-
self.registerVtkWebProtocol(VtkGenericView(mesh_protocols,model_protocols))
65+
self.registerVtkWebProtocol(VtkGenericView(mesh_protocols, model_protocols))
6666

6767
# tell the C++ web app to use no encoding.
6868
# ParaViewWebPublishImageDelivery must be set to decode=False to match.

0 commit comments

Comments
 (0)