Skip to content

Commit 2984d13

Browse files
wip test protocols
1 parent 62acea9 commit 2984d13

File tree

9 files changed

+181
-0
lines changed

9 files changed

+181
-0
lines changed

src/opengeodeweb_viewer/object/object_methods.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,25 @@ def SetPolygonsVisibility(self, id, visibility):
141141
actor.SetVisibility(visibility)
142142
self.render()
143143

144+
144145
def SetPolygonsColor(self, id, color):
145146
actor = self.get_object(id)["actor"]
146147
actor.GetProperty().SetColor(color)
147148
self.render()
148149

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+
149163
def clearColors(self, id):
150164
db = self.get_object(id)
151165
mapper = db["mapper"]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Standard library imports
2+
import os
3+
4+
# Third party imports
5+
from wslink import register as exportRpc
6+
7+
# Local application imports
8+
from opengeodeweb_viewer.utils_functions import get_schemas_dict, validate_schema
9+
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
10+
11+
class VtkMeshPolyhedronsView(VtkMeshView):
12+
mesh_polyhedrons_prefix = "opengeodeweb_viewer.mesh.polyhedrons."
13+
mesh_polyhedrons_schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
14+
15+
def __init__(self):
16+
super().__init__()
17+
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)
25+
26+
@exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["color"]["rpc"])
27+
def setMeshPolyhedronsColor(self, params):
28+
print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["color"]["rpc"], f"{params=}", flush=True)
29+
validate_schema(params, self.mesh_polyhedrons_schemas_dict["color"])
30+
print("id", params["id"], flush=True)
31+
id = params["id"]
32+
print("color", params["color"], flush=True)
33+
red, green, blue = params["color"]["r"]/255, params["color"]["g"]/255, params["color"]["b"]/255
34+
self.SetPolyhedronsColor(id, [red, green, blue])
35+
36+
# @exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["vertex_attribute"]["rpc"])
37+
# def setMeshPolyhedronsVertexAttribute(self, params):
38+
# print(self.mesh_polyhedrons_prefix + self.mesh_polyhedrons_schemas_dict["vertex_attribute"]["rpc"], f"{params=}", flush=True)
39+
# validate_schema(params, self.mesh_polyhedrons_schemas_dict["vertex_attribute"])
40+
# id = params["id"]
41+
# name = str(params["name"])
42+
# self.setMeshVertexAttribute(id, name)
43+
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)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
"a": {
27+
"type": "number",
28+
"minimum": 0,
29+
"maximum": 1,
30+
"default": 1
31+
}
32+
},
33+
"required": [
34+
"r",
35+
"g",
36+
"b"
37+
],
38+
"additionalProperties": false
39+
}
40+
},
41+
"required": [
42+
"id",
43+
"color"
44+
],
45+
"additionalProperties": false
46+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"rpc": "polygon_attribute",
3+
"type": "object",
4+
"properties": {
5+
"id": {
6+
"type": "string"
7+
},
8+
"name": {
9+
"type": "string"
10+
}
11+
},
12+
"required": [
13+
"id",
14+
"name"
15+
],
16+
"additionalProperties": false
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"rpc": "vertex_attribute",
3+
"type": "object",
4+
"properties": {
5+
"id": {
6+
"type": "string"
7+
},
8+
"name": {
9+
"type": "string"
10+
}
11+
},
12+
"required": [
13+
"id",
14+
"name"
15+
],
16+
"additionalProperties": false
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"rpc": "visibility",
3+
"type": "object",
4+
"properties": {
5+
"id": {
6+
"type": "string"
7+
},
8+
"visibility": {
9+
"type": "boolean"
10+
}
11+
},
12+
"required": [
13+
"id",
14+
"visibility"
15+
],
16+
"additionalProperties": false
17+
}
5.17 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Standard library imports
2+
3+
# Third party imports
4+
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
5+
from opengeodeweb_viewer.rpc.mesh.polyhedrons.polyhedrons_protocols import VtkMeshPolyhedronsView
6+
7+
# Local application imports
8+
9+
10+
def test_register_mesh(server):
11+
12+
server.call(VtkMeshView.mesh_prefix + VtkMeshView.mesh_schemas_dict["register"]["rpc"], [{"id": "123456789", "file_name": "hybrid_solid.vtu"}])
13+
assert server.compare_image(3, "mesh/polyhedrons/register.jpeg") == True
14+
15+
def test_polyhedrons_color(server):
16+
17+
test_register_mesh(server)
18+
19+
server.call(VtkMeshPolyhedronsView.mesh_polyhedrons_prefix + VtkMeshPolyhedronsView.mesh_polyhedrons_schemas_dict["color"]["rpc"], [{"id": "123456789", "color": {"r": 255, "g": 0, "b": 0}}])
20+
assert server.compare_image(3, "mesh/polyhedrons/color.jpeg") == True

src/tests/tests_output/test.jpeg

-5.13 KB
Loading

0 commit comments

Comments
 (0)