-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature/view-setting-config #208
Merged
Licini
merged 17 commits into
compas-dev:main
from
ZacZhangzhuo:feature/view-setting-config
Dec 17, 2023
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d1a50f4
push
ZacZhangzhuo c1ee6c7
Merge branch 'main' into feature/view-setting-config
ZacZhangzhuo e9246da
update with the example
ZacZhangzhuo df80ec2
changelog
ZacZhangzhuo 513fcfd
lint
ZacZhangzhuo beeeab5
fix the lint
ZacZhangzhuo dd5c768
Merge remote-tracking branch 'origin/main' into feature/view-setting-…
ZacZhangzhuo 715eaeb
update the better solution
ZacZhangzhuo 9a1d911
Merge branch 'main' into feature/view-setting-config
ZacZhangzhuo 644e72d
Fix rst line `=`, change VIEW_ANGLES to VIEW_PORTS
ZacZhangzhuo 4fc2f70
naming change, viewmode, viewport, etc.
ZacZhangzhuo 4c5cda7
changelog
ZacZhangzhuo 8175e4b
`VIEW_PORTS` to `VIEWPORTS`
ZacZhangzhuo ee73940
patch
ZacZhangzhuo 4b704fa
title lines fix
ZacZhangzhuo 1e1a2e9
Merge branch 'main' into feature/view-setting-config
ZacZhangzhuo ec9abb7
Merge branch 'main' into feature/view-setting-config
ZacZhangzhuo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from compas.geometry import Box | ||
from compas.geometry import Frame | ||
from compas_view2.app import App | ||
|
||
# If you input incomplete configuration, the rest will be filled by the default values. | ||
|
||
config = { | ||
"view": { | ||
"show_grid": True, | ||
"viewmode": "shaded", | ||
"background_color": [1, 1, 1, 1], | ||
"selection_color": [1.0, 1.0, 0.0], | ||
"viewport": "top", | ||
"camera": { | ||
"fov": 45, | ||
"near": 0.1, | ||
"far": 1000, | ||
"position": [-15, -15, 15], | ||
"target": [1,1, 1], | ||
"scale": 1, | ||
}, | ||
} | ||
} | ||
|
||
viewer_default = App() | ||
viewer_custom = App(config=config) | ||
|
||
|
||
box = Box(Frame([0, 0, 0], [1, 0, 0], [0, 1, 0]), 1, 1, 1) | ||
|
||
viewer_default.add(box) | ||
viewer_custom.add(box) | ||
|
||
|
||
viewer_default.run() | ||
viewer_custom.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
******************************************************************************* | ||
Camera Config | ||
******************************************************************************* | ||
|
||
.. autosummary:: | ||
:toctree: | ||
:nosignatures: | ||
|
||
Default Camera Config | ||
======================================= | ||
|
||
By default, the camera is configed 45 dregees perspective: | ||
|
||
.. figure:: /_images/example_camera_config.jpg | ||
:figclass: figure | ||
:class: figure-img img-fluid | ||
|
||
|
||
|
||
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. | ||
|
||
.. figure:: /_images/example_camera_config_2.jpg | ||
:figclass: figure | ||
:class: figure-img img-fluid | ||
|
||
.. literalinclude:: example_camera_config.py | ||
:language: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import time | ||
from OpenGL import GL | ||
|
||
from OpenGL import GL | ||
from qtpy import QtCore | ||
from qtpy import QtWidgets | ||
|
||
from compas_view2.scene import Camera | ||
from compas_view2.objects import GridObject | ||
from compas_view2.scene import Camera | ||
|
||
|
||
class View(QtWidgets.QOpenGLWidget): | ||
|
@@ -19,23 +19,20 @@ class View(QtWidgets.QOpenGLWidget): | |
The view configuration. | ||
""" | ||
|
||
FRONT = 1 | ||
RIGHT = 2 | ||
TOP = 3 | ||
PERSPECTIVE = 4 | ||
VIEWPORTS = {"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 = View.PERSPECTIVE | ||
self._current = self.VIEWPORTS[view_config["viewport"]] | ||
self.shader_model = None | ||
self.app = app | ||
self.color = view_config["background_color"] | ||
self.mode = view_config["view_mode"] | ||
self.mode = view_config["viewmode"] | ||
self.selection_color = view_config["selection_color"] | ||
self.show_grid = view_config["show_grid"] | ||
self.camera = Camera(self) | ||
self.camera = Camera(self, **view_config["camera"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also to my point earlier, |
||
self.grid = GridObject(1, 10, 10) | ||
self.objects = {} | ||
self.keys = {"shift": False, "control": False, "f": False} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the default value is already custom.