Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
5 changes: 4 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
const Configuration = {
extends: ["@commitlint/config-angular"],
rules: {
"scope-empty": [2, "never"],
Expand All @@ -12,5 +12,8 @@ export default {
"subject-full-stop": [0],
"type-case": [0],
"type-empty": [0],
"type-enum": [2, "always", ["feat", "fix", "perf"]],
},
}

export default Configuration
109 changes: 109 additions & 0 deletions opengeodeweb_viewer_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,115 @@
}
},
"mesh": {
"cells": {
"visibility": {
"$id": "opengeodeweb_viewer.mesh.cells.visibility",
"rpc": "visibility",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"visibility": {
"type": "boolean"
}
},
"required": [
"id",
"visibility"
],
"additionalProperties": false
},
"vertex_attribute": {
"$id": "opengeodeweb_viewer.mesh.cells.vertex_attribute",
"rpc": "vertex_attribute",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"name": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"name"
],
"additionalProperties": false
},
"color": {
"$id": "opengeodeweb_viewer.mesh.cells.color",
"rpc": "color",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
"r": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"g": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"b": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"a": {
"type": "number",
"minimum": 0,
"maximum": 1,
"default": 1
}
},
"required": [
"r",
"g",
"b"
],
"additionalProperties": false
}
},
"required": [
"id",
"color"
],
"additionalProperties": false
},
"cell_attribute": {
"$id": "opengeodeweb_viewer.mesh.cells.cell_attribute",
"rpc": "cell_attribute",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"name": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"name"
],
"additionalProperties": false
}
},
"edges": {
"width": {
"$id": "opengeodeweb_viewer.mesh.edges.size",
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ where = ["src"]
"opengeodeweb_viewer.rpc.mesh.schemas" = ["*.json"]
"opengeodeweb_viewer.rpc.mesh.points.schemas" = ["*.json"]
"opengeodeweb_viewer.rpc.mesh.edges.schemas" = ["*.json"]
"opengeodeweb_viewer.rpc.mesh.cells.schemas" = ["*.json"]
"opengeodeweb_viewer.rpc.mesh.polygons.schemas" = ["*.json"]
"opengeodeweb_viewer.rpc.mesh.polyhedra.schemas" = ["*.json"]
"opengeodeweb_viewer.rpc.model.schemas" = ["*.json"]
Expand Down
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.9
65 changes: 65 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/cells_protocols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Standard library imports
import os

# Third party imports
from wslink import register as exportRpc # type: ignore
from opengeodeweb_microservice.schemas import get_schemas_dict

# Local application imports
from opengeodeweb_viewer.utils_functions import (
validate_schema,
RpcParams,
)
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
from . import schemas


class VtkMeshCellsView(VtkMeshView):
mesh_cells_prefix = "opengeodeweb_viewer.mesh.cells."
mesh_cells_schemas_dict = get_schemas_dict(
os.path.join(os.path.dirname(__file__), "schemas")
)

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

@exportRpc(mesh_cells_prefix + mesh_cells_schemas_dict["visibility"]["rpc"])
def setMeshCellsVisibility(self, rpc_params: RpcParams) -> None:
validate_schema(
rpc_params,
self.mesh_cells_schemas_dict["visibility"],
self.mesh_cells_prefix,
)
params = schemas.Visibility.from_dict(rpc_params)
self.SetVisibility(params.id, params.visibility)

@exportRpc(mesh_cells_prefix + mesh_cells_schemas_dict["color"]["rpc"])
def setMeshCellsColor(self, rpc_params: RpcParams) -> None:
validate_schema(
rpc_params,
self.mesh_cells_schemas_dict["color"],
self.mesh_cells_prefix,
)
params = schemas.Color.from_dict(rpc_params)
color = params.color
self.SetColor(params.id, color.r, color.g, color.b)

@exportRpc(mesh_cells_prefix + mesh_cells_schemas_dict["vertex_attribute"]["rpc"])
def setMeshCellsVertexAttribute(self, rpc_params: RpcParams) -> None:
validate_schema(
rpc_params,
self.mesh_cells_schemas_dict["vertex_attribute"],
self.mesh_cells_prefix,
)
params = schemas.VertexAttribute.from_dict(rpc_params)
self.displayAttributeOnVertices(params.id, params.name)

@exportRpc(mesh_cells_prefix + mesh_cells_schemas_dict["cell_attribute"]["rpc"])
def setMeshCellsCellAttribute(self, rpc_params: RpcParams) -> None:
validate_schema(
rpc_params,
self.mesh_cells_schemas_dict["cell_attribute"],
self.mesh_cells_prefix,
)
params = schemas.CellAttribute.from_dict(rpc_params)
self.displayAttributeOnCells(params.id, params.name)
4 changes: 4 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/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 .color import *
from .cell_attribute import *
16 changes: 16 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/schemas/cell_attribute.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"rpc": "cell_attribute",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"name": {
"type": "string",
"minLength": 1
}
},
"required": ["id", "name"],
"additionalProperties": false
}
11 changes: 11 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/schemas/cell_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class CellAttribute(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

id: str
name: str
47 changes: 47 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/schemas/color.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"rpc": "color",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
"r": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"g": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"b": {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"a": {
"type": "number",
"minimum": 0,
"maximum": 1,
"default": 1
}
},
"required": [
"r",
"g",
"b"
],
"additionalProperties": false
}
},
"required": [
"id",
"color"
],
"additionalProperties": false
}
23 changes: 23 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/schemas/color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass
from typing import Optional


@dataclass
class ColorClass(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

b: int
g: int
r: int
a: Optional[float] = None


@dataclass
class Color(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

color: ColorClass
id: str
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"rpc": "vertex_attribute",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"name": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"name"
],
"additionalProperties": false
}
11 changes: 11 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/schemas/vertex_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class VertexAttribute(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

id: str
name: str
18 changes: 18 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/schemas/visibility.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"rpc": "visibility",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"visibility": {
"type": "boolean"
}
},
"required": [
"id",
"visibility"
],
"additionalProperties": false
}
11 changes: 11 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/cells/schemas/visibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass


@dataclass
class Visibility(DataClassJsonMixin):
def __post_init__(self) -> None:
print(self, flush=True)

id: str
visibility: bool
4 changes: 2 additions & 2 deletions src/opengeodeweb_viewer/rpc/mesh/mesh_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def registerMesh(self, rpc_params: RpcParams) -> None:
params = schemas.Register.from_dict(rpc_params)
data_id = params.id
try:
file_name = str(self.get_data(data_id)["viewable_file_name"])
file_name = str(self.get_data(data_id)["viewable_file"])
reader = vtkXMLGenericDataObjectReader()
mapper = vtkDataSetMapper()
mapper.SetInputConnection(reader.GetOutputPort())
Expand Down Expand Up @@ -108,7 +108,7 @@ def meshApplyTextures(self, rpc_params: RpcParams) -> None:
texture_data = Data.get(texture_id)
if texture_data is None:
continue
texture_file = texture_data.viewable_file_name
texture_file = texture_data.viewable_file
if not texture_file.lower().endswith(".vti"):
continue
texture_file_path = self.get_data_file_path(texture_id)
Expand Down
Loading
Loading