]> AND Private Git Repository - blast.git/blobdiff - ConnectionItem.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
clkconvert OP compute done
[blast.git] / ConnectionItem.cpp
index c99d489918461c3d2a79e208443a80293ccfef13..61af6c83e1a893d96477f245bd413acd4c29ab43 100644 (file)
@@ -9,24 +9,30 @@
 
 //int ConnectionItem::counter = 0;
 
-ConnectionItem::ConnectionItem(InterfaceItem* _iface1,
-                               InterfaceItem* _iface2,
+ConnectionItem::ConnectionItem(InterfaceItem* _fromInterfaceItem,
+                               InterfaceItem* _toInterfaceItem,
                                Dispatcher* _dispatcher,
                                Parameters* _params) : QGraphicsItem() {
 
 
   dispatcher = _dispatcher;
   params = _params;
+  fromInterfaceItem = _fromInterfaceItem;
+  toInterfaceItem = _toInterfaceItem;
+
+  /* NOTE: originally, the following was testing the correct order
+   * to connect the 2 interfaces. Presently, the order is predetermined
+   * when testing the AbstractInterface objets that must be connected.
 
   ConnectedInterface* ref1 = _iface1->refInter;
   ConnectedInterface* ref2 = _iface2->refInter;
-  /* ref. note in .h
+   ref. note in .h
      case 1 : ref1 is group interface, and ref2 block interface of a block within the group
      case 2 : the opposite of case 1
      case 3 : ref1 and ref2 are block interface of blocks that are both within the same parent group.
-     case 4 : ref1 is source interface and ref2 interface of top group
+     case 4 : ref1 is stimuli interface and ref2 interface of top group
      case 5 : the opposite of case 4
-   */
+
   if (ref1->getOwner() == ref2->getOwner()->getParent()) {
 
     if (ref1->getDirection() == AbstractInterface::Input) {
@@ -73,14 +79,16 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1,
       fromInterfaceItem = _iface1;
     }
   }
-  else if ((ref1->getOwner()->isSourceBlock()) && (ref2->getOwner()->isTopGroupBlock())) {    
-    fromInterfaceItem = _iface1;    
+  else if ((ref1->getOwner()->isStimuliBlock()) && (ref2->getOwner()->isTopGroupBlock())) {    
+    fromInterfaceItem = _iface1;
     toInterfaceItem = _iface2;
   }
-  else if ((ref2->getOwner()->isSourceBlock()) && (ref1->getOwner()->isTopGroupBlock())) {    
-    fromInterfaceItem = _iface2;    
+  else if ((ref2->getOwner()->isStimuliBlock()) && (ref1->getOwner()->isTopGroupBlock())) {    
+    fromInterfaceItem = _iface2;
     toInterfaceItem = _iface1;
   }
+
+  */
   // adding this to interface items
   fromInterfaceItem->addConnectionItem(this);
   toInterfaceItem->addConnectionItem(this);
@@ -92,7 +100,7 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1,
   setAcceptHoverEvents(true);
   setFlag(ItemSendsGeometryChanges);
   setCursor(Qt::PointingHandCursor);
-  setZValue(0);
+  setZValue(200);
   
   if (fromInterfaceItem->refInter->getPurpose() == AbstractInterface::Data) {
     visible = true;
@@ -397,8 +405,8 @@ void ConnectionItem::setPath() {
     }
   }
 
-  pps.setWidth(5);
-  pathShape = pps.createStroke(pathPaint);
+  //pps.setWidth(5);
+  //pathShape = pps.createStroke(pathPaint);
 }
 
 
@@ -406,86 +414,123 @@ void ConnectionItem::computeEsse(int orientationFrom) {
 
   //cout << "drawing an esse" << endl;
   pathPaint = QPainterPath(pointFrom);
+  QPainterPath s;
   interPoints.clear();
-  double gap = marginConn;
+  double gap = marginConn;  
+  
   if ((orientationFrom == Parameters::North)||(orientationFrom == Parameters::West)) gap = -gap;
   QPointF p(0.0,0.0);
 
   if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
+        
     // must draw a complete esse
-    p = QPointF(pointFrom.x()+gap,pointFrom.y());
+    p = QPointF(pointFrom.x()+gap,pointFrom.y());    
+    s.moveTo(p);
     pathPaint.lineTo(p);
     interPoints.append(p);
     p = QPointF(pointFrom.x()+gap,(pointFrom.y()+pointTo.y())/2.0);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     p = QPointF(pointTo.x()-gap,(pointFrom.y()+pointTo.y())/2.0);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     p = QPointF(pointTo.x()-gap,pointTo.y());
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
   }
   else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
 
     // must draw a complete esse
-    p = QPointF(pointFrom.x(),pointFrom.y()+gap);
+    p = QPointF(pointFrom.x(),pointFrom.y()+gap);    
     pathPaint.lineTo(p);
+    s.moveTo(p);
     interPoints.append(p);
     p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y()+gap);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y()-gap);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     p = QPointF(pointTo.x(), pointTo.y()-gap);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
   }
+  pps.setWidth(5);
+  pathShape = pps.createStroke(s);
 }
 
 void ConnectionItem::computeStaircase(int orientationFrom) {
 
   pathPaint = QPainterPath(pointFrom);
-  interPoints.clear();
+  QPainterPath s;
+  double gap = marginConn;
+  interPoints.clear();  
   QPointF p(0.0,0.0);
 
   if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
+    
+    if (orientationFrom == Parameters::West) gap = -gap;
+    p = QPointF(pointFrom.x()+gap,pointFrom.y());    
+    s.moveTo(p);
+    
     if (pointFrom.y() == pointTo.y()) {
       //cout << "drawing straight line" << endl;
       pathPaint.lineTo(pointTo);
+      
     }
     else  {
       //cout << "drawing a staircase" << endl;
       // sufficient place to draw a simple staircase
       p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y());
       pathPaint.lineTo(p);
+      s.lineTo(p);   
       interPoints.append(p);
       p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y());
       pathPaint.lineTo(p);
+      s.lineTo(p);   
       interPoints.append(p);
       pathPaint.lineTo(pointTo);
     }
+    p = QPointF(pointTo.x()-gap,pointTo.y());    
+    s.lineTo(p);   
   }
   else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
+    
+    if (orientationFrom == Parameters::North) gap = -gap;
+    
+    p = QPointF(pointFrom.x(),pointFrom.y()+gap);    
+    s.moveTo(p);
+    
     if (pointFrom.x() == pointTo.x()) {
       //cout << "drawing straight line" << endl;
-      pathPaint.lineTo(pointTo);
+      pathPaint.lineTo(pointTo);      
     }
     else {
       //cout << "drawing a staircase" << endl;
       // sufficient place to draw a simple staircase
       p = QPointF(pointFrom.x(),(pointFrom.y()+pointTo.y())/2.0);
       pathPaint.lineTo(p);
+      s.lineTo(p);   
       interPoints.append(p);
       p = QPointF(pointTo.x(),(pointFrom.y()+pointTo.y())/2.0);
       pathPaint.lineTo(p);
+      s.lineTo(p);   
       interPoints.append(p);
       pathPaint.lineTo(pointTo);
     }
+    p = QPointF(pointTo.x(),pointTo.y()-gap);    
+    s.lineTo(p);   
   }
+  pps.setWidth(5);
+  pathShape = pps.createStroke(s);
 }
 
 /* drawCorner():
@@ -500,20 +545,37 @@ void ConnectionItem::computeCorner(int orientationFrom) {
   pathPaint = QPainterPath(pointFrom);
   interPoints.clear();
   QPointF p(0.0,0.0);
+  QPainterPath s;
+  double gap = marginConn;
+  
   //cout << "drawing a corner" << endl;
 
   if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
+    if (orientationFrom == Parameters::West) gap = -gap;
+    p = QPointF(pointFrom.x()+gap,pointFrom.y());    
+    s.moveTo(p);
     p = QPointF(pointTo.x(),pointFrom.y());
     pathPaint.lineTo(p);
+    s.lineTo(p);   
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
+    p = QPointF(pointTo.x(),pointTo.y()-gap);    
+    s.lineTo(p);   
   }
   else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
+    if (orientationFrom == Parameters::North) gap = -gap;
+    p = QPointF(pointFrom.x(),pointFrom.y()+gap);    
+    s.moveTo(p);
     p = QPointF(pointFrom.x(),pointTo.y());
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
+    p = QPointF(pointTo.x()-gap,pointTo.y());    
+    s.lineTo(p);   
   }
+  pps.setWidth(5);
+  pathShape = pps.createStroke(s);
 }
 
 /* drawOpenRect():
@@ -522,6 +584,8 @@ void ConnectionItem::computeCorner(int orientationFrom) {
   __
   |
   |_|
+  
+  Its beginning and end have always a size of marginConn
 */
 void ConnectionItem::computeOpenRect(int orientationFrom, int orientationTo) {
   pathPaint = QPainterPath(pointFrom);
@@ -529,6 +593,7 @@ void ConnectionItem::computeOpenRect(int orientationFrom, int orientationTo) {
   QPointF p(0.0,0.0);
   double gap1 = marginConn;
   double gap2 = marginConn;
+  QPainterPath s;  
   //cout << "drawing an OpenRect" << endl;
 
   if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
@@ -540,12 +605,15 @@ void ConnectionItem::computeOpenRect(int orientationFrom, int orientationTo) {
     }
     p = QPointF(pointFrom.x()+gap1,pointFrom.y());
     pathPaint.lineTo(p);
+    s.moveTo(p);
     interPoints.append(p);
     p = QPointF(pointFrom.x()+gap1,pointTo.y()+gap2);
     pathPaint.lineTo(p);
+    s.lineTo(p);   
     interPoints.append(p);
     p = QPointF(pointTo.x(),pointTo.y()+gap2);
     pathPaint.lineTo(p);
+    s.lineTo(p);   
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
 
@@ -559,17 +627,23 @@ void ConnectionItem::computeOpenRect(int orientationFrom, int orientationTo) {
     }
     p = QPointF(pointFrom.x(),pointFrom.y()+gap1);
     pathPaint.lineTo(p);
+    s.moveTo(p);
     interPoints.append(p);
     p = QPointF(pointTo.x()+gap2,pointFrom.y()+gap1);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     p = QPointF(pointTo.x()+gap2,pointTo.y());
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
   }
+  pps.setWidth(5);
+  pathShape = pps.createStroke(s);
 }
 
+
 /* drawHookSmallEnd():
 
   A Hook has the following shape :
@@ -581,41 +655,57 @@ void ConnectionItem::computeOpenRect(int orientationFrom, int orientationTo) {
 void ConnectionItem::computeHookSmallEnd(int orientationFrom, int orientationTo) {
   pathPaint = QPainterPath(pointFrom);
   interPoints.clear();
-  QPointF p(0.0,0.0);
-  double gap = marginConn;
+  QPointF p(0.0,0.0);  
+  QPainterPath s;
+  double gap2 = marginConn;
+  double gap1 = marginConn;
   //cout << "drawing a Hook with small end" << endl;
 
   if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
 
-    if (orientationTo == Parameters::North) gap = -gap;
+    if (orientationFrom == Parameters::West) gap1 = -gap1;
+    if (orientationTo == Parameters::North) gap2 = -gap2;
 
+    p = QPointF(pointFrom.x()+gap1,pointFrom.y());
+    s.moveTo(p);
     p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y());
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
-    p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y()+gap);
+    p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y()+gap2);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
-    p = QPointF(pointTo.x(),pointTo.y()+gap);
+    p = QPointF(pointTo.x(),pointTo.y()+gap2);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
 
   }
   else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
 
-    if (orientationTo == Parameters::West) gap = -gap;
-
+    if (orientationFrom == Parameters::North) gap1 = -gap1;
+    if (orientationTo == Parameters::West) gap2 = -gap2;
+    
+    p = QPointF(pointFrom.x(),pointFrom.y()+gap1);
+    s.moveTo(p);
     p = QPointF(pointFrom.x(),(pointFrom.y()+pointTo.y())/2.0);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
-    p = QPointF(pointTo.x()+gap,(pointFrom.y()+pointTo.y())/2.0);
+    p = QPointF(pointTo.x()+gap2,(pointFrom.y()+pointTo.y())/2.0);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
-    p = QPointF(pointTo.x()+gap,pointTo.y());
+    p = QPointF(pointTo.x()+gap2,pointTo.y());
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
   }
+  pps.setWidth(5);
+  pathShape = pps.createStroke(s);
 }
 
 /* drawHookSmallStart():
@@ -630,39 +720,55 @@ void ConnectionItem::computeHookSmallStart(int orientationFrom, int orientationT
   pathPaint = QPainterPath(pointFrom);
   interPoints.clear();
   QPointF p(0.0,0.0);
-  double gap = marginConn;
+  QPainterPath s;
+  double gap1 = marginConn;
+  double gap2 = marginConn;
   //cout << "drawing a Hook with small start" << endl;
 
   if ((orientationFrom == Parameters::East)||(orientationFrom == Parameters::West)) {
 
-    if (orientationFrom == Parameters::West) gap = -gap;
+    if (orientationFrom == Parameters::West) gap1 = -gap1;
+    if (orientationTo == Parameters::North) gap2 = -gap2;
 
-    p = QPointF(pointFrom.x()+gap,pointFrom.y());
+    p = QPointF(pointFrom.x()+gap1,pointFrom.y());
+    s.moveTo(p);
     pathPaint.lineTo(p);
     interPoints.append(p);
-    p = QPointF(pointFrom.x()+gap,(pointFrom.y()+pointTo.y())/2.0);
+    p = QPointF(pointFrom.x()+gap1,(pointFrom.y()+pointTo.y())/2.0);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     p = QPointF(pointTo.x(),(pointFrom.y()+pointTo.y())/2.0);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
+    p = QPointF(pointTo.x(),pointFrom.y()+gap2);
+    s.lineTo(p);
   }
   else if ((orientationFrom == Parameters::South)||(orientationFrom == Parameters::North)) {
 
-    if (orientationFrom == Parameters::North) gap = -gap;
+    if (orientationFrom == Parameters::North) gap1 = -gap1;
+    if (orientationTo == Parameters::West) gap2 = -gap2;
 
-    p = QPointF(pointFrom.x(),pointFrom.y()+gap);
+    p = QPointF(pointFrom.x(),pointFrom.y()+gap1);
+    s.moveTo(p);
     pathPaint.lineTo(p);
     interPoints.append(p);
-    p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y()+gap);
+    p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointFrom.y()+gap1);
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     p = QPointF((pointFrom.x()+pointTo.x())/2.0,pointTo.y());
     pathPaint.lineTo(p);
+    s.lineTo(p);
     interPoints.append(p);
     pathPaint.lineTo(pointTo);
+    p = QPointF(pointTo.x()+gap2,pointFrom.y());
+    s.lineTo(p);
   }
+  pps.setWidth(5);
+  pathShape = pps.createStroke(s);
 }
 
 /* drawElle():
@@ -677,78 +783,84 @@ void ConnectionItem::computeElle(int orientationFrom) {
   pathPaint = QPainterPath(pointFrom);
   interPoints.clear();
   QPointF p(0.0,0.0);
+  QPainterPath s;
+  double gap = marginConn;  
+  
   double x;
   double y;
-  switch(orientationFrom){
-  case Parameters::North :
-    if(pointFrom.y() < pointTo.y()) {
-      y = pointFrom.y()-marginConn;
-    }
-    else {
-      y = pointTo.y()-marginConn;
-    }
-    p = QPointF(pointFrom.x(),y);
-    pathPaint.lineTo(p);
-    interPoints.append(p);
-    p = QPointF(pointTo.x(),y);
-    pathPaint.lineTo(p);
-    interPoints.append(p);
-    pathPaint.lineTo(pointTo);
-    break;
-  case Parameters::South :
-    if(pointFrom.y() > pointTo.y()) {
-      y = pointFrom.y()+marginConn;
-    }
-    else {
-      y = pointTo.y()+marginConn;
+  if ((orientationFrom == Parameters::North) || (orientationFrom == Parameters::South)) {
+    double diffPos = pointFrom.y() - pointTo.y();
+    if (orientationFrom == Parameters::North) {
+      gap = -gap;
+      diffPos = -diffPos;
     }
-    p = QPointF(pointFrom.x(),y);
-    pathPaint.lineTo(p);
-    interPoints.append(p);
-    p = QPointF(pointTo.x(),y);
-    pathPaint.lineTo(p);
-    interPoints.append(p);
-    pathPaint.lineTo(pointTo);
-    break;
-  case Parameters::West :
-    if(pointFrom.x() < pointTo.x()) {
-      x = pointFrom.x()-marginConn;
+    p = QPointF(pointFrom.x(),pointFrom.y()+gap);
+    s.moveTo(p);
+    if (diffPos >= 0.0) {      
+      pathPaint.lineTo(p);
+      interPoints.append(p);
+      p = QPointF(pointTo.x(),pointFrom.y()+gap);
+      pathPaint.lineTo(p);
+      s.lineTo(p);
+      interPoints.append(p);
+      pathPaint.lineTo(pointTo);
+      p = QPointF(pointTo.x(),pointTo.y()+gap);
+      s.lineTo(p);
     }
     else {
-      x = pointTo.x()-marginConn;
+      p = QPointF(pointFrom.x(),pointTo.y()+gap);
+      pathPaint.lineTo(p);
+      s.lineTo(p);
+      interPoints.append(p);
+      p = QPointF(pointTo.x(),pointTo.y()+gap);
+      pathPaint.lineTo(p);
+      s.lineTo(p);
+      interPoints.append(p);
+      pathPaint.lineTo(pointTo);
+    }    
+  }
+  else if ((orientationFrom == Parameters::West) || (orientationFrom == Parameters::East)) {
+    double diffPos = pointFrom.x() - pointTo.x();
+    if (orientationFrom == Parameters::West) {
+      gap = -gap;
+      diffPos = -diffPos;
     }
-    p = QPointF(x, pointFrom.y());
-    pathPaint.lineTo(p);
-    interPoints.append(p);
-    p = QPointF(x, pointTo.y());
-    pathPaint.lineTo(p);
-    interPoints.append(p);
-    pathPaint.lineTo(pointTo);
-    break;
-  case Parameters::East :
-    if(pointFrom.x() > pointTo.x()) {
-      x = pointFrom.x()+marginConn;
+    p = QPointF(pointFrom.x()+gap,pointFrom.y());
+    s.moveTo(p);
+    if (diffPos >= 0.0) {      
+      pathPaint.lineTo(p);
+      interPoints.append(p);
+      p = QPointF(pointTo.x()+gap,pointFrom.y());
+      pathPaint.lineTo(p);
+      s.lineTo(p);
+      interPoints.append(p);
+      pathPaint.lineTo(pointTo);
+      p = QPointF(pointTo.x()+gap,pointTo.y());
+      s.lineTo(p);
     }
     else {
-      x = pointTo.x()+marginConn;
+      p = QPointF(pointFrom.x()+gap,pointTo.y());
+      pathPaint.lineTo(p);
+      s.lineTo(p);
+      interPoints.append(p);
+      p = QPointF(pointTo.x()+gap,pointTo.y());
+      pathPaint.lineTo(p);
+      s.lineTo(p);
+      interPoints.append(p);
+      pathPaint.lineTo(pointTo);
     }
-    p = QPointF(x, pointFrom.y());
-    pathPaint.lineTo(p);
-    interPoints.append(p);
-    p = QPointF(x, pointTo.y());
-    pathPaint.lineTo(p);
-    interPoints.append(p);
-    pathPaint.lineTo(pointTo);
-    break;
   }
+  
+  pps.setWidth(5);
+  pathShape = pps.createStroke(s);
 }
 
 void ConnectionItem::setSelected(bool selected) {
   this->selected = selected;
   if(selected){
-    setZValue(50);
+    setZValue(201);
   } else {
-    setZValue(0);
+    setZValue(200);
   }
 }
 
@@ -772,18 +884,22 @@ void ConnectionItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
   /* have to check if the connection can be removed.
      If the from or to InterfaceItem is owned by a group item, and this item
      is both connected to and from, thus it is impossible to remove this connection
+     because there would be a  group interface alone and not connected and this situation is not allowed.
+
+     Nevertheless, there are 2 exceptions :
+        - a from group interface is connected to more than one input interface
+        - the connection is between a source block outside the top group and the top group
    */
   bool canRemove = true;
-  InterfaceItem* groupIfaceItem = NULL;
+
   if (fromInterfaceItem->getOwner()->isGroupItem()) {
-    groupIfaceItem = fromInterfaceItem;
-  }
-  else if (toInterfaceItem->getOwner()->isGroupItem()) {
-    groupIfaceItem = toInterfaceItem;
+    ConnectedInterface* ref = fromInterfaceItem->refInter;
+    if ((ref->isConnectedFrom()) && (ref->getConnectedTo().length() == 1)) {
+      canRemove = false;
+    }
   }
-
-  if (groupIfaceItem != NULL) {
-    ConnectedInterface* ref = groupIfaceItem->refInter;
+  else if ((toInterfaceItem->getOwner()->isGroupItem()) && (! toInterfaceItem->getOwner()->getRefBlock()->isTopGroupBlock())) {
+    ConnectedInterface* ref = toInterfaceItem->refInter;
     if ((ref->isConnectedFrom()) && (ref->isConnectedTo())) {
       canRemove = false;
     }
@@ -798,7 +914,7 @@ void ConnectionItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
     QAction * selectedAction= menu.exec(event->screenPos());
 
     if(selectedAction == removeAction){
-      dispatcher->removeConnection(this);
+      dispatcher->removeConnection(Dispatcher::Design, this);
     }
   }
 }