00001 #ifndef DISPLAYEDGE_H 00002 #define DISPLAYEDGE_H 00003 00004 00005 #include <QGraphicsItem> 00006 00007 00008 class DisplayNode; 00009 00018 class DisplayEdge : public QGraphicsItem 00019 { 00020 public: 00021 DisplayEdge(DisplayNode * from, DisplayNode * to); 00022 virtual ~DisplayEdge() {} 00023 00024 DisplayNode *sourceNode() const { return source; } 00025 DisplayNode *destNode() const { return dest; } 00026 00028 void adjust(); 00029 00032 enum { EdgeType = UserType + 2 }; 00033 int type() const { return EdgeType; } 00034 00036 void setColor(const QColor & c) { color=c; } 00038 void setWidth(double width) { penWidth=1; } 00039 00040 enum PaintMode { STRAIGHT, 00041 RECTANGULAR, 00042 BEZIER_QUAD, 00043 BEZIER_CUBIC 00044 }; 00045 00047 void setPaintMode(PaintMode m) { paintMode=m; } 00048 00049 00050 void setEdgeLabel(const QString & label); 00051 const QString & getEdgeLabel() const { return edgeLabel; } 00052 00053 protected: 00054 void setSourceNode(DisplayNode *node) { source=node; adjust(); } 00055 void setDestNode (DisplayNode *node) { dest=node; adjust(); } 00056 00057 00058 00059 QRectF boundingRect() const; 00060 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 00061 00062 00063 private: 00064 bool intersectPolyWithLine(QPointF & res, const QPolygonF & poly, const QLineF & l); 00065 00066 DisplayNode * source; 00067 DisplayNode * dest; 00068 00069 QPointF sourcePoint; 00070 QPointF destPoint; 00071 00072 PaintMode paintMode; 00073 00074 QString edgeLabel; 00075 00076 double arrowSize; 00077 00078 double penWidth; 00079 00080 QColor color; 00081 }; 00082 00083 #endif
1.4.7