X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/abbc64cf04a35ab3549d5c516f44c7c5921baa63..HEAD:/ConnectionItem.h diff --git a/ConnectionItem.h b/ConnectionItem.h index 567a31d..c4852c8 100644 --- a/ConnectionItem.h +++ b/ConnectionItem.h @@ -10,13 +10,14 @@ class Dispatcher; class Parameters; class InterfaceItem; +class GroupScene; using namespace std; using namespace Qt; -/* NOTES : +/*! \brief ConnectionItem class - A connection item represent a graphical link between two interface items. + A ConnectionItem represents a graphical link between two interface items. Even if it links two in/out interfaces, it is always oriented. The orientation depends on the type and direction of linked interfaces : @@ -37,11 +38,10 @@ class ConnectionItem : public QGraphicsItem { public: - ConnectionItem(InterfaceItem* _iface1, - InterfaceItem* _iface2, + ConnectionItem(InterfaceItem* _fromInterfaceItem, + InterfaceItem* _toInterfaceItem, Dispatcher* _dispatcher, - Parameters* _params, - QGraphicsItem* _parent); + Parameters* _params); ConnectionItem (const ConnectionItem & copy); ConnectionItem(); ~ConnectionItem(); @@ -50,18 +50,39 @@ public: QPainterPath shape() const; void prepareChange(); - + + // getters + inline GroupScene* getScene() { return (GroupScene*)(scene()); } inline InterfaceItem* getToInterfaceItem(){ return toInterfaceItem; } - inline void setToInterfaceItem(InterfaceItem *iface){ toInterfaceItem = iface; } inline InterfaceItem* getFromInterfaceItem(){ return fromInterfaceItem; } - inline void setFromInterfaceItem(InterfaceItem* iface){ fromInterfaceItem = iface; } inline int getId(){ return id; } + + // setters + inline void setToInterfaceItem(InterfaceItem *iface){ toInterfaceItem = iface; } + inline void setFromInterfaceItem(InterfaceItem* iface){ fromInterfaceItem = iface; } inline void setId(int id){ this->id = id; } - inline bool isSelected() { return selected; } void setSelected(bool selected); - + inline void setVisible(bool state) { visible = state; } + + // testers + inline bool isSelected() { return selected; } + inline bool isVisible() { return visible; } + + // others void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - void setPathes(); + + /*! + * \brief setPath + * setPath() allows to compute the graphical shape of the ConnectionItem + * taking into account the position/direction of from and to interface items. + * Depending on their vlaue, it calls on of the dedicated methods. + * + * CAUTION: this method calls prepareGeometryChange() so that the scene + * can automatically updates and redraw the ConnectionItem. Thus, there is + * no need to call update() after the termination of this method. + * + */ + void setPath(); void addInterPoint(QPointF point); static int counter; @@ -73,7 +94,14 @@ protected: void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); private: - + void computeEsse(int orientationFrom); + void computeStaircase(int orientationFrom); + void computeHookSmallEnd(int orientationFrom, int orientationTo); + void computeHookSmallStart(int orientationFrom, int orientationTo); + void computeOpenRect(int orientationFrom, int orientationTo); + void computeElle(int orientationFrom); + void computeCorner(int orientationFrom); + QPointF pointFrom; QPointF pointTo; QList interPoints; @@ -92,13 +120,8 @@ private: bool selected; int id; int marginConn; - void computeEsse(int orientationFrom); - void computeStaircase(int orientationFrom); - void computeHookSmallEnd(int orientationFrom, int orientationTo); - void computeHookSmallStart(int orientationFrom, int orientationTo); - void computeOpenRect(int orientationFrom, int orientationTo); - void computeElle(int orientationFrom); - void computeCorner(int orientationFrom); + + bool visible; friend QDataStream &operator << (QDataStream &out, ConnectionItem &c); friend QDataStream &operator >> (QDataStream &in, ConnectionItem &c);