Skip to content

Commit 2c42968

Browse files
feat(viewer): dynamic grid scale
1 parent 201f82e commit 2c42968

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+254
-270
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
### Features
6767

68-
- **polyhedrons**: Color protocol
68+
- **polyhedra**: Color protocol
6969
([`15b35fc`](https://github.com/Geode-solutions/OpenGeodeWeb-Viewer/commit/15b35fcfdda1afc66f4eb4942d9f54006bbc9a0f))
7070

7171

pyproject.toml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,12 @@ where = ["src"]
4141
"opengeodeweb_viewer.rpc.mesh.points.schemas" = ["*.json"]
4242
"opengeodeweb_viewer.rpc.mesh.edges.schemas" = ["*.json"]
4343
"opengeodeweb_viewer.rpc.mesh.polygons.schemas" = ["*.json"]
44-
"opengeodeweb_viewer.rpc.mesh.polyhedrons.schemas" = ["*.json"]
44+
"opengeodeweb_viewer.rpc.mesh.polyhedra.schemas" = ["*.json"]
4545
"opengeodeweb_viewer.rpc.model.schemas" = ["*.json"]
46-
"opengeodeweb_viewer.rpc.model.corners.points.schemas" = ["*.json"]
47-
"opengeodeweb_viewer.rpc.model.lines.points.schemas" = ["*.json"]
48-
"opengeodeweb_viewer.rpc.model.lines.edges.schemas" = ["*.json"]
49-
"opengeodeweb_viewer.rpc.model.surfaces.points.schemas" = ["*.json"]
50-
"opengeodeweb_viewer.rpc.model.surfaces.edges.schemas" = ["*.json"]
51-
"opengeodeweb_viewer.rpc.model.surfaces.polygons.schemas" = ["*.json"]
52-
"opengeodeweb_viewer.rpc.model.blocks.points.schemas" = ["*.json"]
53-
"opengeodeweb_viewer.rpc.model.blocks.edges.schemas" = ["*.json"]
54-
"opengeodeweb_viewer.rpc.model.blocks.polygons.schemas" = ["*.json"]
55-
"opengeodeweb_viewer.rpc.model.blocks.polyhedrons.schemas" = ["*.json"]
46+
"opengeodeweb_viewer.rpc.model.corners.schemas" = ["*.json"]
47+
"opengeodeweb_viewer.rpc.model.lines.schemas" = ["*.json"]
48+
"opengeodeweb_viewer.rpc.model.surfaces.schemas" = ["*.json"]
49+
"opengeodeweb_viewer.rpc.model.blocks.schemas" = ["*.json"]
5650
"opengeodeweb_viewer.rpc.viewer.schemas" = ["*.json"]
5751

5852
[tool.semantic_release]

src/opengeodeweb_viewer/rpc/mesh/polyhedrons/polyhedrons_protocols.py renamed to src/opengeodeweb_viewer/rpc/mesh/polyhedra/polyhedra_protocols.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,33 @@
99
from opengeodeweb_viewer.rpc.mesh.mesh_protocols import VtkMeshView
1010

1111

12-
class VtkMeshPolyhedronsView(VtkMeshView):
13-
mesh_polyhedrons_prefix = "opengeodeweb_viewer.mesh.polyhedrons."
14-
mesh_polyhedrons_schemas_dict = get_schemas_dict(
12+
class VtkMeshPolyhedraView(VtkMeshView):
13+
mesh_polyhedra_prefix = "opengeodeweb_viewer.mesh.polyhedra."
14+
mesh_polyhedra_schemas_dict = get_schemas_dict(
1515
os.path.join(os.path.dirname(__file__), "schemas")
1616
)
1717

1818
def __init__(self):
1919
super().__init__()
2020

2121
@exportRpc(
22-
mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["visibility"]["rpc"]
22+
mesh_polyhedra_prefix + mesh_polyhedra_schemas_dict["visibility"]["rpc"]
2323
)
24-
def setMeshPolyhedronsVisibility(self, params):
24+
def setMeshPolyhedraVisibility(self, params):
2525
validate_schema(
2626
params,
27-
self.mesh_polyhedrons_schemas_dict["visibility"],
28-
self.mesh_polyhedrons_prefix,
27+
self.mesh_polyhedra_schemas_dict["visibility"],
28+
self.mesh_polyhedra_prefix,
2929
)
3030
id, visibility = params["id"], params["visibility"]
3131
self.SetVisibility(id, visibility)
3232

33-
@exportRpc(mesh_polyhedrons_prefix + mesh_polyhedrons_schemas_dict["color"]["rpc"])
34-
def setMeshPolyhedronsColor(self, params):
33+
@exportRpc(mesh_polyhedra_prefix + mesh_polyhedra_schemas_dict["color"]["rpc"])
34+
def setMeshPolyhedraColor(self, params):
3535
validate_schema(
3636
params,
37-
self.mesh_polyhedrons_schemas_dict["color"],
38-
self.mesh_polyhedrons_prefix,
37+
self.mesh_polyhedra_schemas_dict["color"],
38+
self.mesh_polyhedra_prefix,
3939
)
4040
id, red, green, blue = (
4141
params["id"],
@@ -46,27 +46,27 @@ def setMeshPolyhedronsColor(self, params):
4646
self.SetColor(id, red, green, blue)
4747

4848
@exportRpc(
49-
mesh_polyhedrons_prefix
50-
+ mesh_polyhedrons_schemas_dict["vertex_attribute"]["rpc"]
49+
mesh_polyhedra_prefix
50+
+ mesh_polyhedra_schemas_dict["vertex_attribute"]["rpc"]
5151
)
52-
def setMeshPolyhedronsVertexAttribute(self, params):
52+
def setMeshPolyhedraVertexAttribute(self, params):
5353
validate_schema(
5454
params,
55-
self.mesh_polyhedrons_schemas_dict["vertex_attribute"],
56-
self.mesh_polyhedrons_prefix,
55+
self.mesh_polyhedra_schemas_dict["vertex_attribute"],
56+
self.mesh_polyhedra_prefix,
5757
)
5858
id, name = params["id"], params["name"]
5959
self.displayAttributeOnVertices(id, name)
6060

6161
@exportRpc(
62-
mesh_polyhedrons_prefix
63-
+ mesh_polyhedrons_schemas_dict["polyhedron_attribute"]["rpc"]
62+
mesh_polyhedra_prefix
63+
+ mesh_polyhedra_schemas_dict["polyhedron_attribute"]["rpc"]
6464
)
65-
def setMeshPolyhedronsPolyhedronAttribute(self, params):
65+
def setMeshPolyhedraPolyhedronAttribute(self, params):
6666
validate_schema(
6767
params,
68-
self.mesh_polyhedrons_schemas_dict["polyhedron_attribute"],
69-
self.mesh_polyhedrons_prefix,
68+
self.mesh_polyhedra_schemas_dict["polyhedron_attribute"],
69+
self.mesh_polyhedra_prefix,
7070
)
7171
id, name = params["id"], params["name"]
7272
self.displayAttributeOnCells(id, name)
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView
1010

1111

12-
class VtkModelBlocksPolyhedronsView(VtkModelView):
13-
model_blocks_polyhedrons_prefix = "opengeodeweb_viewer.model.blocks.polyhedrons."
14-
model_blocks_polyhedrons_schemas_dict = get_schemas_dict(
12+
class VtkModelBlocksView(VtkModelView):
13+
model_blocks_prefix = "opengeodeweb_viewer.model.blocks."
14+
model_blocks_schemas_dict = get_schemas_dict(
1515
os.path.join(os.path.dirname(__file__), "schemas")
1616
)
1717

1818
def __init__(self):
1919
super().__init__()
2020

2121
@exportRpc(
22-
model_blocks_polyhedrons_prefix
23-
+ model_blocks_polyhedrons_schemas_dict["visibility"]["rpc"]
22+
model_blocks_prefix
23+
+ model_blocks_schemas_dict["visibility"]["rpc"]
2424
)
25-
def setModelBlocksPolyhedronsVisibility(self, params):
25+
def setModelBlocksPolyhedraVisibility(self, params):
2626
validate_schema(
2727
params,
28-
self.model_blocks_polyhedrons_schemas_dict["visibility"],
29-
self.model_blocks_polyhedrons_prefix,
28+
self.model_blocks_schemas_dict["visibility"],
29+
self.model_blocks_prefix,
3030
)
3131
id, block_ids, visibility = (
3232
params["id"],
@@ -36,14 +36,14 @@ def setModelBlocksPolyhedronsVisibility(self, params):
3636
self.SetBlocksVisibility(id, block_ids, visibility)
3737

3838
@exportRpc(
39-
model_blocks_polyhedrons_prefix
40-
+ model_blocks_polyhedrons_schemas_dict["color"]["rpc"]
39+
model_blocks_prefix
40+
+ model_blocks_schemas_dict["color"]["rpc"]
4141
)
42-
def setModelBlocksPolyhedronsColor(self, params):
42+
def setModelBlocksPolyhedraColor(self, params):
4343
validate_schema(
4444
params,
45-
self.model_blocks_polyhedrons_schemas_dict["color"],
46-
self.model_blocks_polyhedrons_prefix,
45+
self.model_blocks_schemas_dict["color"],
46+
self.model_blocks_prefix,
4747
)
4848
id, block_ids, red, green, blue = (
4949
params["id"],

src/opengeodeweb_viewer/rpc/model/corners/points/corners_points_protocols.py renamed to src/opengeodeweb_viewer/rpc/model/corners/corners_protocols.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView
1010

1111

12-
class VtkModelCornersPointsView(VtkModelView):
13-
model_corners_points_prefix = "opengeodeweb_viewer.model.corners.points."
14-
model_corners_points_schemas_dict = get_schemas_dict(
12+
class VtkModelCornersView(VtkModelView):
13+
model_corners_prefix = "opengeodeweb_viewer.model.corners."
14+
model_corners_schemas_dict = get_schemas_dict(
1515
os.path.join(os.path.dirname(__file__), "schemas")
1616
)
1717

1818
def __init__(self):
1919
super().__init__()
2020

2121
@exportRpc(
22-
model_corners_points_prefix
23-
+ model_corners_points_schemas_dict["visibility"]["rpc"]
22+
model_corners_prefix
23+
+ model_corners_schemas_dict["visibility"]["rpc"]
2424
)
2525
def setModelCornersPointsVisibility(self, params):
2626
validate_schema(
2727
params,
28-
self.model_corners_points_schemas_dict["visibility"],
29-
self.model_corners_points_prefix,
28+
self.model_corners_schemas_dict["visibility"],
29+
self.model_corners_prefix,
3030
)
3131
id, block_ids, visibility = (
3232
params["id"],
@@ -36,13 +36,13 @@ def setModelCornersPointsVisibility(self, params):
3636
self.SetBlocksVisibility(id, block_ids, visibility)
3737

3838
@exportRpc(
39-
model_corners_points_prefix + model_corners_points_schemas_dict["color"]["rpc"]
39+
model_corners_prefix + model_corners_schemas_dict["color"]["rpc"]
4040
)
4141
def setModelCornersPointsColor(self, params):
4242
validate_schema(
4343
params,
44-
self.model_corners_points_schemas_dict["color"],
45-
self.model_corners_points_prefix,
44+
self.model_corners_schemas_dict["color"],
45+
self.model_corners_prefix,
4646
)
4747
id, block_ids, red, green, blue = (
4848
params["id"],

src/opengeodeweb_viewer/rpc/model/lines/edges/lines_edges_protocols.py renamed to src/opengeodeweb_viewer/rpc/model/lines/lines_protocols.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView
1010

1111

12-
class VtkModelLinesEdgesView(VtkModelView):
13-
model_lines_edges_prefix = "opengeodeweb_viewer.model.lines.edges."
14-
model_lines_edges_schemas_dict = get_schemas_dict(
12+
class VtkModelLinesView(VtkModelView):
13+
model_lines_prefix = "opengeodeweb_viewer.model.lines."
14+
model_lines_schemas_dict = get_schemas_dict(
1515
os.path.join(os.path.dirname(__file__), "schemas")
1616
)
1717

1818
def __init__(self):
1919
super().__init__()
2020

2121
@exportRpc(
22-
model_lines_edges_prefix + model_lines_edges_schemas_dict["visibility"]["rpc"]
22+
model_lines_prefix + model_lines_schemas_dict["visibility"]["rpc"]
2323
)
2424
def setModelLinesEdgesVisibility(self, params):
2525
validate_schema(
2626
params,
27-
self.model_lines_edges_schemas_dict["visibility"],
28-
self.model_lines_edges_prefix,
27+
self.model_lines_schemas_dict["visibility"],
28+
self.model_lines_prefix,
2929
)
3030
id, block_ids, visibility = (
3131
params["id"],
@@ -35,13 +35,13 @@ def setModelLinesEdgesVisibility(self, params):
3535
self.SetBlocksVisibility(id, block_ids, visibility)
3636

3737
@exportRpc(
38-
model_lines_edges_prefix + model_lines_edges_schemas_dict["color"]["rpc"]
38+
model_lines_prefix + model_lines_schemas_dict["color"]["rpc"]
3939
)
4040
def setModelLinesEdgesColor(self, params):
4141
validate_schema(
4242
params,
43-
self.model_lines_edges_schemas_dict["color"],
44-
self.model_lines_edges_prefix,
43+
self.model_lines_schemas_dict["color"],
44+
self.model_lines_prefix,
4545
)
4646
id, block_ids, red, green, blue = (
4747
params["id"],
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
from opengeodeweb_viewer.rpc.model.model_protocols import VtkModelView
1010

1111

12-
class VtkModelSurfacesPolygonsView(VtkModelView):
13-
model_surfaces_polygons_prefix = "opengeodeweb_viewer.model.surfaces.polygons."
14-
model_surfaces_polygons_schemas_dict = get_schemas_dict(
12+
class VtkModelSurfacesView(VtkModelView):
13+
model_surfaces_prefix = "opengeodeweb_viewer.model.surfaces."
14+
model_surfaces_schemas_dict = get_schemas_dict(
1515
os.path.join(os.path.dirname(__file__), "schemas")
1616
)
1717

1818
def __init__(self):
1919
super().__init__()
2020

2121
@exportRpc(
22-
model_surfaces_polygons_prefix
23-
+ model_surfaces_polygons_schemas_dict["visibility"]["rpc"]
22+
model_surfaces_prefix
23+
+ model_surfaces_schemas_dict["visibility"]["rpc"]
2424
)
2525
def setModelSurfacesPolygonsVisibility(self, params):
2626
validate_schema(
2727
params,
28-
self.model_surfaces_polygons_schemas_dict["visibility"],
29-
self.model_surfaces_polygons_prefix,
28+
self.model_surfaces_schemas_dict["visibility"],
29+
self.model_surfaces_prefix,
3030
)
3131
id, block_ids, visibility = (
3232
params["id"],
@@ -36,14 +36,14 @@ def setModelSurfacesPolygonsVisibility(self, params):
3636
self.SetBlocksVisibility(id, block_ids, visibility)
3737

3838
@exportRpc(
39-
model_surfaces_polygons_prefix
40-
+ model_surfaces_polygons_schemas_dict["color"]["rpc"]
39+
model_surfaces_prefix
40+
+ model_surfaces_schemas_dict["color"]["rpc"]
4141
)
4242
def setModelSurfacesPolygonsCOlor(self, params):
4343
validate_schema(
4444
params,
45-
self.model_surfaces_polygons_schemas_dict["color"],
46-
self.model_surfaces_polygons_prefix,
45+
self.model_surfaces_schemas_dict["color"],
46+
self.model_surfaces_prefix,
4747
)
4848
id, block_ids, red, green, blue = (
4949
params["id"],

src/opengeodeweb_viewer/rpc/viewer/schemas/create_visualization.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/opengeodeweb_viewer/rpc/viewer/schemas/reset.json renamed to src/opengeodeweb_viewer/rpc/viewer/schemas/reset_visualization.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"rpc": "reset",
2+
"rpc": "reset_visualization",
33
"type": "object",
44
"properties": {},
55
"required": [],

src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Third party imports
66
import vtk
77
from vtkmodules.vtkIOImage import vtkPNGWriter, vtkJPEGWriter
8+
from vtkmodules.vtkRenderingAnnotation import vtkCubeAxesActor
89
from vtkmodules.vtkRenderingCore import vtkWindowToImageFilter
910
from wslink import register as exportRpc
1011

@@ -22,14 +23,42 @@ class VtkViewerView(VtkView):
2223
def __init__(self):
2324
super().__init__()
2425

25-
@exportRpc(viewer_prefix + viewer_schemas_dict["create_visualization"]["rpc"])
26-
def createVisualization(self, params):
26+
@exportRpc(viewer_prefix + viewer_schemas_dict["reset_visualization"]["rpc"])
27+
def resetVisualization(self, params):
2728
validate_schema(
28-
params, self.viewer_schemas_dict["create_visualization"], self.viewer_prefix
29+
params, self.viewer_schemas_dict["reset_visualization"], self.viewer_prefix
2930
)
3031
renderWindow = self.getView("-1")
3132
renderer = renderWindow.GetRenderers().GetFirstRenderer()
33+
renderer.RemoveAllViewProps()
34+
35+
grid_scale = vtkCubeAxesActor()
36+
grid_scale.SetCamera(renderer.GetActiveCamera())
37+
grid_scale.DrawXGridlinesOn()
38+
grid_scale.DrawYGridlinesOn()
39+
grid_scale.DrawZGridlinesOn()
40+
grid_scale.SetGridLineLocation(grid_scale.VTK_GRID_LINES_FURTHEST)
41+
grid_scale.GetTitleTextProperty(0).SetColor(0, 0, 0)
42+
grid_scale.GetTitleTextProperty(1).SetColor(0, 0, 0)
43+
grid_scale.GetTitleTextProperty(2).SetColor(0, 0, 0)
44+
grid_scale.GetXAxesLinesProperty().SetColor(0, 0, 0)
45+
grid_scale.GetYAxesLinesProperty().SetColor(0, 0, 0)
46+
grid_scale.GetZAxesLinesProperty().SetColor(0, 0, 0)
47+
grid_scale.GetLabelTextProperty(0).SetColor(0, 0, 0)
48+
grid_scale.GetLabelTextProperty(1).SetColor(0, 0, 0)
49+
grid_scale.GetLabelTextProperty(2).SetColor(0, 0, 0)
50+
grid_scale.GetXAxesGridlinesProperty().SetColor(0, 0, 0)
51+
grid_scale.GetYAxesGridlinesProperty().SetColor(0, 0, 0)
52+
grid_scale.GetZAxesGridlinesProperty().SetColor(0, 0, 0)
53+
54+
grid_scale.SetVisibility(False)
55+
# grid_scale.SetFlyModeToStaticEdges()
56+
self.register_object("grid_scale", "", "", grid_scale, "", "")
57+
58+
59+
renderer.AddActor(grid_scale)
3260
renderer.SetBackground([180 / 255, 180 / 255, 180 / 255])
61+
3362
renderer.ResetCamera()
3463
renderWindow.Render()
3564
self.render()
@@ -147,12 +176,6 @@ def getPointPosition(self, params):
147176
ppos = picker.GetPickPosition()
148177
return {"x": ppos[0], "y": ppos[1], "z": ppos[2]}
149178

150-
@exportRpc(viewer_prefix + viewer_schemas_dict["reset"]["rpc"])
151-
def reset(self, params):
152-
validate_schema(params, self.viewer_schemas_dict["reset"], self.viewer_prefix)
153-
renderWindow = self.getView("-1")
154-
renderWindow.GetRenderers().GetFirstRenderer().RemoveAllViewProps()
155-
156179
def computeEpsilon(self, renderer, z):
157180
renderer.SetDisplayPoint(0, 0, z)
158181
renderer.DisplayToWorld()

0 commit comments

Comments
 (0)