Skip to content
17 changes: 9 additions & 8 deletions opengeodeweb_viewer_schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
},
"edges": {
"width": {
"$id": "opengeodeweb_viewer.mesh.edges.size",
"rpc": "size",
"$id": "opengeodeweb_viewer.mesh.edges.width",
"rpc": "width",
"type": "object",
"properties": {
"id": {
Expand Down Expand Up @@ -357,22 +357,23 @@
],
"additionalProperties": false
},
"size": {
"$id": "opengeodeweb_viewer.mesh.edges.size",
"rpc": "size",
"edge_attribute": {
"$id": "opengeodeweb_viewer.mesh.edges.edge_attribute",
"rpc": "edge_attribute",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"size": {
"type": "integer"
"name": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"size"
"name"
],
"additionalProperties": false
},
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ numpy>=2
# via
# contourpy
# matplotlib
packaging==25.0
packaging==26.0
# via matplotlib
pillow>=12
# via matplotlib
Expand All @@ -61,4 +61,3 @@ wslink==1.12.4
yarl>=1
# via aiohttp

opengeodeweb-microservice==1.*,>=1.0.12
6 changes: 5 additions & 1 deletion src/opengeodeweb_viewer/object/object_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ def SetEdgesVisibility(self, data_id: str, visibility: bool) -> None:

def SetEdgesWidth(self, data_id: str, width: float) -> None:
actor = self.get_object(data_id).actor
actor.GetProperty().SetEdgeWidth(width)
max_dimension = self.get_object(data_id).max_dimension
if max_dimension == "edges":
actor.GetProperty().SetLineWidth(width)
else:
actor.GetProperty().SetEdgeWidth(width)

def SetEdgesColor(self, data_id: str, red: int, green: int, blue: int) -> None:
actor = self.get_object(data_id).actor
Expand Down
10 changes: 10 additions & 0 deletions src/opengeodeweb_viewer/rpc/mesh/edges/mesh_edges_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,13 @@ def setMeshEdgesVertexColorMap(self, rpc_params: RpcParams) -> None:
)
params = schemas.VertexColorMap.from_dict(rpc_params)
self.setupColorMap(params.id, params.points)

@exportRpc(mesh_edges_prefix + mesh_edges_schemas_dict["edge_attribute"]["rpc"])
def setMeshEdgesEdgeAttribute(self, rpc_params: RpcParams) -> None:
validate_schema(
rpc_params,
self.mesh_edges_schemas_dict["edge_attribute"],
self.mesh_edges_prefix,
)
params = schemas.EdgeAttribute.from_dict(rpc_params)
self.displayAttributeOnCells(params.id, params.name)
2 changes: 1 addition & 1 deletion src/opengeodeweb_viewer/rpc/mesh/edges/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
from .vertex_scalar_range import *
from .vertex_color_map import *
from .vertex_attribute import *
from .size import *
from .edge_attribute import *
from .color import *
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"rpc": "size",
"rpc": "edge_attribute",
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1
},
"size": {
"type": "integer"
"name": {
"type": "string",
"minLength": 1
}
},
"required": [
"id",
"size"
"name"
],
"additionalProperties": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


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

id: str
size: int
name: str
2 changes: 1 addition & 1 deletion src/opengeodeweb_viewer/rpc/mesh/edges/schemas/width.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"rpc": "size",
"rpc": "width",
"type": "object",
"properties": {
"id": {
Expand Down
22 changes: 9 additions & 13 deletions src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
vtkRenderWindowInteractor,
vtkAbstractMapper,
vtkWorldPointPicker,
vtkPicker,
)
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleTrackball
from vtkmodules.vtkCommonCore import reference
Expand Down Expand Up @@ -224,20 +225,15 @@ def pickedIds(self, rpc_params: RpcParams) -> dict[str, list[str]]:
params = schemas.PickedIDS.from_dict(rpc_params)
renderWindow = self.getView("-1")
renderer = renderWindow.GetRenderers().GetFirstRenderer()
picker = vtkWorldPointPicker()
picker.Pick([params.x, params.y, 0], renderer)
point = picker.GetPickPosition()
epsilon = self.computeEpsilon(renderer, point[2])
bbox = vtkBoundingBox()
bbox.AddPoint(point[0] + epsilon, point[1] + epsilon, point[2] + epsilon)
bbox.AddPoint(point[0] - epsilon, point[1] - epsilon, point[2] - epsilon)

picker = vtkPicker()
picker.Pick(params.x, params.y, 0, renderer)
picked_actor = picker.GetActor()
array_ids = []
for id in params.ids:
bounds = self.get_object(id).actor.GetBounds()
bounds_box = vtkBoundingBox(bounds)
if bbox.Intersects(bounds_box):
array_ids.append(id)
if picked_actor:
for id in params.ids:
if self.get_object(id).actor == picked_actor:
array_ids.append(id)
break

return {"array_ids": array_ids}

Expand Down
1 change: 0 additions & 1 deletion src/opengeodeweb_viewer/vtkw_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
from .rpc.generic.generic_protocols import VtkGenericView
from .rpc.utils_protocols import VtkUtilsView


# =============================================================================
# Server class
# =============================================================================
Expand Down