Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ wslink==1.12.4
yarl>=1
# via aiohttp

opengeodeweb-microservice==1.*,>=1.0.5
13 changes: 10 additions & 3 deletions src/opengeodeweb_viewer/rpc/generic/generic_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

# Local application imports
from opengeodeweb_viewer.vtk_protocol import VtkView
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView
from opengeodeweb_viewer.utils_functions import get_schemas_dict, validate_schema
from . import schemas


class VtkGenericView(VtkView):
Expand All @@ -16,7 +19,9 @@ class VtkGenericView(VtkView):
os.path.join(os.path.dirname(__file__), "schemas")
)

def __init__(self, mesh_protocols, model_protocols):
def __init__(
self, mesh_protocols: VtkMeshView, model_protocols: VtkModelView
) -> None:
super().__init__()
self.mesh_protocols = mesh_protocols
self.model_protocols = model_protocols
Expand All @@ -26,7 +31,8 @@ def register(self, params):
validate_schema(
params, self.generic_schemas_dict["register"], self.generic_prefix
)
data_id = str(params["id"])
params = schemas.Register.from_dict(params)
data_id = params.id
specific_params = {"id": data_id}
data = self.get_data(data_id)
viewer_object = str(data["viewer_object"])
Expand All @@ -40,7 +46,8 @@ def deregister(self, params):
validate_schema(
params, self.generic_schemas_dict["deregister"], self.generic_prefix
)
data_id = str(params["id"])
params = schemas.Deregister.from_dict(params)
data_id = params.id
specific_params = {"id": data_id}
data = self.get_data(data_id)
viewer_object = str(data["viewer_object"])
Expand Down
2 changes: 2 additions & 0 deletions src/opengeodeweb_viewer/rpc/generic/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .register import *
from .deregister import *
7 changes: 7 additions & 0 deletions src/opengeodeweb_viewer/rpc/generic/schemas/deregister.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class Deregister(DataClassJsonMixin):
id: str
7 changes: 7 additions & 0 deletions src/opengeodeweb_viewer/rpc/generic/schemas/register.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class Register(DataClassJsonMixin):
id: str
21 changes: 9 additions & 12 deletions src/opengeodeweb_viewer/rpc/mesh/edges/mesh_edges_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# Local application imports
from opengeodeweb_viewer.utils_functions import get_schemas_dict, validate_schema
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
from . import schemas


class VtkMeshEdgesView(VtkMeshView):
Expand All @@ -15,34 +16,30 @@ class VtkMeshEdgesView(VtkMeshView):
os.path.join(os.path.dirname(__file__), "schemas")
)

def __init__(self):
def __init__(self) -> None:
super().__init__()

@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["visibility"]["rpc"])
def setMeshEdgesVisibility(self, params):
validate_schema(
params, self.mesh_edges_schemas_dict["visibility"], self.mesh_edges_prefix
)
id, visibility = params["id"], params["visibility"]
self.SetEdgesVisibility(id, visibility)
params = schemas.Visibility.from_dict(params)
self.SetEdgesVisibility(params.id, params.visibility)

@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["color"]["rpc"])
def setMeshEdgesColor(self, params):
validate_schema(
params, self.mesh_edges_schemas_dict["color"], self.mesh_edges_prefix
)
id, red, green, blue = (
params["id"],
params["color"]["r"],
params["color"]["g"],
params["color"]["b"],
)
self.SetEdgesColor(id, red, green, blue)
params = schemas.Color.from_dict(params)
color = params.color
self.SetEdgesColor(params.id, color.r, color.g, color.b)

@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["width"]["rpc"])
def setMeshEdgesWidth(self, params):
validate_schema(
params, self.mesh_edges_schemas_dict["width"], self.mesh_edges_prefix
)
id, size = params["id"], params["width"]
self.SetEdgesWidth(id, width)
params = schemas.Color.from_dict(params)
self.SetEdgesWidth(params.id, params.width)
5 changes: 5 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/edges/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .width import *
from .visibility import *
from .vertex_attribute import *
from .size import *
from .color import *
17 changes: 17 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/edges/schemas/color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass
from typing import Optional


@dataclass
class ColorClass(DataClassJsonMixin):
b: int
g: int
r: int
a: Optional[float] = None


@dataclass
class Color(DataClassJsonMixin):
color: ColorClass
id: str
8 changes: 8 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/edges/schemas/size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class Size(DataClassJsonMixin):
id: str
size: int
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class VertexAttribute(DataClassJsonMixin):
id: str
name: str
8 changes: 8 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/edges/schemas/visibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class Visibility(DataClassJsonMixin):
id: str
visibility: bool
8 changes: 8 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/edges/schemas/width.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class Width(DataClassJsonMixin):
id: str
width: float
47 changes: 19 additions & 28 deletions src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
RpcParamsWithColor,
)
from opengeodeweb_viewer.object.object_methods import VtkObjectView
from . import schemas


class VtkMeshView(VtkObjectView):
Expand All @@ -30,7 +31,8 @@ def __init__(self) -> None:
def registerMesh(self, params: RpcParams) -> None:
print(f"{self.mesh_schemas_dict["register"]}", flush=True)
validate_schema(params, self.mesh_schemas_dict["register"], self.mesh_prefix)
data_id = str(params["id"])
params = schemas.Register.from_dict(params)
data_id = params.id
try:
data = self.get_data(data_id)
file_name = str(data["viewable_file_name"])
Expand Down Expand Up @@ -70,52 +72,41 @@ def registerMesh(self, params: RpcParams) -> None:
@exportRpc(mesh_prefix + mesh_schemas_dict["deregister"]["rpc"])
def deregisterMesh(self, params: RpcParams) -> None:
validate_schema(params, self.mesh_schemas_dict["deregister"], self.mesh_prefix)
data_id = str(params["id"])
self.deregisterObject(data_id)
params = schemas.Deregister.from_dict(params)
self.deregisterObject(params.id)

@exportRpc(mesh_prefix + mesh_schemas_dict["visibility"]["rpc"])
def SetMeshVisibility(self, params: RpcParams) -> None:
validate_schema(params, self.mesh_schemas_dict["visibility"], self.mesh_prefix)
data_id, visibility = str(params["id"]), bool(params["visibility"])
self.SetVisibility(data_id, visibility)
params = schemas.Visibility.from_dict(params)
self.SetVisibility(params.id, parmas.visibility)

@exportRpc(mesh_prefix + mesh_schemas_dict["opacity"]["rpc"])
def setMeshOpacity(self, params: RpcParams) -> None:
validate_schema(params, self.mesh_schemas_dict["opacity"], self.mesh_prefix)
data_id, opacity = str(params["id"]), float(
cast(int | float, params["opacity"])
)
self.SetOpacity(data_id, opacity)
params = schemas.Opacity.from_dict(params)
self.SetOpacity(params.id, params.opacity)

@exportRpc(mesh_prefix + mesh_schemas_dict["color"]["rpc"])
def setMeshColor(self, params: RpcParamsWithColor) -> None:
validate_schema(params, self.mesh_schemas_dict["color"], self.mesh_prefix)
color_dict = cast(dict[str, int], params["color"])
data_id, red, green, blue = (
str(params["id"]),
int(color_dict["r"]),
int(color_dict["g"]),
int(color_dict["b"]),
)
self.SetColor(data_id, red, green, blue)
params = schemas.Color.from_dict(params)
color = params.color
self.SetColor(params.id, color.r, color.g, color.b)

@exportRpc(mesh_prefix + mesh_schemas_dict["apply_textures"]["rpc"])
def meshApplyTextures(self, params: RpcParams) -> None:
validate_schema(
params, self.mesh_schemas_dict["apply_textures"], self.mesh_prefix
)
data_id = str(params["id"])
textures_info = cast(list[dict[str, str]], params["textures"])
self.applyTextures(data_id, textures_info)

def applyTextures(self, mesh_id: str, textures_info: list[dict[str, str]]) -> None:
for tex_info in textures_info:
texture_id = tex_info["id"]
texture_name = tex_info["texture_name"]
params = schemas.ApplyTextures.from_dict(params)
mesh_id = params.id
for tex_info in params.textures:
texture_id = tex_info.id
texture_data = Data.get(texture_id)
if not texture_data:
if texture_data is None:
continue
texture_file = str(texture_data.viewable_file_name)
texture_file = texture_data.viewable_file_name
if not texture_file.lower().endswith(".vti"):
continue
texture_file_path = self.get_data_file_path(texture_id)
Expand All @@ -130,7 +121,7 @@ def applyTextures(self, mesh_id: str, textures_info: list[dict[str, str]]) -> No
point_data = output.GetPointData()
for i in range(point_data.GetNumberOfArrays()):
array = point_data.GetArray(i)
if array.GetName() == texture_name:
if array.GetName() == tex_info.texture_name:
point_data.SetTCoords(array)
break
actor = cast(vtk.vtkActor, self.get_object(mesh_id)["actor"])
Expand Down
23 changes: 10 additions & 13 deletions src/opengeodeweb_viewer/rpc/mesh/points/mesh_points_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
RpcParamsWithColor,
)
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
from . import schemas


class VtkMeshPointsView(VtkMeshView):
Expand All @@ -28,29 +29,25 @@ def setMeshPointsVisibility(self, params: RpcParams) -> None:
validate_schema(
params, self.mesh_points_schemas_dict["visibility"], self.mesh_points_prefix
)
id, visibility = params["id"], params["visibility"]
self.SetPointsVisibility(id, visibility)
params = schemas.Visibility.from_dict(params)
self.SetPointsVisibility(params.id, params.visibility)

@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["color"]["rpc"])
def setMeshPointsColor(self, params: RpcParamsWithColor) -> None:
validate_schema(
params, self.mesh_points_schemas_dict["color"], self.mesh_points_prefix
)
id, red, green, blue = (
params["id"],
params["color"]["r"],
params["color"]["g"],
params["color"]["b"],
)
self.SetPointsColor(id, red, green, blue)
params = schemas.Color.from_dict(params)
color = params.color
self.SetPointsColor(params.id, color.r, color.g, color.b)

@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["size"]["rpc"])
def setMeshPointsSize(self, params: RpcParams) -> None:
validate_schema(
params, self.mesh_points_schemas_dict["size"], self.mesh_points_prefix
)
id, size = params["id"], params["size"]
self.SetPointsSize(id, size)
params = schemas.Size.from_dict(params)
self.SetPointsSize(params.id, params.size)

@exportRpc(mesh_points_prefix + mesh_points_schemas_dict["vertex_attribute"]["rpc"])
def setMeshPointsVertexAttribute(self, params: RpcParams) -> None:
Expand All @@ -59,5 +56,5 @@ def setMeshPointsVertexAttribute(self, params: RpcParams) -> None:
self.mesh_points_schemas_dict["vertex_attribute"],
self.mesh_points_prefix,
)
id, name = params["id"], params["name"]
self.displayAttributeOnVertices(id, name)
params = schemas.VertexAttribute.from_dict(params)
self.displayAttributeOnVertices(params.id, pramas.name)
4 changes: 4 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/points/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .visibility import *
from .vertex_attribute import *
from .size import *
from .color import *
17 changes: 17 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/points/schemas/color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass
from typing import Optional


@dataclass
class ColorClass(DataClassJsonMixin):
b: int
g: int
r: int
a: Optional[float] = None


@dataclass
class Color(DataClassJsonMixin):
color: ColorClass
id: str
8 changes: 8 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/points/schemas/size.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class Size(DataClassJsonMixin):
id: str
size: float
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class VertexAttribute(DataClassJsonMixin):
id: str
name: str
8 changes: 8 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/points/schemas/visibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class Visibility(DataClassJsonMixin):
id: str
visibility: bool
Loading
Loading