Beispiel #1
0
    def __init__(self, color='red'):
        pm = QtGui.QPixmap(16, 16)
        mask = QtGui.QBitmap(16, 16)
        black = QtCore.Qt.color1
        white = QtCore.Qt.color0
        clr = QtGui.QColor(color)

        pm.fill(clr)
        mask.fill(black)
        p1 = QtGui.QPainter(mask)
        p1.setPen(white)

        p1.drawLine(0, 6, 5, 6)
        p1.drawLine(0, 8, 5, 8)

        p1.drawLine(10, 6, 15, 6)
        p1.drawLine(10, 8, 15, 8)

        p1.drawLine(6, 0, 6, 5)
        p1.drawLine(8, 0, 8, 5)

        p1.drawLine(6, 10, 6, 15)
        p1.drawLine(8, 10, 8, 15)

        p1.end()
        pm.setAlphaChannel(mask)
        self.cur = QtGui.QCursor(pm, 8, 8)
Beispiel #2
0
    def _render_offscreen(self, drawable, data, dst_x, dst_y, width, height):
        # NOTE [A]
        daht, dawd, depth = data.shape
        self.logger.debug("data shape is %dx%dx%d" % (dawd, daht, depth))

        # Get qimage for copying pixel data
        qimage = self._get_qimage(data)

        painter = QtGui.QPainter(drawable)
        painter.setWorldMatrixEnabled(True)

        # fill pixmap with background color
        imgwin_wd, imgwin_ht = self.get_window_size()
        painter.fillRect(QtCore.QRect(0, 0, imgwin_wd, imgwin_ht), self.img_bg)

        # draw image data from buffer to offscreen pixmap
        painter.drawImage(QtCore.QRect(dst_x, dst_y, width, height), qimage,
                          QtCore.QRect(0, 0, width, height))

        # Draw a cross in the center of the window in debug mode
        if self.t_['show_pan_position']:
            clr = QtGui.QColor()
            clr.setRgbF(1.0, 0.0, 0.0)
            painter.setPen(clr)
            ctr_x, ctr_y = self.get_center()
            painter.drawLine(ctr_x - 10, ctr_y, ctr_x + 10, ctr_y)
            painter.drawLine(ctr_x, ctr_y - 10, ctr_x, ctr_y + 10)

        # render self.message
        if self.message:
            self.draw_message(painter, imgwin_wd, imgwin_ht, self.message)
Beispiel #3
0
    def setup_cr(self):
        cr = QtGui.QPainter(self.fitsimage.pixmap)

        pen = QtGui.QPen()
        if hasattr(self, 'linewidth'):
            pen.setWidth(self.linewidth)
        else:
            pen.setWidth(1)

        if hasattr(self, 'linestyle'):
            if self.linestyle == 'dash':
                pen.setDashPattern([3.0, 4.0, 6.0, 4.0])
                pen.setDashOffset(5.0)

        color = self.__get_color(self.color)
        pen.setColor(color)
        cr.setPen(pen)

        if hasattr(self, 'fill') and self.fill:
            if hasattr(self, 'fillcolor') and self.fillcolor:
                color = self.fillcolor
            else:
                color = self.color
            if not color:
                cr.setBrush(QtCore.Qt.NoBrush)
            else:
                color = self.__get_color(color)
                cr.setBrush(color)
        else:
            cr.setBrush(QtCore.Qt.NoBrush)

        return cr
Beispiel #4
0
    def repaint(self, rect):
        x1, y1, x2, y2 = rect.getCoords()
        width = x2 - x1
        height = y2 - y1

        # redraw the screen from backing pixmap
        #print "copying pixmap to widget"
        painter = QtGui.QPainter(self)
        rect = QtCore.QRect(x1, y1, width, height)
        painter.drawPixmap(rect, self.pixmap, rect)
Beispiel #5
0
    def paintEvent(self, event):
        """When an area of the window is exposed, we just copy out of the
        server-side, off-screen pixmap to that area.
        """
        if not self.pixmap:
            return
        rect = event.rect()
        x1, y1, x2, y2 = rect.getCoords()
        width = x2 - x1
        height = y2 - y1

        # redraw the screen from backing pixmap
        painter = QtGui.QPainter(self)
        rect = QtCore.QRect(x1, y1, width, height)
        painter.drawPixmap(rect, self.pixmap, rect)
Beispiel #6
0
 def setup_cr(self):
     cr = QtGui.QPainter(self.pixmap)
     pen = QtGui.QPen()
     pen.setWidth(1)
     cr.setPen(pen)
     return cr