forked from FahimaNoor/MinimumSpanningTree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.h
43 lines (31 loc) · 973 Bytes
/
node.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
#ifndef NODE_H
#define NODE_H
#include <QGraphicsItem>
#include <QVector>
class Edge;
class GraphWidget;
//! [0]
class Node : public QGraphicsItem
{
public:
Node(GraphWidget *graphWidget);
int numberOfNodes;
void addEdge(Edge *edge);
QVector<Edge *> edges() const;
enum { Type = UserType + 1 };
int type() const override { return Type; }
bool advancePosition();
QRectF boundingRect() const override;
QPainterPath shape() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
private:
QVector<Edge *> edgeList;
QPointF newPos;
GraphWidget *graph;
};
//! [0]
#endif // NODE_H