Exemplo n.º 1
0
    def paintEvent(self, event):

        # We need to preserve aspect ratio. Figure out bounding box for
        # webcam image.

        im_dx = self._image.width()
        im_dy = self._image.height()
        im_ratio = im_dx / float(im_dy)

        wi_dx = self.width()
        wi_dy = self.height()
        wi_ratio = wi_dx / float(wi_dy)

        if wi_ratio > im_ratio:  # Need to pad on sides

            xmin = wi_dx / 2. - wi_dy / 2. * im_ratio
            ymin = 0.
            width = wi_dy * im_ratio
            height = wi_dy

        else:  # Need to pad on top/bottom

            xmin = 0.
            ymin = wi_dy / 2. - wi_dx / 2. / float(im_ratio)
            width = wi_dx
            height = wi_dx / float(im_ratio)

        painter = QtGui.QPainter(self)
        painter.drawImage(QtCore.QRect(xmin, ymin, width, height), self._image)
Exemplo n.º 2
0
    def paintEvent(self, event):
        # draw the zoom rectangle more prominently
        try:
            drawRect = self.drawRect
            self.drawRect = False

        except AttributeError:  # mpl  1.4
            drawRect = self._drawRect
            self._drawRect = None

        # super needs this
        if self.renderer is None:
            self.renderer = self.get_renderer()

        super(MplCanvas, self).paintEvent(event)
        if drawRect:
            try:
                x, y, w, h = self.rect[0], self.rect[1], self.rect[
                    2], self.rect[3]
            except TypeError:  # mpl 1.4
                x, y, w, h = drawRect
            p = QtGui.QPainter(self)
            p.setPen(QtGui.QPen(Qt.red, 2, Qt.DotLine))
            p.drawRect(x, y, w, h)
            p.end()

        if self.roi_callback is not None:
            self.roi_callback(self)
Exemplo n.º 3
0
    def paintEvent(self, event):
        super(GlueMdiArea, self).paintEvent(event)

        painter = QtGui.QPainter(self.viewport())
        painter.setPen(QtGui.QColor(210, 210, 210))
        font = painter.font()
        font.setPointSize(48)
        font.setWeight(font.Black)
        painter.setFont(font)
        rect = self.contentsRect()
        painter.drawText(rect, Qt.AlignHCenter | Qt.AlignVCenter,
                         "Drag Data To Plot")
Exemplo n.º 4
0
def status_pixmap(attention=False):
    """
    A small icon to grab attention

    :param attention: If True, return attention-grabbing pixmap
    """
    color = Qt.red if attention else Qt.lightGray

    pm = QtGui.QPixmap(15, 15)
    p = QtGui.QPainter(pm)
    b = QtGui.QBrush(color)
    p.fillRect(-1, -1, 20, 20, b)
    return pm
Exemplo n.º 5
0
Arquivo: roi.py Projeto: robintw/glue
    def get_painter(self, canvas):
        p = QtGui.QPainter(canvas)
        facecolor = mpl_to_qt4_color(self.plot_opts['facecolor'],
                                     self.plot_opts['alpha'])
        edgecolor = mpl_to_qt4_color(self.plot_opts['edgecolor'],
                                     self.plot_opts['alpha'])

        pen = QtGui.QPen(edgecolor)
        pen.setWidth(self.plot_opts.get('edgewidth', 0))
        p.setPen(pen)

        p.setBrush(QtGui.QBrush(facecolor))

        return p