From: <ds...@us...> - 2007-09-24 12:56:53
|
Revision: 3879 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3879&view=rev Author: dsdale Date: 2007-09-24 05:56:38 -0700 (Mon, 24 Sep 2007) Log Message: ----------- fix backend_qt* bug with multiple plot windows and show() Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-09-23 13:50:01 UTC (rev 3878) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-09-24 12:56:38 UTC (rev 3879) @@ -46,11 +46,11 @@ qApp = qt.QApplication( [" "] ) qt.QObject.connect( qApp, qt.SIGNAL( "lastWindowClosed()" ), qApp, qt.SLOT( "quit()" ) ) - else: - # someone else aready created the qApp and - # we let them handle the event-loop control. - show._needmain = False + #remember that matplotlib created the qApp - will be used by show() + _create_qApp.qAppCreatedHere = True +_create_qApp.qAppCreatedHere = False + def show(): """ Show all the figures and enter the qt main loop @@ -65,13 +65,10 @@ if figManager != None: figManager.canvas.draw() - if ( show._needmain ): - qt.qApp.exec_loop() - show._needmain = False + if _create_qApp.qAppCreatedHere: + qt.qApp.exec_loop() -show._needmain = True - def new_figure_manager( num, *args, **kwargs ): """ Create a new figure manager instance Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-09-23 13:50:01 UTC (rev 3878) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-09-24 12:56:38 UTC (rev 3879) @@ -47,10 +47,10 @@ QtCore.QObject.connect( qApp, QtCore.SIGNAL( "lastWindowClosed()" ), qApp, QtCore.SLOT( "quit()" ) ) else: - # someone else aready created the qApp and - # we let them handle the event-loop control. - show._needmain = False + _create_qApp.qAppCreatedHere = True +_create_qApp.qAppCreatedHere = False + def show(): """ Show all the figures and enter the qt main loop @@ -65,13 +65,10 @@ if figManager != None: figManager.canvas.draw() - if ( show._needmain ): - qApp.exec_() - show._needmain = False + if _create_qApp.qAppCreatedHere: + QtGui.qApp.exec_() -show._needmain = True - def new_figure_manager( num, *args, **kwargs ): """ Create a new figure manager instance This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jr...@us...> - 2007-10-03 22:23:50
|
Revision: 3910 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3910&view=rev Author: jrevans Date: 2007-10-03 15:23:48 -0700 (Wed, 03 Oct 2007) Log Message: ----------- Moved a couple of routines from the Agg version of the FigureCanvas to the base qt version where they belong. Added a couple of overloaded qt methods that should be there and reduce having to inherit when embedding in another QWidget. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-10-03 12:51:16 UTC (rev 3909) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-10-03 22:23:48 UTC (rev 3910) @@ -135,11 +135,38 @@ def resizeEvent( self, event ): if DEBUG: print 'resize (%d x %d)' % (event.size().width(), event.size().height()) + print "JRE--DBG: qt : resizeEvent" qt.QWidget.resizeEvent( self, event ) + w = event.size().width() + h = event.size().height() + if DEBUG: print "FigureCanvasQt.resizeEvent(", w, ",", h, ")" + dpival = self.figure.dpi.get() + winch = w/dpival + hinch = h/dpival + self.figure.set_size_inches( winch, hinch ) + self.draw() def resize( self, w, h ): + print "JRE--DBG: qt : resize" + # Pass through to Qt to resize the widget. qt.QWidget.resize( self, w, h ) + # Resize the figure by converting pixels to inches. + pixelPerInch = self.figure.dpi.get() + wInch = w / pixelPerInch + hInch = h / pixelPerInch + self.figure.set_size_inches( wInch, hInch ) + + # Redraw everything. + self.draw() + + def sizeHint( self ): + w, h = self.get_width_height() + return qt.QSize( w, h ) + + def minumumSizeHint( self ): + return qt.QSize( 10, 10 ) + def _get_key( self, event ): if event.key() < 256: key = event.text().latin1() Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-10-03 12:51:16 UTC (rev 3909) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-10-03 22:23:48 UTC (rev 3910) @@ -135,10 +135,35 @@ def resizeEvent( self, event ): if DEBUG: print 'resize (%d x %d)' % (event.size().width(), event.size().height()) QtGui.QWidget.resizeEvent( self, event ) + w = event.size().width() + h = event.size().height() + if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")" + dpival = self.figure.dpi.get() + winch = w/dpival + hinch = h/dpival + self.figure.set_size_inches( winch, hinch ) + self.draw() def resize( self, w, h ): + # Pass through to Qt to resize the widget. QtGui.QWidget.resize( self, w, h ) + # Resize the figure by converting pixels to inches. + pixelPerInch = self.figure.dpi.get() + wInch = w / pixelPerInch + hInch = h / pixelPerInch + self.figure.set_size_inches( wInch, hInch ) + + # Redraw everything. + self.draw() + + def sizeHint( self ): + w, h = self.get_width_height() + return QtCore.QSize( w, h ) + + def minumumSizeHint( self ): + return QtCore.QSize( 10, 10 ) + def _get_key( self, event ): if event.key() < 256: key = str(event.text()) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2007-10-03 12:51:16 UTC (rev 3909) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2007-10-03 22:23:48 UTC (rev 3910) @@ -65,14 +65,6 @@ def resizeEvent( self, e ): FigureCanvasQT.resizeEvent( self, e ) - w = e.size().width() - h = e.size().height() - if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")" - dpival = self.figure.dpi.get() - winch = w/dpival - hinch = h/dpival - self.figure.set_size_inches( winch, hinch ) - self.draw() def drawRectangle( self, rect ): self.rect = rect Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2007-10-03 12:51:16 UTC (rev 3909) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2007-10-03 22:23:48 UTC (rev 3910) @@ -64,14 +64,6 @@ def resizeEvent( self, e ): FigureCanvasQT.resizeEvent( self, e ) - w = e.size().width() - h = e.size().height() - if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")" - dpival = self.figure.dpi.get() - winch = w/dpival - hinch = h/dpival - self.figure.set_size_inches( winch, hinch ) - self.draw() def drawRectangle( self, rect ): self.rect = rect This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-03-10 12:46:29
|
Revision: 4995 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4995&view=rev Author: mdboom Date: 2008-03-10 05:46:12 -0700 (Mon, 10 Mar 2008) Log Message: ----------- Fixing Qt/Qt4 blit shearing problem Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-03-04 22:58:49 UTC (rev 4994) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-03-10 12:46:12 UTC (rev 4995) @@ -109,8 +109,9 @@ # we are blitting here else: bbox = self.replot - l, b, w, h = bbox.bounds - t = b + h + l, b, r, t = bbox.extents + w = int(r) - int(l) + h = int(t) - int(b) reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string() qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-03-04 22:58:49 UTC (rev 4994) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-03-10 12:46:12 UTC (rev 4995) @@ -115,8 +115,9 @@ # we are blitting here else: bbox = self.replot - l, b, w, h = bbox.bounds - t = b + h + l, b, r, t = bbox.extents + w = int(r) - int(l) + h = int(t) - int(b) reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string() qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jr...@us...> - 2008-04-07 22:25:41
|
Revision: 5031 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5031&view=rev Author: jrevans Date: 2008-04-07 15:25:37 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Edited so that a double draw does not occur. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-04-07 18:48:02 UTC (rev 5030) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-04-07 22:25:37 UTC (rev 5031) @@ -130,7 +130,7 @@ if DEBUG: print "FigureCanvasQtAgg.draw", self self.replot = True - self.update() + FigureCanvasAgg.draw(self) def blit(self, bbox=None): """ Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-04-07 18:48:02 UTC (rev 5030) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qtagg.py 2008-04-07 22:25:37 UTC (rev 5031) @@ -135,7 +135,7 @@ if DEBUG: print "FigureCanvasQtAgg.draw", self self.replot = True - self.repaint( False ) + FigureCanvasAgg.draw(self) def blit(self, bbox=None): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2008-04-27 02:27:06
|
Revision: 5078 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5078&view=rev Author: jdh2358 Date: 2008-04-26 19:27:01 -0700 (Sat, 26 Apr 2008) Log Message: ----------- removed backend_agg2 Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_template.py Removed Paths: ------------- trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py Deleted: trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2008-04-26 21:59:17 UTC (rev 5077) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2008-04-27 02:27:01 UTC (rev 5078) @@ -1,206 +0,0 @@ -""" -An agg http://antigrain.com/ backend - -""" -from __future__ import division - -import os, sys -import matplotlib.agg as agg - -from matplotlib import verbose - -from matplotlib._pylab_helpers import Gcf -from matplotlib.backend_bases import RendererBase,\ - GraphicsContextBase, FigureManagerBase, FigureCanvasBase - -from matplotlib.cbook import enumerate, is_string_like, exception_to_str -from matplotlib.figure import Figure -from matplotlib.ft2font import FT2Font -from matplotlib.mathtext import MathTextParser - - -from _backend_agg import RendererAgg as _RendererAgg - -backend_version = 'v2.2' -_fontd = {} # a map from fname to font instances - - -class RendererAgg(RendererBase): - """ - The renderer handles all the drawing primitives using a graphics - context instance that controls the colors/styles - """ - - debug=1 - def __init__(self, width, height, dpi): - if __debug__: verbose.report('RendererAgg.__init__', 'debug-annoying') - self.dpi = dpi - self.width = int(width) - self.height = int(height) - - stride = self.width*4 - self.buffer = agg.buffer(self.width, self.height, stride) - - self.rbuf = agg.rendering_buffer() - self.rbuf.attachb(self.buffer) - - self.pf = agg.pixel_format(self.rbuf) - self.rbase = agg.renderer_base(self.pf) - - self.rasterizer = agg.rasterizer_scanline_aa() - self.scanline = agg.scanline_p8() - self.renderer = agg.renderer_scanline_aa_solid(self.rbase); - - - def draw_lines(self, gc, x, y, trans): - """ - x and y are equal length arrays, draw lines connecting each - point in x, y - """ - - x, y = trans.numerix_x_y(x,y) - if len(x)<2: return - path = agg.path_storage() - path.move_to(x[0],self.height-y[0]) - for i in xrange(1, len(x)): - path.line_to(x[i],self.height-y[i]) - - stroke = agg.conv_stroke(path) - stroke.width(1.0) - r,g,b = [int(255*val) for val in gc.get_rgb()] - a = int(255*gc.get_alpha()) - - color = agg.rgba8(r,g,b,a) - self.renderer.color( color ) - self.rasterizer.add_path(stroke) - agg.render_scanlines(self.rasterizer, self.scanline, self.renderer); - - def draw_markers(self, gc, path, rgbFace, xt, yt, trans): - pass - - def draw_arc(self, gcEdge, rgbFace, x, y, width, height, angle1, angle2, rotation): - pass - - def draw_image(self, x, y, im, origin, bbox): - pass - - def draw_line(self, gc, x1, y1, x2, y2): - pass - - def draw_point(self, gc, x, y): - pass - - def draw_polygon(self, gcEdge, rgbFace, points): - pass - - def draw_rectangle(self, gcEdge, rgbFace, x, y, width, height): - pass - - def draw_text(self, gc, x, y, s, prop, angle, ismath=False): - pass - - def flipy(self): - return True - - def get_canvas_width_height(self): - return 100, 100 - - def get_text_width_height(self, s, prop, ismath): - return 1, 1 - - def new_gc(self): - return GraphicsContextBase() - - - def points_to_pixels(self, points): - """ - convert point measures to pixes using dpi and the pixels per - inch of the display - """ - if __debug__: verbose.report('RendererAgg.points_to_pixels', 'debug-annoying') - return points*self.dpi.get()/72.0 - - - - - -def new_figure_manager(num, *args, **kwargs): - """ - Create a new figure manager instance - """ - if __debug__: verbose.report('backend_agg.new_figure_manager', 'debug-annoying') - FigureClass = kwargs.pop('FigureClass', Figure) - thisFig = FigureClass(*args, **kwargs) - canvas = FigureCanvasAgg(thisFig) - manager = FigureManagerBase(canvas, num) - return manager - - -class FigureCanvasAgg(FigureCanvasBase): - """ - The canvas the figure renders into. Calls the draw and print fig - methods, creates the renderers, etc... - - Public attribute - - figure - A Figure instance - """ - - - - def draw(self): - """ - Draw the figure using the renderer - """ - if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying') - - renderer = self.get_renderer() - self.figure.draw(renderer) - return renderer - - def get_renderer(self): - l,b,w,h = self.figure.bbox.get_bounds() - key = w, h, self.figure.dpi.get() - try: self._lastKey, self.renderer - except AttributeError: need_new_renderer = True - else: need_new_renderer = (self._lastKey != key) - - if need_new_renderer: - self.renderer = RendererAgg(w, h, self.figure.dpi) - self._lastKey = key - return self.renderer - - def tostring_rgb(self): - if __debug__: verbose.report('FigureCanvasAgg.tostring_rgb', 'debug-annoying') - return self.renderer.tostring_rgb() - - def tostring_argb(self): - if __debug__: verbose.report('FigureCanvasAgg.tostring_argb', 'debug-annoying') - return self.renderer.tostring_argb() - - def buffer_rgba(self,x,y): - if __debug__: verbose.report('FigureCanvasAgg.buffer_rgba', 'debug-annoying') - return self.renderer.buffer_rgba(x,y) - - - def print_figure(self, filename, dpi=150, facecolor='w', edgecolor='w', - orientation='portrait', **kwargs): - """ - Render the figure to hardcopy. Set the figure patch face and - edge colors. This is useful because some of the GUIs have a - gray figure face color background and you'll probably want to - override this on hardcopy - - If the extension matches PNG, write a PNG file - - If the extension matches BMP or RAW, write an RGBA bitmap file - - If filename is a fileobject, write png to file object (thus - you can, for example, write the png to stdout - """ - - r = self.draw() - s = r.buffer.to_string() - import Image - im = Image.fromstring( "RGBA", (r.width, r.height), s) - im.show() Modified: trunk/matplotlib/lib/matplotlib/backends/backend_template.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_template.py 2008-04-26 21:59:17 UTC (rev 5077) +++ trunk/matplotlib/lib/matplotlib/backends/backend_template.py 2008-04-27 02:27:01 UTC (rev 5078) @@ -68,13 +68,15 @@ def draw_path(self, gc, path, transform, rgbFace=None): pass - # draw_markers is optional, and we get more correct - # relative timings by leaving it out. + # draw_markers is optional, and we get more correct relative + # timings by leaving it out. backend implementers concerned with + # performance will probably want to implement it # def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): # pass # draw_path_collection is optional, and we get more correct - # relative timings by leaving it out. + # relative timings by leaving it out. backend implementers concerned with + # performance will probably want to implement it # def draw_path_collection(self, master_transform, cliprect, clippath, # clippath_trans, paths, all_transforms, offsets, # offsetTrans, facecolors, edgecolors, linewidths, @@ -82,7 +84,8 @@ # pass # draw_quad_mesh is optional, and we get more correct - # relative timings by leaving it out. + # relative timings by leaving it out. backend implementers concerned with + # performance will probably want to implement it # def draw_quad_mesh(self, master_transform, cliprect, clippath, # clippath_trans, meshWidth, meshHeight, coordinates, # offsets, offsetTrans, facecolors, antialiased, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ds...@us...> - 2008-05-05 18:56:41
|
Revision: 5116 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5116&view=rev Author: dsdale Date: 2008-05-05 11:56:38 -0700 (Mon, 05 May 2008) Log Message: ----------- fixed a bug where notify_axes_change was not connected passed to figure.add_axobserver in qt backends Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-05-05 18:54:59 UTC (rev 5115) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2008-05-05 18:56:38 UTC (rev 5116) @@ -238,7 +238,7 @@ def notify_axes_change( fig ): # This will be called whenever the current axes is changed if self.toolbar != None: self.toolbar.update() - self.canvas.figure.add_axobserver( notify_axes_change ) + self.canvas.figure.add_axobserver( notify_axes_change ) def _widgetclosed( self ): if self.window._destroying: return Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-05-05 18:54:59 UTC (rev 5115) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2008-05-05 18:56:38 UTC (rev 5116) @@ -221,7 +221,7 @@ def notify_axes_change( fig ): # This will be called whenever the current axes is changed if self.toolbar != None: self.toolbar.update() - self.canvas.figure.add_axobserver( notify_axes_change ) + self.canvas.figure.add_axobserver( notify_axes_change ) def _widgetclosed( self ): if self.window._destroying: return This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |