Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
correct relative positionning of source/group
authorstephane Domas <stephane.domas@univ-fcomte.fr>
Wed, 10 May 2017 14:31:11 +0000 (16:31 +0200)
committerstephane Domas <stephane.domas@univ-fcomte.fr>
Wed, 10 May 2017 14:31:11 +0000 (16:31 +0200)
14 files changed:
AbstractBoxItem.cpp
AbstractBoxItem.h
AbstractInterface.h
BoxItem.cpp
Dispatcher.cpp
GroupInterface.cpp
GroupItem.cpp
GroupScene.h
Parameters.cpp
Parameters.h
ReferenceBlock.cpp
SourceItem.cpp
blast.creator.user
lib/references/references.bmf

index 8ef607a6aa1af618a3c4d39bcb21408dec394b10..391f79541c7c9f45935d86669fe7ed01b283e89e 100644 (file)
@@ -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)
index 132adc996f7f1ef979c4d97932adbff30713841e..fe08535f65b38d5cdc9020b29410c765d1e2ef0e 100644 (file)
@@ -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);
 };
index 29be72915f50648b92b074875d82deb53e2058cd..39157a65bbb58869fa63ca6aac23964a6c1af4de 100644 (file)
@@ -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
index 6e6f15aace5731771cc753171d3b0af4ba77877a..190200339538cf01b94eb41af66d076e65261b30 100644 (file)
@@ -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);
     }    
   }
index 10880cc1aa3179367d5413249d97805d5cb0c7bd..e7846b4545b9f2f2febed7b4ca57fdb4b3bc5e50 100644 (file)
@@ -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) {
index b59eb23c38d62aa1aa35f4fa32c46d9f5317ef00..67577900b5bb85c22261ff96d2d779b430924b25 100644 (file)
@@ -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;
index e219f4c7fa68e24843f95bbb6c6060096a7e7bba..90c5574f025c58578e1277154f3371b8143775dc 100644 (file)
@@ -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) {
index 61319df3c5fb0abf988d5fdc32210856094ff0d9..a691a6dec8d7bdd41fe1590b0023c9e2dcd3ec07 100644 (file)
@@ -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<BoxItem*> getBoxItems() { return boxItems; }
+  inline QList<SourceItem*> getSourceItems() { return sourceItems; }
   inline QList<ConnectionItem*> getConnectionItems() { return connectionItems; }
   inline QList<GroupScene*> getChildrenScene() { return childrenScene; }
   inline GroupScene* getParentScene() { return parentScene; }
index 001fdc3e0921b568ec2311557d8d96ed2125a60a..12f5b2b0e44e73d5cdeae81562323be4db7550d6 100644 (file)
@@ -43,6 +43,8 @@ Parameters::Parameters() {
   isRstClkShown = false;\r
 \r
   projectPath = QDir::currentPath();\r
+  \r
+  validityExtension = "_enb";\r
 }\r
 \r
 Parameters::~Parameters() {\r
index a152f1cca2c41549113c9f63ddf0d9f34454ce37..27dc08f93dcca70912b766c69cec707cdf642eca 100644 (file)
@@ -93,6 +93,8 @@ public :
   // defaults for vhdl\r
   int wbDataWidth;\r
   int wbAddressWidth;\r
+  QString validityExtension; //! the string to add to ports to obtain the name of the associated validity port.\r
+  \r
   // defaults for scene elements\r
   int defaultBlockWidth;\r
   int defaultBlockHeight;\r
index 05fd29a785e921fbf1f42fa1ae6869ca1249ef99..f8a99ca9fd42843a790c15ef71e966a43e0386ec 100644 (file)
@@ -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)) {
index 82a41b08cea3b5528fd38ea3165b3ae3edfedf96..4f297616dd0397bc47dda4b56c7962740f2b2678 100644 (file)
@@ -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);
     }    
   }
index da6e7315ac191d718aeae3239b79803fffeb2aea..887802402cf142deaec9070600f423ef0e0e40c9 100755 (executable)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.2.1, 2017-05-09T22:33:21. -->
+<!-- Written by QtCreator 3.2.1, 2017-05-10T16:30:40. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
-  <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
+  <value type="QByteArray">{1d077e47-e3a1-47fd-8b12-4de650e39df5}</value>
  </data>
  <data>
   <variable>ProjectExplorer.Project.ActiveTarget</variable>
   <valuemap type="QVariantMap">
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
-   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2c9bf876-3476-44eb-8065-1f0844704dda}</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{451ee8a3-56ff-4aba-8a8e-3da882cc142e}</value>
    <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
    <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
    <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
-    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/sdomas/Projet/Blast/code/blast</value>
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/localhome/sdomas/Projet/Blast/code/blast</value>
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
      <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
       <valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">
     <value type="int" key="PE.EnvironmentAspect.Base">2</value>
     <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
     <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
-    <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
+    <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">blast</value>
     <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
     <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
-    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécutable personnalisé</value>
+    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécuter blast</value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
     <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
index 432ac5d4306e7bace654a8404fe6dbeb74199ac6..7eefb86f5b9c126156af3b149b5029ce13bb34fd 100644 (file)
Binary files a/lib/references/references.bmf and b/lib/references/references.bmf differ