Revision: 8922 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8922&view=rev Author: efiring Date: 2011-01-17 07:13:37 +0000 (Mon, 17 Jan 2011)
Log Message: ----------- backend_qt4agg: eliminate duplicate call to FigureCanvasAgg.draw() The basic problem is that the most efficient way to eliminate the duplication appears to be to do the Agg drawing in the paintEvent, not in draw(); but then a draw() followed by copy_from_bbox may result in a copy being made before the Agg draw has occurred. The solution here is to do that drawing inside copy_from_bbox when necessary. Side note: it seems that by using the update() method, the qt4agg draw() is acting more like draw_idle() than like the draw() methods in the other interactive backends. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2011-01-16 01:09:08 UTC (rev 8921) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2011-01-17 07:13:37 UTC (rev 8922) @@ -110,7 +110,7 @@ w = int(r) - int(l) h = int(t) - int(b) t = int(b) + h - reg = self.copy_from_bbox(bbox) + reg = FigureCanvasAgg.copy_from_bbox(self, bbox) stringBuffer = reg.to_string_argb() qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32) pixmap = QtGui.QPixmap.fromImage(qImage) @@ -127,7 +127,6 @@ if DEBUG: print "FigureCanvasQtAgg.draw", self self.replot = True - FigureCanvasAgg.draw(self) self.update() def blit(self, bbox=None): @@ -140,6 +139,16 @@ t = b + h self.repaint(l, self.renderer.height-t, w, h) + def copy_from_bbox(self, *args): + """ + If a draw() has been called but the update() has not + occurred, draw into the agg canvas before copying. + """ + if self.replot: + FigureCanvasAgg.draw(self) + self.replot = False + return FigureCanvasAgg.copy_from_bbox(self, *args) + def print_figure(self, *args, **kwargs): FigureCanvasAgg.print_figure(self, *args, **kwargs) self.draw() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins