X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/d111eaf49741a0a79d372445f97c314a637e331e..2bdaa0aa3fab52f0808f60d9bbdabcd56d0efae9:/AbstractBoxItem.h?ds=inline diff --git a/AbstractBoxItem.h b/AbstractBoxItem.h index fe08535..e490088 100644 --- a/AbstractBoxItem.h +++ b/AbstractBoxItem.h @@ -9,20 +9,31 @@ class Dispatcher; class InterfaceItem; +#include "Parameters.h" class Parameters; class AbstractBlock; class GroupScene; class ConnectedInterface; +#define ABI_TO_BI(ptr) ((BoxItem*)ptr) +#define ABI_TO_GI(ptr) ((GroupItem*)ptr) +#define ABI_TO_SI(ptr) ((SourceItem*)ptr) + class AbstractBoxItem : public QGraphicsItem { public: enum BorderType { NoBorder = 0, BorderEast, BorderNorth, BorderWest, BorderSouth, CornerSouthEast, Title}; - enum ChangeType { Resize = 0, InterfaceMove }; + enum ChangeType { Creation = 0, Resize, InterfaceMove }; + + static int NoLock; + static int Position; + static int Dimension; + static int Interfaces; + static int Names; - AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent = Q_NULLPTR); - AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent = Q_NULLPTR); + 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(); @@ -39,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); @@ -47,7 +60,18 @@ 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; } + inline void unlockPosition() { lock = (lock&Position)^lock; } + inline void lockDimension() { lock = lock | Dimension; } + inline void unlockDimension() { lock = (lock&Dimension)^lock; } + inline void lockInterfaces() { lock = lock | Interfaces; } + inline void unlockInterfaces() { lock = (lock&Interfaces)^lock; } + inline void lockNames() { lock = lock | Names; } + inline void unlockNames() { lock = (lock&Names)^lock; } // testers virtual bool isBoxItem(); @@ -57,13 +81,16 @@ public: inline bool isRstClkVisible(){ return rstClkVisible;} inline bool isWishboneVisible(){ return wishboneVisible;} bool isInterfaces(int orientation) const; - + inline bool isPositionLock() { return (lock&Position)!=0?true:false; } + inline bool isDimensionLock() { return (lock&Dimension)!=0?true:false; } + inline bool isInterfacesLock() { return (lock&Interfaces)!=0?true:false; } + inline bool isNamesLock() { return (lock&Names)!=0?true:false; } // others QRectF boundingRectInScene(); virtual void nameChanged() = 0; // called when an interface or box name have changed - void addInterface(InterfaceItem* i, bool resetPosition = false); - void removeInterface(InterfaceItem* i); - void resetInterfacesPosition(); + void addInterfaceItem(InterfaceItem* i, bool resetPosition = false); + void removeInterfaceItem(InterfaceItem* i); + void resetInterfaceItemsPosition(); /*! * \brief moveInterfaceTo * \param pos the new position (in scene) of the interface @@ -71,7 +98,7 @@ public: * This method is called when user moves an InterfaceItem. * see BoxItem::mouseMoveEvent() and GroupItem::mouseMoveEvent() */ - void moveInterfaceTo(QPointF pos); + void moveInterfaceItemTo(QPointF pos); /*! * \brief updateInterfacesAndConnections * @@ -86,11 +113,13 @@ public: * that is called in this method. Thus, there is no need to call update() after the termination of * this method. */ - void updateInterfacesAndConnections(); + void updateInterfaceAndConnectionItems(); - InterfaceItem *searchInterfaceByName(QString name); - InterfaceItem *searchInterfaceByRef(ConnectedInterface* ref); - InterfaceItem* getInterfaceFromCursor(qreal x, qreal y); + InterfaceItem *searchInterfaceItemByName(QString name); + InterfaceItem *searchInterfaceItemByRef(ConnectedInterface* ref); + InterfaceItem* getInterfaceItemFromCursor(qreal x, qreal y); + + QRectF boundingRect() const; protected: Dispatcher *dispatcher; @@ -119,6 +148,7 @@ protected: int ifaceMargin; // the margin around each side of interfaces' name QPointF originPoint; // the left-top point that is the origin of the bounding box, in the item coordinates + int lock; bool selected; bool rstClkVisible; //! true if clock/reset interfaces are visible bool wishboneVisible; //! true if wishbone interfaces are visible @@ -128,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 initInterfaces(); + void createInterfaceItems(Parameters::Direction posInputs = Parameters::West, Parameters::Direction posOutputs = Parameters::East, Parameters::Direction posBidirs = Parameters::South); int nbInterfacesByOrientation(int orientation); };