Skip to content
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
merged 17 commits into from
Dec 17, 2023

Conversation

ZacZhangzhuo
Copy link
Collaborator

What type of change is this?

Added view_angle and camera in the config. This should close #207 .

Thanks @tomvanmele for the proposal.

Copy link
Collaborator

@Licini Licini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add an example script.

RIGHT = 2
TOP = 3
PERSPECTIVE = 4
VIEW_ANGLES = {"CUSTOM": 0, "FRONT": 1, "RIGHT": 2, "TOP": 3, "PERSPECTIVE": 4}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the benefit to change these numeration to dict?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

The reason is for the readability of the config file: the original version would only allow us to put numbers (i,e. "view_angle":1 ) in the config. While using dict would allow us to indicate the key: "view_angle": "TOP".

@@ -14,8 +14,17 @@
"view": {
"show_grid": true,
"view_mode": "shaded",
"view_angle": "CUSTOM",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

angle suggest things like Euler angle, any other name?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think we should use a custom setting here in the default config. It should be something minimal and simple.

Copy link
Collaborator Author

@ZacZhangzhuo ZacZhangzhuo Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

angle suggest things like Euler angle, any other name?

agree, I was having trouble with naming this as well. In rhino it is called view setting which is a bit general as well.

how about view_port ? like "view_port":"TOP"

Copy link
Collaborator Author

@ZacZhangzhuo ZacZhangzhuo Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think we should use a custom setting here in the default config. It should be something minimal and simple.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I meant we shouldn't ............. I miss typed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"view_port" is better, let's use that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pin the sphinx version, related to compas-dev/compas_invocations@067a873

Copy link
Collaborator Author

@ZacZhangzhuo ZacZhangzhuo Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think we should use a custom setting here in the default config. It should be something minimal and simple.

the default value is already custom.

@ZacZhangzhuo ZacZhangzhuo self-assigned this Dec 14, 2023
@ZacZhangzhuo
Copy link
Collaborator Author

image

@ZacZhangzhuo ZacZhangzhuo marked this pull request as draft December 15, 2023 08:12
@ZacZhangzhuo
Copy link
Collaborator Author

ZacZhangzhuo commented Dec 15, 2023

Wait, I should put out a better solution that also solves #209 . I convert it into draft and will work on it.

maybe do you have any clue about the break point of the camera? sometimes it becomes blank and not useable. there might be some trick in setting the params. @Licini

image

@Licini
Copy link
Collaborator

Licini commented Dec 15, 2023

@ZacZhangzhuo We should also allow using programmable API to achieve this besides config.
Something like

viewer = App()
...
viewer.camera.top_view()
viewer.show()

or

viewer = App(view_port="top")
...
viewer.show()

@ZacZhangzhuo
Copy link
Collaborator Author

ZacZhangzhuo commented Dec 15, 2023

Hi @Licini , I updated the solution and it is ready to be reviewed:

  • no CUSTOM option, but in PERSPECTIVE you can define the target, position and any other params.
  • The default config is minimal: PERSPECTIVE, looking at the origin.
  • Params for TOP, FRONT, and RIGHT are also configurable, like the target. Except for the position

2023-12-12-15-19-21-02
example_camera_config_2
example_camera_config

@ZacZhangzhuo ZacZhangzhuo marked this pull request as ready for review December 15, 2023 18:31
docs/examples/control/example_camera_config.rst Outdated Show resolved Hide resolved
docs/tutorials/tutorial_basics.rst Outdated Show resolved Hide resolved
docs/tutorials/tutorial_configuration.rst Outdated Show resolved Hide resolved
docs/tutorials/tutorial_software_concepts.rst Outdated Show resolved Hide resolved
requirements-dev.txt Outdated Show resolved Hide resolved
@@ -14,8 +14,17 @@
"view": {
"show_grid": true,
"view_mode": "shaded",
"view_port": "PERSPECTIVE",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally, i would not add an underscore in keys like these. you could consider "viewmode" and "viewport" as one word. "show_grid" is different in that sense...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I didn't find the naming conversions for the configuration / .jason file so I named it this way. All the items in this file, including some long words, like enable_propertyform, flow_view_size, zoom_selected, view_perspective, background_color, and selection_color, then need to be changed. Shall we decide fixing them all?

We could create a separate PR/Issue for this

src/compas_view2/app/controller.py Outdated Show resolved Hide resolved
src/compas_view2/views/view.py Outdated Show resolved Hide resolved
self.shader_model = None
self.app = app
self.color = view_config["background_color"]
self.mode = view_config["view_mode"]
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"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also to my point earlier, view_config could be interpreted as "viewing the config" (action + subject). it is clearer what is meant when viewconfig is used, in my opinion...

@ZacZhangzhuo ZacZhangzhuo deleted the feature/view-setting-config branch December 16, 2023 16:07
@ZacZhangzhuo ZacZhangzhuo restored the feature/view-setting-config branch December 16, 2023 16:08
@ZacZhangzhuo ZacZhangzhuo reopened this Dec 16, 2023
@Licini
Copy link
Collaborator

Licini commented Dec 16, 2023

@ZacZhangzhuo We should also allow using programmable API to achieve this besides config. Something like

viewer = App()
...
viewer.camera.top_view()
viewer.show()

or

viewer = App(view_port="top")
...
viewer.show()

Almost there, as Tom mentioned, let's make view_port to viewport and view_mode to viewmode. And please add kwarg to App init api e.g. App(viewport="Top")

@ZacZhangzhuo
Copy link
Collaborator Author

changed, you can use the below code to exam:

viewer = App(viewport="front")
viewer.show()

since this is a small update, I have not put an example yet. but the doc is updated in the tutorial_configuration:

2. In-code definition which overwrites the configuration:

::

    >>> from compas_view2.app import App
    >>> viewer = App(viewmode="lighted", viewport = "top", enable_sceneform=True, enable_propertyform=True, enable_sidebar=True, width=2000, height=1000)

let me know if you think we should add an extra example file.


also, the underscores of other options in the config:

like enable_propertyform, flow_view_size, zoom_selected, view_perspective, background_color, and selection_color,

are not changed. let me know if you want to change them too.

docs/examples/control/example_camera_config.rst Outdated Show resolved Hide resolved
docs/tutorials/tutorial_basics.rst Outdated Show resolved Hide resolved
@tomvanmele tomvanmele self-requested a review December 17, 2023 10:01
@tomvanmele
Copy link
Member

sorry i approved this by accident. will leave the approval up to @Licini

@tomvanmele
Copy link
Member

@ZacZhangzhuo if you bring in the latest changes from main the docs will build a lot faster...

@ZacZhangzhuo
Copy link
Collaborator Author

@ZacZhangzhuo if you bring in the latest changes from main the docs will build a lot faster...

thanks for the update change!

@Licini Licini merged commit 349b0ba into compas-dev:main Dec 17, 2023
11 checks passed
@ZacZhangzhuo ZacZhangzhuo deleted the feature/view-setting-config branch December 18, 2023 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistant view angle and look at
3 participants