Esempio n. 1
0
class Shape():
	def __init__(self, nbp, list_of_points):
		self.shape = QPolygonF(nbp)
		for i in range(nbp):
			pt = list_of_points[i]
			self.shape.replace(i, QPointF(pt[0], pt[1]))
		self.nbp = nbp
Esempio n. 2
0
 def drawPolygon(self, refPolygon, painter):
     # Scale coordinates
     draw = QPolygonF(refPolygon.size())
     for i in range(refPolygon.size()):
         curr = QPointF()
         curr.setX(self.refToScreenX(refPolygon.at(i).x()))
         curr.setY(self.refToScreenY(refPolygon.at(i).y()))
         draw.replace(i, curr)
     painter.drawPolygon(draw)
Esempio n. 3
0
 def rotatePolygonClockWiseRad(self, p: QPolygonF, angle, origin):
     '''
     Rotate a polygon around a point
     :param p: polygon to rotate
     :param origin: the rotation center
     :param angle: rotation angle, in radians
     :return p: Polygon p rotated by angle around the origin point
     '''
     for i in range(p.size()):
         curr = p.at(i)
         x = curr.x()
         y = curr.y()
         curr.setX(((cos(angle) * (x-origin.x())) + (-sin(angle) * (y-origin.y()))) + origin.x())
         curr.setY(((sin(angle) * (x-origin.x())) + (cos(angle) * (y-origin.y()))) + origin.y())
         p.replace(i, curr)
Esempio n. 4
0
    def drawChangeIndicatorGauge(self, xRef, yRef, radius, expectedMaxChange, value, color, painter, solid):
        # Draw the circle
        circlePen = QPen(Qt.SolidLine)
        if solid == False:
            circlePen.setStyle(Qt.DotLine)
        circlePen.setColor(self.defaultColor)
        circlePen.setWidth(self.refLineWidthToPen(2.0))
        painter.setBrush(Qt.NoBrush)
        painter.setPen(circlePen)
        self.drawCircle(xRef, yRef, radius, 200.0, 170.0, 1.5, color, painter)

        label = '{:05.1f}'.format(value)

        _textSize = radius / 2.5

        # Draw the value
        self.paintText(label, color, _textSize, xRef-_textSize*1.7, yRef-_textSize*0.4, painter)

        # Draw the needle
        # Scale the rotation so that the gauge does one revolution
        # per max. change
        _rangeScale = (2.0 * M_PI) / expectedMaxChange
        _maxWidth = radius / 10.0
        _minWidth = _maxWidth * 0.3

        p = QPolygonF(6)
        p.replace(0, QPointF(xRef-_maxWidth/2.0, yRef-radius * 0.5))
        p.replace(1, QPointF(xRef-_minWidth/2.0, yRef-radius * 0.9))
        p.replace(2, QPointF(xRef+_minWidth/2.0, yRef-radius * 0.9))
        p.replace(3, QPointF(xRef+_maxWidth/2.0, yRef-radius * 0.5))
        p.replace(4, QPointF(xRef,              yRef-radius * 0.46))
        p.replace(5, QPointF(xRef-_maxWidth/2.0, yRef-radius * 0.5))

        self.rotatePolygonClockWiseRad(p, value*_rangeScale, QPointF(xRef, yRef))

        indexBrush = QBrush()
        indexBrush.setColor(self.defaultColor)
        indexBrush.setStyle(Qt.SolidPattern)
        painter.setPen(Qt.SolidLine)
        painter.setPen(self.defaultColor)
        painter.setBrush(indexBrush)
        self.drawPolygon(p, painter)