Пример #1
0
    def paint(self, painter, option, widget):

        if self.is_node1:
            color = Qt.green
            dark_color = Qt.darkGreen
        else:
            color = Qt.yellow
            dark_color = Qt.darkYellow

        gradient = QRadialGradient(-3, -3, 10)
        if option.state & QStyle.State_MouseOver:
            gradient.setCenter(3, 3)
            gradient.setFocalPoint(3, 3)
            gradient.setColorAt(1, QColor(color).lighter(120))
            gradient.setColorAt(0, QColor(dark_color).lighter(120))
        else:
            gradient.setColorAt(0, color)
            gradient.setColorAt(1, dark_color)

        painter.setBrush(QBrush(gradient))
        painter.setPen(QPen(Qt.black, 0))
        painter.drawEllipse(-10, -10, 20, 20)

        # node text
        painter.setPen(QPen(QColor(Qt.black), 0))
        painter.drawText(13, 4, "%s" % self.node_record.index)
Пример #2
0
    def drawMagnifierOnVideo(width, height, maskPixmap, dragPos, zoomPixmap, surface, painter, offset):
        ''' Draw Magnifier on Video '''
        dim = min(width, height)
        MAX_MAGNIFIER = 229
        magnifierSize = min(MAX_MAGNIFIER, dim * 2 / 3)
        radius = magnifierSize / 2
        ring = radius - 15
        box = QSize(magnifierSize, magnifierSize)

        # reupdate our mask
        if maskPixmap.size() != box:
            maskPixmap = QPixmap(box)
            maskPixmap.fill(Qt.transparent)
            g = QRadialGradient()
            g.setCenter(radius, radius)
            g.setFocalPoint(radius, radius)
            g.setRadius(radius)
            g.setColorAt(1.0, QColor(64, 64, 64, 0))
            g.setColorAt(0.5, QColor(0, 0, 0, 255))
            mask = QPainter(maskPixmap)
            mask.setRenderHint(QPainter.HighQualityAntialiasing)
            mask.setCompositionMode(QPainter.CompositionMode_Source)
            mask.setBrush(g)
            mask.setPen(Qt.NoPen)
            mask.drawRect(maskPixmap.rect())
            mask.setBrush(QColor(Qt.transparent))
            mask.drawEllipse(g.center(), ring, ring)
            mask.end()

        center = dragPos - QPoint(0, radius)
        center += QPoint(0, radius / 2)
        corner = center - QPoint(radius, radius)
        xy = center * 2 - QPoint(radius, radius)
        # only set the dimension to the magnified portion
        if zoomPixmap.size() != box:
            zoomPixmap = QPixmap(box)
            zoomPixmap.fill(Qt.lightGray)

        if True:
            painter_p = QPainter(zoomPixmap)
            painter_p.translate(-xy)
            largePixmap = QPixmap.fromImage(surface.image)
            painter_p.drawPixmap(offset, largePixmap)
            painter_p.end()

        clipPath = QPainterPath()
        clipPath.addEllipse(QPointF(center), ring, ring)
        painter.setClipPath(clipPath)
        painter.drawPixmap(corner, zoomPixmap)
        painter.setClipping(False)
        painter.drawPixmap(corner, maskPixmap)
        painter.setPen(Qt.gray)
        painter.drawPath(clipPath)
        return
Пример #3
0
 def paint(self, painter, option, widget):
     gradient = QRadialGradient(-3, -3, 10)
     if option.state & QStyle.State_Sunken:
         gradient.setCenter(3, 3)
         gradient.setFocalPoint(3, 3)
         gradient.setColorAt(0, QColor(Qt.yellow).light(120))
     else:
         gradient.setColorAt(0, QColor(Qt.yellow).light(120))
     painter.setBrush(gradient)
     painter.setPen(QPen(Qt.black, 0))
     painter.drawRoundedRect(self.boundingRect(), 3, 3)
Пример #4
0
    def paint(self, painter, option, widget):
        painter.setPen(Qt.NoPen)
        painter.setBrush(Qt.darkGray)
        painter.drawEllipse(-7, -7, 20, 20)

        gradient = QRadialGradient(-3, -3, 10)
        if option.state & QStyle.State_Sunken:
            gradient.setCenter(3, 3)
            gradient.setFocalPoint(3, 3)
            gradient.setColorAt(1, QColor(Qt.red).lighter(120))
            gradient.setColorAt(0, QColor(Qt.darkRed).lighter(120))
        else:
            gradient.setColorAt(0, Qt.cyan)
            gradient.setColorAt(1, Qt.darkCyan)

        painter.setBrush(QBrush(gradient))
        painter.setPen(QPen(Qt.black, 0))
        painter.drawEllipse(-10, -10, 20, 20)
Пример #5
0
    def paint(self, painter, option, widget):
        painter.setPen(Qt.NoPen)
        painter.setBrush(Qt.darkGray)
        painter.drawEllipse(-7, -7, 20, 20)

        gradient = QRadialGradient(-3, -3, 10)
        if option.state & QStyle.State_Sunken:
            gradient.setCenter(3, 3)
            gradient.setFocalPoint(3, 3)
            gradient.setColorAt(1, QColor(Qt.yellow).lighter(120))
            gradient.setColorAt(0, QColor(Qt.darkYellow).lighter(120))
        else:
            gradient.setColorAt(0, Qt.yellow)
            gradient.setColorAt(1, Qt.darkYellow)

        painter.setBrush(QBrush(gradient))
        painter.setPen(QPen(Qt.black, 0))
        painter.drawEllipse(-10, -10, 20, 20)
Пример #6
0
    def paint(self, painter, option, widget):
        start_draw = -self._draw_size
        end_draw = self._draw_size

        painter.setPen(Qt.NoPen)
        painter.setBrush(Qt.darkGray)
        painter.drawEllipse(start_draw + 3, start_draw + 3, end_draw, end_draw)

        gradient = QRadialGradient(start_draw * 0.6, start_draw * 0.6,
                                   end_draw / 2)
        if option.state & QStyle.State_Sunken:
            gradient.setCenter(3, 3)
            gradient.setFocalPoint(3, 3)
            if self.state == State.INITIAL:
                gradient.setColorAt(1, QColor(Qt.darkMagenta))  #.light(120))
                gradient.setColorAt(0, QColor(Qt.magenta))  #.light(120))
            elif self.state == State.TRANSITION:
                gradient.setColorAt(1, QColor(Qt.darkCyan))  # .light(120))
                gradient.setColorAt(0, QColor(Qt.cyan))  # .light(120))
            elif self.state == State.FINAL:
                gradient.setColorAt(1, QColor(Qt.darkGreen))  # .light(120))
                gradient.setColorAt(0, QColor(Qt.green))  # .light(120))
            elif self.state == State.INITIAL_FINAL:
                gradient.setColorAt(1, QColor(Qt.darkRed))  # .light(120))
                gradient.setColorAt(0, QColor(Qt.red))  # .light(120))
        else:
            if self.state == State.INITIAL:
                gradient.setColorAt(1, QColor(Qt.darkMagenta))  #.light(120))
                gradient.setColorAt(0, QColor(Qt.magenta))  #.light(120))
            elif self.state == State.TRANSITION:
                gradient.setColorAt(1, QColor(Qt.darkCyan))  # .light(120))
                gradient.setColorAt(0, QColor(Qt.cyan))  # .light(120))
            elif self.state == State.FINAL:
                gradient.setColorAt(1, QColor(Qt.darkGreen))  # .light(120))
                gradient.setColorAt(0, QColor(Qt.green))  # .light(120))
            elif self.state == State.INITIAL_FINAL:
                gradient.setColorAt(1, QColor(Qt.darkRed))  # .light(120))
                gradient.setColorAt(0, QColor(Qt.red))  # .light(120))

        painter.setBrush(QBrush(gradient))
        painter.setPen(QPen(Qt.black, 0))
        painter.drawEllipse(start_draw, start_draw, end_draw, end_draw)
    def paintEvent(self, event):
        p = QPainter()
        p.begin(self)
        self._normalMap.render(p, event.rect())
        p.setPen(Qt.black)
        p.drawText(self.rect(), Qt.AlignBottom | Qt.TextWordWrap,
                   "Map data CCBYSA 2009 OpenStreetMap.org contributors")
        p.end()

        if self.zoomed:
            dim = min(self.width(), self.height())
            magnifierSize = min(MAX_MAGNIFIER, dim * 2 / 3)
            radius = magnifierSize / 2
            ring = radius - 15
            box = QSize(magnifierSize, magnifierSize)

            # reupdate our mask
            if self.maskPixmap.size() != box:
                self.maskPixmap = QPixmap(box)
                self.maskPixmap.fill(Qt.transparent)
                g = QRadialGradient()
                g.setCenter(radius, radius)
                g.setFocalPoint(radius, radius)
                g.setRadius(radius)
                g.setColorAt(1.0, QColor(255, 255, 255, 0))
                g.setColorAt(0.5, QColor(128, 128, 128, 255))
                mask = QPainter(self.maskPixmap)
                mask.setRenderHint(QPainter.Antialiasing)
                mask.setCompositionMode(QPainter.CompositionMode_Source)
                mask.setBrush(g)
                mask.setPen(Qt.NoPen)
                mask.drawRect(self.maskPixmap.rect())
                mask.setBrush(QColor(Qt.transparent))
                mask.drawEllipse(g.center(), ring, ring)
                mask.end()

            center = self.dragPos - QPoint(0, radius)
            center += QPoint(0, radius / 2)
            corner = center - QPoint(radius, radius)
            xy = center * 2 - QPoint(radius, radius)
            # only set the dimension to the magnified portion
            if self.zoomPixmap.size() != box:
                self.zoomPixmap = QPixmap(box)
                self.zoomPixmap.fill(Qt.lightGray)

            if True:
                p = QPainter(self.zoomPixmap)
                p.translate(-xy)
                self._largeMap.render(p, QRect(xy, box))
                p.end()

            clipPath = QPainterPath()
            clipPath.addEllipse(QPointF(center), ring, ring)
            p = QPainter(self)
            p.setRenderHint(QPainter.Antialiasing)
            p.setClipPath(clipPath)
            p.drawPixmap(corner, self.zoomPixmap)
            p.setClipping(False)
            p.drawPixmap(corner, self.maskPixmap)
            p.setPen(Qt.gray)
            p.drawPath(clipPath)

        if self.invert:
            p = QPainter(self)
            p.setCompositionMode(QPainter.CompositionMode_Difference)
            p.fillRect(event.rect(), Qt.white)
            p.end()
Пример #8
0
    def paintEvent(self, event):
        p = QPainter()
        p.begin(self)
        self._normalMap.render(p, event.rect())
        p.setPen(Qt.black)
        p.drawText(self.rect(), Qt.AlignBottom | Qt.TextWordWrap,
                   "Map data CCBYSA 2009 OpenStreetMap.org contributors")
        p.end()

        if self.zoomed:
            dim = min(self.width(), self.height())
            magnifierSize = min(MAX_MAGNIFIER, dim * 2 / 3)
            radius = magnifierSize / 2
            ring = radius - 15
            box = QSize(magnifierSize, magnifierSize)

            # reupdate our mask
            if self.maskPixmap.size() != box:
                self.maskPixmap = QPixmap(box)
                self.maskPixmap.fill(Qt.transparent)
                g = QRadialGradient()
                g.setCenter(radius, radius)
                g.setFocalPoint(radius, radius)
                g.setRadius(radius)
                g.setColorAt(1.0, QColor(255, 255, 255, 0))
                g.setColorAt(0.5, QColor(128, 128, 128, 255))
                mask = QPainter(self.maskPixmap)
                mask.setRenderHint(QPainter.Antialiasing)
                mask.setCompositionMode(QPainter.CompositionMode_Source)
                mask.setBrush(g)
                mask.setPen(Qt.NoPen)
                mask.drawRect(self.maskPixmap.rect())
                mask.setBrush(QColor(Qt.transparent))
                mask.drawEllipse(g.center(), ring, ring)
                mask.end()

            center = self.dragPos - QPoint(0, radius)
            center += QPoint(0, radius / 2)
            corner = center - QPoint(radius, radius)
            xy = center * 2 - QPoint(radius, radius)
            # only set the dimension to the magnified portion
            if self.zoomPixmap.size() != box:
                self.zoomPixmap = QPixmap(box)
                self.zoomPixmap.fill(Qt.lightGray)
    
            if True:
                p = QPainter(self.zoomPixmap)
                p.translate(-xy)
                self._largeMap.render(p, QRect(xy, box))
                p.end()

            clipPath = QPainterPath()
            clipPath.addEllipse(QPointF(center), ring, ring)
            p = QPainter(self)
            p.setRenderHint(QPainter.Antialiasing)
            p.setClipPath(clipPath)
            p.drawPixmap(corner, self.zoomPixmap)
            p.setClipping(False)
            p.drawPixmap(corner, self.maskPixmap)
            p.setPen(Qt.gray)
            p.drawPath(clipPath)

        if self.invert:
            p = QPainter(self)
            p.setCompositionMode(QPainter.CompositionMode_Difference)
            p.fillRect(event.rect(), Qt.white)
            p.end()
Пример #9
0
    def paintEvent(self, event):
        self.gt = GetGCPGeoTransform()
        painter = QPainter(self)

        if (self.surface.isActive()):
            videoRect = self.surface.videoRect()
            if not videoRect.contains(event.rect()):
                region = event.region()
                region.subtracted(QRegion(videoRect))
                brush = self.palette().window()
                for rect in region.rects():
                    painter.fillRect(rect, brush)

            try:
                self.surface.paint(painter)
            except Exception:
                None
        else:
            painter.fillRect(event.rect(), self.palette().window())
        try:
            SetImageSize(self.surface.currentFrame.width(),
                         self.surface.currentFrame.height())
        except:
            None

        # Magnifier Glass
        if self.zoomed and magnifier:
            dim = min(self.width(), self.height())
            magnifierSize = min(MAX_MAGNIFIER, dim * 2 / 3)
            radius = magnifierSize / 2
            ring = radius - 15
            box = QSize(magnifierSize, magnifierSize)

            # reupdate our mask
            if self.maskPixmap.size() != box:
                self.maskPixmap = QPixmap(box)
                self.maskPixmap.fill(Qt.transparent)
                g = QRadialGradient()
                g.setCenter(radius, radius)
                g.setFocalPoint(radius, radius)
                g.setRadius(radius)
                g.setColorAt(1.0, QColor(64, 64, 64, 0))
                g.setColorAt(0.5, QColor(0, 0, 0, 255))
                mask = QPainter(self.maskPixmap)
                mask.setRenderHint(QPainter.Antialiasing)
                mask.setCompositionMode(QPainter.CompositionMode_Source)
                mask.setBrush(g)
                mask.setPen(Qt.NoPen)
                mask.drawRect(self.maskPixmap.rect())
                mask.setBrush(QColor(Qt.transparent))
                mask.drawEllipse(g.center(), ring, ring)
                mask.end()

            center = self.dragPos - QPoint(0, radius)
            center += QPoint(0, radius / 2)
            corner = center - QPoint(radius, radius)
            xy = center * 2 - QPoint(radius, radius)
            # only set the dimension to the magnified portion
            if self.zoomPixmap.size() != box:
                self.zoomPixmap = QPixmap(box)
                self.zoomPixmap.fill(Qt.lightGray)

            if True:
                painter = QPainter(self.zoomPixmap)
                painter.translate(-xy)
                self.largePixmap = QPixmap.fromImage(self.surface.image)
                painter.drawPixmap(self.offset, self.largePixmap)
                painter.end()

            clipPath = QPainterPath()
            clipPath.addEllipse(QPointF(center), ring, ring)
            painter = QPainter(self)
            painter.setRenderHint(QPainter.Antialiasing)
            painter.setClipPath(clipPath)
            painter.drawPixmap(corner, self.zoomPixmap)
            painter.drawPixmap(corner, self.maskPixmap)
            painter.setPen(Qt.gray)
            painter.drawPath(clipPath)
        return