X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/1b7818e18ed7bcf3464e307b97c6e0e6d72cc69b..8fb3c55ee009a11db5e1c08a4cfb286979412745:/AbstractBoxItem.h diff --git a/AbstractBoxItem.h b/AbstractBoxItem.h index 84a4fbc..d0965cf 100644 --- a/AbstractBoxItem.h +++ b/AbstractBoxItem.h @@ -9,6 +9,7 @@ class Dispatcher; class InterfaceItem; +#include "Parameters.h" class Parameters; class AbstractBlock; class GroupScene; @@ -16,18 +17,23 @@ class ConnectedInterface; #define ABI_TO_BI(ptr) ((BoxItem*)ptr) #define ABI_TO_GI(ptr) ((GroupItem*)ptr) -#define ABI_TO_SI(ptr) ((SourceItem*)ptr) +#define ABI_TO_SI(ptr) ((StimuliItem*)ptr) class AbstractBoxItem : public QGraphicsItem { public: enum BorderType { NoBorder = 0, BorderEast, BorderNorth, BorderWest, BorderSouth, CornerSouthEast, Title}; - enum ChangeType { Resize = 0, InterfaceMove }; - enum LockType { NoLock = 0, Position = 1, Dimension = 2, Interfaces = 4, Names = 8}; + enum ChangeType { Creation = 0, Resize, InterfaceMove }; - AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, LockType _lock = NoLock, QGraphicsItem* parent = Q_NULLPTR); - AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, LockType _lock = NoLock, QGraphicsItem* parent = Q_NULLPTR); + static int NoLock; + static int Position; + static int Dimension; + static int Interfaces; + static int Names; + + AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, int _lock = NoLock, QGraphicsItem* parent = Q_NULLPTR); + AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, int _lock = NoLock, QGraphicsItem* parent = Q_NULLPTR); virtual ~AbstractBoxItem(); @@ -44,6 +50,8 @@ public: inline int getIfaceMargin() { return ifaceMargin; } inline int getNameMargin() { return nameMargin; } inline QPointF getOriginPoint() { return originPoint; } + inline int getMinimumBoxWidth() { return minimumBoxWidth; } + inline int getMinimumBoxHeight() { return minimumBoxHeight; } // setters void setRefBlock(AbstractBlock* _refBlock); @@ -52,6 +60,8 @@ public: void setRstClkVisible(bool b); void setWishboneVisible(bool b); void setDimension(int x, int y); + inline void setWidth(int width) { boxWidth = width; } + inline void setHeight(int height) {boxHeight = height; } inline void setCurrentInterface(InterfaceItem* iface) { currentInterface = iface; } inline void setLock(int _lock) { lock = _lock; } inline void lockPosition() { lock = lock | Position; } @@ -66,7 +76,7 @@ public: // testers virtual bool isBoxItem(); virtual bool isGroupItem(); - virtual bool isSourceItem(); + virtual bool isStimuliItem(); inline bool isSelected() { return selected; } inline bool isRstClkVisible(){ return rstClkVisible;} inline bool isWishboneVisible(){ return wishboneVisible;} @@ -109,6 +119,8 @@ public: InterfaceItem *searchInterfaceItemByRef(ConnectedInterface* ref); InterfaceItem* getInterfaceItemFromCursor(qreal x, qreal y); + QRectF boundingRect() const; + protected: Dispatcher *dispatcher; Parameters *params; @@ -146,13 +158,13 @@ protected: virtual void updateMinimumSize() = 0; // modify the minimum size virtual bool updateGeometry(ChangeType type) = 0; // modify the originPoint and the total dimension - QRectF boundingRect() const; + /* pure virtual method inherited from QGraphicsItem : virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) =0; virtual QRectF boundingRect() const =0; */ - void initInterfaceItems(); + void createInterfaceItems(Parameters::Direction posInputs = Parameters::West, Parameters::Direction posOutputs = Parameters::East, Parameters::Direction posBidirs = Parameters::South); int nbInterfacesByOrientation(int orientation); };