-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqnode.h
48 lines (35 loc) · 1.05 KB
/
qnode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef QNODE_H
#define QNODE_H
#include <QGraphicsItem>
#include <QList>
class QEdge;
class QGraphWidget;
QT_BEGIN_NAMESPACE
class QGraphicsSceneMouseEvent;
QT_END_NAMESPACE
//! [0]
class QNode : public QGraphicsItem
{
public:
QNode(QGraphWidget *graphWidget);
void addEdge(QEdge *edge);
QList<QEdge *> edges() const;
enum { Type = UserType + 1 };
int type() const override { return Type; }
void calculateForces();
bool advancePosition();
QRectF boundingRect() const override;
QPainterPath shape() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
QString nodeName;
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
private:
QList<QEdge *> edgeList;
QPointF newPos;
QGraphWidget *graph;
};
//! [0]
#endif // QNODE_H