Skip to content
Merged

Next #83

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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "OpenGeodeWeb-Viewer"
version = "1.9.1"
version = "1.10.0-rc.1"
dynamic = ["dependencies"]
authors = [
{ name="Geode-solutions", email="[email protected]" },
Expand Down
4 changes: 2 additions & 2 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
jsonschema
wslink
wslink<2
fastjsonschema
websocket-client
47 changes: 21 additions & 26 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile requirements.in
#
aiohttp==3.9.3
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.14
# via wslink
aiosignal==1.3.1
aiosignal==1.4.0
# via aiohttp
async-timeout==4.0.3
async-timeout==5.0.1
# via aiohttp
attrs==23.2.0
# via
# aiohttp
# jsonschema
# referencing
frozenlist==1.4.1
attrs==25.3.0
# via aiohttp
fastjsonschema==2.21.1
# via -r requirements.in
frozenlist==1.7.0
# via
# aiohttp
# aiosignal
idna==3.6
idna==3.10
# via yarl
jsonschema==4.21.1
# via -r requirements.in
jsonschema-specifications==2023.12.1
# via jsonschema
multidict==6.0.5
multidict==6.6.3
# via
# aiohttp
# yarl
python-dotenv==1.0.1
# via -r requirements.in
referencing==0.33.0
propcache==0.3.2
# via
# jsonschema
# jsonschema-specifications
rpds-py==0.18.0
# aiohttp
# yarl
typing-extensions==4.14.1
# via
# jsonschema
# referencing
websocket-client==1.7.0
# aiosignal
# multidict
websocket-client==1.8.0
# via -r requirements.in
wslink==1.12.4
# via -r requirements.in
yarl==1.9.4
yarl==1.20.1
# via aiohttp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"type": "object",
"properties": {
"z_scale": {
"type": "number"
"type": "number",
"minimum": 1
}
},
"required": [
Expand Down
22 changes: 11 additions & 11 deletions src/opengeodeweb_viewer/rpc/viewer/viewer_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ def toggleGridScale(self, params):
params, self.viewer_schemas_dict["grid_scale"], self.viewer_prefix
)
id, visibility = "grid_scale", params["visibility"]
actor = self.get_object(id)["actor"]
actor.SetVisibility(visibility)
if "grid_scale" in self.get_data_base():
actor = self.get_object(id)["actor"]
actor.SetVisibility(visibility)
self.render()

@exportRpc(viewer_prefix + viewer_schemas_dict["axes"]["rpc"])
Expand Down Expand Up @@ -281,19 +282,18 @@ def renderNow(self, params):

@exportRpc(viewer_prefix + viewer_schemas_dict["set_z_scaling"]["rpc"])
def setZScaling(self, params):

validate_schema(
params, self.viewer_schemas_dict["set_z_scaling"], self.viewer_prefix
)
z_scale = params["z_scale"]

renderWindow = self.getView("-1")
renderer = renderWindow.GetRenderers().GetFirstRenderer()

actors = renderer.GetActors()

for actor in actors:
transform = vtkTransform()
transform.Scale(1, 1, z_scale)
actor.SetUserTransform(transform)
cam = renderer.GetActiveCamera()
transform = vtk.vtkTransform()
transform.Scale(1, 1, z_scale)
cam.SetModelTransformMatrix(transform.GetMatrix())

if "grid_scale" in self.get_data_base():
cube_axes_actor = self.get_object("grid_scale")["actor"]
cube_axes_actor.SetUse2DMode(1)
self.render()
9 changes: 5 additions & 4 deletions src/opengeodeweb_viewer/utils_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import json

# Third party imports
from jsonschema import validate
from jsonschema.exceptions import ValidationError
import fastjsonschema
from fastjsonschema import JsonSchemaException

# Local application imports

Expand All @@ -24,8 +24,9 @@ def get_schemas_dict(path):
def validate_schema(params, schema, prefix=""):
print(f"{prefix}{schema['rpc']}", f"{params=}", flush=True)
try:
validate(instance=params, schema=schema)
except ValidationError as e:
validate = fastjsonschema.compile(schema)
validate(params)
except fastjsonschema.JsonSchemaException as e:
print(f"Validation error: {e.message}", flush=True)
raise Exception(
{
Expand Down
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.
Binary file modified src/tests/data/take_screenshot_with_background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/tests/data/take_screenshot_with_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/tests/data/take_screenshot_without_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions src/tests/test_viewer_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,50 @@ def test_set_z_scaling(server):
[{"z_scale": 2.5}],
)
assert server.compare_image(3, "viewer/set_z_scaling.jpeg") == True


def test_combined_scaling_and_grid(server):
# test_set_z_scaling(server)

# server.call(
# VtkViewerView.viewer_prefix
# + VtkViewerView.viewer_schemas_dict["set_background_color"]["rpc"],
# [{"color": {"r": 180, "g": 180, "b": 180}}],
# )
# assert server.compare_image(3, "viewer/scaling_and_grid_color.jpeg") == True

# server.call(
# VtkViewerView.viewer_prefix
# + VtkViewerView.viewer_schemas_dict["grid_scale"]["rpc"],
# [{"visibility": True}],
# )

# assert server.compare_image(3, "viewer/grid_scale_on.jpeg") == True
server.call(
VtkViewerView.viewer_prefix
+ VtkViewerView.viewer_schemas_dict["reset_visualization"]["rpc"],
)

assert server.compare_image(3, "viewer/reset_visualization.jpeg") == True

server.call(
VtkMeshView.mesh_prefix + VtkMeshView.mesh_schemas_dict["register"]["rpc"],
[{"id": "123456789", "file_name": "hat.vtp"}],
)
assert server.compare_image(3, "viewer/register_hat.jpeg") == True

server.call(
VtkViewerView.viewer_prefix
+ VtkViewerView.viewer_schemas_dict["grid_scale"]["rpc"],
[{"visibility": True}],
)

assert server.compare_image(3, "viewer/grid_scale_on.jpeg") == True

server.call(
VtkViewerView.viewer_prefix
+ VtkViewerView.viewer_schemas_dict["set_z_scaling"]["rpc"],
[{"z_scale": 2.5}],
)

assert server.compare_image(3, "viewer/combined_scaling_and_grid.jpeg") == True