Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Improve RectangleSelector rotation#21945
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
8eeae8e923a90eab8b1d7d2d2ce1baea572File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -738,13 +738,6 @@ def __init__(self, xy, width, height, angle=0.0, *, | ||
| self._height = height | ||
| self.angle = float(angle) | ||
| self.rotation_point = rotation_point | ||
| self._convert_units() # Validate the inputs. | ||
| def get_path(self): | ||
| @@ -772,13 +765,11 @@ def get_patch_transform(self): | ||
| rotation_point = bbox.x0, bbox.y0 | ||
| else: | ||
| rotation_point = self.rotation_point | ||
| return (transforms.BboxTransformTo(bbox) + | ||
| transforms.Affine2D() | ||
| .translate(-rotation_point[0], -rotation_point[1]) | ||
| .rotate_deg(self.angle) | ||
| .translate(*rotation_point)) | ||
| @property | ||
| def rotation_point(self): | ||
| @@ -816,6 +807,14 @@ def get_corners(self): | ||
| return self.get_patch_transform().transform( | ||
| [(0, 0), (1, 0), (1, 1), (0, 1)]) | ||
| def _get_edge_midpoints(self): | ||
| """ | ||
| Return the edge midpoints of the rectangle, moving anti-clockwise from | ||
| the center of the left-hand edge. | ||
| """ | ||
| return self.get_patch_transform().transform( | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It would be good to have test. MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is private API, and is implicitly tested by a lot of the selector tests. If the points were somehow wrong here, the handles would be in the wrong place, and if they were correct but in the wrong order the resizing logic would not work as intended. | ||
| [(0, 0.5), (0.5, 0), (1, 0.5), (0.5, 1)]) | ||
| def get_center(self): | ||
| """Return the centre of the rectangle.""" | ||
| return self.get_patch_transform().transform((0.5, 0.5)) | ||
| @@ -1565,12 +1564,6 @@ def __init__(self, xy, width, height, angle=0, **kwargs): | ||
| self._width, self._height = width, height | ||
| self._angle = angle | ||
| self._path = Path.unit_circle() | ||
| # Note: This cannot be calculated until this is added to an Axes | ||
| self._patch_transform = transforms.IdentityTransform() | ||
| @@ -1588,9 +1581,8 @@ def _recompute_transform(self): | ||
| width = self.convert_xunits(self._width) | ||
| height = self.convert_yunits(self._height) | ||
| self._patch_transform = transforms.Affine2D() \ | ||
| .scale(width * 0.5, height * 0.5) \ | ||
| .rotate_deg(self.angle) \ | ||
| .translate(*center) | ||
| def get_path(self): | ||
| @@ -1681,6 +1673,14 @@ def get_corners(self): | ||
| return self.get_patch_transform().transform( | ||
| [(-1, -1), (1, -1), (1, 1), (-1, 1)]) | ||
| def _get_edge_midpoints(self): | ||
| """ | ||
| Return the corners of the ellipse, moving anti-clockwise from | ||
| the center of the left-hand edge before rotation. | ||
| """ | ||
| return self.get_patch_transform().transform( | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It would be good to have test. MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. See comment above. | ||
| [(-1, 0), (0, -1), (1, 0), (0, 1)]) | ||
| class Annulus(Patch): | ||
| """ | ||
Uh oh!
There was an error while loading.Please reload this page.