示例#1
0
    def paintEvent(self, e):
        """
        Draw to the Agg backend and then copy the image to the qt.drawable.
        In Qt, all drawing should be done inside of here when a widget is
        shown onscreen.
        """

        FigureCanvasQT.paintEvent(self, e)
        if DEBUG:            print 'FigureCanvasQtAgg.paintEvent: ', self, \
     self.get_width_height()

        p = qt.QPainter(self)

        # only replot data when needed
        if type(self.replot) is bool:  # might be a bbox for blitting
            if self.replot:
                FigureCanvasAgg.draw(self)
                #stringBuffer = str( self.buffer_rgba(0,0) )

                # matplotlib is in rgba byte order.
                # qImage wants to put the bytes into argb format and
                # is in a 4 byte unsigned int.  little endian system is LSB first
                # and expects the bytes in reverse order (bgra).
                if (qt.QImage.systemByteOrder() == qt.QImage.LittleEndian):
                    stringBuffer = self.renderer._renderer.tostring_bgra()
                else:
                    stringBuffer = self.renderer._renderer.tostring_argb()

                qImage = qt.QImage(stringBuffer, self.renderer.width,
                                   self.renderer.height, 32, None, 0,
                                   qt.QImage.IgnoreEndian)

                self.pixmap.convertFromImage(qImage, qt.QPixmap.Color)

            p.drawPixmap(qt.QPoint(0, 0), self.pixmap)

            # draw the zoom rectangle to the QPainter
            if (self.drawRect):
                p.setPen(qt.QPen(qt.Qt.black, 1, qt.Qt.DotLine))
                p.drawRect(self.rect[0], self.rect[1], self.rect[2],
                           self.rect[3])

        # we are blitting here
        else:
            bbox = self.replot
            l, t = int(bbox.ll().x().get()), int(bbox.ur().y().get())
            r, b = int(bbox.ur().x().get()), int(bbox.ll().y().get())
            w = r - l
            h = t - b
            reg = self.copy_from_bbox(bbox)
            stringBuffer = reg.to_string_argb()
            qImage = qt.QImage(stringBuffer, w, h, 32, None, 0,
                               qt.QImage.IgnoreEndian)
            self.pixmap.convertFromImage(qImage, qt.QPixmap.Color)
            p.drawPixmap(qt.QPoint(l, self.renderer.height - t), self.pixmap)

        p.end()
        self.replot = False
        self.drawRect = False
示例#2
0
 def draw( self ):
     """
     Draw the figure when xwindows is ready for the update
     """
     if DEBUG: print "FigureCanvasQtAgg.draw", self
     self.replot = True
     FigureCanvasAgg.draw(self)
     self.update()
示例#3
0
    def paintEvent( self, e ):
        """
        Draw to the Agg backend and then copy the image to the qt.drawable.
        In Qt, all drawing should be done inside of here when a widget is
        shown onscreen.
        """

        FigureCanvasQT.paintEvent( self, e )
        if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
           self.get_width_height()

        p = qt.QPainter( self )

        # only replot data when needed
        if type(self.replot) is bool: # might be a bbox for blitting
            if self.replot:
                FigureCanvasAgg.draw( self )
                #stringBuffer = str( self.buffer_rgba(0,0) )

                # matplotlib is in rgba byte order.
                # qImage wants to put the bytes into argb format and
                # is in a 4 byte unsigned int.  little endian system is LSB first
                # and expects the bytes in reverse order (bgra).
                if ( qt.QImage.systemByteOrder() == qt.QImage.LittleEndian ):
                    stringBuffer = self.renderer._renderer.tostring_bgra()
                else:
                    stringBuffer = self.renderer._renderer.tostring_argb()

                qImage = qt.QImage( stringBuffer, self.renderer.width,
                                    self.renderer.height, 32, None, 0,
                                    qt.QImage.IgnoreEndian )

                self.pixmap.convertFromImage( qImage, qt.QPixmap.Color )

            p.drawPixmap( qt.QPoint( 0, 0 ), self.pixmap )

            # draw the zoom rectangle to the QPainter
            if ( self.drawRect ):
                p.setPen( qt.QPen( qt.Qt.black, 1, qt.Qt.DotLine ) )
                p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] )

        # we are blitting here
        else:
            bbox = self.replot
            l, t = int(bbox.ll().x().get()), int(bbox.ur().y().get())
            r, b = int(bbox.ur().x().get()), int(bbox.ll().y().get())
            w = r - l
            h = t - b
            reg = self.copy_from_bbox(bbox)
            stringBuffer = reg.to_string_argb()
            qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian)
            self.pixmap.convertFromImage(qImage, qt.QPixmap.Color)
            p.drawPixmap(qt.QPoint(l, self.renderer.height-t), self.pixmap)

        p.end()
        self.replot = False
        self.drawRect = False
示例#4
0
    def draw( self ):
        """
        Draw the figure when xwindows is ready for the update
        """

        if DEBUG: print "FigureCanvasQtAgg.draw", self
        self.replot = True
        FigureCanvasAgg.draw(self)
        self.repaint(False)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 def draw(self, drawDC=None):
     """
     Render the figure using agg.
     """
     DEBUG_MSG("draw()", 1, self)
     FigureCanvasAgg.draw(self)
     self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
     self._isDrawn = True
     self.gui_repaint(drawDC=drawDC)
示例#8
0
 def draw( self ):
     """
     Draw the figure with Agg, and queue a request
     for a Qt draw.
     """
     # The Agg draw is done here; delaying it until the paintEvent
     # causes problems with code that uses the result of the
     # draw() to update plot elements.
     FigureCanvasAgg.draw(self)
     self.update()
示例#9
0
    def draw(self, repaint=True):
        """
        Render the figure using agg.
        """
        DEBUG_MSG("draw()", 1, self)
        FigureCanvasAgg.draw(self)

        self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
        if repaint:
            self.gui_repaint()
示例#10
0
    def draw(self, repaint=True):
        """
        Render the figure using agg.
        """
        DEBUG_MSG("draw()", 1, self)
        FigureCanvasAgg.draw(self)

        self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
        if repaint:
            self.gui_repaint()
示例#11
0
    def draw(self, drawDC=None):
        """
        Render the figure using agg.
        """
        DEBUG_MSG("draw()", 1, self)
        FigureCanvasAgg.draw(self)

        self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
        self._isDrawn = True
        self.gui_repaint(drawDC=drawDC)
示例#12
0
    def paintEvent(self, e):
        """
        Draw to the Agg backend and then copy the image to the qt.drawable.
        In Qt, all drawing should be done inside of here when a widget is
        shown onscreen.
        """

        #FigureCanvasQT.paintEvent( self, e )
        if DEBUG:            print 'FigureCanvasQtAgg.paintEvent: ', self, \
     self.get_width_height()

        # only replot data when needed
        if type(self.replot) is bool:  # might be a bbox for blitting
            if self.replot:
                FigureCanvasAgg.draw(self)

            # matplotlib is in rgba byte order.  QImage wants to put the bytes
            # into argb format and is in a 4 byte unsigned int.  Little endian
            # system is LSB first and expects the bytes in reverse order
            # (bgra).
            if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian:
                stringBuffer = self.renderer._renderer.tostring_bgra()
            else:
                stringBuffer = self.renderer._renderer.tostring_argb()

            qImage = QtGui.QImage(stringBuffer, self.renderer.width,
                                  self.renderer.height,
                                  QtGui.QImage.Format_ARGB32)
            p = QtGui.QPainter(self)
            p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))

            # draw the zoom rectangle to the QPainter
            if self.drawRect:
                p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine))
                p.drawRect(self.rect[0], self.rect[1], self.rect[2],
                           self.rect[3])

            p.end()
        # we are blitting here
        else:
            bbox = self.replot
            l, t = int(bbox.ll().x().get()), int(bbox.ur().y().get())
            r, b = int(bbox.ur().x().get()), int(bbox.ll().y().get())
            w = r - l
            h = t - b
            reg = self.copy_from_bbox(bbox)
            stringBuffer = reg.to_string_argb()
            qImage = QtGui.QImage(stringBuffer, w, h,
                                  QtGui.QImage.Format_ARGB32)
            pixmap = QtGui.QPixmap.fromImage(qImage)
            p = QtGui.QPainter(self)
            p.drawPixmap(QtCore.QPoint(l, self.renderer.height - t), pixmap)
            p.end()
        self.replot = False
        self.drawRect = False
示例#13
0
    def draw( self ):
        """
        Draw the figure when xwindows is ready for the update
        """

        if DEBUG: print "FigureCanvasQtAgg.draw", self
        self.replot = True
        FigureCanvasAgg.draw(self)
        self.update()
        # Added following line to improve realtime pan/zoom on windows:
        QtGui.qApp.processEvents()
示例#14
0
    def paintEvent( self, e ):
        """
        Draw to the Agg backend and then copy the image to the qt.drawable.
        In Qt, all drawing should be done inside of here when a widget is
        shown onscreen.
        """

        #FigureCanvasQT.paintEvent( self, e )
        if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
           self.get_width_height()

        # only replot data when needed
        if type(self.replot) is bool: # might be a bbox for blitting
            if self.replot:
                FigureCanvasAgg.draw(self)

            # matplotlib is in rgba byte order.  QImage wants to put the bytes
            # into argb format and is in a 4 byte unsigned int.  Little endian
            # system is LSB first and expects the bytes in reverse order
            # (bgra).
            if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian:
                stringBuffer = self.renderer._renderer.tostring_bgra()
            else:
                stringBuffer = self.renderer._renderer.tostring_argb()

            qImage = QtGui.QImage(stringBuffer, self.renderer.width,
                                  self.renderer.height,
                                  QtGui.QImage.Format_ARGB32)
            p = QtGui.QPainter(self)
            p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))

            # draw the zoom rectangle to the QPainter
            if self.drawRect:
                p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) )
                p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] )

            p.end()
        # we are blitting here
        else:
            bbox = self.replot
            l, b, r, t = bbox.extents
            w = int(r) - int(l)
            h = int(t) - int(b)
            t = int(b) + h
            reg = self.copy_from_bbox(bbox)
            stringBuffer = reg.to_string_argb()
            qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
            pixmap = QtGui.QPixmap.fromImage(qImage)
            p = QtGui.QPainter( self )
            p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
            p.end()
        self.replot = False
        self.drawRect = False
示例#15
0
 def draw(self):
     """
     Render the figure using agg
     """
     DEBUG_MSG("draw()", 1, self)
     FigureCanvasAgg.draw(self)
     s = self.tostring_rgb()
     w = int(self.renderer.width)
     h = int(self.renderer.height)
     image = wxEmptyImage(w, h)
     image.SetData(s)
     self.bitmap = image.ConvertToBitmap()
     self.gui_repaint()
示例#16
0
 def draw(self):
     """
     Render the figure using agg
     """
     DEBUG_MSG("draw()", 1, self)
     FigureCanvasAgg.draw(self)
     s = self.tostring_rgb()  
     w = int(self.renderer.width)
     h = int(self.renderer.height)
     image = wxEmptyImage(w,h)
     image.SetData(s)
     self.bitmap = image.ConvertToBitmap()
     self.gui_repaint()
示例#17
0
    def draw(self):
        """
        Draw to the Agg backend and then copy the image to the
        gtk.gdk.drawable.

        """
        if DEBUG: print 'FigureCanvasGTKAgg.draw'  
            
        FigureCanvasAgg.draw(self)
        if self.window is None: 
            return
        else: 
            self.blit()
示例#18
0
    def draw(self):
        """
        Draw to the Agg backend and then copy the image to the
        gtk.gdk.drawable.

        """
        if DEBUG: print 'FigureCanvasGTKAgg.draw'  
            
        FigureCanvasAgg.draw(self)
        if self.window is None: 
            return
        else: 
            self.blit()
示例#19
0
    def _render_figure(self, pixmap, width, height):
        if DEBUG: print 'FigureCanvasGTKAgg.render_figure'
        FigureCanvasAgg.draw(self)
        if DEBUG: print 'FigureCanvasGTKAgg.render_figure pixmap', pixmap
        #agg_to_gtk_drawable(pixmap, self.renderer._renderer, None)

        buf = self.buffer_rgba(0,0)
        ren = self.get_renderer()
        w = int(ren.width)
        h = int(ren.height)
        pixbuf = gtk.gdk.pixbuf_new_from_data(
            buf, gtk.gdk.COLORSPACE_RGB,  True, 8, w, h, w*4)
        pixmap.draw_pixbuf(pixmap.new_gc(), pixbuf, 0, 0, 0, 0, w, h, gtk.gdk.RGB_DITHER_NONE, 0, 0)
        if DEBUG: print 'FigureCanvasGTKAgg.render_figure done'
示例#20
0
    def _render_figure(self, pixmap, width, height):
        if DEBUG: print 'FigureCanvasGTKAgg.render_figure'
        FigureCanvasAgg.draw(self)
        if DEBUG: print 'FigureCanvasGTKAgg.render_figure pixmap', pixmap
        #agg_to_gtk_drawable(pixmap, self.renderer._renderer, None)

        buf = self.buffer_rgba(0, 0)
        ren = self.get_renderer()
        w = int(ren.width)
        h = int(ren.height)
        pixbuf = gtk.gdk.pixbuf_new_from_data(buf, gtk.gdk.COLORSPACE_RGB,
                                              True, 8, w, h, w * 4)
        pixmap.draw_pixbuf(pixmap.new_gc(), pixbuf, 0, 0, 0, 0, w, h,
                           gtk.gdk.RGB_DITHER_NONE, 0, 0)
        if DEBUG: print 'FigureCanvasGTKAgg.render_figure done'
    def paintEvent(self, e):
        """
        Draw to the Agg backend and then copy the image to the qt.drawable.
        In Qt, all drawing should be done inside of here when a widget is
        shown onscreen.
        """
        p = QtGui.QPainter( self )

        # only replot data when needed
        if type(self.replot) is bool: # might be a bbox for blitting
            if (self.replot ):
                #stringBuffer = str( self.buffer_rgba(0,0) )
                FigureCanvasAgg.draw( self )

                # matplotlib is in rgba byte order.
                # qImage wants to put the bytes into argb format and
                # is in a 4 byte unsigned int.  little endian system is LSB first
                # and expects the bytes in reverse order (bgra).
                if ( QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian ):
                    stringBuffer = self.renderer._renderer.tostring_bgra()
                else:
                    stringBuffer = self.renderer._renderer.tostring_argb()
                qImage = QtGui.QImage(stringBuffer, self.renderer.width,
                                       self.renderer.height,
                                       QtGui.QImage.Format_ARGB32)
                self.pixmap = self.pixmap.fromImage(qImage)
            p.drawPixmap(QtCore.QPoint(0, 0), self.pixmap)

            # draw the zoom rectangle to the QPainter
            if (self.drawRect):
                p.setPen(QtGui.QPen(Qt.black, 1, Qt.DotLine))
                p.drawRect(self.rect[0], self.rect[1], self.rect[2], self.rect[3])

        # 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()
            reg = self.copy_from_bbox(bbox)
            stringBuffer = reg.to_string()
            qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
            self.pixmap = self.pixmap.fromImage(qImage)
            p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), self.pixmap)

        p.end()
        self.replot = False
        self.drawRect = False
示例#22
0
    def _render_figure(self, width, height):
        """Render the figure to a gdk.Pixmap, used by expose_event().
        """
        if DEBUG: print 'FigureCanvasGTKAgg._render_figure'
        create_pixmap = False
        if width > self._pixmap_width:
            # increase the pixmap in 10%+ (rather than 1 pixel) steps
            self._pixmap_width = max(int(self._pixmap_width * 1.1), width)
            create_pixmap = True

        if height > self._pixmap_height:
            self._pixmap_height = max(int(self._pixmap_height * 1.1), height)
            create_pixmap = True

        if create_pixmap:
            if DEBUG: print 'FigureCanvasGTK._render_figure new pixmap'
            self._pixmap = gtk.gdk.Pixmap(self.window, self._pixmap_width,
                                          self._pixmap_height)

        FigureCanvasAgg.draw(self)
        agg_to_gtk_drawable(self._pixmap, self.renderer._renderer)
示例#23
0
 def paintEvent( self, e ):
     """
     Draw to the Agg backend and then copy the image to the qt.drawable.
     In Qt, all drawing should be done inside of here when a widget is
     shown onscreen.
     """
     if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
        self.get_width_height()
     if type(self.replot) is bool: # might be a bbox for blitting
         if self.replot:
             FigureCanvasAgg.draw(self)
         if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian:
             stringBuffer = self.renderer._renderer.tostring_bgra()
         else:
             stringBuffer = self.renderer._renderer.tostring_argb()
         qImage = QtGui.QImage(stringBuffer, self.renderer.width,
                               self.renderer.height,
                               QtGui.QImage.Format_ARGB32)
         p = QtGui.QPainter(self)
         p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))
         if self.drawRect:
             p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) )
             p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] )
         p.end()
     else:
         bbox = self.replot
         l, b, r, t = bbox.extents
         w = int(r) - int(l)
         h = int(t) - int(b)
         t = int(b) + h
         reg = self.copy_from_bbox(bbox)
         stringBuffer = reg.to_string_argb()
         qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
         pixmap = QtGui.QPixmap.fromImage(qImage)
         p = QtGui.QPainter( self )
         p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
         p.end()
     self.replot = False
     self.drawRect = False
示例#24
0
 def paintEvent( self, e ):
     """
     Draw to the Agg backend and then copy the image to the qt.drawable.
     In Qt, all drawing should be done inside of here when a widget is
     shown onscreen.
     """
     FigureCanvasQT.paintEvent( self, e )
     if DEBUG: print 'FigureCanvasQtAgg.paintEvent: ', self, \
        self.get_width_height()
     p = qt.QPainter( self )
     if type(self.replot) is bool: # might be a bbox for blitting
         if self.replot:
             FigureCanvasAgg.draw( self )
             if ( qt.QImage.systemByteOrder() == qt.QImage.LittleEndian ):
                 stringBuffer = self.renderer._renderer.tostring_bgra()
             else:
                 stringBuffer = self.renderer._renderer.tostring_argb()
             qImage = qt.QImage( stringBuffer, self.renderer.width,
                                 self.renderer.height, 32, None, 0,
                                 qt.QImage.IgnoreEndian )
             self.pixmap.convertFromImage( qImage, qt.QPixmap.Color )
         p.drawPixmap( qt.QPoint( 0, 0 ), self.pixmap )
         if ( self.drawRect ):
             p.setPen( qt.QPen( qt.Qt.black, 1, qt.Qt.DotLine ) )
             p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] )
     else:
         bbox = self.replot
         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_argb()
         qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian)
         self.pixmap.convertFromImage(qImage, qt.QPixmap.Color)
         p.drawPixmap(qt.QPoint(l, self.renderer.height-t), self.pixmap)
     p.end()
     self.replot = False
     self.drawRect = False
示例#25
0
 def _render_figure(self, pixmap, width, height):
     FigureCanvasAgg.draw(self)
     agg_to_gtk_drawable(pixmap, self.renderer._renderer, None)
示例#26
0
 def draw(self):
     FigureCanvasAgg.draw(self)
     self.canvas.redraw()
示例#27
0
 def draw(self):
     FigureCanvasAgg.draw(self)
     self.canvas.redraw()
示例#28
0
 def draw(self):
     FigureCanvasAgg.draw(self)
示例#29
0
 def _render_figure(self, pixmap, width, height):
     FigureCanvasAgg.draw(self)
     agg_to_gtk_drawable(pixmap, self.renderer._renderer, None)
示例#30
0
def draw(self): 
 FigureCanvasAgg.draw(self) 
 tkagg.blit(self._tkphoto, self.renderer._renderer, 2) 
 self._master.update_idletasks() 

 show = draw 
示例#31
0
 def draw(self):
     FigureCanvasAgg.draw(self)