From d111eaf49741a0a79d372445f97c314a637e331e Mon Sep 17 00:00:00 2001 From: stephane Domas Date: Wed, 10 May 2017 16:31:11 +0200 Subject: [PATCH 1/1] correct relative positionning of source/group --- AbstractBoxItem.cpp | 43 +++++++++++++++-------- AbstractBoxItem.h | 5 +-- AbstractInterface.h | 2 +- BoxItem.cpp | 19 +++++----- Dispatcher.cpp | 64 ++++++++++++++++++++++------------ GroupInterface.cpp | 2 +- GroupItem.cpp | 59 ++++++++++++++++++------------- GroupScene.h | 3 +- Parameters.cpp | 2 ++ Parameters.h | 2 ++ ReferenceBlock.cpp | 8 ++--- SourceItem.cpp | 61 ++++++++++++++++++-------------- blast.creator.user | 12 +++---- lib/references/references.bmf | Bin 7216 -> 7216 bytes 14 files changed, 170 insertions(+), 112 deletions(-) diff --git a/AbstractBoxItem.cpp b/AbstractBoxItem.cpp index 8ef607a..391f795 100644 --- a/AbstractBoxItem.cpp +++ b/AbstractBoxItem.cpp @@ -134,20 +134,20 @@ void AbstractBoxItem::initInterfaces() { foreach(AbstractInterface *inter, refBlock->getInterfaces()){ - /* NB: create InterfaceItem for every interfaces, even if they do not have a graphical representation - It will allow to save them in the XML project file and thus to create their equivalent - in the graph while the file is loaded. + /* NB: does not create InterfaceItem for control interfaces. */ - InterfaceItem *item; - if(inter->getDirection() == AbstractInterface::Input){ - orientation = Parameters::West; - } else if(inter->getDirection() == AbstractInterface::Output){ - orientation = Parameters::East; - } else if(inter->getDirection() == AbstractInterface::InOut){ - orientation = Parameters::North; + if (inter->getPurpose() != AbstractInterface::Control) { + InterfaceItem *item; + if(inter->getDirection() == AbstractInterface::Input){ + orientation = Parameters::West; + } else if(inter->getDirection() == AbstractInterface::Output){ + orientation = Parameters::East; + } else if(inter->getDirection() == AbstractInterface::InOut){ + orientation = Parameters::North; + } + item = new InterfaceItem(0.0 , orientation, (ConnectedInterface *)inter, this, params); + interfaces.append(item); } - item = new InterfaceItem(0.0 , orientation, (ConnectedInterface *)inter, this, params); - interfaces.append(item); } } @@ -269,11 +269,26 @@ void AbstractBoxItem::moveInterfaceTo(QPointF pos) { QRectF AbstractBoxItem::boundingRect() const { // returns a QRectF that contains the block (i.e the main rectangle, interfaces, title, ...) - QPointF p = originPoint - QPointF(nameHeight,nameHeight); - QSizeF s(totalWidth+2*nameHeight,totalHeight+2*nameHeight); + QPointF p = originPoint; + QSizeF s(totalWidth,totalHeight); return QRectF(p,s); } +QRectF AbstractBoxItem::boundingRectInScene() { + /* returns a QRectF in scene coordinates, that contains the block plus + a margin of size arrowWidth+arrowLineLength + */ + int marginConn = params->arrowLineLength+params->arrowWidth; + + QPointF posBox = scenePos(); + posBox.setX(posBox.x()+originPoint.x()-marginConn); + posBox.setY(posBox.y()+originPoint.y()-marginConn); + + QSizeF sizeBox(totalWidth+2*marginConn,totalHeight+2*marginConn); + + return QRectF(posBox,sizeBox); +} + /* isInterface() : return true if there are some interfaces with the given orientation (N,S,E,O) diff --git a/AbstractBoxItem.h b/AbstractBoxItem.h index 132adc9..fe08535 100644 --- a/AbstractBoxItem.h +++ b/AbstractBoxItem.h @@ -59,7 +59,7 @@ public: bool isInterfaces(int orientation) const; // 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); @@ -132,7 +132,8 @@ protected: /* 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(); int nbInterfacesByOrientation(int orientation); }; diff --git a/AbstractInterface.h b/AbstractInterface.h index 29be729..39157a6 100644 --- a/AbstractInterface.h +++ b/AbstractInterface.h @@ -23,7 +23,7 @@ class AbstractInterface { public : - enum IfaceWidthType { Expression = 1, Boolean, Natural}; + enum IfaceWidthType { Expression = 1, Boolean, Natural, Inherited}; //! Inherited is only for Group interface enum IfacePurpose { Data = 1, Control, Clock, Reset, Wishbone }; enum IfaceDirection { Input = 1, Output = 2, InOut = 3 }; enum IfaceVHDLContext { Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface diff --git a/BoxItem.cpp b/BoxItem.cpp index 6e6f15a..1902003 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -342,7 +342,7 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { } } else if (mode == GroupScene::ItemEdition) { - setZValue(zValue()+100); + //setZValue(zValue()+100); if (params->cursorState == Parameters::CursorOnInterface) { InterfaceItem *inter = getInterfaceFromCursor(x,y); if (inter != NULL) { @@ -373,7 +373,7 @@ void BoxItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { void BoxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - setZValue(zValue()-100); + //setZValue(zValue()-100); int mode = getScene()->getEditionMode(); @@ -397,7 +397,9 @@ void BoxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { bool ok = dispatcher->createConnectionItem(iface1,iface2); if (ok) { iface1->selected = false; - // no update needed since the whole scene will be repainted + update(iface1->boundingRect()); + iface2->selected = false; + update(iface2->boundingRect()); getScene()->setSelectedInterface(1,NULL); getScene()->setSelectedInterface(2,NULL); params->setEditState(Parameters::EditNoOperation); @@ -483,13 +485,12 @@ void BoxItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event) { } } } - QGraphicsItem::hoverMoveEvent(event); + //QGraphicsItem::hoverMoveEvent(event); + event->ignore(); } -void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { - - event->accept(); +void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) { QMenu menu; QAction* titleAction = NULL; @@ -743,7 +744,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { functionalBlock->addInterface(functionalInterface); // searching for control interface - QString ctlRefName = refName+"_ctl"; + QString ctlRefName = refName+"_enb"; ReferenceInterface* ctlRefIface = AI_TO_REF(reference->getIfaceFromName(ctlRefName)); if (ctlRefIface != NULL) { @@ -752,7 +753,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { if (! ctlIface->setAssociatedIface(functionalInterface)) { throw(Exception(PROJECTFILE_CORRUPTED)); } - ctlIface->setName(name+"_ctl"); + ctlIface->setName(name+"_enb"); functionalBlock->addInterface(ctlIface); } } diff --git a/Dispatcher.cpp b/Dispatcher.cpp index 10880cc..e7846b4 100644 --- a/Dispatcher.cpp +++ b/Dispatcher.cpp @@ -85,6 +85,8 @@ bool Dispatcher::createConnectionItem(InterfaceItem *iface1, InterfaceItem *ifac ConnectedInterface* ref1 = iface1->refInter; ConnectedInterface* ref2 = iface2->refInter; + ConnectedInterface* asso1 = iface1->refInter->getAssociatedIface(); + ConnectedInterface* asso2 = iface2->refInter->getAssociatedIface(); // connect both interface bool ok1 = false; @@ -94,12 +96,20 @@ bool Dispatcher::createConnectionItem(InterfaceItem *iface1, InterfaceItem *ifac if ((ref1->canConnectTo(ref2)) && (ref2->canConnectFrom(ref1))) { ref1->connectTo(ref2); ref2->connectFrom(ref1); + if ((asso1 != NULL) && (asso2 != NULL)) { + asso1->connectTo(asso2); + asso2->connectFrom(asso1); + } ok1 = true; } // if the frist one did not work, test ref2->ref1 if ((ok1 == false) && (ref2->canConnectTo(ref1)) && (ref1->canConnectFrom(ref2))) { ref2->connectTo(ref1); ref1->connectFrom(ref2); + if ((asso1 != NULL) && (asso2 != NULL)) { + asso1->connectFrom(asso2); + asso2->connectTo(asso1); + } ok2 = true; } if ((ok1 == true) || (ok2 == true)) { @@ -331,7 +341,7 @@ void Dispatcher::renameInterface(InterfaceItem *item) { item->refInter->setName(text); AbstractInterface* assoIface = item->refInter->getAssociatedIface(); if (assoIface != NULL) { - assoIface->setName(text+"_ctl"); + assoIface->setName(text+"_enb"); } item->updateName(text); item->getOwner()->nameChanged(); @@ -409,7 +419,7 @@ void Dispatcher::duplicateInterfaceItem(InterfaceItem *item) { // creating control interface if needed if (refI->getAssociatedIface() != NULL) { - QString ctlName = cloneIface->getName()+"_ctl"; + QString ctlName = cloneIface->getName()+"_enb"; ReferenceInterface* ctlIface = new ReferenceInterface(refB,ctlName,"boolean","1",cloneIface->getDirection(), AbstractInterface::Control, 1); refB->addInterface(ctlIface); if (! ctlIface->setAssociatedIface(cloneIface)) { @@ -892,7 +902,7 @@ void Dispatcher::removeConnection(ConnectionItem *conn) { ConnectedInterface *fromInter = fromIfaceItem->refInter; ConnectedInterface *toInter = toIfaceItem->refInter; - // process the speical case source->group apart + // process the special case source->group apart if (fromIfaceItem->getOwner()->isSourceItem()) { // remove from graph fromInter->removeConnectedTo(toInter); @@ -987,11 +997,12 @@ void Dispatcher::connectInterToGroup(InterfaceItem *item){ GroupItem *parentItem = item->getOwner()->getScene()->getGroupItem(); // creating/adding the group interface in the graph model - GroupInterface *groupInter = new GroupInterface(parentBlock,refInter->getName()+"_group",refInter->getDirection(),refInter->getPurpose()); - groupInter->setType(refInter->getType()); - groupInter->setWidth(refInter->getWidth()); - groupInter->setPurpose(refInter->getPurpose()); + GroupInterface *groupInter = new GroupInterface(parentBlock,refInter->getName()+"_group",refInter->getDirection(),refInter->getPurpose()); parentItem->getRefBlock()->addInterface(groupInter); + // creating/adding the group control interface in the graph model + GroupInterface *groupCtlInter = new GroupInterface(parentBlock,refInter->getName()+"_group_enb",refInter->getDirection(),AbstractInterface::Control); + groupCtlInter->setAssociatedIface(groupInter); + parentItem->getRefBlock()->addInterface(groupCtlInter); // connect both interface bool ok = true; @@ -1058,7 +1069,7 @@ void Dispatcher::disconnectInterFromGroup(InterfaceItem *item) { else if (refInter->getDirection() == AbstractInterface::Input) { groupInter = refInter->getConnectedFrom(); refInter->clearConnectedFrom(); - groupInter->clearConnectedTo(); + groupInter->removeConnectedTo(refInter); } else if (refInter->getDirection() == AbstractInterface::InOut) { groupInter = refInter->getConnectionToParentGroup(); // must be a single connection to @@ -1097,36 +1108,43 @@ void Dispatcher::disconnectInterFromGroup(InterfaceItem *item) { cout << "removing group interface item, and connection item ..." ; #endif + bool groupInterRemove = false; + if ((groupInter->isConnectedTo() == false) && (groupInter->isConnectedFrom() == false)) groupInterRemove = true; + item->removeConnectionItem(conn); groupIfaceItem->removeConnectionItem(conn); - parentItem->removeInterface(groupIfaceItem); // CAUTION : this deletes the interface item. + if (groupInterRemove) { + parentItem->removeInterface(groupIfaceItem); // CAUTION : this deletes the interface item. + } parentItem->getScene()->removeConnectionItem(conn); #ifdef DEBUG cout << "done." << endl ; #endif - // removing the interface box item in the parent scene + if (groupInterRemove) { + // removing the interface box item in the parent scene #ifdef DEBUG - cout << "removing the inteeface item of box item in parent scene if needed ..." ; + cout << "removing the inteeface item of box item in parent scene if needed ..." ; #endif - - BoxItem* parent2Item = parentItem->getParentItem(); - if (parent2Item != NULL) { - InterfaceItem* group2IfaceItem = parent2Item->searchInterfaceByRef(groupInter); - parent2Item->removeInterface(group2IfaceItem); - } + + BoxItem* parent2Item = parentItem->getParentItem(); + if (parent2Item != NULL) { + InterfaceItem* group2IfaceItem = parent2Item->searchInterfaceByRef(groupInter); + parent2Item->removeInterface(group2IfaceItem); + } #ifdef DEBUG - cout << "done." << endl ; + cout << "done." << endl ; #endif - - // removing the interface group from the group + + // removing the interface group from the group #ifdef DEBUG - cout << "removing group interface ..." ; + cout << "removing group interface ..." ; #endif - parentGroup->removeInterface(groupInter); + parentGroup->removeInterface(groupInter); #ifdef DEBUG - cout << "done." << endl ; + cout << "done." << endl ; #endif + } } void Dispatcher::removeFunctionalInterface(InterfaceItem *item) { diff --git a/GroupInterface.cpp b/GroupInterface.cpp index b59eb23..6757790 100644 --- a/GroupInterface.cpp +++ b/GroupInterface.cpp @@ -2,7 +2,7 @@ #include "FunctionalInterface.h" #include "GroupBlock.h" -GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,"expression","",_direction,_purpose) { +GroupInterface::GroupInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose) throw(Exception) : ConnectedInterface(_owner,_name,AbstractInterface::Inherited,"",_direction,_purpose) { if (! _owner->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE)); connectedFrom = NULL; diff --git a/GroupItem.cpp b/GroupItem.cpp index e219f4c..90c5574 100644 --- a/GroupItem.cpp +++ b/GroupItem.cpp @@ -5,6 +5,7 @@ #include "Dispatcher.h" #include "Parameters.h" #include "BoxItem.h" +#include "SourceItem.h" #include "AbstractBlock.h" #include "AbstractInterface.h" #include "ConnectedInterface.h" @@ -38,7 +39,7 @@ GroupItem::GroupItem(BoxItem *_parentItem, selected = false; - setZValue(-100); + setZValue(100); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges); @@ -55,7 +56,7 @@ GroupItem::GroupItem(Dispatcher *_dispatcher,Parameters *_params) throw(Exceptio parentItem = NULL; rectTitle = QRectF(0,-(nameHeight+2*nameMargin),nameWidth+2*nameMargin,nameHeight+2*nameMargin); selected = false; - setZValue(-100); + setZValue(100); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges); updateGeometry(InterfaceMove); @@ -259,7 +260,7 @@ bool GroupItem::updateGeometry(ChangeType type) { originPoint.setY(y); if ((boxSizeChanged) || (newSize != oldSize) || (originPoint != oldOrigin)) { - cout << "GroupItem: must change group item shape" << endl; + //cout << "GroupItem: must change group item shape" << endl; prepareGeometryChange(); return true; } @@ -284,26 +285,28 @@ void GroupItem::nameChanged() { void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - if(params->editState == Parameters::EditGroupMove) { - QPointF absPos = currentPosition + originPoint; + if(params->editState == Parameters::EditGroupMove) { int gapX = event->scenePos().x() - cursorPosition.x(); int gapY = event->scenePos().y() - cursorPosition.y(); - //cout << "block abs. pos: " << absPos.x() << "," << absPos.y() << " | "; - //cout << "block current. pos: " << currentPosition.x() << "," << currentPosition.y() << " | "; -/* - if (absPos.x()+gapX < 0) { - gapX = -absPos.x(); + bool canMove = true; + if (refBlock->isTopGroupBlock()) { + QRectF rectGroup = boundingRectInScene(); + rectGroup.moveTo(rectGroup.x()+gapX,rectGroup.y()+gapY); + foreach(SourceItem* source, getScene()->getSourceItems()) { + QRectF rectSource = source->boundingRectInScene(); + if (rectGroup.intersects(rectSource)) canMove = false; + } } - if (absPos.y()+gapY < 0) { - gapY = -absPos.y(); + + if (canMove) { + QPointF gap(gapX,gapY); + currentPosition = currentPosition+gap; + setPos(currentPosition); + + // updating all connections of the scene. + getScene()->updateConnectionItemsShape(); } - */ - //cout << "gap: " << gapX << "," << gapY << " | "; - //cout << "scene: " << getScene()->sceneRect().x() << "," << getScene()->sceneRect().y() << endl; - QPointF gap(gapX,gapY); - currentPosition = currentPosition+gap; - setPos(currentPosition); cursorPosition = event->scenePos(); } else if(params->editState == Parameters::EditGroupResize) { @@ -383,7 +386,7 @@ void GroupItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { dispatcher->setCurrentGroupWidget(getScene()->getGroupWidget()); - if ((refBlock->isTopGroupBlock()) && (mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { + if ((mode == GroupScene::AddConnection) && (params->cursorState == Parameters::CursorOnInterface)) { InterfaceItem *inter = getInterfaceFromCursor(x,y); if (inter != NULL) { @@ -427,7 +430,7 @@ void GroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { int mode = getScene()->getEditionMode(); - if ((refBlock->isTopGroupBlock()) && (mode == GroupScene::AddConnection)) { + if (mode == GroupScene::AddConnection) { if (params->editState == Parameters::EditStartConnection) { params->setEditState(Parameters::EditStartConnection); @@ -444,15 +447,22 @@ void GroupItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { } else if (params->editState == Parameters::EditCloseConnection) { InterfaceItem* iface1 = getScene()->getSelectedInterface(1); - InterfaceItem* iface2 = getScene()->getSelectedInterface(2); - bool ok = dispatcher->createConnectionItem(iface1,iface2); + InterfaceItem* iface2 = getScene()->getSelectedInterface(2); + bool ok = dispatcher->createConnectionItem(iface1,iface2); if (ok) { iface1->selected = false; update(iface1->boundingRect()); + iface2->selected = false; + update(iface2->boundingRect()); getScene()->setSelectedInterface(1,NULL); getScene()->setSelectedInterface(2,NULL); params->setEditState(Parameters::EditNoOperation); } + else { + //QMessageBox::warning(NULL,"Error","Cannot connect selected interfaces", QMessageBox::Ok); + getScene()->setSelectedInterface(2,NULL); + params->setEditState(Parameters::EditStartConnection); + } } } else if (mode == GroupScene::ItemEdition) { @@ -527,7 +537,8 @@ void GroupItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { } } } - QGraphicsItem::hoverMoveEvent(event); + //QGraphicsItem::hoverMoveEvent(event); + event->ignore(); } void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { @@ -586,7 +597,7 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { } else if(selectedAction == showParameters) { new ParametersWindow(refBlock, params, NULL); - } + } } InterfaceItem* GroupItem::isHoverInterface(QPointF point) { diff --git a/GroupScene.h b/GroupScene.h index 61319df..a691a6d 100644 --- a/GroupScene.h +++ b/GroupScene.h @@ -42,7 +42,7 @@ public: - AddGroup: while a new group (empty or from selected blocks) is created - ItemEdtion: can move/resize blocks/interfaces, remove blocks/interface/group, ... */ - enum EditMode { InitState, AddBlock, AddConnection, AddGroup, ItemEdition }; + enum EditMode { InitState, AddConnection, ItemEdition }; GroupScene(GroupScene* _parentScene, GroupWidget* _window, Dispatcher* _dispatcher, Parameters* _params, bool topScene = false, QObject *parent = 0); ~GroupScene(); @@ -50,6 +50,7 @@ public: // attributes getters inline GroupItem* getGroupItem() {return groupItem;} inline QList getBoxItems() { return boxItems; } + inline QList getSourceItems() { return sourceItems; } inline QList getConnectionItems() { return connectionItems; } inline QList getChildrenScene() { return childrenScene; } inline GroupScene* getParentScene() { return parentScene; } diff --git a/Parameters.cpp b/Parameters.cpp index 001fdc3..12f5b2b 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -43,6 +43,8 @@ Parameters::Parameters() { isRstClkShown = false; projectPath = QDir::currentPath(); + + validityExtension = "_enb"; } Parameters::~Parameters() { diff --git a/Parameters.h b/Parameters.h index a152f1c..27dc08f 100644 --- a/Parameters.h +++ b/Parameters.h @@ -93,6 +93,8 @@ public : // defaults for vhdl int wbDataWidth; int wbAddressWidth; + QString validityExtension; //! the string to add to ports to obtain the name of the associated validity port. + // defaults for scene elements int defaultBlockWidth; int defaultBlockHeight; diff --git a/ReferenceBlock.cpp b/ReferenceBlock.cpp index 05fd29a..f8a99ca 100644 --- a/ReferenceBlock.cpp +++ b/ReferenceBlock.cpp @@ -251,7 +251,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) { nameStr = eltInput.attribute("iface","none"); AbstractInterface* dataIface = getIfaceFromName(nameStr); if (dataIface == NULL) throw (Exception(BLOCKFILE_CORRUPTED)); - nameStr = dataIface->getName()+"_ctl"; + nameStr = dataIface->getName()+"_enb"; inter = new ReferenceInterface(this,nameStr,"boolean","1",AbstractInterface::Input, AbstractInterface::Control, 1); if (!inter->setAssociatedIface(dataIface)) { throw (Exception(BLOCKFILE_CORRUPTED)); @@ -283,7 +283,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) { nameStr = eltOutput.attribute("iface","none"); AbstractInterface* dataIface = getIfaceFromName(nameStr); if (dataIface == NULL) throw (Exception(BLOCKFILE_CORRUPTED)); - nameStr = dataIface->getName()+"_ctl"; + nameStr = dataIface->getName()+"_enb"; inter = new ReferenceInterface(this,nameStr,"boolean","1",AbstractInterface::Output, AbstractInterface::Control, 1); if (!inter->setAssociatedIface(dataIface)) { throw (Exception(BLOCKFILE_CORRUPTED)); @@ -511,7 +511,7 @@ QDataStream& operator>>(QDataStream &in, ReferenceBlock &b) { iface->setMultiplicity(val); b.inputs.append(iface); if (iface->getPurpose() == AbstractInterface::Data) { - QString ctlRefName = iface->getName()+"_ctl"; + QString ctlRefName = iface->getName()+"_enb"; ReferenceInterface* ctlRefIface = AI_TO_REF(b.getIfaceFromName(ctlRefName)); if (ctlRefIface != NULL) { if (! ctlRefIface->setAssociatedIface(iface)) { @@ -537,7 +537,7 @@ QDataStream& operator>>(QDataStream &in, ReferenceBlock &b) { iface->setMultiplicity(val); b.outputs.append(iface); if (iface->getPurpose() == AbstractInterface::Data) { - QString ctlRefName = iface->getName()+"_ctl"; + QString ctlRefName = iface->getName()+"_enb"; ReferenceInterface* ctlRefIface = AI_TO_REF(b.getIfaceFromName(ctlRefName)); if (ctlRefIface != NULL) { if (! ctlRefIface->setAssociatedIface(iface)) { diff --git a/SourceItem.cpp b/SourceItem.cpp index 82a41b0..4f29761 100644 --- a/SourceItem.cpp +++ b/SourceItem.cpp @@ -142,6 +142,7 @@ void SourceItem::updateMinimumSize() { if (minimumBoxHeight < (nbMaxEW*ifaceHeight+ifaceMargin*(nbMaxEW+1))) { minimumBoxHeight = (nbMaxEW*ifaceHeight+ifaceMargin*(nbMaxEW+1)); } + cout << "source minimum size = " << minimumBoxWidth << "x" << minimumBoxHeight << endl; } @@ -203,6 +204,7 @@ bool SourceItem::updateGeometry(ChangeType type) { originPoint.setX(x); originPoint.setY(y); + cout << "source size = " << totalWidth << "x" << totalHeight << endl; if ((boxSizeChanged) || (newSize != oldSize) || (originPoint != oldOrigin)) { prepareGeometryChange(); return true; @@ -217,32 +219,34 @@ void SourceItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { int gapX = event->scenePos().x() - cursorPosition.x(); int gapY = event->scenePos().y() - cursorPosition.y(); - - //cout << "block abs. pos: " << absPos.x() << "," << absPos.y() << " | "; - //cout << "block current. pos: " << currentPosition.x() << "," << currentPosition.y() << " | "; - + + bool canMove = true; + + QRectF rectSource = boundingRectInScene(); + rectSource.moveTo(rectSource.x()+gapX,rectSource.y()+gapY); + GroupItem* group = getScene()->getGroupItem(); + QRectF rectGroup = group->boundingRectInScene(); + if (rectSource.intersects(rectGroup)) canMove = false; /* - if (absPos.x()+gapX < marginConn) { - gapX = marginConn-absPos.x(); - } - if (absPos.y()+gapY < marginConn) { - gapY = marginConn-absPos.y(); + if (canMove) { + foreach(SourceItem* source, getScene()->getSourceItems()) { + QRectF rectOther = source->boundingRectInScene(); + if ((source != this) && (rectSource.intersects(rectOther))) canMove = false; + } } */ - //cout << "gap: " << gapX << "," << gapY << endl; - QPointF gap(gapX,gapY); - currentPosition = currentPosition+gap; - setPos(currentPosition); - // update all connections from/to this block - foreach(ConnectionItem *item, getScene()->getConnectionItems()){ - if ((item->getFromInterfaceItem()->getOwner() == this) || (item->getToInterfaceItem()->getOwner() == this)) { - item->setPath(); - } + if (canMove) { + QPointF gap(gapX,gapY); + currentPosition = currentPosition+gap; + setPos(currentPosition); + // update all connections from/to this block + foreach(ConnectionItem *item, getScene()->getConnectionItems()){ + if ((item->getFromInterfaceItem()->getOwner() == this) || (item->getToInterfaceItem()->getOwner() == this)) { + item->setPath(); + } + } } cursorPosition = event->scenePos(); - - // udpate the groupitem - (getScene()->getGroupItem())->updateShape(); } else if(params->editState == Parameters::EditBlockResize) { @@ -333,7 +337,7 @@ void SourceItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { } } else if (mode == GroupScene::ItemEdition) { - setZValue(zValue()+100); + //setZValue(zValue()+100); if (params->cursorState == Parameters::CursorOnInterface) { InterfaceItem *inter = getInterfaceFromCursor(x,y); if (inter != NULL) { @@ -364,7 +368,7 @@ void SourceItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { void SourceItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - setZValue(zValue()-100); + //setZValue(zValue()-100); int mode = getScene()->getEditionMode(); @@ -388,7 +392,9 @@ void SourceItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { bool ok = dispatcher->createConnectionItem(iface1,iface2); if (ok) { iface1->selected = false; - // no update needed since the whole scene will be repainted + update(iface1->boundingRect()); + iface2->selected = false; + update(iface2->boundingRect()); getScene()->setSelectedInterface(1,NULL); getScene()->setSelectedInterface(2,NULL); params->setEditState(Parameters::EditNoOperation); @@ -474,7 +480,8 @@ void SourceItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event) { } } } - QGraphicsItem::hoverMoveEvent(event); + //QGraphicsItem::hoverMoveEvent(event); + event->ignore(); } @@ -648,7 +655,7 @@ void SourceItem::load(QDomElement funcElement) throw(Exception) { functionalBlock->addInterface(functionalInterface); // searching for control interface - QString ctlRefName = refName+"_ctl"; + QString ctlRefName = refName+"_enb"; ReferenceInterface* ctlRefIface = AI_TO_REF(reference->getIfaceFromName(ctlRefName)); if (ctlRefIface != NULL) { @@ -657,7 +664,7 @@ void SourceItem::load(QDomElement funcElement) throw(Exception) { if (! ctlIface->setAssociatedIface(functionalInterface)) { throw(Exception(PROJECTFILE_CORRUPTED)); } - ctlIface->setName(name+"_ctl"); + ctlIface->setName(name+"_enb"); functionalBlock->addInterface(ctlIface); } } diff --git a/blast.creator.user b/blast.creator.user index da6e731..8878024 100755 --- a/blast.creator.user +++ b/blast.creator.user @@ -1,10 +1,10 @@ - + EnvironmentId - {c8006d66-d34f-42be-ad10-d0207752286d} + {1d077e47-e3a1-47fd-8b12-4de650e39df5} ProjectExplorer.Project.ActiveTarget @@ -60,12 +60,12 @@ Desktop Desktop - {2c9bf876-3476-44eb-8065-1f0844704dda} + {451ee8a3-56ff-4aba-8a8e-3da882cc142e} 0 0 0 - /home/sdomas/Projet/Blast/code/blast + /localhome/sdomas/Projet/Blast/code/blast @@ -162,10 +162,10 @@ 2 - + blast false %{buildDir} - Exécutable personnalisé + Exécuter blast ProjectExplorer.CustomExecutableRunConfiguration 3768 diff --git a/lib/references/references.bmf b/lib/references/references.bmf index 432ac5d4306e7bace654a8404fe6dbeb74199ac6..7eefb86f5b9c126156af3b149b5029ce13bb34fd 100644 GIT binary patch delta 28 gcmdmBvB6@)MM2h7hCGI($=3v@Ls*-Og!XX)0GO)@<^TWy delta 28 gcmdmBvB6@)MM2hNh7yLH$=3v@Ls*-Og!XX)0Ga0s0ssI2 -- 2.39.5