Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Fix rst line =, change VIEW_ANGLES to VIEW_PORTS
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacZhangzhuo committed Dec 16, 2023
1 parent 9a1d911 commit 644e72d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions docs/examples/control/example_camera_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Camera Config
:nosignatures:

Default Camera Config
====================
======================

By default, the camera is configed 45 dregees perspective:

Expand All @@ -18,12 +18,12 @@ By default, the camera is configed 45 dregees perspective:


Custom Camera Config
====================
======================

You can customize the camera configreation by passing the dictionary to the viewer: fov, near, fac, position, target, scale.

.. note::
The `position` is not editable and would be ingored from the config file in `TOP`, `FRONT`, `RIGHT`modes.
The `position` is not editable and would be ingored from the config file in `TOP`, `FRONT`, `RIGHT` modes.

.. figure:: /_images/example_camera_config_2.jpg
:figclass: figure
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/tutorial_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ This is a quick way to customize your viewer. It is suitable for task-specific c


Configuration Structure
======================
========================================
The default configuration file can be downloaded here: :download:`Link <files/config_default.json>`,
or can be printed by the following code:

Expand All @@ -78,7 +78,7 @@ or can be printed by the following code:
It it the template for creating your own settings, keyboard preferences, etc.

Supported Keys
===============
===================
In the `controller -> keys`, you can add you preferred keys. Currently, :mod:`compas_view2` supports below keys:

.. figure:: /_images/keyboard.png
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/tutorial_software_concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ to help you better the design concepts behind it.


Software Architecture
===================
======================

.. figure:: /_images/software_concept.png
:figclass: figure
Expand All @@ -39,7 +39,7 @@ UI Components
:class: figure-img img-fluid

Configuration Structure
=====================
===========================
.. figure:: /_images/config_structure.png
:figclass: figure
:class: figure-img img-fluid
8 changes: 4 additions & 4 deletions src/compas_view2/app/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def view_front(self):
None
"""
self.app.view.current = self.app.view.VIEW_ANGLES["FRONT"]
self.app.view.current = self.app.view.VIEW_PORTS["FRONT"]
self.app.view.camera.reset_position()
self.app.view.update_projection()
self.app.view.update()
Expand All @@ -444,7 +444,7 @@ def view_right(self):
None
"""
self.app.view.current = self.app.view.VIEW_ANGLES["RIGHT"]
self.app.view.current = self.app.view.VIEW_PORTS["RIGHT"]
self.app.view.camera.reset_position()
self.app.view.update_projection()
self.app.view.update()
Expand All @@ -457,7 +457,7 @@ def view_top(self):
None
"""
self.app.view.current = self.app.view.VIEW_ANGLES["TOP"]
self.app.view.current = self.app.view.VIEW_PORTS["TOP"]
self.app.view.camera.reset_position()
self.app.view.update_projection()
self.app.view.update()
Expand All @@ -470,7 +470,7 @@ def view_perspective(self):
None
"""
self.app.view.current = self.app.view.VIEW_ANGLES["PERSPECTIVE"]
self.app.view.current = self.app.view.VIEW_PORTS["PERSPECTIVE"]
self.app.view.camera.reset_position()
self.app.view.update_projection()
self.app.view.update()
Expand Down
14 changes: 7 additions & 7 deletions src/compas_view2/scene/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ def _on_target_update(self, target):
def reset_position(self):
"""Reset the position of the camera based current view type."""
self.target.set(0, 0, 0)
if self.view.current == self.view.VIEW_ANGLES["PERSPECTIVE"]:
if self.view.current == self.view.VIEW_PORTS["PERSPECTIVE"]:
self.rotation.set(pi / 4, 0, -pi / 4)
if self.view.current == self.view.VIEW_ANGLES["TOP"]:
if self.view.current == self.view.VIEW_PORTS["TOP"]:
self.rotation.set(0, 0, 0)
if self.view.current == self.view.VIEW_ANGLES["FRONT"]:
if self.view.current == self.view.VIEW_PORTS["FRONT"]:
self.rotation.set(pi / 2, 0, 0)
if self.view.current == self.view.VIEW_ANGLES["RIGHT"]:
if self.view.current == self.view.VIEW_PORTS["RIGHT"]:
self.rotation.set(pi / 2, 0, pi / 2)

def rotate(self, dx, dy):
Expand All @@ -263,10 +263,10 @@ def rotate(self, dx, dy):
Notes
-----
Camera rotations are only available if the current view is a perspective view (``camera.view.current == camera.view.VIEW_ANGLES["PERSPECTIVE"]``).
Camera rotations are only available if the current view is a perspective view (``camera.view.current == camera.view.VIEW_PORTS["PERSPECTIVE"]``).
"""
if self.view.current == self.view.VIEW_ANGLES["PERSPECTIVE"]:
if self.view.current == self.view.VIEW_PORTS["PERSPECTIVE"]:
self.rotation += [-self.rotation_delta * dy, 0, -self.rotation_delta * dx]

def pan(self, dx, dy):
Expand Down Expand Up @@ -326,7 +326,7 @@ def projection(self, width, height):
"""
aspect = width / height
if self.view.current == self.view.VIEW_ANGLES["PERSPECTIVE"]:
if self.view.current == self.view.VIEW_PORTS["PERSPECTIVE"]:
P = perspective(self.fov, aspect, self.near * self.scale, self.far * self.scale)
else:
left = -self.distance
Expand Down
4 changes: 2 additions & 2 deletions src/compas_view2/views/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class View(QtWidgets.QOpenGLWidget):
The view configuration.
"""

VIEW_ANGLES = {"FRONT": 1, "RIGHT": 2, "TOP": 3, "PERSPECTIVE": 4}
VIEW_PORTS = {"FRONT": 1, "RIGHT": 2, "TOP": 3, "PERSPECTIVE": 4}

def __init__(self, app, view_config):
super().__init__()
self.setFocusPolicy(QtCore.Qt.StrongFocus)
self._opacity = 1.0
self._current = self.VIEW_ANGLES[view_config["view_port"]]
self._current = self.VIEW_PORTS[view_config["view_port"]]
self.shader_model = None
self.app = app
self.color = view_config["background_color"]
Expand Down
2 changes: 1 addition & 1 deletion src/compas_view2/views/view120.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def sort_objects_from_viewworld(self, viewworld):

def paint(self):
viewworld = self.camera.viewworld()
if self.current != self.VIEW_ANGLES["PERSPECTIVE"]:
if self.current != self.VIEW_PORTS["PERSPECTIVE"]:
self.update_projection()

# Draw instance maps
Expand Down

0 comments on commit 644e72d

Please sign in to comment.