[go: up one dir, main page]

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

Add interactive matplotlib selector to PolygonPixelRegion #406

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dhomeier
Copy link
Contributor
@dhomeier dhomeier commented Dec 8, 2021

As next part of the work on interactive regions #391 this PR adds an as_mpl_selector widget to the PolygonPixelRegion class to allow moving and resizing through the draw_box functionality added to PolygonSelector in matplotlib/matplotlib#21830, as well as reshaping by direct manipulation of the vertices. The draw_box handles are working analogously to the selector methods for Rectangle and Ellipse PixelRegions.
Rotation is not yet included, but can be added once the mpl PR or a follow-up supports this. A centroid method is already included to provide a robust and rotation-invariant reference point.
The connected PolygonSelector is instantiated in a rather pedestrian manner, using several private methods, which should perhaps be replaced by a public method on the matplotlib side. using the new verts.setter method for updating the vertices; tiny remaining quirk is the bounding box not being displayed after creation, but only after the first event inside.

@dhomeier
Copy link
Contributor Author

The last commit adds a method to set the rotation angle on a given Polygon instance as polygon.rotation = 30 * u.deg, and update the selector from it, if present (no test for the latter as the mpl PR is not merged) – as kind of a template for how rotation from the selector might eventually be implemented.

@pllim
Copy link
Member
pllim commented Mar 30, 2023

If #500 is merged first, the doc needs to be updated here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants