X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/d111eaf49741a0a79d372445f97c314a637e331e..bc5d59217a24b25c1b913bec4a41dd026d02720c:/AbstractBoxItem.cpp?ds=inline diff --git a/AbstractBoxItem.cpp b/AbstractBoxItem.cpp index 391f795..0a82055 100644 --- a/AbstractBoxItem.cpp +++ b/AbstractBoxItem.cpp @@ -12,11 +12,17 @@ #include "AbstractInterface.h" #include "ConnectedInterface.h" +int AbstractBoxItem::NoLock = 0; +int AbstractBoxItem::Position = 1; +int AbstractBoxItem::Dimension = 2; +int AbstractBoxItem::Interfaces = 4; +int AbstractBoxItem::Names = 8; -AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem *parent) : QGraphicsItem(parent) { +AbstractBoxItem::AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, int _lock, QGraphicsItem *parent) : QGraphicsItem(parent) { dispatcher = _dispatcher; params = _params; refBlock = _refBlock; + lock = _lock; QFontMetrics fmId(params->defaultBlockFont); nameWidth = fmId.width(refBlock->getName()); nameHeight = fmId.height(); @@ -35,6 +41,7 @@ AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispat selected = false; currentInterface = NULL; + visible = true; rstClkVisible = false; wishboneVisible = false; @@ -43,10 +50,11 @@ AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispat // NOTE : initInterfaces() is only called in subclasses } -AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent) : QGraphicsItem(parent) { +AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, int _lock, QGraphicsItem* parent) : QGraphicsItem(parent) { dispatcher = _dispatcher; - params = _params; + params = _params; refBlock = NULL; + lock = _lock; nameWidth = 0; nameHeight = 0; nameMargin = 10; @@ -64,6 +72,7 @@ AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, Q selected = false; currentInterface = NULL; + visible = true; rstClkVisible = false; wishboneVisible = false; @@ -87,7 +96,7 @@ bool AbstractBoxItem::isGroupItem() { return false; } -bool AbstractBoxItem::isSourceItem() { +bool AbstractBoxItem::isStimuliItem() { return false; } @@ -99,7 +108,7 @@ void AbstractBoxItem::setRstClkVisible(bool b) { ifaceItem->visible = b; } } - resetInterfacesPosition(); + resetInterfaceItemsPosition(); updateGeometry(InterfaceMove); update(); getScene()->updateConnectionItemsShape(); @@ -114,7 +123,7 @@ void AbstractBoxItem::setWishboneVisible(bool b) { ifaceItem->visible = b; } } - resetInterfacesPosition(); + resetInterfaceItemsPosition(); updateGeometry(InterfaceMove); update(); getScene()->updateConnectionItemsShape(); @@ -128,7 +137,7 @@ void AbstractBoxItem::setRefBlock(AbstractBlock* _refBlock) { nameHeight = fmId.height(); } -void AbstractBoxItem::initInterfaces() { +void AbstractBoxItem::createInterfaceItems(Parameters::Direction posInputs, Parameters::Direction posOutputs, Parameters::Direction posBidirs) { /* TO DO : creating all needed InterfaceItem, with by default, input at west and output at east */ int orientation = Parameters::West; @@ -139,11 +148,11 @@ void AbstractBoxItem::initInterfaces() { if (inter->getPurpose() != AbstractInterface::Control) { InterfaceItem *item; if(inter->getDirection() == AbstractInterface::Input){ - orientation = Parameters::West; + orientation = posInputs; } else if(inter->getDirection() == AbstractInterface::Output){ - orientation = Parameters::East; + orientation = posOutputs; } else if(inter->getDirection() == AbstractInterface::InOut){ - orientation = Parameters::North; + orientation = posBidirs; } item = new InterfaceItem(0.0 , orientation, (ConnectedInterface *)inter, this, params); interfaces.append(item); @@ -151,7 +160,7 @@ void AbstractBoxItem::initInterfaces() { } } -InterfaceItem* AbstractBoxItem::searchInterfaceByName(QString name) { +InterfaceItem* AbstractBoxItem::searchInterfaceItemByName(QString name) { foreach(InterfaceItem *inter, interfaces){ if(inter->getName() == name) return inter; @@ -159,7 +168,7 @@ InterfaceItem* AbstractBoxItem::searchInterfaceByName(QString name) { return NULL; } -InterfaceItem* AbstractBoxItem::searchInterfaceByRef(ConnectedInterface *ref) { +InterfaceItem* AbstractBoxItem::searchInterfaceItemByRef(ConnectedInterface *ref) { foreach(InterfaceItem *inter, interfaces){ if(inter->refInter == ref) { return inter; @@ -168,16 +177,16 @@ InterfaceItem* AbstractBoxItem::searchInterfaceByRef(ConnectedInterface *ref) { return NULL; } -void AbstractBoxItem::addInterface(InterfaceItem *i, bool resetPosition) { +void AbstractBoxItem::addInterfaceItem(InterfaceItem *i, bool resetPosition) { interfaces.append(i); - if (resetPosition) resetInterfacesPosition(); + if (resetPosition) resetInterfaceItemsPosition(); updateGeometry(InterfaceMove); update(); } -void AbstractBoxItem::removeInterface(InterfaceItem *i) { +void AbstractBoxItem::removeInterfaceItem(InterfaceItem *i) { // NB : removing from model is done in dispatcher - interfaces.removeOne(i); + interfaces.removeAll(i); delete i; //resetInterfacesPosition(); @@ -186,7 +195,7 @@ void AbstractBoxItem::removeInterface(InterfaceItem *i) { } -void AbstractBoxItem::resetInterfacesPosition() { +void AbstractBoxItem::resetInterfaceItemsPosition() { int nbNorth=0, nbSouth=0, nbEast=0, nbWest=0; double cntNorth=1.0,cntSouth=1.0,cntEast=1.0,cntWest=1.0; @@ -231,7 +240,7 @@ void AbstractBoxItem::resetInterfacesPosition() { } } -void AbstractBoxItem::moveInterfaceTo(QPointF pos) { +void AbstractBoxItem::moveInterfaceItemTo(QPointF pos) { double positionRatio; if(currentInterface->getOrientation() == Parameters::North || currentInterface->getOrientation() == Parameters::South){ if(pos.x() < 0){ @@ -295,7 +304,7 @@ QRectF AbstractBoxItem::boundingRectInScene() { */ bool AbstractBoxItem::isInterfaces(int orientation) const { foreach(InterfaceItem* inter, interfaces) { - if (inter->getOrientation() == orientation) return true; + if ((inter->visible) && (inter->getOrientation() == orientation)) return true; } return false; } @@ -308,7 +317,7 @@ int AbstractBoxItem::nbInterfacesByOrientation(int orientation) { return nb; } -void AbstractBoxItem::updateInterfacesAndConnections() { +void AbstractBoxItem::updateInterfaceAndConnectionItems() { // update all interfaces positions foreach(InterfaceItem *item, interfaces){ @@ -330,7 +339,7 @@ void AbstractBoxItem::setDimension(int x, int y) { boxHeight = y; } -InterfaceItem* AbstractBoxItem::getInterfaceFromCursor(qreal x, qreal y) { +InterfaceItem* AbstractBoxItem::getInterfaceItemFromCursor(qreal x, qreal y) { foreach(InterfaceItem* inter, interfaces) { if(x > inter->boundingRect().x() && x < (inter->boundingRect().x() + inter->boundingRect().width())){