示例#1
0
 def roundedRectPath(x,y,width,height,
                     TLRX,TLRY,  TRRX,TRRY,
                     BLRX,BLRY,  BRRX,BRRY):
     right = x + width
     bottom = y + height
     
     if TLRX <= 0: TLRX = 0.1
     if TLRY <= 0: TLRY = 0.1
     if TRRX <= 0: TRRX = 0.1
     if TRRY <= 0: TRRY = 0.1 # path cannot handle 0
     if BLRX <= 0: BLRX = 0.1 # as rounding values
     if BLRY <= 0: BLRY = 0.1
     if BRRX <= 0: BRRX = 0.1
     if BRRY <= 0: BRRY = 0.1
     
     path = QPainterPath(QPointF(x,y))
         
     path.arcTo(x,                       y,
                TLRX * 2.0,              TLRY * 2.0,
                180.0, -90.0);
                
     path.arcTo(right - TRRX * 2.0,      y,
                TRRX * 2.0,              TRRY * 2.0,
                90.0, -90.0);
                
     path.arcTo(right - BRRX * 2.0,      bottom - BRRY * 2.0,
                BRRX * 2.0,              BRRY * 2.0,
                0.0 , -90.0);
     path.arcTo(x,                       bottom - BLRY * 2.0,
                BLRX * 2.0,    BLRY * 2.0,
                -90.0, -90.0);
     
     path.closeSubpath()
     
     return path
 def _setupPainterPath(self):
   painter_path = QPainterPath()
   painter_path.moveTo(0, 15) #left
   painter_path.lineTo(0, 0) #up
   painter_path.lineTo(self.width() - 1, 0) # right
   painter_path.lineTo(self.width() - 1, 15) # down
   painter_path.arcTo(QRect(self.width() - 6, 15, 5, 4), 0, -90) # control point1, cp2, destPoint
   painter_path.lineTo(5, 19) # left
   painter_path.arcTo(QRect(1, 15, 5, 4), 270, -90) #arc left up
   painter_path.closeSubpath()
   self._painter_path = painter_path
示例#3
0
    def _draw_serie(self, painter, ndx_serie, color):

        last_item = len(self.data) - 1

        serie = self.data[ndx_serie]

        serie_below = [0] * len(self.data[last_item])
        if ndx_serie < len(self.data) - 1:
            serie_below = self.data[ ndx_serie + 1 ]

        qlp = QPainterPath() # The top line path
        qfp = QPainterPath() # the filled region path


        x = float(0) * self.x_factor
        y = serie[0] * self.y_factor
        qlp.moveTo(self.x_base + x,self.y_base - y)
        qfp.moveTo(self.x_base + x,self.y_base - y)

        for i in range(1,len(serie)):
            x = float(i) * self.x_factor
            y = float(serie[i]) * self.y_factor

            #print i,y

            qlp.lineTo(self.x_base + x, self.y_base-y)
            qfp.lineTo(self.x_base + x, self.y_base-y)



        for i in reversed(range(0,len(serie_below))):
            x = float(i) * self.x_factor
            y = float(serie_below[i]) * self.y_factor

            qfp.lineTo(self.x_base + x, self.y_base-y)

        qfp.closeSubpath()


        fill_color = QColor(color)
        fill_color.setAlpha(64)
        brush = QBrush(fill_color)
        painter.fillPath(qfp,brush)

        pen = QPen()
        pen.setColor(color)
        if ndx_serie == self.ndx_best_serie:
            pen.setWidth(6)
        else:
            pen.setWidth(2)

        painter.setPen(pen)

        painter.drawPath(qlp)
示例#4
0
 def _setupPainterPath(self):
     painter_path = QPainterPath()
     painter_path.moveTo(0, 15)  #left
     painter_path.lineTo(0, 0)  #up
     painter_path.lineTo(self.width() - 1, 0)  # right
     painter_path.lineTo(self.width() - 1, 15)  # down
     painter_path.arcTo(QRect(self.width() - 6, 15, 5, 4), 0,
                        -90)  # control point1, cp2, destPoint
     painter_path.lineTo(5, 19)  # left
     painter_path.arcTo(QRect(1, 15, 5, 4), 270, -90)  #arc left up
     painter_path.closeSubpath()
     self._painter_path = painter_path
示例#5
0
文件: lines_chart.py 项目: wiz21b/koi
    def _draw_over_grid(self,painter):
        # painter.setRenderHint(QPainter.Antialiasing, False)

        line_color = QColor(60, 20, 200, 255)
        flat_structure = QColor(20,20,255,128)
        line_color = flat_structure

        w = min(self.height(), self.width()) / 20
        m = self.margin / 2

        x0 = m
        x1 = m + w
        x15 = m + 9*w
        x2 = self.width() - m - w
        x3 = self.width() - m

        y0 = m
        y1 = m + w
        y15 = m + 5*w
        y2 = self.height() - m - w
        y3 = self.height() - m


        # ----------------------------------------------------------------------

        d = w / 4
        p = [ (x0,y15+d),
              (x0,y1),
              (x1,y0),

              (x15+2*d,y0),     #         /
              (x15+d,y0+d),     #    ____/
              (x1,y0+d),    #   /
              (x0+d,y1),        #  |
              (x0+d,y15),       #  |
              (x0,y15+d)        # _|
        ]

        qp = QPainterPath()
        qp.moveTo( p[0][0], p[0][1],)
        for i in range(1,len(p)):
            qp.lineTo( p[i][0], p[i][1],)
        qp.closeSubpath()


        painter.fillPath(qp,QBrush(QColor(20,20,255,128)))

        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)

        pen.setColor(line_color) # alpha=255=fully opaque
        pen.setWidth(1)
        painter.setPen(pen)
        painter.drawPath(qp)

        # ---------------------------------------------------------

        qp = QPainterPath()


        p = [ (x0,y1), (x1,y0),
              (x2,y0), (x3,y1),
              (x3,y2), (x2,y3),
              (x1,y3), (x0,y2),
              (x0,y1)]

        qp.moveTo( p[0][0], p[0][1],)
        for i in range(1,len(p)):
            qp.lineTo( p[i][0], p[i][1],)

        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)
        pen.setColor(QColor(0, 0, 80, 196)) # alpha=255=fully opaque
        pen.setWidth(5)
        painter.setPen(pen)

        painter.drawPath(qp)

        pen = QPen()
        pen.setCapStyle(Qt.RoundCap)
        pen.setColor(line_color) # alpha=255=fully opaque
        pen.setWidth(1)
        painter.setPen(pen)

        painter.drawPath(qp)