-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add pan and zoom toolbar handling to 3D Axes (Replaces PR#22614) #23449
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
Conversation
1) This moves the pan logic that was already in the mouse move handler into the "drag_pan" method to make it available from the toolbar. 2) This expands upon the panning logic to enable a zoom-to-box feature. The zoom-to-box is done relative to the Axes, so it shrinks/expands the box as a fraction of each delta, from lower-left Axes to lower-left zoom-box. Thus, it tries to handle non-centered zooms, which adds more cases to handle versus the current right-click zoom only scaling from the center of the projection.
0ea88d2
to
da4fccc
Compare
026802a
to
353d8b8
Compare
353d8b8
to
1eb74b6
Compare
Talked about this in the dev call today, I got a few things to update but this should merge in after #23409 so zooming can respect fixed aspect ratios if those are set. |
afa49ce
to
7ac9f0a
Compare
Thank you for looking it over @oscargus! I deprecated The alternative was to rewrite it to match the functionality of what I put in as |
OK! Maybe it is better to just deprecate the whole That deprecation may naturally be better off in a different PR though. (Sorry, could have thought of that earlier, but didn't realize that Btw, do you know what happens if I squash-merge the commits? Will it still contain both you and @greglucas as authors? (That doesn't happen on Gitlab I've noticed...) |
I've found some libraries that use
Most seem to use Which may mean that there is no big deal if one method is deprecated here and some others in another PR. |
Thinking a bit more about it I suggest the following for now:
|
Sounds good to me, I undeprecated |
I don't believe that a squash merge would preserve that... I can rebase to just squash all mine if that make sense but might be a few days till I can get back to my personal computer for the CLI. |
0b58a03
to
7ef2f41
Compare
7ef2f41
to
a045f36
Compare
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.
Subject to wording in deprecation notice and uncertainty how to deal with the multiple commits, especially the merge commits.
" The only time we are really strict about it is ... to remove upstream merges."
Not sure if it holds here or if the size of this PR means that we can ignore it.
Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
56ca03a
to
ad52d28
Compare
ad52d28
to
28fae53
Compare
Cool, docs are building with that notice now. |
I'm not following the squash discussion. Is this only about crediting multiple people in the squash commit? That is done by Co-authored-by lines. Important: This needs two empty lines before. When you squash via the GitHub UI you can edit the commit message. AFAIR the co-author lines are in there by default. |
Thanks @timhoffm for the clarification/reminder! You are correct that they are there by default, but not two empty in front of it (I added those though, to be on the safe side). (Context: I did something similar in GitLab and there it wasn't added by default so I had to do a force push on the main branch. DId want to avoid that there...) |
…plotlib#23449) * ENH: Add pan and zoom toolbar handling to 3D Axes 1) This moves the pan logic that was already in the mouse move handler into the "drag_pan" method to make it available from the toolbar. 2) This expands upon the panning logic to enable a zoom-to-box feature. The zoom-to-box is done relative to the Axes, so it shrinks/expands the box as a fraction of each delta, from lower-left Axes to lower-left zoom-box. Thus, it tries to handle non-centered zooms, which adds more cases to handle versus the current right-click zoom only scaling from the center of the projection. * Rewrite zooming with bounding box * Rewrite 3d panning to work with a roll angle * Whats new for zoom and pan buttons * Make pan button configurable * Do not jump when zooming and mouse goes over other subplot * Rework zooming for 3d plots * Handle x/y lock when zooming and panning * Update tests * Docstrings * Dont assume a scale_z * Limit zoom box * Test zoom pan key modifiers * Save some calculation by saving view axes * Deprecation warnings for Axes3D.eye, .vvec * Remove Axes3D._prepare_view_from_bbox for now * Comments and docstrings * Switch from uvn to uvw * Save aspect to axes * Constrain zooming with mouse when one of the equal aspect ratios is set * Cleanup * Cleanup * Consolidate finding equal aspect axis indices * linting * More intuitive scaling * Box zoom keeps existing aspect ratios * Linting * Code review comments * Revert parameters for view_transformation * Fix new 3d pan/zoom view going on view stack twice * Better clipping * Test 3d toolbar navigation * Privatize helper functions * Deprecations * Code review changes * Deprecation note * Undeprecate proj3d.view_transformation * Undeprecate proj3d.view_transformation * Update doc/api/next_api_changes/deprecations/23449-SS.rst Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com> Co-authored-by: Scott Shambaugh <scottshambaugh@users.noreply.github.com> Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
…plotlib#23449) * ENH: Add pan and zoom toolbar handling to 3D Axes 1) This moves the pan logic that was already in the mouse move handler into the "drag_pan" method to make it available from the toolbar. 2) This expands upon the panning logic to enable a zoom-to-box feature. The zoom-to-box is done relative to the Axes, so it shrinks/expands the box as a fraction of each delta, from lower-left Axes to lower-left zoom-box. Thus, it tries to handle non-centered zooms, which adds more cases to handle versus the current right-click zoom only scaling from the center of the projection. * Rewrite zooming with bounding box * Rewrite 3d panning to work with a roll angle * Whats new for zoom and pan buttons * Make pan button configurable * Do not jump when zooming and mouse goes over other subplot * Rework zooming for 3d plots * Handle x/y lock when zooming and panning * Update tests * Docstrings * Dont assume a scale_z * Limit zoom box * Test zoom pan key modifiers * Save some calculation by saving view axes * Deprecation warnings for Axes3D.eye, .vvec * Remove Axes3D._prepare_view_from_bbox for now * Comments and docstrings * Switch from uvn to uvw * Save aspect to axes * Constrain zooming with mouse when one of the equal aspect ratios is set * Cleanup * Cleanup * Consolidate finding equal aspect axis indices * linting * More intuitive scaling * Box zoom keeps existing aspect ratios * Linting * Code review comments * Revert parameters for view_transformation * Fix new 3d pan/zoom view going on view stack twice * Better clipping * Test 3d toolbar navigation * Privatize helper functions * Deprecations * Code review changes * Deprecation note * Undeprecate proj3d.view_transformation * Undeprecate proj3d.view_transformation * Update doc/api/next_api_changes/deprecations/23449-SS.rst Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com> Co-authored-by: Scott Shambaugh <scottshambaugh@users.noreply.github.com> Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
…plotlib#23449) * ENH: Add pan and zoom toolbar handling to 3D Axes 1) This moves the pan logic that was already in the mouse move handler into the "drag_pan" method to make it available from the toolbar. 2) This expands upon the panning logic to enable a zoom-to-box feature. The zoom-to-box is done relative to the Axes, so it shrinks/expands the box as a fraction of each delta, from lower-left Axes to lower-left zoom-box. Thus, it tries to handle non-centered zooms, which adds more cases to handle versus the current right-click zoom only scaling from the center of the projection. * Rewrite zooming with bounding box * Rewrite 3d panning to work with a roll angle * Whats new for zoom and pan buttons * Make pan button configurable * Do not jump when zooming and mouse goes over other subplot * Rework zooming for 3d plots * Handle x/y lock when zooming and panning * Update tests * Docstrings * Dont assume a scale_z * Limit zoom box * Test zoom pan key modifiers * Save some calculation by saving view axes * Deprecation warnings for Axes3D.eye, .vvec * Remove Axes3D._prepare_view_from_bbox for now * Comments and docstrings * Switch from uvn to uvw * Save aspect to axes * Constrain zooming with mouse when one of the equal aspect ratios is set * Cleanup * Cleanup * Consolidate finding equal aspect axis indices * linting * More intuitive scaling * Box zoom keeps existing aspect ratios * Linting * Code review comments * Revert parameters for view_transformation * Fix new 3d pan/zoom view going on view stack twice * Better clipping * Test 3d toolbar navigation * Privatize helper functions * Deprecations * Code review changes * Deprecation note * Undeprecate proj3d.view_transformation * Undeprecate proj3d.view_transformation * Update doc/api/next_api_changes/deprecations/23449-SS.rst Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com> Co-authored-by: Scott Shambaugh <scottshambaugh@users.noreply.github.com> Co-authored-by: Oscar Gustafsson <oscar.gustafsson@gmail.com>
PR Summary
Starting with @greglucas's work in #22614, I got panning and zooming working again with the toolbar buttons. Closes #110 (the oldest open issue!)
Changes in this PR:
._view_u
,._view_v
,._view_w
.eye
,.vvec
,.sx
,.sy
, andproj3d.view_transformation()
If this is too much packed in a single PR, I can separate it out into the panning and the zooming features.
Zooming behavior:
With right mouse button: All axes are zoomed equally.With the bounding box and an aspect ratio of'auto'
: The scale factors set by the bounding box extents zoom the data axes such that the data is stretched in theu
,v
plane parallel to the screen but not in thew
axis into/out of the screen. In other words, this zooms in 2D, projected onto the 3D data axes. Aspect ratio is set by the aspect of the bounding box. Note that the bounding box scale factors are calculated with respect to the whole canvas rather than the (shrunk) 3D axis limits.With the bounding box and an aspect ratio of'equal'
,'equalzy'
,'equalyz'
, or'equalxz'
: Similar to the above, but the constrained data axes are kept equal, which may induce scaling in thew
axis.'equal'
zooms all axes equally.Please play around with it and see if the behavior is as expected!
Here's my test plot code which you can use:
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).