X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/abbc64cf04a35ab3549d5c516f44c7c5921baa63..d43174d0eb3d293b3bb5fbe76662241134e74d0d:/AbstractBoxItem.cpp diff --git a/AbstractBoxItem.cpp b/AbstractBoxItem.cpp index 0afbe29..c4cdae9 100644 --- a/AbstractBoxItem.cpp +++ b/AbstractBoxItem.cpp @@ -15,9 +15,8 @@ AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem *parent) : QGraphicsItem(parent) { dispatcher = _dispatcher; params = _params; - refBlock = _refBlock; - QFont fontId("Arial",10); - QFontMetrics fmId(fontId); + refBlock = _refBlock; + QFontMetrics fmId(params->defaultBlockFont); nameWidth = fmId.width(refBlock->getName()); nameHeight = fmId.height(); nameMargin = 10; @@ -42,6 +41,34 @@ AbstractBoxItem:: AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispat // NOTE : initInterfaces() is only called in subclasses } +AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, QGraphicsItem* parent) : QGraphicsItem(parent) { + dispatcher = _dispatcher; + params = _params; + refBlock = NULL; + nameWidth = 0; + nameHeight = 0; + nameMargin = 10; + ifaceMargin = 10; + + // the six following values will be override in subclass constructors + minimumBoxWidth = 0; + minimumBoxHeight = 0; + boxWidth = 0; + boxHeight = 0; + totalWidth = 0; + totalHeight = 0; + + originPoint = QPointF(0.0,0.0); + + selected = false; + currentInterface = NULL; + rstClkVisible = false; + + setAcceptHoverEvents(true); + + // NOTE : initInterfaces() is only called in subclasses +} + AbstractBoxItem::~AbstractBoxItem() { foreach(InterfaceItem* inter, interfaces) { delete inter; @@ -57,8 +84,14 @@ bool AbstractBoxItem::isGroupItem() { return false; } -void AbstractBoxItem::initInterfaces() -{ +void AbstractBoxItem::setRefBlock(AbstractBlock* _refBlock) { + refBlock = _refBlock; + QFontMetrics fmId(params->defaultBlockFont); + nameWidth = fmId.width(refBlock->getName()); + nameHeight = fmId.height(); +} + +void AbstractBoxItem::initInterfaces() { /* TO DO : creating all needed InterfaceItem, with by default, input at west and output at east */ int orientation = Parameters::West; @@ -98,7 +131,7 @@ InterfaceItem* AbstractBoxItem::searchInterfaceByRef(ConnectedInterface *ref) { void AbstractBoxItem::addInterface(InterfaceItem *i, bool resetPosition) { interfaces.append(i); if (resetPosition) resetInterfacesPosition(); - updateGeometry(); + updateGeometry(InterfaceMove); update(); } @@ -108,7 +141,7 @@ void AbstractBoxItem::removeInterface(InterfaceItem *i) { delete i; //resetInterfacesPosition(); - updateGeometry(); + updateGeometry(InterfaceMove); update(); } @@ -158,7 +191,7 @@ void AbstractBoxItem::resetInterfacesPosition() { } } -void AbstractBoxItem::deplaceInterface(QPointF pos) { +void AbstractBoxItem::moveInterfaceTo(QPointF pos) { double positionRatio; if(currentInterface->getOrientation() == Parameters::North || currentInterface->getOrientation() == Parameters::South){ if(pos.x() < 0){ @@ -226,11 +259,12 @@ void AbstractBoxItem::updateInterfacesAndConnections() { foreach(InterfaceItem *item, interfaces){ item->updatePosition(); } + // NB: dunno the utility of this test !! if (getScene() != NULL) { // update all connections from/to this block foreach(ConnectionItem *item, getScene()->getConnectionItems()){ if ((item->getFromInterfaceItem()->getOwner() == this) || (item->getToInterfaceItem()->getOwner() == this)) { - item->setPathes(); + item->setPath(); } } }