55 #include <QGraphicsScene>
56 #include <QGraphicsSceneMouseEvent>
58 #include <QStyleOption>
87 if (!
scene() ||
scene()->mouseGrabberItem() ==
this) {
106 double l = 2.0 * (dx * dx + dy * dy);
108 xvel += (dx * 150.0) /
l;
109 yvel += (dy * 150.0) /
l;
117 for (
const Edge *edge : qAsConst(edgeList)) {
119 if (edge->sourceNode() ==
this)
129 if (
qAbs(xvel) < 0.1 &&
qAbs(yvel) < 0.1)
136 newPos.
setX(qMin(qMax(newPos.
x(), sceneRect.
left() + 10), sceneRect.
right() - 10));
137 newPos.
setY(qMin(qMax(newPos.
y(), sceneRect.
top() + 10), sceneRect.
bottom() - 10));
156 return QRectF( -10 - adjust, -10 - adjust, 23 + adjust, 23 + adjust);
164 path.addEllipse(-10, -10, 20, 20);
198 for (
Edge *edge : qAsConst(edgeList))
QRectF boundingRect() const override
[7]
bool advancePosition()
[6]
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
[9]
void calculateForces()
[1]
QPainterPath shape() const override
[8]
void addEdge(Edge *edge)
[0]
QList< Edge * > edges() const
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
[11]
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
[10]
The QColor class provides colors based on RGB, HSV or CMYK values.
void setColorAt(qreal pos, const QColor &color)
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QPointF mapToItem(const QGraphicsItem *item, const QPointF &point) const
void update(const QRectF &rect=QRectF())
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
QGraphicsScene * scene() const
@ ItemSendsGeometryChanges
void setPos(const QPointF &pos)
void setCacheMode(CacheMode mode, const QSize &cacheSize=QSize())
void setFlag(GraphicsItemFlag flag, bool enabled=true)
QList< QGraphicsItem * > items(Qt::SortOrder order=Qt::DescendingOrder) const
QRectF sceneRect
the scene rectangle; the bounding rectangle of the scene
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
qsizetype size() const noexcept
The QPainter class performs low-level painting on widgets and other paint devices.
void setPen(const QColor &color)
void drawEllipse(const QRectF &r)
void setBrush(const QBrush &brush)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
The QPen class defines how a QPainter should draw lines and outlines of shapes.
The QPointF class defines a point in the plane using floating point precision.
constexpr qreal x() const noexcept
constexpr qreal y() const noexcept
constexpr void setY(qreal y) noexcept
constexpr void setX(qreal x) noexcept
The QRadialGradient class is used in combination with QBrush to specify a radial gradient brush.
void setCenter(const QPointF ¢er)
void setFocalPoint(const QPointF &focalPoint)
The QRectF class defines a finite rectangle in the plane using floating point precision.
constexpr qreal bottom() const noexcept
constexpr qreal left() const noexcept
constexpr qreal top() const noexcept
constexpr qreal right() const noexcept
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem.
The QVariant class acts like a union for the most common Qt data types.
EGLOutputLayerEXT EGLint EGLAttrib value
QT_END_INCLUDE_NAMESPACE typedef double qreal
GLuint GLuint GLfloat weight
GLsizei const GLchar *const * path