You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
799 B
39 lines
799 B
11 years ago
|
#ifndef NODE_H
|
||
|
#define NODE_H
|
||
|
|
||
|
#include <QtGui/QGraphicsItem>
|
||
|
#include <QtCore/QList>
|
||
|
|
||
|
class Edge;
|
||
|
class GraphWidget;
|
||
|
class QGraphicsSceneMouseEvent;
|
||
|
|
||
|
class Node : public QGraphicsItem
|
||
|
{
|
||
|
public:
|
||
|
Node(GraphWidget *graphWidget);
|
||
|
|
||
|
void addEdge(Edge *edge);
|
||
|
QList<Edge *> edges() const;
|
||
|
|
||
|
enum { Type = UserType + 1 };
|
||
|
int type() const { return Type; }
|
||
|
|
||
|
QRectF boundingRect() const;
|
||
|
QPainterPath shape() const;
|
||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||
|
|
||
|
protected:
|
||
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||
|
|
||
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||
|
|
||
|
private:
|
||
|
QList<Edge *> edgeList;
|
||
|
QPointF newPos;
|
||
|
GraphWidget *graph;
|
||
|
};
|
||
|
|
||
|
#endif
|