Revision: 3996 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3996&view=rev Author: mdboom Date: 2007-10-24 11:49:08 -0700 (Wed, 24 Oct 2007)
Log Message: ----------- Initial pass of Gtk, Qt, Qt4, Fltk and Wx GUI backends. Lots more examples passing. Modified Paths: -------------- branches/transforms/PASSED_DEMOS branches/transforms/examples/dynamic_demo_wx.py branches/transforms/examples/embedding_in_gtk.py branches/transforms/examples/embedding_in_gtk2.py branches/transforms/examples/embedding_in_gtk3.py branches/transforms/examples/embedding_in_tk.py branches/transforms/examples/embedding_in_tk2.py branches/transforms/examples/embedding_in_wx.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/backends/backend_fltkagg.py branches/transforms/lib/matplotlib/backends/backend_gdk.py branches/transforms/lib/matplotlib/backends/backend_gtk.py branches/transforms/lib/matplotlib/backends/backend_qt.py branches/transforms/lib/matplotlib/backends/backend_qt4.py branches/transforms/lib/matplotlib/backends/backend_qt4agg.py branches/transforms/lib/matplotlib/backends/backend_qtagg.py branches/transforms/lib/matplotlib/backends/backend_wx.py branches/transforms/lib/matplotlib/backends/backend_wxagg.py branches/transforms/lib/matplotlib/backends/tkagg.py branches/transforms/lib/matplotlib/lines.py branches/transforms/setupext.py branches/transforms/src/_backend_agg.h branches/transforms/src/_gtkagg.cpp branches/transforms/src/_tkagg.cpp Modified: branches/transforms/PASSED_DEMOS =================================================================== --- branches/transforms/PASSED_DEMOS 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/PASSED_DEMOS 2007-10-24 18:49:08 UTC (rev 3996) @@ -2,14 +2,14 @@ agg_buffer_to_array.py O agg_oo.py O agg_resize.py [BROKEN IN TRUNK] -agg_test.py +agg_test.py ??? alignment_test.py O -animation_blit_fltk.py -animation_blit.py -animation_blit_qt4.py -animation_blit_qt.py -animation_blit_tk.py -animation_blit_wx.py +animation_blit_fltk.py [terminate called after throwing an instance of 'Swig::DirectorMethodException'] +animation_blit.py O +animation_blit_qt4.py O +animation_blit_qt.py O +animation_blit_tk.py O +animation_blit_wx.py O anim.py O [BUT SLOWER] annotation_demo.py O anscombe.py O @@ -56,24 +56,24 @@ date_demo_rrule.py O date_index_formatter.py O dynamic_collection.py O -dynamic_demo.py [GTK] -dynamic_demo_wx.py [WX] -dynamic_image_gtkagg.py -dynamic_image_wxagg2.py -dynamic_image_wxagg.py +dynamic_demo.py O +dynamic_demo_wx.py [REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED] +dynamic_image_gtkagg.py O +dynamic_image_wxagg2.py O +dynamic_image_wxagg.py ellipse_demo.py O ellipse_rotated.py O -embedding_in_gtk2.py -embedding_in_gtk3.py -embedding_in_gtk.py -embedding_in_qt4.py -embedding_in_qt.py -embedding_in_tk2.py -embedding_in_tk.py -embedding_in_wx2.py -embedding_in_wx3.py -embedding_in_wx4.py -embedding_in_wx.py +embedding_in_gtk2.py [REQUIRES NON-AGG GDK RENDERER, WHICH IS NOT YET IMPLEMENTED] +embedding_in_gtk3.py O +embedding_in_gtk.py [REQUIRES NON-AGG GDK RENDERER, WHICH IS NOT YET IMPLEMENTED] +embedding_in_qt4.py O +embedding_in_qt.py O +embedding_in_tk2.py O +embedding_in_tk.py O +embedding_in_wx2.py [IDENTICAL BUG IN TRUNK -- Y-AXIS VALUES ARE TRUNCATED] +embedding_in_wx3.py O +embedding_in_wx4.py O +embedding_in_wx.py [REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED] errorbar_demo.py O errorbar_limits.py O figimage_demo.py O @@ -91,20 +91,20 @@ font_table_ttf.py [N/A] ftface_props.py [N/A] ganged_plots.py O -glyph_to_path.py [Requires PIL] +glyph_to_path.py O gradient_bar.py O -gtk_spreadsheet.py +gtk_spreadsheet.py [REQUIRES NON-AGG GDK RENDERER, WHICH IS NOT YET IMPLEMENTED] hatch_demo.py O histogram_demo_canvasagg.py [???] histogram_demo.py O image_demo2.py O -image_demo3.py [Requires PIL] +image_demo3.py O image_demo.py O image_interp.py O image_masked.py O [Whew!] image_origin.py O image_slices_viewer.py [BROKEN ON TRUNK] -__init__.py +__init__.py [N/A] integral_demo.py O interactive2.py [N/A] interactive.py [N/A] @@ -119,7 +119,7 @@ legend_scatter.py O line_collection2.py O line_collection.py O -lineprops_dialog_gtk.py +lineprops_dialog_gtk.py O line_styles.py O load_converter.py O loadrec.py O @@ -132,7 +132,7 @@ masked_demo.py O mathtext_demo.py O mathtext_examples.py O -mathtext_wx.py +mathtext_wx.py O matplotlib_icon.py [N/A] matshow.py O movie_demo.py O Modified: branches/transforms/examples/dynamic_demo_wx.py =================================================================== --- branches/transforms/examples/dynamic_demo_wx.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/examples/dynamic_demo_wx.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -62,7 +62,6 @@ FigureManager, NavigationToolbar2Wx from matplotlib.figure import Figure -from matplotlib.axes import Subplot import numpy from wx import * Modified: branches/transforms/examples/embedding_in_gtk.py =================================================================== --- branches/transforms/examples/embedding_in_gtk.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/examples/embedding_in_gtk.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -6,7 +6,6 @@ import gtk -from matplotlib.axes import Subplot from matplotlib.figure import Figure from numpy import arange, sin, pi Modified: branches/transforms/examples/embedding_in_gtk2.py =================================================================== --- branches/transforms/examples/embedding_in_gtk2.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/examples/embedding_in_gtk2.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -5,7 +5,6 @@ """ import gtk -from matplotlib.axes import Subplot from matplotlib.figure import Figure from numpy import arange, sin, pi Modified: branches/transforms/examples/embedding_in_gtk3.py =================================================================== --- branches/transforms/examples/embedding_in_gtk3.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/examples/embedding_in_gtk3.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -5,7 +5,6 @@ import gtk -from matplotlib.axes import Subplot from matplotlib.figure import Figure from numpy import arange, sin, pi Modified: branches/transforms/examples/embedding_in_tk.py =================================================================== --- branches/transforms/examples/embedding_in_tk.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/examples/embedding_in_tk.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -3,7 +3,6 @@ matplotlib.use('TkAgg') from numpy import arange, sin, pi -from matplotlib.axes import Subplot from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib.figure import Figure Modified: branches/transforms/examples/embedding_in_tk2.py =================================================================== --- branches/transforms/examples/embedding_in_tk2.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/examples/embedding_in_tk2.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -3,7 +3,6 @@ matplotlib.use('TkAgg') from numpy import arange, sin, pi -from matplotlib.axes import Subplot from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib.figure import Figure Modified: branches/transforms/examples/embedding_in_wx.py =================================================================== --- branches/transforms/examples/embedding_in_wx.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/examples/embedding_in_wx.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -43,7 +43,6 @@ FigureManager from matplotlib.figure import Figure -from matplotlib.axes import Subplot import numpy from wx import * Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/axes.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -1538,7 +1538,8 @@ if other is not self: other.set_xlim(self.viewLim.intervalx, emit=False) - self.figure.canvas.draw_idle() + if self.figure.canvas is not None: + self.figure.canvas.draw_idle() return xmin, xmax @@ -1697,7 +1698,8 @@ if other is not self: other.set_ylim(self.viewLim.ymin, self.viewLim.ymax, emit=False) - self.figure.canvas.draw_idle() + if self.figure.canvas is not None: + self.figure.canvas.draw_idle() return ymin, ymax def get_yscale(self): @@ -3036,39 +3038,13 @@ ''' where = kwargs.pop('where', 'pre') + if where not in ('pre', 'post', 'mid'): + raise ValueError("'where' argument to step must be 'pre', 'post' or 'mid'") + kwargs['linestyle'] = 'steps-' + where + + return self.plot(x, y, *args, **kwargs) - if not cbook.iterable(x): - x = ma.array([x], dtype=npy.float_) - if not cbook.iterable(y): - y = ma.array([y], dtype=npy.float_) - if where=='pre': - x2 = ma.zeros((2*len(x)-1,), npy.float_) - y2 = ma.zeros((2*len(y)-1,), npy.float_) - - x2[0::2], x2[1::2] = x, x[:-1] - y2[0::2], y2[1:-1:2] = y, y[1:] - - elif where=='post': - x2 = ma.zeros((2*len(x)-1,), npy.float_) - y2 = ma.zeros((2*len(y)-1,), npy.float_) - - x2[::2], x2[1:-1:2] = x, x[1:] - y2[0::2], y2[1::2] = y, y[:-1] - - elif where=='mid': - x2 = ma.zeros((2*len(x),), npy.float_) - y2 = ma.zeros((2*len(y),), npy.float_) - - x2[1:-1:2] = 0.5*(x[:-1]+x[1:]) - x2[2::2] = 0.5*(x[:-1]+x[1:]) - x2[0], x2[-1] = x[0], x[-1] - - y2[0::2], y2[1::2] = y, y - - return self.plot(x2, y2, *args, **kwargs) - - def bar(self, left, height, width=0.8, bottom=None, color=None, edgecolor=None, linewidth=None, yerr=None, xerr=None, ecolor=None, capsize=3, Modified: branches/transforms/lib/matplotlib/backends/backend_fltkagg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_fltkagg.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_fltkagg.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -140,16 +140,16 @@ self._oldsize =newsize self._source.resize(newsize) self._source.draw() - t1,t2,w,h = self._source.figure.bbox.get_bounds() + t1,t2,w,h = self._source.figure.bbox.bounds Fltk.fl_draw_image(self._source.buffer_rgba(0,0),0,0,int(w),int(h),4,0) self.redraw() def blit(self,bbox=None): if bbox is None: - t1,t2,w,h = self._source.figure.bbox.get_bounds() + t1,t2,w,h = self._source.figure.bbox.bounds else: - t1o,t2o,wo,ho = self._source.figure.bbox.get_bounds() - t1,t2,w,h = bbox.get_bounds() + t1o,t2o,wo,ho = self._source.figure.bbox.bounds + t1,t2,w,h = bbox.bounds x,y=int(t1),int(t2) Fltk.fl_draw_image(self._source.buffer_rgba(x,y),x,y,int(w),int(h),4,int(wo)*4) #self.redraw() @@ -222,7 +222,7 @@ class FigureCanvasFltkAgg(FigureCanvasAgg): def __init__(self, figure): FigureCanvasAgg.__init__(self,figure) - t1,t2,w,h = self.figure.bbox.get_bounds() + t1,t2,w,h = self.figure.bbox.bounds w, h = int(w), int(h) self.canvas=FltkCanvas(0, 0, w, h, "canvas",self) #self.draw() @@ -263,7 +263,7 @@ def __init__(self, canvas, num, window): FigureManagerBase.__init__(self, canvas, num) #Fltk container window - t1,t2,w,h = canvas.figure.bbox.get_bounds() + t1,t2,w,h = canvas.figure.bbox.bounds w, h = int(w), int(h) self.window = window self.window.size(w,h+30) @@ -405,7 +405,7 @@ Fltk.Fl_File_Icon.load_system_icons() self._fc = Fltk.Fl_File_Chooser( ".", "*", Fltk.Fl_File_Chooser.CREATE, "Save Figure" ) self._fc.hide() - t1,t2,w,h = canvas.figure.bbox.get_bounds() + t1,t2,w,h = canvas.figure.bbox.bounds w, h = int(w), int(h) self._group = Fltk.Fl_Pack(0,h+2,1000,26) self._group.type(Fltk.FL_HORIZONTAL) @@ -591,7 +591,7 @@ Fltk.Fl_File_Icon.load_system_icons() self._fc = Fltk.Fl_File_Chooser( ".", "*", Fltk.Fl_File_Chooser.CREATE, "Save Figure" ) self._fc.hide() - t1,t2,w,h = self.canvas.figure.bbox.get_bounds() + t1,t2,w,h = self.canvas.figure.bbox.bounds w, h = int(w), int(h) self._group = Fltk.Fl_Pack(0,h+2,1000,26) self._group.type(Fltk.FL_HORIZONTAL) Modified: branches/transforms/lib/matplotlib/backends/backend_gdk.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_gdk.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_gdk.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -353,7 +353,7 @@ def points_to_pixels(self, points): - return points/72.0 * self.dpi.get() + return points/72.0 * self.dpi class GraphicsContextGDK(GraphicsContextBase): Modified: branches/transforms/lib/matplotlib/backends/backend_gtk.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_gtk.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_gtk.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -249,7 +249,7 @@ return # empty fig # resize the figure (in inches) - dpi = self.figure.dpi.get() + dpi = self.figure.dpi self.figure.set_size_inches (w/dpi, h/dpi) self._need_redraw = True Modified: branches/transforms/lib/matplotlib/backends/backend_qt.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_qt.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_qt.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -110,14 +110,14 @@ def mouseMoveEvent( self, event ): x = event.x() # flipy so y=0 is bottom of canvas - y = self.figure.bbox.height() - event.y() + y = self.figure.bbox.height - event.y() FigureCanvasBase.motion_notify_event( self, x, y ) if DEBUG: print 'mouse move' def mouseReleaseEvent( self, event ): x = event.x() # flipy so y=0 is bottom of canvas - y = self.figure.bbox.height() - event.y() + y = self.figure.bbox.height - event.y() button = self.buttond[event.button()] FigureCanvasBase.button_release_event( self, x, y, button ) if DEBUG: print 'button released' @@ -139,7 +139,7 @@ w = event.size().width() h = event.size().height() if DEBUG: print "FigureCanvasQt.resizeEvent(", w, ",", h, ")" - dpival = self.figure.dpi.get() + dpival = self.figure.dpi winch = w/dpival hinch = h/dpival self.figure.set_size_inches( winch, hinch ) @@ -150,7 +150,7 @@ qt.QWidget.resize( self, w, h ) # Resize the figure by converting pixels to inches. - pixelPerInch = self.figure.dpi.get() + pixelPerInch = self.figure.dpi wInch = w / pixelPerInch hInch = h / pixelPerInch self.figure.set_size_inches( wInch, hInch ) @@ -367,7 +367,7 @@ qt.QApplication.setOverrideCursor( qt.QCursor( cursord[cursor] ) ) def draw_rubberband( self, event, x0, y0, x1, y1 ): - height = self.canvas.figure.bbox.height() + height = self.canvas.figure.bbox.height y1 = height - y1 y0 = height - y0 @@ -384,8 +384,8 @@ toolfig = Figure(figsize=(6,3)) toolfig.subplots_adjust(top=0.9) - w = int (toolfig.bbox.width()) - h = int (toolfig.bbox.height()) + w = int (toolfig.bbox.width) + h = int (toolfig.bbox.height) canvas = self._get_canvas(toolfig) tool = SubplotTool(self.canvas.figure, toolfig) Modified: branches/transforms/lib/matplotlib/backends/backend_qt4.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_qt4.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_qt4.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -101,7 +101,7 @@ def mousePressEvent( self, event ): x = event.pos().x() # flipy so y=0 is bottom of canvas - y = self.figure.bbox.height() - event.pos().y() + y = self.figure.bbox.height - event.pos().y() button = self.buttond[event.button()] FigureCanvasBase.button_press_event( self, x, y, button ) if DEBUG: print 'button pressed:', event.button() @@ -109,14 +109,14 @@ def mouseMoveEvent( self, event ): x = event.x() # flipy so y=0 is bottom of canvas - y = self.figure.bbox.height() - event.y() + y = self.figure.bbox.height - event.y() FigureCanvasBase.motion_notify_event( self, x, y ) #if DEBUG: print 'mouse move' def mouseReleaseEvent( self, event ): x = event.x() # flipy so y=0 is bottom of canvas - y = self.figure.bbox.height() - event.y() + y = self.figure.bbox.height - event.y() button = self.buttond[event.button()] FigureCanvasBase.button_release_event( self, x, y, button ) if DEBUG: print 'button released' @@ -138,7 +138,7 @@ w = event.size().width() h = event.size().height() if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")" - dpival = self.figure.dpi.get() + dpival = self.figure.dpi winch = w/dpival hinch = h/dpival self.figure.set_size_inches( winch, hinch ) @@ -149,7 +149,7 @@ QtGui.QWidget.resize( self, w, h ) # Resize the figure by converting pixels to inches. - pixelPerInch = self.figure.dpi.get() + pixelPerInch = self.figure.dpi wInch = w / pixelPerInch hInch = h / pixelPerInch self.figure.set_size_inches( wInch, hInch ) Modified: branches/transforms/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_qt4agg.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_qt4agg.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -112,8 +112,8 @@ # we are blitting here else: bbox = self.replot - w, h = int(bbox.width()), int(bbox.height()) - l, t = bbox.ll().x().get(), bbox.ur().y().get() + l, b, w, h = bbox.bounds + t = b + h reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string() qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32) @@ -140,8 +140,8 @@ """ self.replot = bbox - w, h = int(bbox.width()), int(bbox.height()) - l, t = bbox.ll().x().get(), bbox.ur().y().get() + l, b, w, h = bbox.bounds + t = b + h self.update(l, self.renderer.height-t, w, h) def print_figure(self, *args, **kwargs): Modified: branches/transforms/lib/matplotlib/backends/backend_qtagg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_qtagg.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_qtagg.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -115,8 +115,8 @@ # we are blitting here else: bbox = self.replot - w, h = int(bbox.width()), int(bbox.height()) - l, t = bbox.ll().x().get(), bbox.ur().y().get() + l, b, w, h = bbox.bounds + t = b + h reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string() qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian) Modified: branches/transforms/lib/matplotlib/backends/backend_wx.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_wx.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_wx.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -459,7 +459,7 @@ convert point measures to pixes using dpi and the pixels per inch of the display """ - return points*(PIXELS_PER_INCH/72.0*self.dpi.get()/72.0) + return points*(PIXELS_PER_INCH/72.0*self.dpi/72.0) class GraphicsContextWx(GraphicsContextBase, wx.MemoryDC): """ @@ -735,7 +735,7 @@ FigureCanvasBase.__init__(self, figure) # Set preferred window size hint - helps the sizer (if one is # connected) - l,b,w,h = figure.bbox.get_bounds() + l,b,w,h = figure.bbox.bounds w = int(math.ceil(w)) h = int(math.ceil(h)) @@ -981,6 +981,7 @@ drawDC.BeginDrawing() drawDC.DrawBitmap(self.bitmap, 0, 0) drawDC.EndDrawing() + wx.GetApp().Yield() filetypes = FigureCanvasBase.filetypes.copy() filetypes['bmp'] = 'Windows bitmap' @@ -1092,7 +1093,7 @@ if not self._isConfigured: self._isConfigured = True - dpival = self.figure.dpi.get() + dpival = self.figure.dpi winch = self._width/dpival hinch = self._height/dpival self.figure.set_size_inches(winch, hinch) @@ -1132,7 +1133,7 @@ def _onRightButtonDown(self, evt): """Start measuring on an axis.""" x = evt.GetX() - y = self.figure.bbox.height() - evt.GetY() + y = self.figure.bbox.height - evt.GetY() evt.Skip() self.CaptureMouse() FigureCanvasBase.button_press_event(self, x, y, 3, guiEvent=evt) @@ -1141,7 +1142,7 @@ def _onRightButtonUp(self, evt): """End measuring on an axis.""" x = evt.GetX() - y = self.figure.bbox.height() - evt.GetY() + y = self.figure.bbox.height - evt.GetY() evt.Skip() if self.HasCapture(): self.ReleaseMouse() FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt) @@ -1149,7 +1150,7 @@ def _onLeftButtonDown(self, evt): """Start measuring on an axis.""" x = evt.GetX() - y = self.figure.bbox.height() - evt.GetY() + y = self.figure.bbox.height - evt.GetY() evt.Skip() self.CaptureMouse() FigureCanvasBase.button_press_event(self, x, y, 1, guiEvent=evt) @@ -1157,7 +1158,7 @@ def _onLeftButtonUp(self, evt): """End measuring on an axis.""" x = evt.GetX() - y = self.figure.bbox.height() - evt.GetY() + y = self.figure.bbox.height - evt.GetY() #print 'release button', 1 evt.Skip() if self.HasCapture(): self.ReleaseMouse() @@ -1171,7 +1172,7 @@ """Start measuring on an axis.""" x = evt.GetX() - y = self.figure.bbox.height() - evt.GetY() + y = self.figure.bbox.height - evt.GetY() evt.Skip() FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=evt) @@ -1274,7 +1275,7 @@ pos = wx.DefaultPosition else: pos =wx.Point(20,20) - l,b,w,h = fig.bbox.get_bounds() + l,b,w,h = fig.bbox.bounds wx.Frame.__init__(self, parent=None, id=-1, pos=pos, title="Figure %d" % num, size=(w,h)) @@ -1730,7 +1731,7 @@ dc.ResetBoundingBox() dc.BeginDrawing() - height = self.canvas.figure.bbox.height() + height = self.canvas.figure.bbox.height y1 = height - y1 y0 = height - y0 @@ -2036,7 +2037,7 @@ # so that we can temporarily set them to the dpi of # the printer, and the bg color to white bgcolor = self.canvas.figure.get_facecolor() - fig_dpi = self.canvas.figure.dpi.get() + fig_dpi = self.canvas.figure.dpi # draw the bitmap, scaled appropriately vscale = float(ppw) / fig_dpi Modified: branches/transforms/lib/matplotlib/backends/backend_wxagg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_wxagg.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/backend_wxagg.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -19,7 +19,6 @@ import wx import matplotlib from matplotlib.figure import Figure -from matplotlib.transforms import Bbox, Point, Value from backend_agg import FigureCanvasAgg import backend_wx @@ -74,7 +73,7 @@ self.gui_repaint() return - l, b, w, h = bbox.get_bounds() + l, b, w, h = bbox.bounds r = l + w t = b + h x = int(l) Modified: branches/transforms/lib/matplotlib/backends/tkagg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/tkagg.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/backends/tkagg.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -4,15 +4,19 @@ def blit(photoimage, aggimage, bbox=None, colormode=1): tk = photoimage.tk + if bbox is not None: + bbox_array = bbox.__array__() + else: + bbox_array = None try: - tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox)) + tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array)) except Tk.TclError, v: try: try: _tkagg.tkinit(tk.interpaddr(), 1) except AttributeError: _tkagg.tkinit(id(tk), 0) - tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox)) + tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array)) except (ImportError, AttributeError, Tk.TclError): raise Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/lib/matplotlib/lines.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -113,14 +113,17 @@ class Line2D(Artist): lineStyles = _lineStyles = { # hidden names deprecated - '-' : '_draw_solid', - '--' : '_draw_dashed', - '-.' : '_draw_dash_dot', - ':' : '_draw_dotted', - 'steps': '_draw_steps', - 'None' : '_draw_nothing', - ' ' : '_draw_nothing', - '' : '_draw_nothing', + '-' : '_draw_solid', + '--' : '_draw_dashed', + '-.' : '_draw_dash_dot', + ':' : '_draw_dotted', + 'steps' : '_draw_steps_pre', + 'steps-mid' : '_draw_steps_mid', + 'steps-pre' : '_draw_steps_pre', + 'steps-post' : '_draw_steps_post', + 'None' : '_draw_nothing', + ' ' : '_draw_nothing', + '' : '_draw_nothing', } markers = _markers = { # hidden names deprecated @@ -208,7 +211,7 @@ data: (npy.array xdata, npy.array ydata) figure: a matplotlib.figure.Figure instance label: any string - linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' | ' ' | '' ] + linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ] linewidth or lw: float value in points lod: [True | False] marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4' @@ -566,7 +569,10 @@ """ Set the linestyle of the line - ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' | ' ' | '' ] + 'steps' is equivalent to 'steps-pre' and is maintained for + backward-compatibility. + + ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ] """ if linestyle not in self._lineStyles: verbose.report('Unrecognized line style %s, %s' % @@ -668,11 +674,75 @@ renderer.draw_path(gc, path, trans) - def _draw_steps(self, renderer, gc, path, trans): - # MGDTODO: Implement me - raise NotImplementedError("'steps' linestyle should be returning soon...") + def _step(self, x, y, where): + if not cbook.iterable(x): + x = ma.array([x], dtype=npy.float_) + if not cbook.iterable(y): + y = ma.array([y], dtype=npy.float_) + + if where=='pre': + x2 = ma.zeros((2*len(x)-1,), npy.float_) + y2 = ma.zeros((2*len(y)-1,), npy.float_) + + x2[0::2], x2[1::2] = x, x[:-1] + y2[0::2], y2[1:-1:2] = y, y[1:] + + elif where=='post': + x2 = ma.zeros((2*len(x)-1,), npy.float_) + y2 = ma.zeros((2*len(y)-1,), npy.float_) + + x2[::2], x2[1:-1:2] = x, x[1:] + y2[0::2], y2[1::2] = y, y[:-1] + + elif where=='mid': + x2 = ma.zeros((2*len(x),), npy.float_) + y2 = ma.zeros((2*len(y),), npy.float_) + + x2[1:-1:2] = 0.5*(x[:-1]+x[1:]) + x2[2::2] = 0.5*(x[:-1]+x[1:]) + x2[0], x2[-1] = x[0], x[-1] + + y2[0::2], y2[1::2] = y, y + + return x2, y2 + + + def _draw_steps_pre(self, renderer, gc, path, trans): + vertices = self._xy + steps = ma.zeros((2*len(vertices)-1, 2), npy.float_) + + steps[0::2, 0], steps[1::2, 0] = vertices[:, 0], vertices[:-1, 0] + steps[0::2, 1], steps[1:-1:2, 1] = vertices[:, 1], vertices[1:, 1] + + path = Path(steps, closed=False) + self._draw_solid(renderer, gc, path, trans) + + + def _draw_steps_post(self, renderer, gc, path, trans): + vertices = self._xy + steps = ma.zeros((2*len(vertices)-1, 2), npy.float_) + + steps[::2, 0], steps[1:-1:2, 0] = vertices[:, 0], vertices[1:, 0] + steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:-1, 1] + + path = Path(steps, closed=False) + self._draw_solid(renderer, gc, path, trans) + + def _draw_steps_mid(self, renderer, gc, path, trans): + vertices = self._xy + steps = ma.zeros((2*len(vertices), 2), npy.float_) + steps[1:-1:2, 0] = 0.5 * (vertices[:-1, 0] + vertices[1:, 0]) + steps[2::2, 0] = 0.5 * (vertices[:-1, 0] + vertices[1:, 0]) + steps[0, 0] = vertices[0, 0] + steps[-1, 0] = vertices[-1, 0] + steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:, 1] + + path = Path(steps, closed=False) + self._draw_solid(renderer, gc, path, trans) + + def _draw_dashed(self, renderer, gc, path, trans): gc.set_linestyle('dashed') if self._dashSeq is not None: @@ -922,7 +992,7 @@ [-1.0, 1.0], [1.0, -1.0]], [Path.MOVETO, Path.LINETO, Path.MOVETO, Path.LINETO]) - def _draw_x(self, renderer, gc, xt, yt): + def _draw_x(self, renderer, gc, path, path_trans): offset = 0.5*renderer.points_to_pixels(self._markersize) transform = Affine2D().scale(offset) renderer.draw_markers(gc, self._x_path, transform, Modified: branches/transforms/setupext.py =================================================================== --- branches/transforms/setupext.py 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/setupext.py 2007-10-24 18:49:08 UTC (rev 3996) @@ -813,7 +813,8 @@ add_agg_flags(module) add_ft2font_flags(module) add_pygtk_flags(module) - + add_numpy_flags(module) + ext_modules.append(module) BUILT_GTKAGG = True Modified: branches/transforms/src/_backend_agg.h =================================================================== --- branches/transforms/src/_backend_agg.h 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/src/_backend_agg.h 2007-10-24 18:49:08 UTC (rev 3996) @@ -233,6 +233,7 @@ : Py::ExtensionModule<_backend_agg_module>( "_backend_agg" ) { RendererAgg::init_type(); + BufferRegion::init_type(); add_keyword_method("RendererAgg", &_backend_agg_module::new_renderer, "RendererAgg(width, height, dpi)"); Modified: branches/transforms/src/_gtkagg.cpp =================================================================== --- branches/transforms/src/_gtkagg.cpp 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/src/_gtkagg.cpp 2007-10-24 18:49:08 UTC (rev 3996) @@ -12,6 +12,8 @@ #include "agg_basics.h" #include "_backend_agg.h" +#define PY_ARRAY_TYPES_PREFIX NumPy +#include "numpy/arrayobject.h" // the extension module class _gtkagg_module : public Py::ExtensionModule<_gtkagg_module> @@ -69,27 +71,30 @@ else { //bbox is not None; copy the image in the bbox // MGDTODO: Use PyArray rather than buffer interface here - PyObject* clipbox = args[2].ptr(); - const void* clipbox_buffer; - Py_ssize_t clipbox_buffer_len; - if (!PyObject_CheckReadBuffer(clipbox)) - throw Py::TypeError - ("Argument 3 to agg_to_gtk_drawable must be a Bbox object."); + PyArrayObject* bbox = NULL; + double l, b, r, t; - if (PyObject_AsReadBuffer(clipbox, &clipbox_buffer, &clipbox_buffer_len)) - throw Py::Exception(); + try { + bbox = (PyArrayObject*) PyArray_FromObject(clipbox, PyArray_DOUBLE, 2, 2); + + if (!bbox || bbox->nd != 2 || bbox->dimensions[0] != 2 || bbox->dimensions[1] != 2) { + throw Py::TypeError + ("Argument 3 to agg_to_gtk_drawable must be a Bbox object."); + } + + l = *(double*)PyArray_GETPTR2(bbox, 0, 0); + b = *(double*)PyArray_GETPTR2(bbox, 0, 1); + r = *(double*)PyArray_GETPTR2(bbox, 1, 0); + t = *(double*)PyArray_GETPTR2(bbox, 1, 1); - if (clipbox_buffer_len != sizeof(double) * 4) - throw Py::TypeError - ("Argument 3 to agg_to_gtk_drawable must be a Bbox object."); - - double* clipbox_values = (double*)clipbox_buffer; - double l = clipbox_values[0]; - double b = clipbox_values[1]; - double r = clipbox_values[2]; - double t = clipbox_values[3]; - + Py_XDECREF(bbox); + bbox = NULL; + } catch (...) { + Py_XDECREF(bbox); + bbox = NULL; + throw; + } //std::cout << b << " " // << t << " "; @@ -146,6 +151,7 @@ { init_pygobject(); init_pygtk(); + import_array(); //suppress unused warning by creating in two lines static _gtkagg_module* _gtkagg = NULL; _gtkagg = new _gtkagg_module; Modified: branches/transforms/src/_tkagg.cpp =================================================================== --- branches/transforms/src/_tkagg.cpp 2007-10-24 18:12:19 UTC (rev 3995) +++ branches/transforms/src/_tkagg.cpp 2007-10-24 18:49:08 UTC (rev 3996) @@ -86,28 +86,28 @@ /* check for bbox/blitting */ bboxo = (PyObject*)atol(argv[4]); if (bboxo != Py_None) { - printf("bbox passed in"); - - const void* bbox_buffer; - Py_ssize_t bbox_buffer_len; - if (!PyObject_CheckReadBuffer(bboxo)) - throw Py::TypeError - ("Argument 5 to PyAggImagePhoto must be a Bbox object."); - - if (PyObject_AsReadBuffer(bboxo, &bbox_buffer, &bbox_buffer_len)) - throw Py::Exception(); - - if (bbox_buffer_len != sizeof(double) * 4) - throw Py::TypeError - ("Argument 3 to agg_to_gtk_drawable must be a Bbox object."); - has_bbox = true; + PyArrayObject* bbox = NULL; + try { + bbox = (PyArrayObject*) PyArray_FromObject(bboxo, PyArray_DOUBLE, 2, 2); + + if (!bbox || bbox->nd != 2 || bbox->dimensions[0] != 2 || bbox->dimensions[1] != 2) { + throw Py::TypeError + ("Argument 3 to agg_to_gtk_drawable must be a Bbox object."); + } + + l = *(double*)PyArray_GETPTR2(bbox, 0, 0); + b = *(double*)PyArray_GETPTR2(bbox, 0, 1); + r = *(double*)PyArray_GETPTR2(bbox, 1, 0); + t = *(double*)PyArray_GETPTR2(bbox, 1, 1); - double* bbox_values = (double*)bbox_buffer; - l = bbox_values[0]; - b = bbox_values[1]; - r = bbox_values[2]; - t = bbox_values[3]; + Py_XDECREF(bbox); + bbox = NULL; + } catch (...) { + Py_XDECREF(bbox); + bbox = NULL; + throw; + } destx = (int)l; desty = srcheight-(int)t; @@ -228,5 +228,7 @@ extern "C" DL_EXPORT(void) init_tkagg(void) { - Py_InitModule("_tkagg", functions); + import_array(); + + Py_InitModule("_tkagg", functions); } 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: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins