def updatePath(self):
     """
     TOWRITE
     """
     path = QPainterPath()
     r = self.rect()  # QRectF
     path.arcMoveTo(r, 0)
     path.arcTo(r, 0, 360)
     # NOTE: Reverse the path so that the inside area isn't considered part of the ellipse
     path.arcTo(r, 0, -360)
     self.setObjectPath(path)
Esempio n. 2
0
 def updatePath(self):
     """
     TOWRITE
     """
     path = QPainterPath()
     r = self.rect()  # QRectF
     path.arcMoveTo(r, 0)
     path.arcTo(r, 0, 360)
     # NOTE: Reverse the path so that the inside area isn't considered part of the ellipse
     path.arcTo(r, 0, -360)
     self.setObjectPath(path)
Esempio n. 3
0
 def set_shape(self, width, height):
     ''' ANSWER has round, disjoint sides - does not fit in a polygon '''
     self.width, self.height = width, height
     point = width / 2.85
     path = QPainterPath()
     left = QRect(0, 0, point, height)
     right = QRect(width - point, 0, point, height)
     path.arcMoveTo(left, 125)
     path.arcTo(left, 125, 110)
     path.arcMoveTo(right, -55)
     path.arcTo(right, -55, 110)
     path.moveTo(width, height)
     self.setPath(path)
     super(DecisionAnswer, self).set_shape(width, height)
Esempio n. 4
0
 def set_shape(self, width, height):
     ''' ANSWER has round, disjoint sides - does not fit in a polygon '''
     self.width, self.height = width, height
     point = 20 #width / 2.85
     path = QPainterPath()
     left = QRect(0, 0, point, height)
     right = QRect(width - point, 0, point, height)
     path.arcMoveTo(left, 125)
     path.arcTo(left, 125, 110)
     path.arcMoveTo(right, -55)
     path.arcTo(right, -55, 110)
     path.moveTo(width, height)
     self.setPath(path)
     super(DecisionAnswer, self).set_shape(width, height)
Esempio n. 5
0
 def updatePath(self):
     """
     TOWRITE
     """
     path = QPainterPath()
     r = self.rect()  # QRectF
     # Add the center point.
     path.addRect(-0.00000001, -0.00000001, 0.00000002, 0.00000002)
     # Add the circle.
     path.arcMoveTo(r, 0)
     path.arcTo(r, 0, 360)
     # NOTE: Reverse the path so that the inside area isn't considered part of the circle.
     path.arcTo(r, 0, -360)
     self.setObjectPath(path)
 def updatePath(self):
     """
     TOWRITE
     """
     path = QPainterPath()
     r = self.rect()  # QRectF
     # Add the center point.
     path.addRect(-0.00000001, -0.00000001, 0.00000002, 0.00000002)
     # Add the circle.
     path.arcMoveTo(r, 0)
     path.arcTo(r, 0, 360)
     # NOTE: Reverse the path so that the inside area isn't considered part of the circle.
     path.arcTo(r, 0, -360)
     self.setObjectPath(path)
    def objectSavePath(self):
        """
        TOWRITE

        :rtype: `QPainterPath`_
        """
        path = QPainterPath()
        r = self.rect()  # QRectF
        path.arcMoveTo(r, 0)
        path.arcTo(r, 0, 360)

        s = self.scale()  # qreal
        trans = QTransform()
        trans.rotate(self.rotation())
        trans.scale(s, s)
        return trans.map(path)
Esempio n. 8
0
    def objectSavePath(self):
        """
        TOWRITE

        :rtype: `QPainterPath`_
        """
        path = QPainterPath()
        r = self.rect()  # QRectF
        path.arcMoveTo(r, 0)
        path.arcTo(r, 0, 360)

        s = self.scale()  # qreal
        trans = QTransform()
        trans.rotate(self.rotation())
        trans.scale(s, s)
        return trans.map(path)
Esempio n. 9
0
    def updatePath(self):
        """
        TOWRITE
        """
        startAngle = (self.objectStartAngle() + self.rotation())  # qreal
        spanAngle = self.objectIncludedAngle()                    # qreal

        if self.objectClockwise():
            spanAngle = -spanAngle

        path = QPainterPath()
        path.arcMoveTo(self.rect(), startAngle)
        path.arcTo(self.rect(), startAngle, spanAngle)
        # NOTE: Reverse the path so that the inside area isn't considered part of the arc
        path.arcTo(self.rect(), startAngle + spanAngle, -spanAngle);
        self.setObjectPath(path)
Esempio n. 10
0
    def paintEvent(self, event):
        # print self.height()

        s = (self.target_angle - self.angle) * 0.09

        self.angle += s
        if math.fabs(self.angle - self.target_angle) < 0.001:
            self.angle = self.target_angle
            self.timer.stop()

        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        qp = QPainterPath()

        width = min(self.height(), (self.width() / 2))
        height = self.height()

        # center
        x = self.width() / 2

        big_radius = 1000
        y = big_radius + 10
        small_radius = big_radius - 15

        ac = math.atan(float(self.width()) / 2.0 /
                       float(big_radius)) / math.pi * 180.0 * 0.95

        qp.arcMoveTo(x - big_radius, y - big_radius, 2 * big_radius,
                     2 * big_radius, 90 - ac)
        qp.arcTo(x - big_radius, y - big_radius, 2 * big_radius,
                 2 * big_radius, 90 - ac, 2 * ac)
        qp.arcTo(x - small_radius, y - small_radius, 2 * small_radius,
                 2 * small_radius, 90 + ac, -2 * ac)
        qp.arcTo(x - big_radius, y - big_radius, 2 * big_radius,
                 2 * big_radius, 90 - ac, 0)
        # qp.lineTo(x+big_radius,y)

        grange = ac * 2.0 / 360.0

        # Centered on 0, starting at angle 90-ac, counterclockwise
        self.gradient = QConicalGradient(0, 0, 90 - ac - 1)

        if self.gradient_type == 1:
            self.gradient.setColorAt(0, Qt.GlobalColor.red)
            self.gradient.setColorAt(0.1, Qt.GlobalColor.yellow)
            self.gradient.setColorAt(0.2, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.5, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.5, Qt.GlobalColor.green)
        elif self.gradient_type == 2:
            self.gradient.setColorAt(0, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.6 * grange, Qt.GlobalColor.yellow)
            self.gradient.setColorAt(1 * grange, Qt.GlobalColor.red)
        elif self.gradient_type == 3:
            self.gradient.setColorAt(0 * grange, Qt.GlobalColor.red)
            self.gradient.setColorAt(0.05 * grange, Qt.GlobalColor.yellow)
            self.gradient.setColorAt(0.1 * grange, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.4 * grange, Qt.GlobalColor.green)
            self.gradient.setColorAt(0.45 * grange, Qt.GlobalColor.yellow)
            self.gradient.setColorAt(0.5 * grange, Qt.GlobalColor.red)

        self.gradient.setCenter(x, y)
        painter.fillPath(qp, QBrush(self.gradient))

        pen = QPen()
        pen.setColor(Qt.GlobalColor.black)
        pen.setWidth(max(1, int(1 * self.width() / 300)))
        painter.setPen(pen)
        painter.drawPath(qp)

        qp = QPainterPath()
        #qp.moveTo(0,0)
        #qp.lineTo(x,y)
        #qp.lineTo(self.width(),0)

        angle = 0
        ac = math.atan(float(self.width()) / 2.0 / float(big_radius)) * 0.95

        if self.direction == self.UNIDIRECTIONAL:
            angle = math.pi / 2 + ac * (1 - 2 * self.angle)

        elif self.direction == self.BIDIRECTIONAL:
            angle = math.pi / 2 - self.angle * ac

        length = big_radius + 10
        short_length = small_radius - 10

        qp.moveTo(x + math.cos(angle) * short_length,
                  y - math.sin(angle) * short_length)
        qp.lineTo(x + math.cos(angle) * length, y - math.sin(angle) * length)
        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)
        pen.setColor(Qt.GlobalColor.black)
        pen.setWidth(max(3, int(3 * width / 300)))
        painter.setPen(pen)
        painter.drawPath(qp)

        qp = QPainterPath()
        delta = self.width() * 0.025

        # print "{}-{} {} c:{}".format(x,y,delta,math.cos(angle))
        qp.moveTo(x + delta + math.cos(angle) * short_length,
                  y + delta - math.sin(angle) * short_length)
        qp.lineTo(x + delta + math.cos(angle) * length,
                  y + delta - math.sin(angle) * length)
        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)
        pen.setColor(QColor.fromRgbF(0, 0, 0, 0.3))
        pen.setWidth(max(3, int(3 * width / 300)))
        painter.setPen(pen)
        painter.drawPath(qp)

        qp = QPainterPath()
        qp.addRect(0, 0, self.width(), self.height())
        painter.drawPath(qp)