def bg_item(self): """return a canvas item for the shape in the background""" bg = QtWidgets.QGraphicsPolygonItem() poly = QtGui.QPolygonF() poly.append(QtCore.QPointF(-5, 5)) poly.append(QtCore.QPointF(15, -5)) poly.append(QtCore.QPointF(35, 5)) poly.append(QtCore.QPointF(15, 15)) bg.setPolygon(poly) return bg
def setLine(self, x0, y0, x1, y1, hierarchyLink=False): self.line.setLine(x0, y0, x1, y1) x, y = x1 - (x1 - x0) / 3., y1 - (y1 - y0) / 3. if not hierarchyLink: r = 12. else: r = 6. a = atan2(y1 - y0, x1 - x0) w = 2.79252680 pts = [ QtCore.QPointF(x, y), QtCore.QPointF(x + r * cos(a + w), y + r * sin(a + w)), QtCore.QPointF(x + r * cos(a - w), y + r * sin(a - w)), # QtCore.QPointF(x, y), ] self.head.setPolygon(QtGui.QPolygonF(pts))