Revision: 4956
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4956&view=rev
Author: jdh2358
Date: 2008-02-12 18:10:23 -0800 (Tue, 12 Feb 2008)
Log Message:
-----------
committed eriks span selector patch
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/widgets.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-02-13 02:09:06 UTC (rev 4955)
+++ trunk/matplotlib/CHANGELOG 2008-02-13 02:10:23 UTC (rev 4956)
@@ -1,3 +1,5 @@
+2008-02-12 - Applied Erik Tollerud's span selector patch - JDH
+
2008-02-11 Update plotting() doc string to refer to getp/setp. - JKS
2008-02-10 Fixed a problem with square roots in the pdf backend with
Modified: trunk/matplotlib/lib/matplotlib/widgets.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/widgets.py 2008-02-13 02:09:06 UTC (rev
4955)
+++ trunk/matplotlib/lib/matplotlib/widgets.py 2008-02-13 02:10:23 UTC (rev
4956)
@@ -827,16 +827,14 @@
assert direction in ['horizontal', 'vertical'], 'Must choose
horizontal or vertical for direction'
self.direction = direction
- self.ax = ax
+ self.ax = None
+ self.canvas = None
self.visible = True
- self.canvas = ax.figure.canvas
- self.canvas.mpl_connect('motion_notify_event', self.onmove)
- self.canvas.mpl_connect('button_press_event', self.press)
- self.canvas.mpl_connect('button_release_event', self.release)
- self.canvas.mpl_connect('draw_event', self.update_background)
+ self.cids=[]
self.rect = None
self.background = None
+ self.pressv = None
self.rectprops = rectprops
self.onselect = onselect
@@ -847,8 +845,23 @@
# Needed when dragging out of axes
self.buttonDown = False
self.prev = (0, 0)
-
- if self.direction == 'horizontal':
+
+ self.new_axes(ax)
+
+
+ def new_axes(self,ax):
+ self.ax = ax
+ if self.canvas is not ax.figure.canvas:
+ for cid in self.cids:
+ self.canvas.mpl_disconnect(cid)
+
+ self.canvas = ax.figure.canvas
+
+ self.cids.append(self.canvas.mpl_connect('motion_notify_event',
self.onmove))
+ self.cids.append(self.canvas.mpl_connect('button_press_event',
self.press))
+ self.cids.append(self.canvas.mpl_connect('button_release_event',
self.release))
+ self.cids.append(self.canvas.mpl_connect('draw_event',
self.update_background))
+ if self.direction == 'horizontal':
trans = blended_transform_factory(self.ax.transData,
self.ax.transAxes)
w,h = 0,1
else:
@@ -859,9 +872,8 @@
visible=False,
**self.rectprops
)
-
+
if not self.useblit: self.ax.add_patch(self.rect)
- self.pressv = None
def update_background(self, event):
'force an update of the background'
@@ -931,10 +943,10 @@
minv, maxv = v, self.pressv
if minv>maxv: minv, maxv = maxv, minv
if self.direction == 'horizontal':
- self.rect.xy[0] = minv
+ self.rect.set_x(minv)
self.rect.set_width(maxv-minv)
else:
- self.rect.xy[1] = minv
+ self.rect.set_y(minv)
self.rect.set_height(maxv-minv)
if self.onmove_callback is not None:
@@ -1155,8 +1167,8 @@
miny, maxy = self.eventpress.ydata, y # click-y and actual mouse-y
if minx>maxx: minx, maxx = maxx, minx # get them in the right order
if miny>maxy: miny, maxy = maxy, miny
- self.to_draw.xy[0] = minx # set lower left of box
- self.to_draw.xy[1] = miny
+ self.to_draw.set_x(minx) # set lower left of box
+ self.to_draw.set_y(miny)
self.to_draw.set_width(maxx-minx) # set width and height of box
self.to_draw.set_height(maxy-miny)
self.update()
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins