diff --git a/opengeodeweb_viewer_schemas.json b/opengeodeweb_viewer_schemas.json index 47ffb9db..8a937514 100644 --- a/opengeodeweb_viewer_schemas.json +++ b/opengeodeweb_viewer_schemas.json @@ -1140,6 +1140,182 @@ }, "model": { "blocks": { + "edges": { + "width": { + "$id": "opengeodeweb_viewer.model.blocks.edges.width", + "rpc": "width", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "width": { + "type": "number" + } + }, + "required": [ + "id", + "width" + ], + "additionalProperties": false + }, + "visibility": { + "$id": "opengeodeweb_viewer.model.blocks.edges.visibility", + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "color": { + "$id": "opengeodeweb_viewer.model.blocks.edges.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 + } + }, + "points": { + "visibility": { + "$id": "opengeodeweb_viewer.model.blocks.points.visibility", + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "size": { + "$id": "opengeodeweb_viewer.model.blocks.points.size", + "rpc": "size", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "size": { + "type": "number" + } + }, + "required": [ + "id", + "size" + ], + "additionalProperties": false + }, + "color": { + "$id": "opengeodeweb_viewer.model.blocks.points.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 + } + }, "visibility": { "$id": "opengeodeweb_viewer.model.blocks.visibility", "rpc": "visibility", @@ -1167,6 +1343,44 @@ ], "additionalProperties": false }, + "points_visibility": { + "$id": "opengeodeweb_viewer.model.blocks.points_visibility", + "rpc": "points_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "edges_visibility": { + "$id": "opengeodeweb_viewer.model.blocks.edges_visibility", + "rpc": "edges_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, "color": { "$id": "opengeodeweb_viewer.model.blocks.color", "rpc": "color", @@ -1225,6 +1439,94 @@ } }, "corners": { + "points": { + "visibility": { + "$id": "opengeodeweb_viewer.model.corners.points.visibility", + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "size": { + "$id": "opengeodeweb_viewer.model.corners.points.size", + "rpc": "size", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "size": { + "type": "number" + } + }, + "required": [ + "id", + "size" + ], + "additionalProperties": false + }, + "color": { + "$id": "opengeodeweb_viewer.model.corners.points.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 + } + }, "visibility": { "$id": "opengeodeweb_viewer.model.corners.visibility", "rpc": "visibility", @@ -1252,6 +1554,44 @@ ], "additionalProperties": false }, + "points_visibility": { + "$id": "opengeodeweb_viewer.model.corners.points_visibility", + "rpc": "points_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "edges_visibility": { + "$id": "opengeodeweb_viewer.model.corners.edges_visibility", + "rpc": "edges_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, "color": { "$id": "opengeodeweb_viewer.model.corners.color", "rpc": "color", @@ -1331,6 +1671,182 @@ } }, "lines": { + "edges": { + "width": { + "$id": "opengeodeweb_viewer.model.lines.edges.width", + "rpc": "width", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "width": { + "type": "number" + } + }, + "required": [ + "id", + "width" + ], + "additionalProperties": false + }, + "visibility": { + "$id": "opengeodeweb_viewer.model.lines.edges.visibility", + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "color": { + "$id": "opengeodeweb_viewer.model.lines.edges.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 + } + }, + "points": { + "visibility": { + "$id": "opengeodeweb_viewer.model.lines.points.visibility", + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "size": { + "$id": "opengeodeweb_viewer.model.lines.points.size", + "rpc": "size", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "size": { + "type": "number" + } + }, + "required": [ + "id", + "size" + ], + "additionalProperties": false + }, + "color": { + "$id": "opengeodeweb_viewer.model.lines.points.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 + } + }, "visibility": { "$id": "opengeodeweb_viewer.model.lines.visibility", "rpc": "visibility", @@ -1358,6 +1874,44 @@ ], "additionalProperties": false }, + "points_visibility": { + "$id": "opengeodeweb_viewer.model.lines.points_visibility", + "rpc": "points_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "edges_visibility": { + "$id": "opengeodeweb_viewer.model.lines.edges_visibility", + "rpc": "edges_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, "color": { "$id": "opengeodeweb_viewer.model.lines.color", "rpc": "color", @@ -1504,7 +2058,239 @@ ], "additionalProperties": false }, + "components_color": { + "$id": "opengeodeweb_viewer.model.components_color", + "rpc": "components_color", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "block_ids": { + "type": "array", + "items": { + "type": "integer" + }, + "minItems": 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", + "block_ids", + "color" + ], + "additionalProperties": false + }, "surfaces": { + "edges": { + "width": { + "$id": "opengeodeweb_viewer.model.surfaces.edges.width", + "rpc": "width", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "width": { + "type": "number" + } + }, + "required": [ + "id", + "width" + ], + "additionalProperties": false + }, + "visibility": { + "$id": "opengeodeweb_viewer.model.surfaces.edges.visibility", + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "color": { + "$id": "opengeodeweb_viewer.model.surfaces.edges.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 + } + }, + "points": { + "visibility": { + "$id": "opengeodeweb_viewer.model.surfaces.points.visibility", + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "size": { + "$id": "opengeodeweb_viewer.model.surfaces.points.size", + "rpc": "size", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "size": { + "type": "number" + } + }, + "required": [ + "id", + "size" + ], + "additionalProperties": false + }, + "color": { + "$id": "opengeodeweb_viewer.model.surfaces.points.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 + } + }, "visibility": { "$id": "opengeodeweb_viewer.model.surfaces.visibility", "rpc": "visibility", @@ -1532,6 +2318,44 @@ ], "additionalProperties": false }, + "points_visibility": { + "$id": "opengeodeweb_viewer.model.surfaces.points_visibility", + "rpc": "points_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, + "edges_visibility": { + "$id": "opengeodeweb_viewer.model.surfaces.edges_visibility", + "rpc": "edges_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": [ + "id", + "visibility" + ], + "additionalProperties": false + }, "color": { "$id": "opengeodeweb_viewer.model.surfaces.color", "rpc": "color", diff --git a/requirements.txt b/requirements.txt index 5750c624..13efd779 100644 --- a/requirements.txt +++ b/requirements.txt @@ -61,4 +61,3 @@ wslink==1.12.4 yarl>=1 # via aiohttp -opengeodeweb-microservice==1.*,>=1.1.1 diff --git a/src/opengeodeweb_viewer/object/object_methods.py b/src/opengeodeweb_viewer/object/object_methods.py index 215aabae..2036ea78 100644 --- a/src/opengeodeweb_viewer/object/object_methods.py +++ b/src/opengeodeweb_viewer/object/object_methods.py @@ -42,16 +42,35 @@ def registerObject( if actor.visibility == True: resetCamara = False renderer.AddActor(data.actor) + for category_actor in data.category_actors.values(): + renderer.AddActor(category_actor) if resetCamara: renderer.ResetCamera() def deregisterObject(self, data_id: str) -> None: - actor = self.get_vtk_pipeline(data_id).actor + pipeline = self.get_vtk_pipeline(data_id) + actor = pipeline.actor renderWindow = self.getView("-1") renderer = renderWindow.GetRenderers().GetFirstRenderer() renderer.RemoveActor(actor) + for category_actor in pipeline.category_actors.values(): + renderer.RemoveActor(category_actor) self.deregister_object(data_id) + def SetCategoryEdgesVisibility( + self, data_id: str, category: str, visibility: bool + ) -> None: + actor = self.get_vtk_pipeline(data_id).category_actors.get(category) + if actor is not None: + actor.GetProperty().SetEdgeVisibility(visibility) + + def SetCategoryPointsVisibility( + self, data_id: str, category: str, visibility: bool + ) -> None: + actor = self.get_vtk_pipeline(data_id).category_actors.get(category) + if actor is not None: + actor.GetProperty().SetVertexVisibility(visibility) + def SetVisibility(self, data_id: str, visibility: bool) -> None: actor = self.get_vtk_pipeline(data_id).actor actor.SetVisibility(visibility) diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/__init__.py b/src/opengeodeweb_viewer/rpc/model/blocks/edges/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/model_surfaces_edges_protocols.py b/src/opengeodeweb_viewer/rpc/model/blocks/edges/model_surfaces_edges_protocols.py new file mode 100644 index 00000000..0bf04aeb --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/edges/model_surfaces_edges_protocols.py @@ -0,0 +1,57 @@ +# Standard library imports +import os + +# Third party imports +from wslink import register as exportRpc +from opengeodeweb_microservice.schemas import get_schemas_dict + +# Local application imports +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams +from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView +from . import schemas + + +class VtkModelBlocksEdgesView(VtkModelView): + model_blocks_edges_prefix = "opengeodeweb_viewer.model.blocks.edges." + model_blocks_edges_schemas_dict = get_schemas_dict( + os.path.join(os.path.dirname(__file__), "schemas") + ) + + def __init__(self) -> None: + super().__init__() + + @exportRpc( + model_blocks_edges_prefix + model_blocks_edges_schemas_dict["visibility"]["rpc"] + ) + def setModelBlocksEdgesVisibility(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_blocks_edges_schemas_dict["visibility"], + self.model_blocks_edges_prefix, + ) + params = schemas.Visibility.from_dict(rpc_params) + self.SetEdgesVisibility(params.id, params.visibility) + + @exportRpc( + model_blocks_edges_prefix + model_blocks_edges_schemas_dict["color"]["rpc"] + ) + def setModelBlocksEdgesColor(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_blocks_edges_schemas_dict["color"], + self.model_blocks_edges_prefix, + ) + params = schemas.Color.from_dict(rpc_params) + self.SetEdgesColor(params.id, params.color.r, params.color.g, params.color.b) + + @exportRpc( + model_blocks_edges_prefix + model_blocks_edges_schemas_dict["width"]["rpc"] + ) + def setModelBlocksEdgesWidth(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_blocks_edges_schemas_dict["width"], + self.model_blocks_edges_prefix, + ) + params = schemas.Width.from_dict(rpc_params) + self.SetEdgesWidth(params.id, params.width) diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/__init__.py new file mode 100644 index 00000000..cfe6b7ea --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/__init__.py @@ -0,0 +1,3 @@ +from .width import * +from .visibility import * +from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/color.json b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/color.json new file mode 100644 index 00000000..29f6f880 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/color.json @@ -0,0 +1,40 @@ +{ + "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 +} diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/color.py b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/color.py new file mode 100644 index 00000000..01f0222c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/color.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/visibility.json b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/visibility.json new file mode 100644 index 00000000..dc6b4213 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/visibility.py b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/visibility.py new file mode 100644 index 00000000..56a629d8 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/visibility.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/width.json b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/width.json new file mode 100644 index 00000000..bba8d11c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/width.json @@ -0,0 +1,15 @@ +{ + "rpc": "width", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "width": { + "type": "number" + } + }, + "required": ["id", "width"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/width.py b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/width.py new file mode 100644 index 00000000..eda85e61 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/edges/schemas/width.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class Width(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + width: float diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/__init__.py b/src/opengeodeweb_viewer/rpc/model/blocks/points/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/model_surfaces_points_protocols.py b/src/opengeodeweb_viewer/rpc/model/blocks/points/model_surfaces_points_protocols.py new file mode 100644 index 00000000..433c8c72 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/points/model_surfaces_points_protocols.py @@ -0,0 +1,53 @@ +import os +from wslink import register as exportRpc +from opengeodeweb_microservice.schemas import get_schemas_dict +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams +from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView +from . import schemas + + +class VtkModelBlocksPointsView(VtkModelView): + model_blocks_points_prefix = "opengeodeweb_viewer.model.blocks.points." + model_blocks_points_schemas_dict = get_schemas_dict( + os.path.join(os.path.dirname(__file__), "schemas") + ) + + def __init__(self) -> None: + super().__init__() + + @exportRpc( + model_blocks_points_prefix + + model_blocks_points_schemas_dict["visibility"]["rpc"] + ) + def setModelBlocksPointsVisibility(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_blocks_points_schemas_dict["visibility"], + self.model_blocks_points_prefix, + ) + params = schemas.Visibility.from_dict(rpc_params) + self.SetPointsVisibility(params.id, params.visibility) + + @exportRpc( + model_blocks_points_prefix + model_blocks_points_schemas_dict["size"]["rpc"] + ) + def setModelBlocksPointsSize(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_blocks_points_schemas_dict["size"], + self.model_blocks_points_prefix, + ) + params = schemas.Size.from_dict(rpc_params) + self.SetPointsSize(params.id, params.size) + + @exportRpc( + model_blocks_points_prefix + model_blocks_points_schemas_dict["color"]["rpc"] + ) + def setModelBlocksPointsColor(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_blocks_points_schemas_dict["color"], + self.model_blocks_points_prefix, + ) + params = schemas.Color.from_dict(rpc_params) + self.SetPointsColor(params.id, params.color.r, params.color.g, params.color.b) diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/__init__.py new file mode 100644 index 00000000..231578e0 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/__init__.py @@ -0,0 +1,3 @@ +from .visibility import * +from .size import * +from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/color.json b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/color.json new file mode 100644 index 00000000..29f6f880 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/color.json @@ -0,0 +1,40 @@ +{ + "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 +} diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/color.py b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/color.py new file mode 100644 index 00000000..01f0222c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/color.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/size.json b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/size.json new file mode 100644 index 00000000..eeee2f5a --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/size.json @@ -0,0 +1,15 @@ +{ + "rpc": "size", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "size": { + "type": "number" + } + }, + "required": ["id", "size"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/size.py b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/size.py new file mode 100644 index 00000000..eb182790 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/size.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class Size(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + size: float diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/visibility.json b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/visibility.json new file mode 100644 index 00000000..dc6b4213 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/visibility.py b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/visibility.py new file mode 100644 index 00000000..56a629d8 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/points/schemas/visibility.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/__init__.py index e983533c..b6670d68 100644 --- a/src/opengeodeweb_viewer/rpc/model/blocks/schemas/__init__.py +++ b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/__init__.py @@ -1,2 +1,4 @@ from .visibility import * +from .points_visibility import * +from .edges_visibility import * from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/schemas/edges_visibility.json b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/edges_visibility.json new file mode 100644 index 00000000..ed1cc1bd --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/edges_visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "edges_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/schemas/edges_visibility.py b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/edges_visibility.py new file mode 100644 index 00000000..8e844c29 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/edges_visibility.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class EdgesVisibility(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + visibility: bool diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/schemas/points_visibility.json b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/points_visibility.json new file mode 100644 index 00000000..be25760d --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/points_visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "points_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/blocks/schemas/points_visibility.py b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/points_visibility.py new file mode 100644 index 00000000..2f35f5ba --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/blocks/schemas/points_visibility.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class PointsVisibility(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + visibility: bool diff --git a/src/opengeodeweb_viewer/rpc/model/corners/model_corners_protocols.py b/src/opengeodeweb_viewer/rpc/model/corners/model_corners_protocols.py index ef376891..2f126270 100644 --- a/src/opengeodeweb_viewer/rpc/model/corners/model_corners_protocols.py +++ b/src/opengeodeweb_viewer/rpc/model/corners/model_corners_protocols.py @@ -6,40 +6,40 @@ from opengeodeweb_microservice.schemas import get_schemas_dict # Local application imports -from opengeodeweb_viewer.utils_functions import ( - validate_schema, - RpcParams, -) +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView from . import schemas -class VtkModelCornersView(VtkModelView): - model_corners_prefix = "opengeodeweb_viewer.model.corners." - model_corners_schemas_dict = get_schemas_dict( +class VtkModelBlocksView(VtkModelView): + model_blocks_prefix = "opengeodeweb_viewer.model.blocks." + model_blocks_schemas_dict = get_schemas_dict( os.path.join(os.path.dirname(__file__), "schemas") ) def __init__(self) -> None: super().__init__() - @exportRpc(model_corners_prefix + model_corners_schemas_dict["visibility"]["rpc"]) - def setModelCornersPointsVisibility(self, rpc_params: RpcParams) -> None: + @exportRpc( + model_blocks_prefix + model_blocks_schemas_dict["edges_visibility"]["rpc"] + ) + def setModelBlocksEdgesVisibility(self, rpc_params: RpcParams) -> None: validate_schema( rpc_params, - self.model_corners_schemas_dict["visibility"], - self.model_corners_prefix, + self.model_blocks_schemas_dict["edges_visibility"], + self.model_blocks_prefix, ) params = schemas.Visibility.from_dict(rpc_params) - self.SetBlocksVisibility(params.id, params.block_ids, params.visibility) + self.SetCategoryEdgesVisibility(params.id, "blocks", params.visibility) - @exportRpc(model_corners_prefix + model_corners_schemas_dict["color"]["rpc"]) - def setModelCornersPointsColor(self, rpc_params: RpcParams) -> None: + @exportRpc( + model_blocks_prefix + model_blocks_schemas_dict["points_visibility"]["rpc"] + ) + def setModelBlocksPointsVisibility(self, rpc_params: RpcParams) -> None: validate_schema( rpc_params, - self.model_corners_schemas_dict["color"], - self.model_corners_prefix, + self.model_blocks_schemas_dict["points_visibility"], + self.model_blocks_prefix, ) - params = schemas.Color.from_dict(rpc_params) - color = params.color - self.SetBlocksColor(params.id, params.block_ids, color.r, color.g, color.b) + params = schemas.Visibility.from_dict(rpc_params) + self.SetCategoryPointsVisibility(params.id, "blocks", params.visibility) diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/__init__.py b/src/opengeodeweb_viewer/rpc/model/corners/points/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/model_surfaces_points_protocols.py b/src/opengeodeweb_viewer/rpc/model/corners/points/model_surfaces_points_protocols.py new file mode 100644 index 00000000..d075c7b7 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/points/model_surfaces_points_protocols.py @@ -0,0 +1,53 @@ +import os +from wslink import register as exportRpc +from opengeodeweb_microservice.schemas import get_schemas_dict +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams +from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView +from . import schemas + + +class VtkModelCornersPointsView(VtkModelView): + model_corners_points_prefix = "opengeodeweb_viewer.model.corners.points." + model_corners_points_schemas_dict = get_schemas_dict( + os.path.join(os.path.dirname(__file__), "schemas") + ) + + def __init__(self) -> None: + super().__init__() + + @exportRpc( + model_corners_points_prefix + + model_corners_points_schemas_dict["visibility"]["rpc"] + ) + def setModelCornersPointsVisibility(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_corners_points_schemas_dict["visibility"], + self.model_corners_points_prefix, + ) + params = schemas.Visibility.from_dict(rpc_params) + self.SetPointsVisibility(params.id, params.visibility) + + @exportRpc( + model_corners_points_prefix + model_corners_points_schemas_dict["size"]["rpc"] + ) + def setModelCornersPointsSize(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_corners_points_schemas_dict["size"], + self.model_corners_points_prefix, + ) + params = schemas.Size.from_dict(rpc_params) + self.SetPointsSize(params.id, params.size) + + @exportRpc( + model_corners_points_prefix + model_corners_points_schemas_dict["color"]["rpc"] + ) + def setModelCornersPointsColor(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_corners_points_schemas_dict["color"], + self.model_corners_points_prefix, + ) + params = schemas.Color.from_dict(rpc_params) + self.SetPointsColor(params.id, params.color.r, params.color.g, params.color.b) diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/__init__.py new file mode 100644 index 00000000..231578e0 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/__init__.py @@ -0,0 +1,3 @@ +from .visibility import * +from .size import * +from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/color.json b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/color.json new file mode 100644 index 00000000..29f6f880 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/color.json @@ -0,0 +1,40 @@ +{ + "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 +} diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/color.py b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/color.py new file mode 100644 index 00000000..01f0222c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/color.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/size.json b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/size.json new file mode 100644 index 00000000..eeee2f5a --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/size.json @@ -0,0 +1,15 @@ +{ + "rpc": "size", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "size": { + "type": "number" + } + }, + "required": ["id", "size"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/size.py b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/size.py new file mode 100644 index 00000000..eb182790 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/size.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class Size(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + size: float diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/visibility.json b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/visibility.json new file mode 100644 index 00000000..dc6b4213 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/visibility.py b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/visibility.py new file mode 100644 index 00000000..56a629d8 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/points/schemas/visibility.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/corners/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/corners/schemas/__init__.py index e983533c..b6670d68 100644 --- a/src/opengeodeweb_viewer/rpc/model/corners/schemas/__init__.py +++ b/src/opengeodeweb_viewer/rpc/model/corners/schemas/__init__.py @@ -1,2 +1,4 @@ from .visibility import * +from .points_visibility import * +from .edges_visibility import * from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/corners/schemas/edges_visibility.json b/src/opengeodeweb_viewer/rpc/model/corners/schemas/edges_visibility.json new file mode 100644 index 00000000..ed1cc1bd --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/schemas/edges_visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "edges_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/corners/schemas/edges_visibility.py b/src/opengeodeweb_viewer/rpc/model/corners/schemas/edges_visibility.py new file mode 100644 index 00000000..8e844c29 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/schemas/edges_visibility.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class EdgesVisibility(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + visibility: bool diff --git a/src/opengeodeweb_viewer/rpc/model/corners/schemas/points_visibility.json b/src/opengeodeweb_viewer/rpc/model/corners/schemas/points_visibility.json new file mode 100644 index 00000000..be25760d --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/schemas/points_visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "points_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/corners/schemas/points_visibility.py b/src/opengeodeweb_viewer/rpc/model/corners/schemas/points_visibility.py new file mode 100644 index 00000000..2f35f5ba --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/corners/schemas/points_visibility.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class PointsVisibility(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + visibility: bool diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/__init__.py b/src/opengeodeweb_viewer/rpc/model/lines/edges/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/model_surfaces_edges_protocols.py b/src/opengeodeweb_viewer/rpc/model/lines/edges/model_surfaces_edges_protocols.py new file mode 100644 index 00000000..6d0f690f --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/edges/model_surfaces_edges_protocols.py @@ -0,0 +1,57 @@ +# Standard library imports +import os + +# Third party imports +from wslink import register as exportRpc +from opengeodeweb_microservice.schemas import get_schemas_dict + +# Local application imports +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams +from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView +from . import schemas + + +class VtkModelLinesEdgesView(VtkModelView): + model_lines_edges_prefix = "opengeodeweb_viewer.model.lines.edges." + model_lines_edges_schemas_dict = get_schemas_dict( + os.path.join(os.path.dirname(__file__), "schemas") + ) + + def __init__(self) -> None: + super().__init__() + + @exportRpc( + model_lines_edges_prefix + model_lines_edges_schemas_dict["visibility"]["rpc"] + ) + def setModelLinesEdgesVisibility(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_lines_edges_schemas_dict["visibility"], + self.model_lines_edges_prefix, + ) + params = schemas.Visibility.from_dict(rpc_params) + self.SetEdgesVisibility(params.id, params.visibility) + + @exportRpc( + model_lines_edges_prefix + model_lines_edges_schemas_dict["color"]["rpc"] + ) + def setModelLinesEdgesColor(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_lines_edges_schemas_dict["color"], + self.model_lines_edges_prefix, + ) + params = schemas.Color.from_dict(rpc_params) + self.SetEdgesColor(params.id, params.color.r, params.color.g, params.color.b) + + @exportRpc( + model_lines_edges_prefix + model_lines_edges_schemas_dict["width"]["rpc"] + ) + def setModelLinesEdgesWidth(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_lines_edges_schemas_dict["width"], + self.model_lines_edges_prefix, + ) + params = schemas.Width.from_dict(rpc_params) + self.SetEdgesWidth(params.id, params.width) diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/__init__.py new file mode 100644 index 00000000..cfe6b7ea --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/__init__.py @@ -0,0 +1,3 @@ +from .width import * +from .visibility import * +from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/color.json b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/color.json new file mode 100644 index 00000000..29f6f880 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/color.json @@ -0,0 +1,40 @@ +{ + "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 +} diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/color.py b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/color.py new file mode 100644 index 00000000..01f0222c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/color.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/visibility.json b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/visibility.json new file mode 100644 index 00000000..dc6b4213 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/visibility.py b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/visibility.py new file mode 100644 index 00000000..56a629d8 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/visibility.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/width.json b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/width.json new file mode 100644 index 00000000..bba8d11c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/width.json @@ -0,0 +1,15 @@ +{ + "rpc": "width", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "width": { + "type": "number" + } + }, + "required": ["id", "width"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/width.py b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/width.py new file mode 100644 index 00000000..eda85e61 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/edges/schemas/width.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class Width(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + width: float diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/__init__.py b/src/opengeodeweb_viewer/rpc/model/lines/points/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/model_surfaces_points_protocols.py b/src/opengeodeweb_viewer/rpc/model/lines/points/model_surfaces_points_protocols.py new file mode 100644 index 00000000..24689093 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/points/model_surfaces_points_protocols.py @@ -0,0 +1,52 @@ +import os +from wslink import register as exportRpc +from opengeodeweb_microservice.schemas import get_schemas_dict +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams +from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView +from . import schemas + + +class VtkModelLinesPointsView(VtkModelView): + model_lines_points_prefix = "opengeodeweb_viewer.model.lines.points." + model_lines_points_schemas_dict = get_schemas_dict( + os.path.join(os.path.dirname(__file__), "schemas") + ) + + def __init__(self) -> None: + super().__init__() + + @exportRpc( + model_lines_points_prefix + model_lines_points_schemas_dict["visibility"]["rpc"] + ) + def setModelLinesPointsVisibility(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_lines_points_schemas_dict["visibility"], + self.model_lines_points_prefix, + ) + params = schemas.Visibility.from_dict(rpc_params) + self.SetPointsVisibility(params.id, params.visibility) + + @exportRpc( + model_lines_points_prefix + model_lines_points_schemas_dict["size"]["rpc"] + ) + def setModelLinesPointsSize(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_lines_points_schemas_dict["size"], + self.model_lines_points_prefix, + ) + params = schemas.Size.from_dict(rpc_params) + self.SetPointsSize(params.id, params.size) + + @exportRpc( + model_lines_points_prefix + model_lines_points_schemas_dict["color"]["rpc"] + ) + def setModelLinesPointsColor(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_lines_points_schemas_dict["color"], + self.model_lines_points_prefix, + ) + params = schemas.Color.from_dict(rpc_params) + self.SetPointsColor(params.id, params.color.r, params.color.g, params.color.b) diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/__init__.py new file mode 100644 index 00000000..231578e0 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/__init__.py @@ -0,0 +1,3 @@ +from .visibility import * +from .size import * +from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/color.json b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/color.json new file mode 100644 index 00000000..29f6f880 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/color.json @@ -0,0 +1,40 @@ +{ + "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 +} diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/color.py b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/color.py new file mode 100644 index 00000000..01f0222c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/color.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/size.json b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/size.json new file mode 100644 index 00000000..eeee2f5a --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/size.json @@ -0,0 +1,15 @@ +{ + "rpc": "size", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "size": { + "type": "number" + } + }, + "required": ["id", "size"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/size.py b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/size.py new file mode 100644 index 00000000..eb182790 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/size.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class Size(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + size: float diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/visibility.json b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/visibility.json new file mode 100644 index 00000000..dc6b4213 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/visibility.py b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/visibility.py new file mode 100644 index 00000000..56a629d8 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/points/schemas/visibility.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/lines/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/lines/schemas/__init__.py index e983533c..b6670d68 100644 --- a/src/opengeodeweb_viewer/rpc/model/lines/schemas/__init__.py +++ b/src/opengeodeweb_viewer/rpc/model/lines/schemas/__init__.py @@ -1,2 +1,4 @@ from .visibility import * +from .points_visibility import * +from .edges_visibility import * from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/lines/schemas/edges_visibility.json b/src/opengeodeweb_viewer/rpc/model/lines/schemas/edges_visibility.json new file mode 100644 index 00000000..ed1cc1bd --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/schemas/edges_visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "edges_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/lines/schemas/edges_visibility.py b/src/opengeodeweb_viewer/rpc/model/lines/schemas/edges_visibility.py new file mode 100644 index 00000000..8e844c29 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/schemas/edges_visibility.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class EdgesVisibility(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + visibility: bool diff --git a/src/opengeodeweb_viewer/rpc/model/lines/schemas/points_visibility.json b/src/opengeodeweb_viewer/rpc/model/lines/schemas/points_visibility.json new file mode 100644 index 00000000..be25760d --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/schemas/points_visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "points_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/lines/schemas/points_visibility.py b/src/opengeodeweb_viewer/rpc/model/lines/schemas/points_visibility.py new file mode 100644 index 00000000..2f35f5ba --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/lines/schemas/points_visibility.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class PointsVisibility(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + visibility: bool diff --git a/src/opengeodeweb_viewer/rpc/model/model_protocols.py b/src/opengeodeweb_viewer/rpc/model/model_protocols.py index 6ca47947..633ec108 100644 --- a/src/opengeodeweb_viewer/rpc/model/model_protocols.py +++ b/src/opengeodeweb_viewer/rpc/model/model_protocols.py @@ -30,6 +30,7 @@ class VtkModelView(VtkObjectView): def __init__(self) -> None: super().__init__() + @exportRpc(model_prefix + model_schemas_dict["register"]["rpc"]) @exportRpc(model_prefix + model_schemas_dict["register"]["rpc"]) def registerModel(self, rpc_params: RpcParams) -> None: validate_schema( @@ -61,6 +62,27 @@ def registerModel(self, rpc_params: RpcParams) -> None: data.blockDataSets.append(None) data.blockDataSets.append(block) iterator.GoToNextItem() + + multiblock_output = reader.GetOutput() + category_iterator = multiblock_output.NewIterator() + category_iterator.InitTraversal() + while not category_iterator.IsDoneWithTraversal(): + category_block = category_iterator.GetCurrentDataObject() + category_name = multiblock_output.GetMetaData( + category_iterator.GetCurrentIndex() + ).Get(category_block.NAME()) + if category_block is not None: + category_filter = vtkGeometryFilter() + category_filter.SetInputDataObject(category_block) + category_filter.Update() + category_mapper = vtkCompositePolyDataMapper() + category_mapper.SetInputDataObject( + category_filter.GetOutputDataObject(0) + ) + category_actor = vtkActor() + category_actor.SetMapper(category_mapper) + data.category_actors[category_name] = category_actor + category_iterator.GoToNextItem() self.registerObject(data_id, file_name, data) except Exception as e: print(f"Error registering model {data_id}: {str(e)}", flush=True) @@ -81,3 +103,12 @@ def setModelVisibility(self, rpc_params: RpcParams) -> None: ) params = schemas.Visibility.from_dict(rpc_params) self.SetVisibility(params.id, params.visibility) + + @exportRpc(model_prefix + model_schemas_dict["components_color"]["rpc"]) + def setModelComponentsColor(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, self.model_schemas_dict["components_color"], self.model_prefix + ) + params = schemas.ComponentsColor.from_dict(rpc_params) + color = params.color + self.SetBlocksColor(params.id, params.block_ids, color.r, color.g, color.b) diff --git a/src/opengeodeweb_viewer/rpc/model/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/schemas/__init__.py index a974c1d6..b2eb2b9f 100644 --- a/src/opengeodeweb_viewer/rpc/model/schemas/__init__.py +++ b/src/opengeodeweb_viewer/rpc/model/schemas/__init__.py @@ -1,3 +1,4 @@ from .visibility import * from .register import * from .deregister import * +from .components_color import * diff --git a/src/opengeodeweb_viewer/rpc/model/schemas/components_color.json b/src/opengeodeweb_viewer/rpc/model/schemas/components_color.json new file mode 100644 index 00000000..08afcb6f --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/schemas/components_color.json @@ -0,0 +1,55 @@ +{ + "rpc": "components_color", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "block_ids": { + "type": "array", + "items": { + "type": "integer" + }, + "minItems": 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", + "block_ids", + "color" + ], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/schemas/components_color.py b/src/opengeodeweb_viewer/rpc/model/schemas/components_color.py new file mode 100644 index 00000000..71474acb --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/schemas/components_color.py @@ -0,0 +1,24 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass +from typing import Optional, List + + +@dataclass +class Color(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + b: int + g: int + r: int + a: Optional[float] = None + + +@dataclass +class ComponentsColor(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + block_ids: List[int] + color: Color + id: str diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/__init__.py b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/model_surfaces_edges_protocols.py b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/model_surfaces_edges_protocols.py new file mode 100644 index 00000000..40d67033 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/model_surfaces_edges_protocols.py @@ -0,0 +1,58 @@ +# Standard library imports +import os + +# Third party imports +from wslink import register as exportRpc +from opengeodeweb_microservice.schemas import get_schemas_dict + +# Local application imports +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams +from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView +from . import schemas + + +class VtkModelSurfacesEdgesView(VtkModelView): + model_surfaces_edges_prefix = "opengeodeweb_viewer.model.surfaces.edges." + model_surfaces_edges_schemas_dict = get_schemas_dict( + os.path.join(os.path.dirname(__file__), "schemas") + ) + + def __init__(self) -> None: + super().__init__() + + @exportRpc( + model_surfaces_edges_prefix + + model_surfaces_edges_schemas_dict["visibility"]["rpc"] + ) + def setModelSurfacesEdgesVisibility(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_surfaces_edges_schemas_dict["visibility"], + self.model_surfaces_edges_prefix, + ) + params = schemas.Visibility.from_dict(rpc_params) + self.SetEdgesVisibility(params.id, params.visibility) + + @exportRpc( + model_surfaces_edges_prefix + model_surfaces_edges_schemas_dict["color"]["rpc"] + ) + def setModelSurfacesEdgesColor(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_surfaces_edges_schemas_dict["color"], + self.model_surfaces_edges_prefix, + ) + params = schemas.Color.from_dict(rpc_params) + self.SetEdgesColor(params.id, params.color.r, params.color.g, params.color.b) + + @exportRpc( + model_surfaces_edges_prefix + model_surfaces_edges_schemas_dict["width"]["rpc"] + ) + def setModelSurfacesEdgesWidth(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_surfaces_edges_schemas_dict["width"], + self.model_surfaces_edges_prefix, + ) + params = schemas.Width.from_dict(rpc_params) + self.SetEdgesWidth(params.id, params.width) diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/__init__.py new file mode 100644 index 00000000..cfe6b7ea --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/__init__.py @@ -0,0 +1,3 @@ +from .width import * +from .visibility import * +from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/color.json b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/color.json new file mode 100644 index 00000000..29f6f880 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/color.json @@ -0,0 +1,40 @@ +{ + "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 +} diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/color.py b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/color.py new file mode 100644 index 00000000..01f0222c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/color.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/visibility.json b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/visibility.json new file mode 100644 index 00000000..dc6b4213 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/visibility.py b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/visibility.py new file mode 100644 index 00000000..56a629d8 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/visibility.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/width.json b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/width.json new file mode 100644 index 00000000..bba8d11c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/width.json @@ -0,0 +1,15 @@ +{ + "rpc": "width", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "width": { + "type": "number" + } + }, + "required": ["id", "width"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/width.py b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/width.py new file mode 100644 index 00000000..eda85e61 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/edges/schemas/width.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class Width(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + width: float diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/model_surfaces_protocols.py b/src/opengeodeweb_viewer/rpc/model/surfaces/model_surfaces_protocols.py index aaa3a818..626e4b9f 100644 --- a/src/opengeodeweb_viewer/rpc/model/surfaces/model_surfaces_protocols.py +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/model_surfaces_protocols.py @@ -6,10 +6,7 @@ from opengeodeweb_microservice.schemas import get_schemas_dict # Local application imports -from opengeodeweb_viewer.utils_functions import ( - validate_schema, - RpcParams, -) +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView from . import schemas @@ -23,23 +20,24 @@ class VtkModelSurfacesView(VtkModelView): def __init__(self) -> None: super().__init__() - @exportRpc(model_surfaces_prefix + model_surfaces_schemas_dict["visibility"]["rpc"]) - def setModelSurfacesPolygonsVisibility(self, rpc_params: RpcParams) -> None: + @exportRpc( + model_surfaces_prefix + model_surfaces_schemas_dict["edges_visibility"]["rpc"] + ) + def setModelSurfacesEdgesVisibility(self, rpc_params: RpcParams) -> None: validate_schema( rpc_params, - self.model_surfaces_schemas_dict["visibility"], + self.model_surfaces_schemas_dict["edges_visibility"], self.model_surfaces_prefix, ) params = schemas.Visibility.from_dict(rpc_params) - self.SetBlocksVisibility(params.id, params.block_ids, params.visibility) + self.SetCategoryEdgesVisibility(params.id, "surfaces", params.visibility) @exportRpc(model_surfaces_prefix + model_surfaces_schemas_dict["color"]["rpc"]) - def setModelSurfacesPolygonsCOlor(self, rpc_params: RpcParams) -> None: + def setModelSurfacesPolygonsColor(self, rpc_params: RpcParams) -> None: validate_schema( rpc_params, - self.model_surfaces_schemas_dict["color"], + self.model_surfaces_schemas_dict["points_visibility"], self.model_surfaces_prefix, ) - params = schemas.Color.from_dict(rpc_params) - color = params.color - self.SetBlocksColor(params.id, params.block_ids, color.r, color.g, color.b) + params = schemas.Visibility.from_dict(rpc_params) + self.SetCategoryPointsVisibility(params.id, "surfaces", params.visibility) diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/__init__.py b/src/opengeodeweb_viewer/rpc/model/surfaces/points/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/model_surfaces_points_protocols.py b/src/opengeodeweb_viewer/rpc/model/surfaces/points/model_surfaces_points_protocols.py new file mode 100644 index 00000000..df7f5cc5 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/points/model_surfaces_points_protocols.py @@ -0,0 +1,54 @@ +import os +from wslink import register as exportRpc +from opengeodeweb_microservice.schemas import get_schemas_dict +from opengeodeweb_viewer.utils_functions import validate_schema, RpcParams +from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView +from . import schemas + + +class VtkModelSurfacesPointsView(VtkModelView): + model_surfaces_points_prefix = "opengeodeweb_viewer.model.surfaces.points." + model_surfaces_points_schemas_dict = get_schemas_dict( + os.path.join(os.path.dirname(__file__), "schemas") + ) + + def __init__(self) -> None: + super().__init__() + + @exportRpc( + model_surfaces_points_prefix + + model_surfaces_points_schemas_dict["visibility"]["rpc"] + ) + def setModelSurfacesPointsVisibility(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_surfaces_points_schemas_dict["visibility"], + self.model_surfaces_points_prefix, + ) + params = schemas.Visibility.from_dict(rpc_params) + self.SetPointsVisibility(params.id, params.visibility) + + @exportRpc( + model_surfaces_points_prefix + model_surfaces_points_schemas_dict["size"]["rpc"] + ) + def setModelSurfacesPointsSize(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_surfaces_points_schemas_dict["size"], + self.model_surfaces_points_prefix, + ) + params = schemas.Size.from_dict(rpc_params) + self.SetPointsSize(params.id, params.size) + + @exportRpc( + model_surfaces_points_prefix + + model_surfaces_points_schemas_dict["color"]["rpc"] + ) + def setModelSurfacesPointsColor(self, rpc_params: RpcParams) -> None: + validate_schema( + rpc_params, + self.model_surfaces_points_schemas_dict["color"], + self.model_surfaces_points_prefix, + ) + params = schemas.Color.from_dict(rpc_params) + self.SetPointsColor(params.id, params.color.r, params.color.g, params.color.b) diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/__init__.py new file mode 100644 index 00000000..231578e0 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/__init__.py @@ -0,0 +1,3 @@ +from .visibility import * +from .size import * +from .color import * diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/color.json b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/color.json new file mode 100644 index 00000000..29f6f880 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/color.json @@ -0,0 +1,40 @@ +{ + "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 +} diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/color.py b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/color.py new file mode 100644 index 00000000..01f0222c --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/color.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/size.json b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/size.json new file mode 100644 index 00000000..eeee2f5a --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/size.json @@ -0,0 +1,15 @@ +{ + "rpc": "size", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "size": { + "type": "number" + } + }, + "required": ["id", "size"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/size.py b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/size.py new file mode 100644 index 00000000..eb182790 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/size.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class Size(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + size: float diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/visibility.json b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/visibility.json new file mode 100644 index 00000000..dc6b4213 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/visibility.py b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/visibility.py new file mode 100644 index 00000000..56a629d8 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/points/schemas/visibility.py @@ -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 diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/__init__.py b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/__init__.py index 91183b4c..892c6862 100644 --- a/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/__init__.py +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/__init__.py @@ -1,3 +1,5 @@ from .visibility import * +from .points_visibility import * +from .edges_visibility import * from .color import * from .apply_textures import * diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/edges_visibility.json b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/edges_visibility.json new file mode 100644 index 00000000..ed1cc1bd --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/edges_visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "edges_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/edges_visibility.py b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/edges_visibility.py new file mode 100644 index 00000000..8e844c29 --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/edges_visibility.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class EdgesVisibility(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + visibility: bool diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/points_visibility.json b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/points_visibility.json new file mode 100644 index 00000000..be25760d --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/points_visibility.json @@ -0,0 +1,15 @@ +{ + "rpc": "points_visibility", + "type": "object", + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "visibility": { + "type": "boolean" + } + }, + "required": ["id", "visibility"], + "additionalProperties": false +} diff --git a/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/points_visibility.py b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/points_visibility.py new file mode 100644 index 00000000..2f35f5ba --- /dev/null +++ b/src/opengeodeweb_viewer/rpc/model/surfaces/schemas/points_visibility.py @@ -0,0 +1,11 @@ +from dataclasses_json import DataClassJsonMixin +from dataclasses import dataclass + + +@dataclass +class PointsVisibility(DataClassJsonMixin): + def __post_init__(self) -> None: + print(self, flush=True) + + id: str + visibility: bool diff --git a/src/opengeodeweb_viewer/vtk_protocol.py b/src/opengeodeweb_viewer/vtk_protocol.py index 4fb092a0..425c5113 100644 --- a/src/opengeodeweb_viewer/vtk_protocol.py +++ b/src/opengeodeweb_viewer/vtk_protocol.py @@ -43,6 +43,7 @@ class VtkPipeline: filter: vtkAlgorithm | None = None actor: vtkActor = field(default_factory=vtkActor) blockDataSets: list[vtkDataObject | None] = field(default_factory=list) + category_actors: dict[str, vtkActor] = field(default_factory=dict) class VtkTypingMixin: diff --git a/tests/data/123456789/cube.vtm b/tests/data/123456789/cube.vtm new file mode 100644 index 00000000..f6918d7a --- /dev/null +++ b/tests/data/123456789/cube.vtm @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/model/surfaces/edges/test_model_surfaces_edges_protocols.py b/tests/model/surfaces/edges/test_model_surfaces_edges_protocols.py new file mode 100644 index 00000000..35279c40 --- /dev/null +++ b/tests/model/surfaces/edges/test_model_surfaces_edges_protocols.py @@ -0,0 +1,78 @@ +# Standard library imports +from typing import Callable + +# Third party imports +from opengeodeweb_viewer.rpc.model.surfaces.edges.model_surfaces_edges_protocols import ( + VtkModelSurfacesEdgesView, +) + +# Local application imports +from tests.model.test_model_protocols import test_register_model_cube +from tests.conftest import ServerMonitor + + +def test_surfaces_edges_visibility( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + test_register_model_cube(server, dataset_factory) + + server.call( + VtkModelSurfacesEdgesView.model_surfaces_edges_prefix + + VtkModelSurfacesEdgesView.model_surfaces_edges_schemas_dict["visibility"][ + "rpc" + ], + [{"id": "123456789", "visibility": True}], + ) + assert server.compare_image("model/surfaces/edges/visibility_true.jpeg") == True + + server.call( + VtkModelSurfacesEdgesView.model_surfaces_edges_prefix + + VtkModelSurfacesEdgesView.model_surfaces_edges_schemas_dict["visibility"][ + "rpc" + ], + [{"id": "123456789", "visibility": False}], + ) + assert server.compare_image("model/surfaces/edges/visibility_false.jpeg") == True + + +def test_surfaces_edges_color( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + test_register_model_cube(server, dataset_factory) + + # Activer les edges d'abord + server.call( + VtkModelSurfacesEdgesView.model_surfaces_edges_prefix + + VtkModelSurfacesEdgesView.model_surfaces_edges_schemas_dict["visibility"][ + "rpc" + ], + [{"id": "123456789", "visibility": True}], + ) + # Puis changer la couleur + server.call( + VtkModelSurfacesEdgesView.model_surfaces_edges_prefix + + VtkModelSurfacesEdgesView.model_surfaces_edges_schemas_dict["color"]["rpc"], + [{"id": "123456789", "color": {"r": 255, "g": 0, "b": 0}}], + ) + assert server.compare_image("model/surfaces/edges/color.jpeg") == True + + +def test_surfaces_edges_width( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + test_surfaces_edges_visibility(server, dataset_factory) + + server.call( + VtkModelSurfacesEdgesView.model_surfaces_edges_prefix + + VtkModelSurfacesEdgesView.model_surfaces_edges_schemas_dict["visibility"][ + "rpc" + ], + [{"id": "123456789", "visibility": True}], + ) + + server.call( + VtkModelSurfacesEdgesView.model_surfaces_edges_prefix + + VtkModelSurfacesEdgesView.model_surfaces_edges_schemas_dict["width"]["rpc"], + [{"id": "123456789", "width": 5.0}], + ) + assert server.compare_image("model/surfaces/edges/width.jpeg") == True diff --git a/tests/model/surfaces/points/test_model_surfaces_points_protocols.py b/tests/model/surfaces/points/test_model_surfaces_points_protocols.py new file mode 100644 index 00000000..ebd6e12c --- /dev/null +++ b/tests/model/surfaces/points/test_model_surfaces_points_protocols.py @@ -0,0 +1,77 @@ +# Standard library imports +from typing import Callable + +# Third party imports +from opengeodeweb_viewer.rpc.model.surfaces.points.model_surfaces_points_protocols import ( + VtkModelSurfacesPointsView, +) + +# Local application imports +from tests.model.test_model_protocols import test_register_model_cube +from tests.conftest import ServerMonitor + + +def test_surfaces_points_visibility( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + test_register_model_cube(server, dataset_factory) + + server.call( + VtkModelSurfacesPointsView.model_surfaces_points_prefix + + VtkModelSurfacesPointsView.model_surfaces_points_schemas_dict["visibility"][ + "rpc" + ], + [{"id": "123456789", "visibility": True}], + ) + assert server.compare_image("model/surfaces/points/visibility_true.jpeg") == True + + server.call( + VtkModelSurfacesPointsView.model_surfaces_points_prefix + + VtkModelSurfacesPointsView.model_surfaces_points_schemas_dict["visibility"][ + "rpc" + ], + [{"id": "123456789", "visibility": False}], + ) + assert server.compare_image("model/surfaces/points/visibility_false.jpeg") == True + + +def test_surfaces_points_color( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + test_surfaces_points_visibility(server, dataset_factory) + + server.call( + VtkModelSurfacesPointsView.model_surfaces_points_prefix + + VtkModelSurfacesPointsView.model_surfaces_points_schemas_dict["visibility"][ + "rpc" + ], + [{"id": "123456789", "visibility": True}], + ) + + server.call( + VtkModelSurfacesPointsView.model_surfaces_points_prefix + + VtkModelSurfacesPointsView.model_surfaces_points_schemas_dict["color"]["rpc"], + [{"id": "123456789", "color": {"r": 0, "g": 0, "b": 255}}], + ) + assert server.compare_image("model/surfaces/points/color.jpeg") == True + + +def test_surfaces_points_size( + server: ServerMonitor, dataset_factory: Callable[..., str] +) -> None: + test_surfaces_points_visibility(server, dataset_factory) + + server.call( + VtkModelSurfacesPointsView.model_surfaces_points_prefix + + VtkModelSurfacesPointsView.model_surfaces_points_schemas_dict["visibility"][ + "rpc" + ], + [{"id": "123456789", "visibility": True}], + ) + + server.call( + VtkModelSurfacesPointsView.model_surfaces_points_prefix + + VtkModelSurfacesPointsView.model_surfaces_points_schemas_dict["size"]["rpc"], + [{"id": "123456789", "size": 8.0}], + ) + assert server.compare_image("model/surfaces/points/size.jpeg") == True