Skip to content
Merged
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
16 changes: 16 additions & 0 deletions opengeodeweb_viewer_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,10 @@
"random"
]
},
"collection_id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1673,6 +1677,10 @@
"random"
]
},
"collection_id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1956,6 +1964,10 @@
"random"
]
},
"collection_id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2359,6 +2371,10 @@
"random"
]
},
"collection_id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ wslink==1.12.4
yarl==1.*
# via aiohttp

opengeodeweb-microservice==1.*,>=1.2.2
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ def setModelBlocksColor(self, rpc_params: RpcParams) -> list[ColorResult]:
params = schemas.Color.from_dict(rpc_params)
pipeline = self.get_vtk_pipeline(params.id)
return self.apply_color(
pipeline, params.block_ids, params.color_mode.value, params.color
pipeline,
params.block_ids,
params.color_mode.value,
params.color,
params.collection_id,
)
4 changes: 4 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/blocks/schemas/color.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"type": "string",
"enum": ["constant", "random"]
},
"collection_id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
Expand Down
1 change: 1 addition & 0 deletions src/opengeodeweb_viewer/rpc/model/blocks/schemas/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ def __post_init__(self) -> None:
block_ids: List[int]
color_mode: ColorMode
id: str
collection_id: Optional[str] = None
color: Optional[ColorClass] = None
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ def setModelCornersColor(self, rpc_params: RpcParams) -> list[ColorResult]:
params = schemas.Color.from_dict(rpc_params)
pipeline = self.get_vtk_pipeline(params.id)
return self.apply_color(
pipeline, params.block_ids, params.color_mode.value, params.color
pipeline,
params.block_ids,
params.color_mode.value,
params.color,
params.collection_id,
)
4 changes: 4 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/corners/schemas/color.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"type": "string",
"enum": ["constant", "random"]
},
"collection_id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
Expand Down
1 change: 1 addition & 0 deletions src/opengeodeweb_viewer/rpc/model/corners/schemas/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ def __post_init__(self) -> None:
block_ids: List[int]
color_mode: ColorMode
id: str
collection_id: Optional[str] = None
color: Optional[ColorClass] = None
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ def setModelLinesColor(self, rpc_params: RpcParams) -> list[ColorResult]:
params = schemas.Color.from_dict(rpc_params)
pipeline = self.get_vtk_pipeline(params.id)
return self.apply_color(
pipeline, params.block_ids, params.color_mode.value, params.color
pipeline,
params.block_ids,
params.color_mode.value,
params.color,
params.collection_id,
)
4 changes: 4 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/lines/schemas/color.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"type": "string",
"enum": ["constant", "random"]
},
"collection_id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
Expand Down
1 change: 1 addition & 0 deletions src/opengeodeweb_viewer/rpc/model/lines/schemas/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ def __post_init__(self) -> None:
block_ids: List[int]
color_mode: ColorMode
id: str
collection_id: Optional[str] = None
color: Optional[ColorClass] = None
5 changes: 4 additions & 1 deletion src/opengeodeweb_viewer/rpc/model/model_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def apply_color(
block_ids: list[int],
color_mode: str,
color: Optional[ColorProtocol] = None,
collection_id: Optional[str] = None,
) -> list[ColorResult]:
mapper = pipeline.mapper
if not isinstance(mapper, vtkCompositePolyDataMapper):
Expand All @@ -82,7 +83,9 @@ def apply_color(
if isinstance(block_dataset, vtkDataSet):
if color_mode == "random":
geode_id = pipeline.blockGeodeIds[block_id]
red, green, blue = deterministic_color(f"{geode_id}_{block_id}")
red, green, blue = deterministic_color(
collection_id or f"{geode_id}_{block_id}"
)
attr.SetBlockColor(block_dataset, [red, green, blue])
attr.SetBlockOpacity(block_dataset, 1.0)
colors.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@ def setModelSurfacesColor(self, rpc_params: RpcParams) -> list[ColorResult]:
params = schemas.Color.from_dict(rpc_params)
pipeline = self.get_vtk_pipeline(params.id)
return self.apply_color(
pipeline, params.block_ids, params.color_mode.value, params.color
pipeline,
params.block_ids,
params.color_mode.value,
params.color,
params.collection_id,
)
4 changes: 4 additions & 0 deletions src/opengeodeweb_viewer/rpc/model/surfaces/schemas/color.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"type": "string",
"enum": ["constant", "random"]
},
"collection_id": {
"type": "string",
"minLength": 1
},
"color": {
"type": "object",
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ def __post_init__(self) -> None:
block_ids: List[int]
color_mode: ColorMode
id: str
collection_id: Optional[str] = None
color: Optional[ColorClass] = None
25 changes: 25 additions & 0 deletions tests/model/surfaces/test_model_surfaces_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,31 @@ def test_surfaces_polygons_random_color(
assert server.compare_image("model/surfaces/random_color.jpeg") == True


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

test_surfaces_polygons_visibility(server, dataset_factory)

server.call(
VtkModelSurfacesView.model_surfaces_prefix
+ VtkModelSurfacesView.model_surfaces_schemas_dict["color"]["rpc"],
[
{
"id": model_id,
"block_ids": list(range(36, 47)),
"color_mode": "random",
"collection_id": "collection",
}
],
)
response = server.get_response()
assert isinstance(response, dict)
colors = [result["color"] for result in response["result"]]
assert len(colors) == 11
assert all(color == colors[0] for color in colors)


def test_surfaces_clipping_plane(
server: ServerMonitor, dataset_factory: Callable[..., str]
) -> None:
Expand Down
Loading