Skip to content

Commit b8306e4

Browse files
committed
wip
1 parent f487dc1 commit b8306e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+656
-60
lines changed

src/opengeodeweb_viewer/rpc/generic/generic_protocols.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,28 @@
77

88
# Local application imports
99
from opengeodeweb_viewer.vtk_protocol import VtkView
10+
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
11+
from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView
1012
from opengeodeweb_viewer.utils_functions import get_schemas_dict, validate_schema
13+
from . import schemas
1114

1215

1316
class VtkGenericView(VtkView):
14-
generic_prefix = "opengeodeweb_viewer.generic."
15-
generic_schemas_dict = get_schemas_dict(
16-
os.path.join(os.path.dirname(__file__), "schemas")
17-
)
17+
prefix = "opengeodeweb_viewer.generic."
18+
schemas_dict = get_schemas_dict(os.path.join(os.path.dirname(__file__), "schemas"))
1819

19-
def __init__(self, mesh_protocols, model_protocols):
20+
def __init__(
21+
self, mesh_protocols: VtkMeshView, model_protocols: VtkModelView
22+
) -> None:
2023
super().__init__()
2124
self.mesh_protocols = mesh_protocols
2225
self.model_protocols = model_protocols
2326

24-
@exportRpc(generic_prefix + generic_schemas_dict["register"]["rpc"])
27+
@exportRpc(prefix + schemas_dict["register"]["rpc"])
2528
def register(self, params):
26-
validate_schema(
27-
params, self.generic_schemas_dict["register"], self.generic_prefix
28-
)
29-
data_id = str(params["id"])
29+
validate_schema(params, self.schemas_dict["register"], self.prefix)
30+
params = schemas.Register.from_dict(params)
31+
data_id = params.id
3032
specific_params = {"id": data_id}
3133
data = self.get_data(data_id)
3234
viewer_object = str(data["viewer_object"])
@@ -35,12 +37,11 @@ def register(self, params):
3537
elif viewer_object == "model":
3638
self.model_protocols.registerModel(specific_params)
3739

38-
@exportRpc(generic_prefix + generic_schemas_dict["deregister"]["rpc"])
40+
@exportRpc(prefix + schemas_dict["deregister"]["rpc"])
3941
def deregister(self, params):
40-
validate_schema(
41-
params, self.generic_schemas_dict["deregister"], self.generic_prefix
42-
)
43-
data_id = str(params["id"])
42+
validate_schema(params, self.schemas_dict["deregister"], self.prefix)
43+
params = schemas.Deregister.from_dict(params)
44+
data_id = params.id
4445
specific_params = {"id": data_id}
4546
data = self.get_data(data_id)
4647
viewer_object = str(data["viewer_object"])
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .register import *
2+
from .deregister import *
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
4+
5+
@dataclass
6+
class Deregister(DataClassJsonMixin):
7+
id: str
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
4+
5+
@dataclass
6+
class Register(DataClassJsonMixin):
7+
id: str
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .width import *
2+
from .visibility import *
3+
from .vertex_attribute import *
4+
from .size import *
5+
from .color import *
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
from typing import Optional
4+
5+
6+
@dataclass
7+
class ColorClass(DataClassJsonMixin):
8+
b: int
9+
g: int
10+
r: int
11+
a: Optional[float] = None
12+
13+
14+
@dataclass
15+
class Color(DataClassJsonMixin):
16+
color: ColorClass
17+
id: str
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
4+
5+
@dataclass
6+
class Size(DataClassJsonMixin):
7+
id: str
8+
size: int
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
4+
5+
@dataclass
6+
class VertexAttribute(DataClassJsonMixin):
7+
id: str
8+
name: str
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
4+
5+
@dataclass
6+
class Visibility(DataClassJsonMixin):
7+
id: str
8+
visibility: bool
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
4+
5+
@dataclass
6+
class Width(DataClassJsonMixin):
7+
id: str
8+
width: float

0 commit comments

Comments
 (0)