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
32 changes: 32 additions & 0 deletions opengeodeweb_viewer_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,38 @@
"name"
],
"additionalProperties": false
},
"color_map": {
"$id": "opengeodeweb_viewer.mesh.edges.attribute.edge.color_map",
"rpc": "color_map",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"points": {
"type": "array",
"description": "Flat array of [value, r, g, b, ...]",
"items": {
"type": "number"
},
"minItems": 8
},
"minimum": {
"type": "number"
},
"maximum": {
"type": "number"
}
},
"required": [
"id",
"points",
"minimum",
"maximum"
],
"additionalProperties": false
}
},
"vertex": {
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,16 @@ def setMeshEdgesEdgeName(self, rpc_params: RpcParams) -> None:
)
params = schemas.Name.from_dict(rpc_params)
self.displayAttributeOnCells(params.id, params.name)

@exportRpc(
mesh_edges_attribute_edge_prefix
+ mesh_edges_attribute_edge_schemas_dict["color_map"]["rpc"]
)
def setMeshEdgesEdgeColorMap(self, rpc_params: RpcParams) -> None:
validate_schema(
rpc_params,
self.mesh_edges_attribute_edge_schemas_dict["color_map"],
self.mesh_edges_attribute_edge_prefix,
)
params = schemas.ColorMap.from_dict(rpc_params)
self.setupColorMap(params.id, params.points, params.minimum, params.maximum)
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .name import *
from .color_map import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"rpc": "color_map",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"points": {
"type": "array",
"description": "Flat array of [value, r, g, b, ...]",
"items": {
"type": "number"
},
"minItems": 8
},
"minimum": {
"type": "number"
},
"maximum": {
"type": "number"
}
},
"required": ["id", "points", "minimum", "maximum"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from dataclasses_json import DataClassJsonMixin
from dataclasses import dataclass
from typing import List


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

id: str
maximum: float
minimum: float
points: List[float]
"""Flat array of [value, r, g, b, ...]"""
21 changes: 21 additions & 0 deletions tests/data/123456789/edged_curve3D.vtp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<VTKFile type="PolyData" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<PolyData>
<Piece NumberOfPoints="37" NumberOfLines="37">
<PointData>
<DataArray type="Float64" Name="points" format="ascii" NumberOfComponents="3" RangeMin="-0.195351169" RangeMax="1">0.10942 0.532085 1 0.0989554 0.440531 1 0.127689 0.326914 1 -0.0570336 0.453631 1 -0.0440269 0.283532 1 0.0785397 0.338299 1 -0.014577 0.077456 1 0.155983 0.163299 1 0.0333169 0.16082 1 0.321452 0.0802363 1 0.355327 0.212219 1 0.252025 0.158717 1 0.428656 0.359 1 0.299515 0.365925 1 0.316268 0.303525 1 0.318692 0.624577 1 0.210924 0.577468 1 0.314173 0.57517 1 -0.0731802 0.632736 1 -0.0996019 0.598172 1 -0.162041 0.600724 1 -0.147729 0.444528 1 -0.0853436 0.517832 1 -0.0996019 0.598172 1 0.0963617 0.532762 1 0.10407 0.544358 1 -0.195351 0.421707 1 -0.105346 0.266847 1 -0.0987086 0.302912 1 -0.105346 0.266847 1 -0.115428 0.266928 1 -0.118175 0.257315 1 -0.0859438 0.0429719 1 -0.0351803 0.0175902 1 -0.0351803 0.0175902 1 -0.106668 0.248327 1 -0.118175 0.257315 1 </DataArray>
</PointData>
<Points>
<DataArray type="Float64" Name="Points" format="ascii" NumberOfComponents="3" RangeMin="-0.19535116851329803" RangeMax="1">0.109419576823711 0.53208464384079 1 0.0989554226398468 0.440531343221664 1 0.127689048647881 0.326913595199585 1 -0.0570335872471333 0.453630566596985 1 -0.0440268628299236 0.283532381057739 1 0.0785397067666054 0.338299185037613 1 -0.0145769733935595 0.0774560123682022 1 0.155983060598373 0.163299322128296 1 0.0333169139921665 0.160820126533508 1 0.32145157456398 0.0802362933754921 1 0.35532745718956 0.212218835949898 1 0.252025336027145 0.158717021346092 1 0.428656339645386 0.358999729156494 1 0.29951485991478 0.365925401449203 1 0.316268235445023 0.303525328636169 1 0.31869176030159 0.624576926231384 1 0.210924133658409 0.577467858791351 1 0.314173072576523 0.57517009973526 1 -0.0731801614165306 0.632735967636108 1 -0.0996019020676613 0.598172128200531 1 -0.162041246891022 0.600724041461945 1 -0.147729307413101 0.444528311491013 1 -0.0853436291217804 0.517831742763519 1 -0.0996019020676613 0.598172128200531 1 0.0963616594672203 0.532761991024017 1 0.104069948196411 0.544358432292938 1 -0.195351168513298 0.42170724272728 1 -0.105345673859119 0.266847312450409 1 -0.0987086147069931 0.302912443876266 1 -0.105345673859119 0.266847312450409 1 -0.115427635610104 0.266927510499954 1 -0.118174657225609 0.257315069437027 1 -0.0859437808394432 0.0429718904197216 1 -0.0351803153753281 0.017590157687664 1 -0.0351803153753281 0.017590157687664 1 -0.106668494641781 0.248327031731606 1 -0.118174657225609 0.257315069437027 1 </DataArray>
</Points>
<CellData>
<DataArray type="Float64" Name="cycle_id" format="ascii" NumberOfComponents="1" RangeMin="0" RangeMax="8">0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 6 6 6 6 6 7 7 7 8 8 8 8 8 8 8 8 </DataArray>
<DataArray type="Float64" Name="edges" format="ascii" NumberOfComponents="2" RangeMin="0" RangeMax="36">0 1 1 2 0 2 3 4 4 5 3 5 6 7 7 8 6 8 9 10 10 11 9 11 12 13 13 14 12 14 15 16 16 17 15 17 18 19 19 20 20 21 21 22 22 23 23 24 24 25 18 25 26 27 27 28 26 28 29 30 30 31 31 32 32 33 33 34 34 35 35 36 29 36 </DataArray>
</CellData>
<Lines>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="36">0 1 1 2 0 2 3 4 4 5 3 5 6 7 7 8 6 8 9 10 10 11 9 11 12 13 13 14 12 14 15 16 16 17 15 17 18 19 19 20 20 21 21 22 22 23 23 24 24 25 18 25 26 27 27 28 26 28 29 30 30 31 31 32 32 33 33 34 34 35 35 36 29 36 </DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="0" RangeMax="37">2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 </DataArray>
</Lines>
</Piece>
</PolyData>
</VTKFile>
21 changes: 21 additions & 0 deletions tests/data/edged_curve3D.vtp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<VTKFile type="PolyData" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<PolyData>
<Piece NumberOfPoints="37" NumberOfLines="37">
<PointData>
<DataArray type="Float64" Name="points" format="ascii" NumberOfComponents="3" RangeMin="-0.195351169" RangeMax="1">0.10942 0.532085 1 0.0989554 0.440531 1 0.127689 0.326914 1 -0.0570336 0.453631 1 -0.0440269 0.283532 1 0.0785397 0.338299 1 -0.014577 0.077456 1 0.155983 0.163299 1 0.0333169 0.16082 1 0.321452 0.0802363 1 0.355327 0.212219 1 0.252025 0.158717 1 0.428656 0.359 1 0.299515 0.365925 1 0.316268 0.303525 1 0.318692 0.624577 1 0.210924 0.577468 1 0.314173 0.57517 1 -0.0731802 0.632736 1 -0.0996019 0.598172 1 -0.162041 0.600724 1 -0.147729 0.444528 1 -0.0853436 0.517832 1 -0.0996019 0.598172 1 0.0963617 0.532762 1 0.10407 0.544358 1 -0.195351 0.421707 1 -0.105346 0.266847 1 -0.0987086 0.302912 1 -0.105346 0.266847 1 -0.115428 0.266928 1 -0.118175 0.257315 1 -0.0859438 0.0429719 1 -0.0351803 0.0175902 1 -0.0351803 0.0175902 1 -0.106668 0.248327 1 -0.118175 0.257315 1 </DataArray>
</PointData>
<Points>
<DataArray type="Float64" Name="Points" format="ascii" NumberOfComponents="3" RangeMin="-0.19535116851329803" RangeMax="1">0.109419576823711 0.53208464384079 1 0.0989554226398468 0.440531343221664 1 0.127689048647881 0.326913595199585 1 -0.0570335872471333 0.453630566596985 1 -0.0440268628299236 0.283532381057739 1 0.0785397067666054 0.338299185037613 1 -0.0145769733935595 0.0774560123682022 1 0.155983060598373 0.163299322128296 1 0.0333169139921665 0.160820126533508 1 0.32145157456398 0.0802362933754921 1 0.35532745718956 0.212218835949898 1 0.252025336027145 0.158717021346092 1 0.428656339645386 0.358999729156494 1 0.29951485991478 0.365925401449203 1 0.316268235445023 0.303525328636169 1 0.31869176030159 0.624576926231384 1 0.210924133658409 0.577467858791351 1 0.314173072576523 0.57517009973526 1 -0.0731801614165306 0.632735967636108 1 -0.0996019020676613 0.598172128200531 1 -0.162041246891022 0.600724041461945 1 -0.147729307413101 0.444528311491013 1 -0.0853436291217804 0.517831742763519 1 -0.0996019020676613 0.598172128200531 1 0.0963616594672203 0.532761991024017 1 0.104069948196411 0.544358432292938 1 -0.195351168513298 0.42170724272728 1 -0.105345673859119 0.266847312450409 1 -0.0987086147069931 0.302912443876266 1 -0.105345673859119 0.266847312450409 1 -0.115427635610104 0.266927510499954 1 -0.118174657225609 0.257315069437027 1 -0.0859437808394432 0.0429718904197216 1 -0.0351803153753281 0.017590157687664 1 -0.0351803153753281 0.017590157687664 1 -0.106668494641781 0.248327031731606 1 -0.118174657225609 0.257315069437027 1 </DataArray>
</Points>
<CellData>
<DataArray type="Float64" Name="cycle_id" format="ascii" NumberOfComponents="1" RangeMin="0" RangeMax="8">0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 6 6 6 6 6 7 7 7 8 8 8 8 8 8 8 8 </DataArray>
<DataArray type="Float64" Name="edges" format="ascii" NumberOfComponents="2" RangeMin="0" RangeMax="36">0 1 1 2 0 2 3 4 4 5 3 5 6 7 7 8 6 8 9 10 10 11 9 11 12 13 13 14 12 14 15 16 16 17 15 17 18 19 19 20 20 21 21 22 22 23 23 24 24 25 18 25 26 27 27 28 26 28 29 30 30 31 31 32 32 33 33 34 34 35 35 36 29 36 </DataArray>
</CellData>
<Lines>
<DataArray type="Int64" Name="connectivity" format="ascii" RangeMin="0" RangeMax="36">0 1 1 2 0 2 3 4 4 5 3 5 6 7 7 8 6 8 9 10 10 11 9 11 12 13 13 14 12 14 15 16 16 17 15 17 18 19 19 20 20 21 21 22 22 23 23 24 24 25 18 25 26 27 27 28 26 28 29 30 30 31 31 32 32 33 33 34 34 35 35 36 29 36 </DataArray>
<DataArray type="Int64" Name="offsets" format="ascii" RangeMin="0" RangeMax="37">2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 </DataArray>
</Lines>
</Piece>
</PolyData>
</VTKFile>
Binary file added tests/data/images/mesh/edges/edge_color_map.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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,244 @@ def test_register(server: ServerMonitor, dataset_factory: Callable[..., str]) ->

dataset_factory(
id=mesh_id,
viewable_file="attributed_edged_curve.vtp",
viewable_file="edged_curve3D.vtp",
viewer_elements_type="edges",
)

server.call(
VtkMeshView.mesh_prefix + VtkMeshView.mesh_schemas_dict["register"]["rpc"],
[{"id": mesh_id}],
)


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

test_register(server, dataset_factory)

# Set active attribute (cycle_id)
server.call(
VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix
+ VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict["name"][
"rpc"
],
[{"id": mesh_id, "name": "cycle_id"}],
)

# Set color map: Blue to Red
server.call(
VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix
+ VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict[
"color_map"
]["rpc"],
[
{
"id": mesh_id,
"points": [
0.0,
0,
0,
1.0,
8.0,
1.0,
0,
0,
],
"minimum": 0.0,
"maximum": 8.0,
}
],
)

assert server.compare_image("mesh/edges/edge_color_map.jpeg") == True


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

test_register(server, dataset_factory)

# Set active attribute
server.call(
VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix
+ VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict["name"][
"rpc"
],
[{"id": mesh_id, "name": "cycle_id"}],
)

# Set Blue to Red Map
server.call(
VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix
+ VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict[
"color_map"
]["rpc"],
[
{
"id": mesh_id,
"points": [
0.0,
0,
0,
1.0,
8.0,
1.0,
0,
0,
],
"minimum": 0.0,
"maximum": 8.0,
}
],
)

assert server.compare_image("mesh/edges/edge_color_map.jpeg") == True

# Update range via color map
server.call(
VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix
+ VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict[
"color_map"
]["rpc"],
[
{
"id": mesh_id,
"points": [
4.0,
0,
0,
1.0,
8.0,
1.0,
0,
0,
],
"minimum": 4.0,
"maximum": 8.0,
}
],
)

assert server.compare_image("mesh/edges/edge_color_map_range_update.jpeg") == True


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

test_register(server, dataset_factory)

# Set active attribute
server.call(
VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix
+ VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict["name"][
"rpc"
],
[{"id": mesh_id, "name": "cycle_id"}],
)

# Rainbow Desaturated Map
server.call(
VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix
+ VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict[
"color_map"
]["rpc"],
[
{
"id": mesh_id,
"points": [
0.0,
71 / 255,
71 / 255,
219 / 255,
0.143 * 8,
0,
0,
92 / 255,
0.285 * 8,
0,
255 / 255,
255 / 255,
0.429 * 8,
0,
128 / 255,
0,
0.571 * 8,
255 / 255,
255 / 255,
0,
0.714 * 8,
255 / 255,
97 / 255,
0,
0.857 * 8,
107 / 255,
0,
0,
8.0,
224 / 255,
77 / 255,
77 / 255,
],
"minimum": 0.0,
"maximum": 8.0,
}
],
)

assert (
server.compare_image("mesh/edges/edge_color_map_rainbow_initial.jpeg") == True
)

# Update rainbow range via color map
server.call(
VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_prefix
+ VtkMeshEdgesAttributeEdgeView.mesh_edges_attribute_edge_schemas_dict[
"color_map"
]["rpc"],
[
{
"id": mesh_id,
"points": [
2.0,
71 / 255,
71 / 255,
219 / 255,
2.0 + 0.143 * 4,
0,
0,
92 / 255,
2.0 + 0.285 * 4,
0,
255 / 255,
255 / 255,
2.0 + 0.429 * 4,
0,
128 / 255,
0,
2.0 + 0.571 * 4,
255 / 255,
255 / 255,
0,
2.0 + 0.714 * 4,
255 / 255,
97 / 255,
0,
2.0 + 0.857 * 4,
107 / 255,
0,
0,
6.0,
224 / 255,
77 / 255,
77 / 255,
],
"minimum": 2.0,
"maximum": 6.0,
}
],
)

assert server.compare_image("mesh/edges/edge_color_map_rainbow.jpeg") == True
Loading