コード例 #1
0
 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)
コード例 #2
0
ファイル: shape.py プロジェクト: x0rzkov/semiauto-annotate
 def get_line_path(points, shape_type):
     line_path = QPainterPath()
     if shape_type == 'rectangle' and len(points) == 2:
         rectangle = Shape.getRectFromLine(*points)
         line_path.addRect(rectangle)
     elif shape_type == 'circle' and len(points) == 2:
         rectangle = Shape.getCircleRectFromLine(points)
         line_path.addEllipse(rectangle)
     elif shape_type == 'linestrip' and points:
         line_path.moveTo(points[0])
         for p in points:
             line_path.lineTo(p)
     elif shape_type in ['curve', 'freeform'] and points:
         # Paint Bezier curve across given points.
         refined_points = BezierB(points).smooth()
         line_path.moveTo(refined_points[0])
         for p in refined_points:
             line_path.lineTo(p)
     elif points:
         line_path.moveTo(points[0])
         for p in points:
             line_path.lineTo(p)
         if shape_type == 'polygon':
             line_path.lineTo(points[0])
     return line_path
コード例 #3
0
ファイル: shape.py プロジェクト: x0rzkov/semiauto-annotate
 def paint_vertices(painter,
                    points,
                    scale,
                    highlight=None,
                    highlight_mode=None):
     path = QPainterPath()
     if highlight is not None:
         vertex_fill_color = Shape.hvertex_fill_color
     else:
         vertex_fill_color = Shape.vertex_fill_color
     for i, point in enumerate(points):
         d = Shape.point_size / scale
         shape = Shape.def_point_type
         if i == highlight:
             size, shape = Shape._highlightSettings[highlight_mode]
             d *= size
         if shape == Shape.P_SQUARE:
             path.addRect(point.x() - d / 2, point.y() - d / 2, d, d)
         elif shape == Shape.P_ROUND:
             path.addEllipse(point, d / 2.0, d / 2.0)
         else:
             assert False, 'unsupported vertex shape'
     painter.drawPath(path)
     painter.fillPath(path, vertex_fill_color)
コード例 #4
0
 def shape(self):
     path = QPainterPath()
     path.addEllipse(self.boundingRect())
     return path