1 #ifndef __CONNECTIONITEM_H__
2 #define __CONNECTIONITEM_H__
8 #include <QGraphicsItem>
19 A connection item represent a graphical link between two interface items.
20 Even if it links two in/out interfaces, it is always oriented.
21 The orientation depends on the type and direction of linked interfaces :
23 If interfaces are owned by blocks (group or func) that are within the same
24 parent group, then src must be an output, and dest an input, or both are in/out
25 and src/dest may be interchanged.
27 If one interface I1 is owend by a block, and the other I2 by the parent group of that block,
28 then they have the same direction. If this direction is input, then src = I2 and dest = I1,
29 if it is output, then src = I1, dest = I2, and if it is in/out, no order matters.
31 In order to simplify other methods, the constructor of ConnectionItem
32 checks these cases in order to retrieve the good src and dest if they are
33 not provided in the good order.
36 class ConnectionItem : public QGraphicsItem {
40 ConnectionItem(InterfaceItem* _iface1,
41 InterfaceItem* _iface2,
42 Dispatcher* _dispatcher,
44 QGraphicsItem* _parent);
45 ConnectionItem (const ConnectionItem & copy);
49 QRectF boundingRect() const;
50 QPainterPath shape() const;
54 inline InterfaceItem* getToInterfaceItem(){ return toInterfaceItem; }
55 inline void setToInterfaceItem(InterfaceItem *iface){ toInterfaceItem = iface; }
56 inline InterfaceItem* getFromInterfaceItem(){ return fromInterfaceItem; }
57 inline void setFromInterfaceItem(InterfaceItem* iface){ fromInterfaceItem = iface; }
58 inline int getId(){ return id; }
59 inline void setId(int id){ this->id = id; }
60 inline bool isSelected() { return selected; }
61 void setSelected(bool selected);
63 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
65 void addInterPoint(QPointF point);
70 void mousePressEvent(QGraphicsSceneMouseEvent *event);
71 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
72 void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
73 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
79 QList<QPointF> interPoints;
85 QPainterPath pathPaint;
86 QPainterPath pathShape;
87 QPainterPathStroker pps;
88 Dispatcher* dispatcher;
90 InterfaceItem* fromInterfaceItem;
91 InterfaceItem* toInterfaceItem;
95 void computeEsse(int orientationFrom);
96 void computeStaircase(int orientationFrom);
97 void computeHookSmallEnd(int orientationFrom, int orientationTo);
98 void computeHookSmallStart(int orientationFrom, int orientationTo);
99 void computeOpenRect(int orientationFrom, int orientationTo);
100 void computeElle(int orientationFrom);
101 void computeCorner(int orientationFrom);
103 friend QDataStream &operator << (QDataStream &out, ConnectionItem &c);
104 friend QDataStream &operator >> (QDataStream &in, ConnectionItem &c);