00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ORIENTEDEDGEITEM_H
00022 #define ORIENTEDEDGEITEM_H
00023
00024 #include <QGraphicsLineItem>
00025
00026 class QGraphicsSceneMouseEvent;
00027 class Edge;
00028 class Node;
00029 class QGraphicsSimpleTextItem;
00030
00034 class OrientedEdgeItem : public QObject, public QGraphicsPathItem
00035 {
00036 Q_OBJECT
00037 public:
00041 explicit OrientedEdgeItem( Edge* edge, QGraphicsItem* parent = 0 );
00042 virtual ~OrientedEdgeItem();
00044 enum { Type = UserType + 3 };
00045
00049 int type() const
00050 {
00051 return Type;
00052 }
00053
00055 Edge* edge()
00056 {
00057 return _edge;
00058 }
00059
00060 protected:
00064 void mousePressEvent( QGraphicsSceneMouseEvent* event );
00065
00069 void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
00070
00071 void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );
00072
00073 public slots:
00074 void remove();
00075 void updatePos();
00076 void updateAttributes();
00077 private:
00078 Edge* _edge;
00079 int _index;
00080 bool _loop;
00081 QPainterPath createCurves() const;
00082 QPolygonF createArrow( const QPointF& Pos1, const QPointF& Pos2 ) const;
00083 QPainterPath createLoop( QPointF pos ) const;
00084 void connectSignals();
00085
00086 QGraphicsSimpleTextItem* _name;
00087 QGraphicsSimpleTextItem* _value;
00088 };
00089
00090 #endif