Skip to content

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.

@dhomeier
Copy link
Contributor Author

dhomeier commented Feb 5, 2025

Status from December 2024 rebased to current main; to proceed further polygon rotation needs to be added to matplotlib, which should probably be done after the corresponding functionality for rectangles and ellipses in matplotlib/matplotlib#26833 has been merged.

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