Skip to content

Commit

Permalink
Add ortho view
Browse files Browse the repository at this point in the history
  • Loading branch information
Licini committed Aug 14, 2024
1 parent 3b09834 commit 23b6046
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `ColorDialog` to manage color dialog.
* Added `SettingLayout` to manage complex layout with config input.
* Added `robot.py` example.
* Added `ortho` option to view.

### Changed

Expand Down
1 change: 1 addition & 0 deletions src/compas_viewer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class MenubarConfig(ConfigBase):
{"title": "Top", "action": change_view_cmd, "kwargs": {"mode": "top"}},
{"title": "Front", "action": change_view_cmd, "kwargs": {"mode": "front"}},
{"title": "Right", "action": change_view_cmd, "kwargs": {"mode": "right"}},
{"title": "Ortho", "action": change_view_cmd, "kwargs": {"mode": "ortho"}},
],
},
{"type": "separator"},
Expand Down
4 changes: 3 additions & 1 deletion src/compas_viewer/renderer/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ def reset_position(self, view: Optional[str] = None):
self.rotation.set(pi / 2, 0, 0, False)
if view == "right":
self.rotation.set(pi / 2, 0, pi / 2, False)
if view == "ortho":
self.rotation.set(pi / 4, 0, -pi / 4, False)

def rotate(self, dx: float, dy: float):
"""Rotate the camera based on current mouse movement.
Expand All @@ -338,7 +340,7 @@ def rotate(self, dx: float, dy: float):
is a perspective view (``camera.renderer.config.view == "perspective"``).
"""
if self.renderer.view == "perspective":
if self.renderer.view == "perspective" or self.renderer.view == "ortho":
self.rotation += [-self.rotationdelta * dy, 0, -self.rotationdelta * dx]

def pan(self, dx: float, dy: float):
Expand Down

0 comments on commit 23b6046

Please sign in to comment.