38 setAcceptedMouseButtons(
nullptr);
41 source->addEdge(
this);
77 QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0));
78 qreal length = line.length();
80 prepareGeometryChange();
82 if (length > qreal(20.)) {
83 QPointF edgeOffset((line.dx() * 13) / length, (line.dy() * 13) / length);
84 sourcePoint = line.p1() + edgeOffset;
85 destPoint = line.p2() - edgeOffset;
87 sourcePoint = destPoint = line.p1();
97 qreal extra = (penWidth + arrowSize) / 2.0;
99 return QRectF(sourcePoint,
100 QSizeF(destPoint.x() - sourcePoint.x(), destPoint.y() - sourcePoint.y()))
102 .adjusted(-extra, -extra, extra, extra);
105 void Edge::paint(QPainter *painter,
const QStyleOptionGraphicsItem *, QWidget *)
107 if (!source || !dest)
110 QLineF line(sourcePoint, destPoint);
111 if (qFuzzyCompare(line.length(), qreal(0.)))
115 painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
116 painter->drawLine(line);