nodeeditor_doxy
src/Impl/nodeconnection.h
Go to the documentation of this file.
00001 #ifndef CONNECTION_H
00002 #define CONNECTION_H
00003 
00004 #include <QGraphicsLineItem>
00005 #include "NodeItem.h"
00006 #include "nodeconnector.h"
00007 
00008 QT_BEGIN_NAMESPACE
00009 class QGraphicsPolygonItem;
00010 class QGraphicsLineItem;
00011 class QGraphicsScene;
00012 class QRectF;
00013 class QGraphicsSceneMouseEvent;
00014 class QPainterPath;
00015 QT_END_NAMESPACE
00016 
00017 class NodeConnector;
00018 
00020 class NodeConnection : public QGraphicsPathItem
00021 {
00022 public:
00023     enum { Type = UserType + 666 + 0 };
00024         int type() const
00025         { return Type;}
00026 
00027         virtual ~NodeConnection();
00028     NodeConnection(NodeConnector *startConnector, NodeConnector *endConnector,
00029       QGraphicsItem *parent = 0, QGraphicsScene *scene = 0, bool bidirectional = true);
00030 
00031     QRectF boundingRect() const;
00032     QPainterPath shape() const;
00033     void setColor(const QColor &color)
00034         { mColor = color; }
00035     NodeConnector *startConnector() const
00036         { return mStartConnector; }
00037     NodeConnector *endConnector() const
00038         { return mEndConnector; }
00039 
00040         void updatePosition();
00041 
00042         bool bidirectional();
00043         bool setBidirectional(bool bidirectional);
00044 
00045 protected:
00046     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
00047                QWidget *widget = 0);
00048 
00049         //returns used/created control points (eg for debug draw,...)
00050         void recreatePath(QPointF& controlPoint1, QPointF& controlPoint2);
00051         QPolygonF createArrowPoly(QPainterPath& p, NodeConnector* conn);
00052 
00053 private:
00054     NodeConnector *mStartConnector;
00055     NodeConnector *mEndConnector;
00056     QColor mColor;
00057     
00058         qreal arrowSize;
00059         bool mBidirectional;
00060 
00061         void debugPaint(QPainter *painter, QPointF& controlPoint1, QPointF& controlPoint2);
00062 
00063 
00064 };
00066 
00067 #endif