#ifndef NODE_H #define NODE_H #include #include class Edge; class GraphWidget; class QGraphicsSceneMouseEvent; class Node : public QGraphicsItem { public: Node(GraphWidget *graphWidget, qreal radius = 0.2); void addEdge(Edge *edge); void removeEdge(Edge* edge); QList edges() const; Edge* edgeTo(const Node* n) const; enum { Type = UserType + 1 }; int type() const override { return Type; } 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: QList edgeList; GraphWidget *m_graphWidget; qreal m_radius; }; #endif