-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add option of bounding box for PolygonSelector #21830
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
5847eda
to
4ac8e37
Compare
This should be ready for review now |
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.
This works nicely, I made a couple of comments/suggestions.
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.
Thanks for the PR and updates; I have tested this with a method in astropy/regions#406 that uses this new functionality and see that some early quirks have already been resolved!
A general issue with that regions
method, which connects a custom PolygonSelector
, is that creating a complete instance is somewhat tedious – adding the vertices and then triggering a redraw and finally marking the selector _selection_completed
; for most of this I have not found public methods for the required operations. Having those, analogously to extents
etc. in RectangleSelector
would be a plus (but not necessary from this PR).
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.
This looks good, it just need the test to be fixed!
ca3c9c6
to
a2d4414
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.
I wonder if it should be called draw_bbox
, or even draw_bounding_box
(since we seem to have pretty verbose names in widgets already.)
event_sequence = (polygon_place_vertex(*verts[0]) + | ||
polygon_place_vertex(*verts[1]) + | ||
polygon_place_vertex(*verts[2]) + | ||
polygon_place_vertex(*verts[3]) + | ||
polygon_place_vertex(*verts[0])) |
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.
event_sequence = (polygon_place_vertex(*verts[0]) + | |
polygon_place_vertex(*verts[1]) + | |
polygon_place_vertex(*verts[2]) + | |
polygon_place_vertex(*verts[3]) + | |
polygon_place_vertex(*verts[0])) | |
event_sequence = ( | |
*polygon_place_vertex(*verts[0]), | |
*polygon_place_vertex(*verts[1]), | |
*polygon_place_vertex(*verts[2]), | |
*polygon_place_vertex(*verts[3]), | |
*polygon_place_vertex(*verts[0]), | |
) |
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.
I didn't do this since the rest of test_widgets.py
uses the +
notation. I'd be happy to put in a PR to change it all in one go though?
Update polygon every time bounding box is moved Allow box customisation Remove del Prevent rotation on polygon bounding box Fix line length Cleanup transform logic Don't use dicts as keyword defaults Minor doc fixes
Run exising polygon selector tests with draw_box=True
Trigger events on canvas in test Test doc fixes
a2d4414
to
72e95f0
Compare
Thanks for reviewing. I changed the argument name to |
Co-authored-by: Elliott Sales de Andrade <[email protected]>
Co-authored-by: Elliott Sales de Andrade <[email protected]>
PR Summary
This allows one to put a bounding box around a PolygonSelector, that can be used for resizing and moving (and eventually rotating) the selector points.
polygon.mov
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).