Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rectangle Selector Upgrade #3937

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

Merged
merged 48 commits into from
Sep 8, 2015
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2ed0d49
Store prev event to handle out of bounds selections
blink1073 Dec 19, 2014
f8eefe6
Upgrade RectangleSelector with ToolHandles and add Ellipse
blink1073 Dec 19, 2014
7f044cf
Add toolhandles class
blink1073 Dec 19, 2014
f450df6
Add test using tool handles
blink1073 Dec 19, 2014
79294e0
Add a helper function to get axes
blink1073 Dec 19, 2014
fd264a2
Do not allow extents outside the image and add a path property
blink1073 Dec 19, 2014
438715f
Finish rectangle handle tests and add ellipse test with key modifiers
blink1073 Dec 19, 2014
e560713
Rename path property to geometry and return consistent results.
blink1073 Dec 20, 2014
5025ba2
Add geometry tests.
blink1073 Dec 20, 2014
b118294
Remove extra line.
blink1073 Dec 20, 2014
b15cf12
Refactor the event handling methods
blink1073 Dec 20, 2014
e96fe81
Update rectangle logic to include '_moving'
blink1073 Dec 20, 2014
240cfa2
Clean up event handling and add a state attribute
blink1073 Dec 20, 2014
7915db8
Add state handling to onmove
blink1073 Dec 20, 2014
f7a9222
More "state" refactoring
blink1073 Dec 20, 2014
7c04e25
Add key release and continue refactoring state handling
blink1073 Dec 20, 2014
cf491db
Recreate the _get_data method and more event refactoring
blink1073 Dec 20, 2014
7ece2fa
Refactor the event creator to call the private methods
blink1073 Dec 20, 2014
59ccd81
Preserve existing api for event handler functions
blink1073 Dec 21, 2014
a033e8e
Preserve event return values
blink1073 Dec 24, 2014
2923f97
Add cleanup to tests and fix default rect prop
blink1073 Dec 24, 2014
6549538
Pep8 fixes
blink1073 Dec 24, 2014
491276e
Fix bug in SpanSelector when blit=True
blink1073 Jan 17, 2015
744308c
Clear events after valid release
blink1073 Jan 18, 2015
a7518b3
Do not attempt to draw artists if ax is invisible
blink1073 Jan 18, 2015
77dc52b
Ignore events when axes are invisible
blink1073 Jan 18, 2015
48ebf30
Fix span selector onmove when we exit axes
blink1073 Feb 21, 2015
3ffd7c0
Restore previous behaviour and allow escape to clear the current sele…
blink1073 Aug 19, 2015
e802991
Fix failing tests
blink1073 Aug 19, 2015
af6e1b4
Fix handling of center handle
blink1073 Aug 20, 2015
f5666a4
Remove debug print
blink1073 Aug 20, 2015
545a727
STY: PEP8
tacaswell Aug 22, 2015
feb58fe
FIX: do not call draw_idle if blitting
tacaswell Aug 22, 2015
7bd67d2
DOC: make rectangle demo use handles
tacaswell Aug 22, 2015
b60a84d
Add docstring for EllipseSelector and use print() statements
blink1073 Aug 22, 2015
840a671
Revert to old draw types and add docs about key modifiers
blink1073 Aug 23, 2015
2a11f5f
Revert change to the example
blink1073 Aug 23, 2015
8da7985
Remove extra draw_idle trigger
blink1073 Aug 23, 2015
cfe4df1
Update the docstring
blink1073 Aug 23, 2015
bc225b6
Remove extraneous doc
blink1073 Aug 23, 2015
59145af
Fix failing test
blink1073 Aug 23, 2015
d491ac9
Update docstring, use self.useblit, use space for move
blink1073 Aug 25, 2015
8e8e473
Use new state_modifier_keys dictionary
blink1073 Aug 26, 2015
2ed0419
Clear the active handle when invisible
blink1073 Aug 26, 2015
d5b5d86
Collapse the shape on improper draw to prevent showing the previous s…
blink1073 Aug 26, 2015
87ab199
Fix test using 'alt' key
blink1073 Aug 26, 2015
9eaae32
Clean up and add more docs
blink1073 Sep 1, 2015
819804f
Make on_key_release use the state_modifier_keys
blink1073 Sep 1, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Recreate the _get_data method and more event refactoring
  • Loading branch information
blink1073 committed Aug 22, 2015
commit cf491db131d19d0f7caad79334851528d783d39e
29 changes: 18 additions & 11 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,18 @@ def update(self):
self.canvas.draw_idle()
return False

def _get_data(self, event):
"""Get the xdata and ydata for event, with limits"""
if event.xdata is None:
return None, None
x0, x1 = self.ax.get_xbound()
y0, y1 = self.ax.get_ybound()
xdata = max(x0, event.xdata)
xdata = min(x1, xdata)
ydata = max(y0, event.ydata)
ydata = min(y1, ydata)
return xdata, ydata

def _clean_event(self, event):
"""Clean up an event

Expand All @@ -1241,14 +1253,8 @@ def _clean_event(self, event):
event = self._prev_event
else:
event = copy.copy(event)

x0, x1 = self.ax.get_xbound()
y0, y1 = self.ax.get_ybound()
xdata = max(x0, event.xdata)
event.xdata = min(x1, xdata)
ydata = max(y0, event.ydata)
event.ydata = min(y1, ydata)

event.xdata, event.ydata = self._get_data(event)

self._prev_event = event
return event

Expand All @@ -1269,10 +1275,11 @@ def press(self, event):

def _release(self, event):
"""Button release event handler and validator"""
if not self.ignore(event):
if not self.ignore(event) and self.eventpress:
event = self._clean_event(event)
self.eventrelease = event
self.release(event)
self.state.discard('move')

def release(self, event):
"""Button release event handler"""
Expand Down Expand Up @@ -1840,9 +1847,9 @@ def onmove(self, event):
return
maxd = max(abs(dx_pix), abs(dy_pix))
if abs(dx_pix) < maxd:
dx *= maxd / abs(dx_pix)
dx *= maxd / (abs(dx_pix) + 1e-6)
if abs(dy_pix) < maxd:
dy *= maxd / abs(dy_pix)
dy *= maxd / (abs(dy_pix) + 1e-6)

# from center
if 'center' in self.state:
Expand Down