-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Minor RectangleSelector refactors #22146
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3005,6 +3005,19 @@ def _press(self, event): | |
|
||
return False | ||
|
||
def _selector_too_small(self): | ||
# Return True if selector is smaller than minimum allowed size | ||
if self.spancoords == 'data': | ||
spanx = self._eventpress.xdata - self._eventrelease.xdata | ||
spany = self._eventpress.ydata - self._eventrelease.ydata | ||
elif self.spancoords == 'pixels': | ||
spanx = self._eventpress.x - self._eventrelease.x | ||
spany = self._eventpress.y - self._eventrelease.y | ||
else: | ||
_api.check_in_list(['data', 'pixels'], | ||
spancoords=self.spancoords) | ||
return abs(spanx) <= self.minspanx or abs(spany) <= self.minspany | ||
|
||
def _release(self, event): | ||
"""Button release event handler.""" | ||
if not self._interactive: | ||
|
@@ -3026,26 +3039,11 @@ def _release(self, event): | |
xy1 = self.ax.transData.transform([x1, y1]) | ||
self._eventrelease.x, self._eventrelease.y = xy1 | ||
|
||
# calculate dimensions of box or line | ||
if self.spancoords == 'data': | ||
spanx = abs(self._eventpress.xdata - self._eventrelease.xdata) | ||
spany = abs(self._eventpress.ydata - self._eventrelease.ydata) | ||
elif self.spancoords == 'pixels': | ||
spanx = abs(self._eventpress.x - self._eventrelease.x) | ||
spany = abs(self._eventpress.y - self._eventrelease.y) | ||
else: | ||
_api.check_in_list(['data', 'pixels'], | ||
spancoords=self.spancoords) | ||
# check if drawn distance (if it exists) is not too small in | ||
# either x or y-direction | ||
minspanxy = (spanx <= self.minspanx or spany <= self.minspany) | ||
if (self._drawtype != 'none' and minspanxy): | ||
< 8000 span class='blob-code-inner blob-code-marker js-skip-tagsearch' data-code-marker="-"> for artist in self.artists: | ||
artist.set_visible(False) | ||
if self._drawtype != 'none' and self._selector_too_small(): | ||
if self._selection_completed: | ||
# Call onselect, only when the selection is already existing | ||
self.onselect(self._eventpress, self._eventrelease) | ||
self._selection_completed = False | ||
self.clear() | ||
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. Is this change intended here? It's not a refactoring but changes code, e.g. 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. I don't remember what is the purpose of the 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. For the record: it seems that the |
||
else: | ||
self.onselect(self._eventpress, self._eventrelease) | ||
self._selection_completed = True | ||
|
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.
Should it be a property?