def drawValue(self, p: QPainter, baseRect: QRectF, value: float, delta: float):
     if value == self.m_min:
         return
     if self.m_barStyle == self.BarStyle.EXPAND:
         p.setBrush(self.palette().highlight())
         p.setPen(QPen(self.palette().shadow().color(), self.m_dataPenWidth))
         radius = (baseRect.height() / 2) / delta
         p.drawEllipse(baseRect.center(), radius, radius)
         return
     if self.m_barStyle == self.BarStyle.LINE:
         p.setPen(QPen(self.palette().highlight().color(), self.m_dataPenWidth))
         p.setBrush(Qt.NoBrush)
         if value == self.m_max:
             p.drawEllipse(baseRect.adjusted(self.m_outlinePenWidth / 2, self.m_outlinePenWidth / 2,
                                             -self.m_outlinePenWidth / 2, -self.m_outlinePenWidth / 2))
         else:
             arcLength = 360 / delta
             p.drawArc(baseRect.adjusted(self.m_outlinePenWidth / 2, self.m_outlinePenWidth / 2,
                                         -self.m_outlinePenWidth / 2, -self.m_outlinePenWidth / 2),
                       int(self.m_nullPosition * 16),
                       int(-arcLength * 16))
         return
     dataPath = QPainterPath()
     dataPath.setFillRule(Qt.WindingFill)
     if value == self.m_max:
         dataPath.addEllipse(baseRect)
     else:
         arcLength = 360 / delta
         dataPath.moveTo(baseRect.center())
         dataPath.arcTo(baseRect, self.m_nullPosition, -arcLength)
         dataPath.lineTo(baseRect.center())
     p.setBrush(self.palette().highlight())
     p.setPen(QPen(self.palette().shadow().color(), self.m_dataPenWidth))
     p.drawPath(dataPath)
 def drawBase(self, p: QPainter, baseRect: QRectF):
     if self.m_barStyle == self.BarStyle.DONUT:
         p.setPen(QPen(self.palette().shadow().color(), self.m_outlinePenWidth))
         p.setBrush(self.palette().base())
         p.drawEllipse(baseRect)
     elif self.m_barStyle == self.BarStyle.LINE:
         p.setPen(QPen(self.palette().base().color(), self.m_outlinePenWidth))
         p.setBrush(Qt.NoBrush)
         p.drawEllipse(baseRect.adjusted(self.m_outlinePenWidth / 2, self.m_outlinePenWidth / 2,
                                         -self.m_outlinePenWidth / 2, -self.m_outlinePenWidth / 2))
     elif self.m_barStyle in (self.BarStyle.PIE, self.BarStyle.EXPAND):
         p.setPen(QPen(self.palette().base().color(), self.m_outlinePenWidth))
         p.setBrush(self.palette().base())
         p.drawEllipse(baseRect)
예제 #3
0
 def get_shapes_bounding_rect(shapes, margin=0.0):
     rects = [shape.boundingRect() for shape in shapes]
     reduced = QRectF()
     for rect in rects:
         reduced = reduced.united(rect)
     return reduced.adjusted(-margin, -margin, margin, margin)