|
From: <lee...@us...> - 2010-03-22 16:47:33
|
Revision: 8210
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8210&view=rev
Author: leejjoon
Date: 2010-03-22 16:47:27 +0000 (Mon, 22 Mar 2010)
Log Message:
-----------
fix incorrect rubber band during the zoom mode when mouse the axes
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backend_bases.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2010-03-21 22:02:31 UTC (rev 8209)
+++ trunk/matplotlib/CHANGELOG 2010-03-22 16:47:27 UTC (rev 8210)
@@ -1,3 +1,6 @@
+2010-03-22 fix incorrect rubber band during the zoom mode when mouse
+ leaves the axes. -JJL
+
2010-03-21 x/y key during the zoom mode only changes the x/y limits. -JJL
2010-03-20 Added pyplot.sca() function suggested by JJL. - EF
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-03-21 22:02:31 UTC (rev 8209)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2010-03-22 16:47:27 UTC (rev 8210)
@@ -2124,18 +2124,6 @@
if self._lastCursor != cursors.SELECT_REGION:
self.set_cursor(cursors.SELECT_REGION)
self._lastCursor = cursors.SELECT_REGION
- if self._xypress:
- x, y = event.x, event.y
- lastx, lasty, a, ind, lim, trans = self._xypress[0]
-
- if self._zoom_mode == "x":
- x1, y1, x2, y2 = event.inaxes.bbox.extents
- y, lasty = y1, y2
- elif self._zoom_mode == "y":
- x1, y1, x2, y2 = event.inaxes.bbox.extents
- x, lastx = x1, x2
-
- self.draw_rubberband(event, x, y, lastx, lasty)
elif (self._active=='PAN' and
self._lastCursor != cursors.MOVE):
self.set_cursor(cursors.MOVE)
@@ -2237,12 +2225,14 @@
and a.get_navigate() and a.can_zoom():
self._xypress.append(( x, y, a, i, a.viewLim.frozen(), a.transData.frozen()))
- id1 = self.canvas.mpl_connect('key_press_event',
+ id1 = self.canvas.mpl_connect('motion_notify_event', self.drag_zoom)
+
+ id2 = self.canvas.mpl_connect('key_press_event',
self._switch_on_zoom_mode)
- id2 = self.canvas.mpl_connect('key_release_event',
+ id3 = self.canvas.mpl_connect('key_release_event',
self._switch_off_zoom_mode)
- self._ids_zoom = id1, id2
+ self._ids_zoom = id1, id2, id3
self._zoom_mode = event.key
@@ -2301,6 +2291,29 @@
a.drag_pan(self._button_pressed, event.key, event.x, event.y)
self.dynamic_update()
+ def drag_zoom(self, event):
+ 'the drag callback in zoom mode'
+
+ if self._xypress:
+ x, y = event.x, event.y
+ lastx, lasty, a, ind, lim, trans = self._xypress[0]
+
+ # adjust x, last, y, last
+ x1, y1, x2, y2 = a.bbox.extents
+ x, lastx = max(min(x, lastx), x1), min(max(x, lastx), x2)
+ y, lasty = max(min(y, lasty), y1), min(max(y, lasty), y2)
+
+ if self._zoom_mode == "x":
+ x1, y1, x2, y2 = a.bbox.extents
+ y, lasty = y1, y2
+ elif self._zoom_mode == "y":
+ x1, y1, x2, y2 = a.bbox.extents
+ x, lastx = x1, x2
+
+ self.draw_rubberband(event, x, y, lastx, lasty)
+
+
+
def release_zoom(self, event):
'the release mouse button callback in zoom to rect mode'
if not self._xypress: return
@@ -2313,7 +2326,6 @@
for cur_xypress in self._xypress:
x, y = event.x, event.y
lastx, lasty, a, ind, lim, trans = cur_xypress
-
# ignore singular clicks - 5 pixels is a threshold
if abs(x-lastx)<5 or abs(y-lasty)<5:
self._xypress = None
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|