def draw_path(self, cp): self.cr.pen().setCapStyle(QtCore.Qt.RoundCap) pts = [ QtCore.QLineF(QtCore.QPointF(cp[i][0], cp[i][1]), QtCore.QPointF(cp[i + 1][0], cp[i + 1][1])) for i in range(len(cp) - 1) ] self.cr.drawLines(pts)
def draw_arrowhead(self, cr, x1, y1, x2, y2): i1, j1, i2, j2 = self.calcVertexes(x1, y1, x2, y2) self.fill(cr, True) cr.pen().setJoinStyle(QtCore.Qt.MiterJoin) cr.drawPolygon( QtGui.QPolygonF([ QtCore.QPointF(x2, y2), QtCore.QPointF(i1, j1), QtCore.QPointF(i2, j2) ])) cr.pen().setJoinStyle(QtCore.Qt.BevelJoin) self.fill(cr, False)
def draw_arrowhead(self, cr, x1, y1, x2, y2): i1, j1, i2, j2 = self.calcVertexes(x1, y1, x2, y2) alpha = getattr(self, 'alpha', 1.0) self.set_fill(cr, True, alpha=alpha) cr.pen().setJoinStyle(QtCore.Qt.MiterJoin) cr.drawPolygon( QPolygonF([ QtCore.QPointF(x2, y2), QtCore.QPointF(i1, j1), QtCore.QPointF(i2, j2) ])) cr.pen().setJoinStyle(QtCore.Qt.BevelJoin) self.set_fill(cr, False)
def draw(self): cx1, cy1, cradius = self.calc_radius(self.x, self.y, self.radius) # this is necessary to work around a bug in Qt--radius of 0 # causes a crash cradius = max(cradius, 0.000001) cr = self.setup_cr() pt = QtCore.QPointF(cx1, cy1) cr.drawEllipse(pt, float(cradius), float(cradius)) if self.editing: self.draw_edit(cr) elif self.showcap: self.draw_caps(cr, self.cap, ((cx1, cy1), ))
def draw_circle(self, cx, cy, cradius): # this is necessary to work around a bug in Qt--radius of 0 # causes a crash cradius = max(cradius, 0.000001) pt = QtCore.QPointF(cx, cy) self.cr.drawEllipse(pt, float(cradius), float(cradius))