def mouseReleaseEvent(self, event):
     x = event.x()
     # flipy so y=0 is bottom of canvas
     y = self.figure.bbox.height - event.y()
     button = self.buttond[event.button()]
     FigureCanvasAgg.button_release_event(self, x, y, button)
     self.draw()
Exemplo n.º 2
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
Exemplo n.º 3
0
 def __init__( self, figure ):
     if DEBUG: print 'FigureCanvasQtAgg: ', figure
     FigureCanvasQT.__init__( self, figure )
     FigureCanvasAgg.__init__( self, figure )
     self.drawRect = False
     self.rect = []
     self.replot = True
     self.pixmap = qt.QPixmap()
Exemplo n.º 4
0
 def __init__( self, figure ):
     if DEBUG: print 'FigureCanvasQtAgg: ', figure
     FigureCanvasQT.__init__( self, figure )
     FigureCanvasAgg.__init__( self, figure )
     self.drawRect = False
     self.rect = []
     self.replot = True
     self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
Exemplo n.º 5
0
 def __init__( self, figure ):
     if DEBUG: print 'FigureCanvasQtAgg: ', figure
     FigureCanvasQT.__init__( self, figure )
     FigureCanvasAgg.__init__( self, figure )
     self.drawRect = False
     self.rect = []
     self.replot = True
     self.pixmap = qt.QPixmap()
Exemplo n.º 6
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()
Exemplo n.º 7
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)
Exemplo n.º 8
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
Exemplo n.º 9
0
 def print_figure(self, filename, *args, **kwargs):
     # Use pure Agg renderer to draw
     FigureCanvasAgg.print_figure(self, filename, *args, **kwargs)
     # Restore the current view; this is needed because the
     # artist contains methods rely on particular attributes
     # of the rendered figure for determining things like
     # bounding boxes.
     if self._isDrawn:
         self.draw()
Exemplo n.º 10
0
 def print_figure(self, filename, *args, **kwargs):
     # Use pure Agg renderer to draw
     FigureCanvasAgg.print_figure(self, filename, *args, **kwargs)
     # Restore the current view; this is needed because the
     # artist contains methods rely on particular attributes
     # of the rendered figure for determining things like
     # bounding boxes.
     if self._isDrawn:
         self.draw()
Exemplo n.º 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)
Exemplo n.º 12
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)
Exemplo n.º 13
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)
Exemplo n.º 14
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()
Exemplo n.º 15
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)
Exemplo n.º 16
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()
Exemplo n.º 17
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()
Exemplo n.º 18
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
Exemplo n.º 19
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()
Exemplo n.º 20
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
Exemplo n.º 21
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()
Exemplo n.º 22
0
    def __init__(self, figure):

        QtGui.QWidget.__init__(self)
        FigureCanvasAgg.__init__(self, figure)
        self.figure = figure
        self.setMouseTracking(True)

        w,h = self.get_width_height()
        self.resize( w, h )
        self.drawRect = False
        self.rect = []
        self.replot = True
        self.pixmap = QtGui.QPixmap()
Exemplo n.º 23
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()
Exemplo n.º 24
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()
Exemplo n.º 25
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()
Exemplo n.º 26
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'
Exemplo n.º 27
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'
Exemplo n.º 28
0
def __init__(self, figure, master=None, resize_callback=None): 
 FigureCanvasAgg.__init__(self, figure) 
 t1,t2,w,h = self.figure.bbox.get_bounds() 
 w, h = int(w), int(h) 
 self._tkcanvas = Tk.Canvas( 
 master=master, width=w, height=h, borderwidth=4) 
 self._tkphoto = Tk.PhotoImage( 
 master=self._tkcanvas, width=w, height=h) 
 self._tkcanvas.create_image(w/2, h/2, image=self._tkphoto) 
 self._resize_callback = resize_callback 
 self._tkcanvas.bind("<Configure>", self.resize) 
 self._tkcanvas.bind("<Key>", self.key_press) 
 self._tkcanvas.bind("<KeyRelease>", self.key_release) 
 self._master = master 
 self._tkcanvas.focus_set() 
 self._key = None # the key that is pressed  
Exemplo n.º 29
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.
        """
        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
Exemplo n.º 30
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)
Exemplo n.º 31
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
Exemplo n.º 32
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
Exemplo n.º 33
0
 def print_figure(self, *args, **kwargs):
     FigureCanvasAgg.print_figure(self, *args, **kwargs)
     self.draw()
Exemplo n.º 34
0
 def _render_figure(self, pixmap, width, height):
     FigureCanvasAgg.draw(self)
     agg_to_gtk_drawable(pixmap, self.renderer._renderer, None)
Exemplo n.º 35
0
 def mousePressEvent(self, event):
     x = event.pos().x()
     # flipy so y=0 is bottom of canvas
     y = self.figure.bbox.height - event.pos().y()
     button = self.buttond[event.button()]
     FigureCanvasAgg.button_press_event( self, x, y, button )
Exemplo n.º 36
0
 def draw(self):
     FigureCanvasAgg.draw(self)
     self.canvas.redraw()
Exemplo n.º 37
0
 def _render_figure(self, pixmap, width, height):
     FigureCanvasAgg.draw(self)
     agg_to_gtk_drawable(pixmap, self.renderer._renderer, None)
Exemplo n.º 38
0
 def mouseMoveEvent(self, event):
     x = event.x()
     # flipy so y=0 is bottom of canvas
     y = self.figure.bbox.height - event.y()
     FigureCanvasAgg.motion_notify_event( self, x, y )
Exemplo n.º 39
0
 def keyPressEvent(self, event):
     key = self._get_key(event)
     FigureCanvasAgg.key_press_event(self, key)
Exemplo n.º 40
0
 def draw(self):
     FigureCanvasAgg.draw(self)
Exemplo n.º 41
0
def draw(self): 
 FigureCanvasAgg.draw(self) 
 tkagg.blit(self._tkphoto, self.renderer._renderer, 2) 
 self._master.update_idletasks() 

 show = draw 
Exemplo n.º 42
0
 def print_figure(self, filename, *args, **kwargs):
     FigureCanvasAgg.print_figure(self, filename, *args, **kwargs)
     if self._isDrawn:
         self.draw()
Exemplo n.º 43
0
def new_figure_manager(num, *args, **kwargs):
    if DEBUG: print >> sys.stderr, 'new_figure_manager'
    thisFig = Figure(*args, **kwargs)
    canvas = FigureCanvasAgg(thisFig)
    return FigureManagerCocoaAgg(canvas, num)
Exemplo n.º 44
0
 def __init__(self, figure):
     FigureCanvasAgg.__init__(self, figure)
     t1, t2, w, h = self.figure.bbox.get_bounds()
     w, h = int(w), int(h)
     self.canvas = FltkCanvas(0, 0, w, h, "canvas", self)
Exemplo n.º 45
0
 def draw(self):
     FigureCanvasAgg.draw(self)
Exemplo n.º 46
0
 def print_figure(self, *args, **kwargs):
     FigureCanvasAgg.print_figure(self, *args, **kwargs)
     self.draw()
Exemplo n.º 47
0
 def __init__(self, figure):
     FigureCanvasAgg.__init__(self, figure)
     t1, t2, w, h = self.figure.bbox.bounds
     w, h = int(w), int(h)
     self.canvas = FltkCanvas(0, 0, w, h, "canvas", self)
Exemplo n.º 48
0
 def keyReleaseEvent(self, event):
     key = self._get_key(event)
     FigureCanvasAgg.key_release_event(self, key)
Exemplo n.º 49
0
 def draw(self):
     FigureCanvasAgg.draw(self)
     self.canvas.redraw()