Skip to content

Commit 54fd180

Browse files
authored
Merge pull request #112 from Geode-solutions/geode-objects-redesign
feat(Cells): mesh cells protocols
2 parents 0d46428 + 08bea89 commit 54fd180

39 files changed

+517
-33
lines changed

commitlint.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default {
1+
const Configuration = {
22
extends: ["@commitlint/config-angular"],
33
rules: {
44
"scope-empty": [2, "never"],
@@ -12,5 +12,8 @@ export default {
1212
"subject-full-stop": [0],
1313
"type-case": [0],
1414
"type-empty": [0],
15+
"type-enum": [2, "always", ["feat", "fix", "perf"]],
1516
},
1617
}
18+
19+
export default Configuration

opengeodeweb_viewer_schemas.json

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,115 @@
3333
}
3434
},
3535
"mesh": {
36+
"cells": {
37+
"visibility": {
38+
"$id": "opengeodeweb_viewer.mesh.cells.visibility",
39+
"rpc": "visibility",
40+
"type": "object",
41+
"properties": {
42+
"id": {
43+
"type": "string",
44+
"minLength": 1
45+
},
46+
"visibility": {
47+
"type": "boolean"
48+
}
49+
},
50+
"required": [
51+
"id",
52+
"visibility"
53+
],
54+
"additionalProperties": false
55+
},
56+
"vertex_attribute": {
57+
"$id": "opengeodeweb_viewer.mesh.cells.vertex_attribute",
58+
"rpc": "vertex_attribute",
59+
"type": "object",
60+
"properties": {
61+
"id": {
62+
"type": "string",
63+
"minLength": 1
64+
},
65+
"name": {
66+
"type": "string",
67+
"minLength": 1
68+
}
69+
},
70+
"required": [
71+
"id",
72+
"name"
73+
],
74+
"additionalProperties": false
75+
},
76+
"color": {
77+
"$id": "opengeodeweb_viewer.mesh.cells.color",
78+
"rpc": "color",
79+
"type": "object",
80+
"properties": {
81+
"id": {
82+
"type": "string",
83+
"minLength": 1
84+
},
85+
"color": {
86+
"type": "object",
87+
"properties": {
88+
"r": {
89+
"type": "integer",
90+
"minimum": 0,
91+
"maximum": 255
92+
},
93+
"g": {
94+
"type": "integer",
95+
"minimum": 0,
96+
"maximum": 255
97+
},
98+
"b": {
99+
"type": "integer",
100+
"minimum": 0,
101+
"maximum": 255
102+
},
103+
"a": {
104+
"type": "number",
105+
"minimum": 0,
106+
"maximum": 1,
107+
"default": 1
108+
}
109+
},
110+
"required": [
111+
"r",
112+
"g",
113+
"b"
114+
],
115+
"additionalProperties": false
116+
}
117+
},
118+
"required": [
119+
"id",
120+
"color"
121+
],
122+
"additionalProperties": false
123+
},
124+
"cell_attribute": {
125+
"$id": "opengeodeweb_viewer.mesh.cells.cell_attribute",
126+
"rpc": "cell_attribute",
127+
"type": "object",
128+
"properties": {
129+
"id": {
130+
"type": "string",
131+
"minLength": 1
132+
},
133+
"name": {
134+
"type": "string",
135+
"minLength": 1
136+
}
137+
},
138+
"required": [
139+
"id",
140+
"name"
141+
],
142+
"additionalProperties": false
143+
}
144+
},
36145
"edges": {
37146
"width": {
38147
"$id": "opengeodeweb_viewer.mesh.edges.size",

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ where = ["src"]
3636
"opengeodeweb_viewer.rpc.mesh.schemas" = ["*.json"]
3737
"opengeodeweb_viewer.rpc.mesh.points.schemas" = ["*.json"]
3838
"opengeodeweb_viewer.rpc.mesh.edges.schemas" = ["*.json"]
39+
"opengeodeweb_viewer.rpc.mesh.cells.schemas" = ["*.json"]
3940
"opengeodeweb_viewer.rpc.mesh.polygons.schemas" = ["*.json"]
4041
"opengeodeweb_viewer.rpc.mesh.polyhedra.schemas" = ["*.json"]
4142
"opengeodeweb_viewer.rpc.model.schemas" = ["*.json"]

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ wslink==1.12.4
6161
yarl>=1
6262
# via aiohttp
6363

64-
opengeodeweb-microservice==1.*,>=1.0.9
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Standard library imports
2+
import os
3+
4+
# Third party imports
5+
from wslink import register as exportRpc # type: ignore
6+
from opengeodeweb_microservice.schemas import get_schemas_dict
7+
8+
# Local application imports
9+
from opengeodeweb_viewer.utils_functions import (
10+
validate_schema,
11+
RpcParams,
12+
)
13+
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
14+
from . import schemas
15+
16+
17+
class VtkMeshCellsView(VtkMeshView):
18+
mesh_cells_prefix = "opengeodeweb_viewer.mesh.cells."
19+
mesh_cells_schemas_dict = get_schemas_dict(
20+
os.path.join(os.path.dirname(__file__), "schemas")
21+
)
22+
23+
def __init__(self) -> None:
24+
super().__init__()
25+
26+
@exportRpc(mesh_cells_prefix + mesh_cells_schemas_dict["visibility"]["rpc"])
27+
def setMeshCellsVisibility(self, rpc_params: RpcParams) -> None:
28+
validate_schema(
29+
rpc_params,
30+
self.mesh_cells_schemas_dict["visibility"],
31+
self.mesh_cells_prefix,
32+
)
33+
params = schemas.Visibility.from_dict(rpc_params)
34+
self.SetVisibility(params.id, params.visibility)
35+
36+
@exportRpc(mesh_cells_prefix + mesh_cells_schemas_dict["color"]["rpc"])
37+
def setMeshCellsColor(self, rpc_params: RpcParams) -> None:
38+
validate_schema(
39+
rpc_params,
40+
self.mesh_cells_schemas_dict["color"],
41+
self.mesh_cells_prefix,
42+
)
43+
params = schemas.Color.from_dict(rpc_params)
44+
color = params.color
45+
self.SetColor(params.id, color.r, color.g, color.b)
46+
47+
@exportRpc(mesh_cells_prefix + mesh_cells_schemas_dict["vertex_attribute"]["rpc"])
48+
def setMeshCellsVertexAttribute(self, rpc_params: RpcParams) -> None:
49+
validate_schema(
50+
rpc_params,
51+
self.mesh_cells_schemas_dict["vertex_attribute"],
52+
self.mesh_cells_prefix,
53+
)
54+
params = schemas.VertexAttribute.from_dict(rpc_params)
55+
self.displayAttributeOnVertices(params.id, params.name)
56+
57+
@exportRpc(mesh_cells_prefix + mesh_cells_schemas_dict["cell_attribute"]["rpc"])
58+
def setMeshCellsCellAttribute(self, rpc_params: RpcParams) -> None:
59+
validate_schema(
60+
rpc_params,
61+
self.mesh_cells_schemas_dict["cell_attribute"],
62+
self.mesh_cells_prefix,
63+
)
64+
params = schemas.CellAttribute.from_dict(rpc_params)
65+
self.displayAttributeOnCells(params.id, params.name)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .visibility import *
2+
from .vertex_attribute import *
3+
from .color import *
4+
from .cell_attribute import *
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"rpc": "cell_attribute",
3+
"type": "object",
4+
"properties": {
5+
"id": {
6+
"type": "string",
7+
"minLength": 1
8+
},
9+
"name": {
10+
"type": "string",
11+
"minLength": 1
12+
}
13+
},
14+
"required": ["id", "name"],
15+
"additionalProperties": false
16+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from dataclasses_json import DataClassJsonMixin
2+
from dataclasses import dataclass
3+
4+
5+
@dataclass
6+
class CellAttribute(DataClassJsonMixin):
7+
def __post_init__(self) -> None:
8+
print(self, flush=True)
9+
10+
id: str
11+
name: str
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"rpc": "color",
3+
"type": "object",
4+
"properties": {
5+
"id": {
6+
"type": "string",
7+
"minLength": 1
8+
},
9+
"color": {
10+
"type": "object",
11+
"properties": {
12+
"r": {
13+
"type": "integer",
14+
"minimum": 0,
15+
"maximum": 255
16+
},
17+
"g": {
18+
"type": "integer",
19+
"minimum": 0,
20+
"maximum": 255
21+
},
22+
"b": {
23+
"type": "integer",
24+
"minimum": 0,
25+
"maximum": 255
26+
},
27+
"a": {
28+
"type": "number",
29+
"minimum": 0,
30+
"maximum": 1,
31+
"default": 1
32+
}
33+
},
34+
"required": [
35+
"r",
36+
"g",
37+
"b"
38+
],
39+
"additionalProperties": false
40+
}
41+
},
42+
"required": [
43+
"id",
44+
"color"
45+
],
46+
"additionalProperties": false
47+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
def __post_init__(self) -> None:
9+
print(self, flush=True)
10+
11+
b: int
12+
g: int
13+
r: int
14+
a: Optional[float] = None
15+
16+
17+
@dataclass
18+
class Color(DataClassJsonMixin):
19+
def __post_init__(self) -> None:
20+
print(self, flush=True)
21+
22+
color: ColorClass
23+
id: str

0 commit comments

Comments
 (0)