Esempio n. 1
0
    def _create_control(self):
        ctrl = QGraphicsView()
        ctrl.setRenderHints(QPainter.Antialiasing)
        scene = QGraphicsScene()
        ctrl.setScene(scene)

        scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))

        ctrl.setStyleSheet("border: 0px")

        w, h = 150, 150
        ctrl.setMinimumHeight(h + 22)
        ctrl.setMinimumWidth(w + 22)

        cx, cy = w / 2, h / 2.
        ex, ey = cx, cy + 20
        pen = QPen()
        pen.setStyle(Qt.NoPen)
        # pen.setColor(QColor(237, 237, 237))
        bounding_rect = scene.addRect(0, 0, w, h, pen=pen)
        bounding_rect.setFlag(QGraphicsItem.ItemClipsChildrenToShape)

        self.animation = QSequentialAnimationGroup()
        self._add_laser_logo(scene, bounding_rect, ex, ey, cx, cy, w, h)
        self._add_bullet(scene, bounding_rect,ex, ey, cx, cy)
        self._add_fragments(scene, bounding_rect, ex, ey)

        self.animation.setLoopCount(-1)

        return ctrl
    def _create_control(self):
        ctrl = QGraphicsView()
        ctrl.setRenderHints(QPainter.Antialiasing)
        scene = QGraphicsScene()
        ctrl.setScene(scene)

        scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))

        ctrl.setStyleSheet("border: 0px")

        w, h = 150, 150
        ctrl.setMinimumHeight(h + 22)
        ctrl.setMinimumWidth(w + 22)

        cx, cy = w / 2, h / 2.
        ex, ey = cx, cy + 20
        pen = QPen()
        pen.setStyle(Qt.NoPen)
        # pen.setColor(QColor(237, 237, 237))
        bounding_rect = scene.addRect(0, 0, w, h, pen=pen)
        bounding_rect.setFlag(QGraphicsItem.ItemClipsChildrenToShape)

        self.animation = QSequentialAnimationGroup()
        self._add_laser_logo(scene, bounding_rect, ex, ey, cx, cy, w, h)
        self._add_bullet(scene, bounding_rect, ex, ey, cx, cy)
        self._add_fragments(scene, bounding_rect, ex, ey)

        self.animation.setLoopCount(-1)

        return ctrl
    def __init__(self, control_points, parent=None):
        super(CurveItem, self).__init__(parent)
        self.control_points = control_points

        for control_point in self.control_points:
            control_point.add_curve(self)

        pen = QPen()
        pen.setWidth(3)
        pen.setColor(QColor(120, 0, 14))
        self.setPen(pen)

        self.update_position()
Esempio n. 4
0
    def _add_bullet(self, scene, bounding_rect, ex, ey, cx, cy):
        pen = QPen()
        pen.setColor(QColor('orange'))
        pen.setWidth(1)
        bullet = scene.addRect(-16, ey - 5, 15, 10, pen=pen)
        bullet.setParentItem(bounding_rect)
        bullet.setBrush(Qt.black)
        self.animation_objects['bullet'] = w = Wrapper(bullet)

        anim = QPropertyAnimation(w, 'position')
        anim.setDuration(500)
        anim.setKeyValueAt(0, bullet.pos())
        anim.setKeyValueAt(1, QPoint(cx + 10, 0))
        self.animation.addAnimation(anim)
Esempio n. 5
0
 def plot_survey(self, qp):
     if self.x_canvas is not None:
         pen = QPen(Qt.blue, 1, Qt.SolidLine)
         qp.setPen(pen)
         # draw survey area rectangle
         qp.drawLine(self.x_canvas[0], self.y_canvas[0],
                     self.x_canvas[1], self.y_canvas[1])
         qp.drawLine(self.x_canvas[1], self.y_canvas[1],
                     self.x_canvas[2], self.y_canvas[2])
         qp.drawLine(self.x_canvas[2], self.y_canvas[2],
                     self.x_canvas[3], self.y_canvas[3])
         qp.drawLine(self.x_canvas[3], self.y_canvas[3],
                     self.x_canvas[0], self.y_canvas[0])
         # draw inl/crl label
         qp.setPen(QPen(Qt.black, 1, Qt.SolidLine))
         for x, y, inl, crl in zip(
                 self.x_canvas, self.y_canvas, self.inlines, self.crlines):
             qp.drawText(QPoint(x, y), "{}/{}".format(inl, crl))
Esempio n. 6
0
    def paintEvent(self, event):
        painter = QtGui.QPainter(self)
        painter.setFont(self.font)

        # painter.setPen(QColor(200, 0, 100))#light grey
        painter.fillRect(event.rect(), self.background_color)

        p=QPen()
        p.setColor(QColor(100,100,100))
        painter.setPen(p)

        rect=event.rect()
        rect.adjust(0,-1, self.adjust_width,1)
        painter.drawRect(rect)

        cw = self.parent()
        block = cw.firstVisibleBlock()
        blocknum = block.blockNumber()
        top = cw.blockBoundingGeometry(block).translated(
            cw.contentOffset()).top()
        bottom = top + int(cw.blockBoundingRect(block).height())

        lineno=self.start
        while block.isValid() and top <= event.rect().bottom():
            if block.isVisible() and bottom >= event.rect().top():
                if blocknum>0:
                    text=block.text()
                    if not text.startswith(self.anti_tag):
                        painter.drawText(0, top, self.width() - 2,
                                         self.fontMetrics().height(),
                                         QtCore.Qt.AlignRight, str(lineno))
                        lineno+=1
                else:
                    painter.drawText(0, top, self.width() - 2,
                                     self.fontMetrics().height(),
                                     QtCore.Qt.AlignRight, '...')

            block = next(block)
            top = bottom
            bottom = top + int(cw.blockBoundingRect(block).height())
            blocknum += 1
Esempio n. 7
0
    def init(self, parent):
        """
        """
        rad = self.factory.radius

        if not rad:
            rad = 20

        if self.control is None:

            scene = QGraphicsScene()

            # system background color
            scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))

            x, y = 10, 10
            cx = x + rad / DIAMETER_SCALAR
            cy = y + rad / DIAMETER_SCALAR

            self.colors = [QColor(ci) for ci in self.factory.colors]
            brush = get_gradient(self.colors[self.value], cx, cy, rad / 2)
            pen = QPen()
            pen.setWidth(0)
            self._led_ellipse = scene.addEllipse(x, y, rad, rad, pen=pen, brush=brush)

            ctrl = LEDGraphicsView(rad, scene)

            layout = QVBoxLayout()
            layout.addWidget(ctrl)
            layout.setAlignment(ctrl, Qt.AlignHCenter)

            if self.factory.label:
                txt = QLabel(self.factory.label)
                layout.addWidget(txt)
                layout.setAlignment(txt, Qt.AlignHCenter)

            self.control = QWidget()
            self.control.setLayout(layout)
    def paintEvent(self, event):
        qp = QPainter()
        qp.begin(self)
        c = QColor()
        c.setNamedColor(self._window_bgcolor)

        h, s, l, a = c.getHsl()
        c.setHsl(h, s, 100, a)

        pen = QPen(c, 8, QtCore.Qt.SolidLine)
        qp.setPen(pen)

        qp.drawRoundedRect(event.rect(), 12, 12)
        qp.end()
    def _add_bullet(self, scene, bounding_rect, ex, ey, cx, cy):
        pen = QPen()
        pen.setColor(QColor('orange'))
        pen.setWidth(1)
        bullet = scene.addRect(-16, ey - 5, 15, 10, pen=pen)
        bullet.setParentItem(bounding_rect)
        bullet.setBrush(Qt.black)
        self.animation_objects['bullet'] = w = Wrapper(bullet)

        anim = QPropertyAnimation(w, 'position')
        anim.setDuration(500)
        anim.setKeyValueAt(0, bullet.pos())
        anim.setKeyValueAt(1, QPoint(cx + 10, 0))
        self.animation.addAnimation(anim)
Esempio n. 10
0
    def _add_fragments(self, scene, bounding_rect, ex, ey):
        pen = QPen()
        pen.setWidth(1)

        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(QColor('orange'))
        ganim = QParallelAnimationGroup()

        n = 8
        s = 360 / n
        vs = ((0, 50, 7), (s / 2, 30, 10))
        vs = ((0, 50, 10), )
        for j, l, ed in vs:
            for i in range(n):
                theta = math.radians(j + i * s)
                x = l * math.cos(theta)
                y = l * math.sin(theta)

                fragment = scene.addEllipse(ex - ed / 2,
                                            ey - ed / 2,
                                            ed,
                                            ed,
                                            pen=pen,
                                            brush=brush)
                fragment.setParentItem(bounding_rect)

                self.animation_objects['fragment{}{}'.format(
                    l, i)] = w = Wrapper(fragment)
                gg = QSequentialAnimationGroup()
                anim = QPropertyAnimation(w, 'position')
                anim.setDuration(750)
                pos = fragment.pos()
                anim.setKeyValueAt(0, pos)

                anim.setKeyValueAt(1, QPoint(x, y))

                gg.addAnimation(anim)
                anim = QPropertyAnimation(w, 'position')
                anim.setDuration(1)
                anim.setKeyValueAt(0, pos)
                anim.setKeyValueAt(1, pos)

                gg.addAnimation(anim)
                ganim.addAnimation(gg)

        r = 15
        center = scene.addEllipse(ex - r / 2.,
                                  ey - r / 2.,
                                  r,
                                  r,
                                  pen=pen,
                                  brush=brush)
        center.setParentItem(bounding_rect)
        center.setBrush(Qt.black)
        self.animation_objects['center'] = w = Wrapper(center,
                                                       opos=(ex - r / 2.,
                                                             ey - r / 2.),
                                                       radius=r)
        gg = QSequentialAnimationGroup()
        anim = QPropertyAnimation(w, 'radius')
        anim.setDuration(750)
        anim.setKeyValueAt(0, r)
        anim.setKeyValueAt(1, r * 3)
        gg.addAnimation(anim)
        anim = QPropertyAnimation(w, 'radius')
        anim.setDuration(1)
        anim.setKeyValueAt(0, r)
        anim.setKeyValueAt(1, r)
        gg.addAnimation(anim)

        ganim.addAnimation(gg)
        self.animation.addAnimation(ganim)
Esempio n. 11
0
    def _add_laser_logo(self, scene, bounding_rect, ex, ey, cx, cy, w, h):
        tw = w - 20
        poly = QPolygon()
        poly.append(QPoint(cx - tw / 2, h - 10))
        poly.append(QPoint(cx + tw / 2, h - 10))
        poly.append(QPoint(cx, 10))
        pen = QPen()
        pen.setWidth(5)
        # brush = QBrush()
        # brush.setStyle(Qt.SolidPattern)
        # brush.setColor(QColor(255, 255, 0))
        item = scene.addPolygon(poly, pen=pen)
        item.setBrush(QColor(255, 255, 0))
        item.setParentItem(bounding_rect)
        pen = QPen()
        pen.setWidth(3)
        item = scene.addLine(cx - 40, ey, cx, ey, pen=pen)
        item.setParentItem(bounding_rect)

        pen = QPen()
        pen.setColor(Qt.black)
        pen.setWidth(2)

        for l, n in ((25, 12), (17, 24)):
            s = 360 / n
            for theta in range(n):
                theta = math.radians(theta * s)
                x = l * math.cos(theta)
                y = l * math.sin(theta)
                ll = scene.addLine(ex, ey, ex + x, ey + y, pen=pen)
                ll.setParentItem(bounding_rect)

        return bounding_rect
Esempio n. 12
0
    def _add_fragments(self, scene, bounding_rect, ex, ey):
        pen = QPen()
        pen.setWidth(1)

        brush = QBrush()
        brush.setStyle(Qt.SolidPattern)
        brush.setColor(QColor('orange'))
        ganim = QParallelAnimationGroup()

        n = 8
        s = 360 / n
        vs = ((0, 50, 7), (s / 2, 30, 10))
        vs = ((0, 50, 10),)
        for j, l, ed in vs:
            for i in range(n):
                theta = math.radians(j + i * s)
                x = l * math.cos(theta)
                y = l * math.sin(theta)

                fragment = scene.addEllipse(ex - ed / 2, ey - ed / 2, ed, ed, pen=pen, brush=brush)
                fragment.setParentItem(bounding_rect)

                self.animation_objects['fragment{}{}'.format(l, i)] = w = Wrapper(fragment)
                gg = QSequentialAnimationGroup()
                anim = QPropertyAnimation(w, 'position')
                anim.setDuration(750)
                pos = fragment.pos()
                anim.setKeyValueAt(0, pos)

                anim.setKeyValueAt(1, QPoint(x, y))

                gg.addAnimation(anim)
                anim = QPropertyAnimation(w, 'position')
                anim.setDuration(1)
                anim.setKeyValueAt(0, pos)
                anim.setKeyValueAt(1, pos)

                gg.addAnimation(anim)
                ganim.addAnimation(gg)

        r = 15
        center = scene.addEllipse(ex - r / 2., ey - r / 2., r, r, pen=pen, brush=brush)
        center.setParentItem(bounding_rect)
        center.setBrush(Qt.black)
        self.animation_objects['center'] = w = Wrapper(center,
                                                       opos=(ex - r / 2., ey - r / 2.),
                                                       radius=r)
        gg = QSequentialAnimationGroup()
        anim = QPropertyAnimation(w, 'radius')
        anim.setDuration(750)
        anim.setKeyValueAt(0, r)
        anim.setKeyValueAt(1, r * 3)
        gg.addAnimation(anim)
        anim = QPropertyAnimation(w, 'radius')
        anim.setDuration(1)
        anim.setKeyValueAt(0, r)
        anim.setKeyValueAt(1, r)
        gg.addAnimation(anim)

        ganim.addAnimation(gg)
        self.animation.addAnimation(ganim)
Esempio n. 13
0
    def _add_laser_logo(self, scene, bounding_rect, ex, ey, cx, cy, w, h):
        tw = w - 20
        poly = QPolygon()
        poly.append(QPoint(cx - tw / 2, h - 10))
        poly.append(QPoint(cx + tw / 2, h - 10))
        poly.append(QPoint(cx, 10))
        pen = QPen()
        pen.setWidth(5)
        # brush = QBrush()
        # brush.setStyle(Qt.SolidPattern)
        # brush.setColor(QColor(255, 255, 0))
        item = scene.addPolygon(poly, pen=pen)
        item.setBrush(QColor(255, 255, 0))
        item.setParentItem(bounding_rect)
        pen = QPen()
        pen.setWidth(3)
        item = scene.addLine(cx - 40, ey, cx, ey, pen=pen)
        item.setParentItem(bounding_rect)

        pen = QPen()
        pen.setColor(Qt.black)
        pen.setWidth(2)

        for l, n in ((25, 12), (17, 24)):
            s = 360 / n
            for theta in range(n):
                theta = math.radians(theta * s)
                x = l * math.cos(theta)
                y = l * math.sin(theta)
                ll = scene.addLine(ex, ey, ex + x, ey + y, pen=pen)
                ll.setParentItem(bounding_rect)

        return bounding_rect