Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
83 changes: 83 additions & 0 deletions opengeodeweb_viewer_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,89 @@
],
"additionalProperties": false
},
"components_visibility": {
"$id": "opengeodeweb_viewer.model.components_visibility",
"rpc": "components_visibility",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"block_ids": {
"type": "array",
"items": {
"type": "integer"
},
"minItems": 1
},
"visibility": {
"type": "boolean"
}
},
"required": [
"id",
"block_ids",
"visibility"
],
"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": {
"visibility": {
"$id": "opengeodeweb_viewer.model.surfaces.visibility",
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.1.1
19 changes: 19 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/model_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,22 @@ 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)

@exportRpc(model_prefix + model_schemas_dict["components_visibility"]["rpc"])
def setModelComponentsVisibility(self, rpc_params: RpcParams) -> None:
validate_schema(
rpc_params,
self.model_schemas_dict["components_visibility"],
self.model_prefix,
)
params = schemas.ComponentsVisibility.from_dict(rpc_params)
self.SetBlocksVisibility(params.id, params.block_ids, params.visibility)
2 changes: 2 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/schemas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .visibility import *
from .register import *
from .deregister import *
from .components_visibility import *
from .components_color import *
55 changes: 55 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/schemas/components_color.json
Original file line number Diff line number Diff line change
@@ -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
}
24 changes: 24 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/schemas/components_color.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"rpc": "components_visibility",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"block_ids": {
"type": "array",
"items": {
"type": "integer"
},
"minItems": 1
},
"visibility": {
"type": "boolean"
}
},
"required": [
"id",
"block_ids",
"visibility"
],
"additionalProperties": false
}
13 changes: 13 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/schemas/components_visibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass
from typing import List


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

block_ids: List[int]
id: str
visibility: bool
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setModelSurfacesPolygonsVisibility(self, rpc_params: RpcParams) -> None:
self.SetBlocksVisibility(params.id, params.block_ids, 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"],
Expand Down
Binary file added tests/data/images/model/components_color.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions tests/model/test_model_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,46 @@ def test_deregister_model(
[{"id": "123456789"}],
)
assert server.compare_image("model/deregister.jpeg") == True


def test_components_color_model(
server: ServerMonitor, dataset_factory: Callable[..., str]
) -> None:

test_register_model_cube(server, dataset_factory)

server.call(
VtkModelView.model_prefix
+ VtkModelView.model_schemas_dict["components_color"]["rpc"],
[
{
"id": "123456789",
"block_ids": [48, 49],
"color": {"r": 255, "g": 0, "b": 0},
}
],
)
assert server.compare_image("model/components_color.jpeg") == True


def test_components_visibility_color_model(
server: ServerMonitor, dataset_factory: Callable[..., str]
) -> None:
test_register_model_cube(server, dataset_factory)

server.call(
VtkModelView.model_prefix + "components_visibility",
[{"id": "123456789", "block_ids": [48, 49], "visibility": False}],
)

server.call(
VtkModelView.model_prefix + "components_color",
[
{
"id": "123456789",
"block_ids": list(range(36, 47)),
"color": {"r": 0, "g": 255, "b": 0},
}
],
)
assert server.compare_image("model/components_visibility_color.jpeg") == True
Loading