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

Private GIT Repository
changed name of the class that converts VHDL -> XML
[blast.git] / InterfaceItem.cpp
index 0047e16f5a810aef7e76f06d88f251e40cf15953..10158d7bd7a97a78fb4b3ce1d8e06d6d4559fee6 100644 (file)
@@ -11,7 +11,7 @@ InterfaceItem::InterfaceItem(double _position,
                              int _orientation,
                              ConnectedInterface *_refInter,
                              AbstractBoxItem* _owner,
                              int _orientation,
                              ConnectedInterface *_refInter,
                              AbstractBoxItem* _owner,
-                             Parameters* _params){
+                             Parameters* _params) {
   positionRatio = _position;
   orientation = _orientation;
   refInter = _refInter;
   positionRatio = _position;
   orientation = _orientation;
   refInter = _refInter;
@@ -95,7 +95,12 @@ void InterfaceItem::paint(QPainter *painter) {
       painter->setPen(QPen(Qt::red,2));
     }    
     else  {
       painter->setPen(QPen(Qt::red,2));
     }    
     else  {
-      painter->setPen(QPen(Qt::black,1));
+      if(owner->isBoxItem()) {
+        painter->setPen(QPen(Qt::black,1));
+      }
+      else if(owner->isSourceItem()) {
+        painter->setPen(QPen(Qt::darkCyan,1));
+      }
     }
 
     painter->translate(originPoint);
     }
 
     painter->translate(originPoint);
@@ -124,6 +129,12 @@ void InterfaceItem::paint(QPainter *painter) {
     }
 
     // draw names
     }
 
     // draw names
+    if(selected) {
+      painter->setPen(QPen(Qt::red,2));
+    }    
+    else  {
+      painter->setPen(QPen(Qt::black,1));      
+    }
 
     // reset to normal if at west
     if(orientation == Parameters::West){
 
     // reset to normal if at west
     if(orientation == Parameters::West){
@@ -141,7 +152,7 @@ void InterfaceItem::paint(QPainter *painter) {
       if(owner->isGroupItem()){
         painter->drawText(-(w+params->arrowWidth+params->arrowLineLength),-h/2,w,h,Qt::AlignLeft | Qt::TextWordWrap, refInter->getName());
       }
       if(owner->isGroupItem()){
         painter->drawText(-(w+params->arrowWidth+params->arrowLineLength),-h/2,w,h,Qt::AlignLeft | Qt::TextWordWrap, refInter->getName());
       }
-      else if(owner->isBoxItem()){
+      else if((owner->isBoxItem()) || (owner->isSourceItem())){
         painter->drawText(0,-h/2,w,h,Qt::AlignRight | Qt::TextWordWrap, refInter->getName());
       }
     }
         painter->drawText(0,-h/2,w,h,Qt::AlignRight | Qt::TextWordWrap, refInter->getName());
       }
     }
@@ -150,7 +161,7 @@ void InterfaceItem::paint(QPainter *painter) {
       if(owner->isGroupItem()) {
         painter->drawText(params->arrowWidth+params->arrowLineLength,-h/2,w,h,Qt::AlignRight | Qt::TextWordWrap, refInter->getName());
       }
       if(owner->isGroupItem()) {
         painter->drawText(params->arrowWidth+params->arrowLineLength,-h/2,w,h,Qt::AlignRight | Qt::TextWordWrap, refInter->getName());
       }
-      else if(owner->isBoxItem()) {
+      else if((owner->isBoxItem()) || (owner->isSourceItem())){     
         painter->drawText(-w,-h/2,w,h,Qt::AlignLeft | Qt::TextWordWrap, refInter->getName());
       }
     }    
         painter->drawText(-w,-h/2,w,h,Qt::AlignLeft | Qt::TextWordWrap, refInter->getName());
       }
     }    
@@ -159,33 +170,30 @@ void InterfaceItem::paint(QPainter *painter) {
   }
 }
 
   }
 }
 
-QPointF InterfaceItem::getEndPointInGroup() {
-  QPointF p;
+QPointF InterfaceItem::getStartPosition() {
+  QPointF p = originPoint;
+  QPointF ownerPos = owner->scenePos();  
+  p += ownerPos;
+  return p;
+}
 
 
-  if (owner->isGroupItem()) {
-    p = originPoint;
-  }
-  else {
-    double x = owner->x() + originPoint.x();
-    double y = owner->y() + originPoint.y();
-    switch(orientation){
-    case Parameters::East:
-      x += params->arrowWidth+params->arrowLineLength;
-      break;
-    case Parameters::North:
-      y -= params->arrowWidth+params->arrowLineLength;
-      break;
-    case Parameters::West:
-      x -= params->arrowWidth+params->arrowLineLength;
-      break;
-    case Parameters::South:
-      y += params->arrowWidth+params->arrowLineLength;
-      break;
-    }
-    p = QPointF(x,y);
+QPointF InterfaceItem::getEndPosition() {
+  QPointF p = getStartPosition();
+  
+  switch(orientation){
+  case Parameters::East:
+    p.setX(p.x()+params->arrowWidth+params->arrowLineLength);
+    break;
+  case Parameters::North:
+    p.setY(p.y() - params->arrowWidth-params->arrowLineLength);
+    break;
+  case Parameters::West:
+    p.setX(p.x() - params->arrowWidth-params->arrowLineLength);
+    break;
+  case Parameters::South:
+    p.setY(p.y() + params->arrowWidth+params->arrowLineLength);
+    break;
   }
   }
-
-  //cout << "iface end point in group item: " << p.x() << "," << p.y() << endl;
   return p;
 }
 
   return p;
 }
 
@@ -249,7 +257,7 @@ void InterfaceItem::addConnectionItem(ConnectionItem* item) {
 }
 
 void InterfaceItem::removeConnectionItem(ConnectionItem* item) {
 }
 
 void InterfaceItem::removeConnectionItem(ConnectionItem* item) {
-  connections.removeOne(item);
+  connections.removeAll(item);
 }
 
 QDataStream &operator <<(QDataStream &out, InterfaceItem *i) {
 }
 
 QDataStream &operator <<(QDataStream &out, InterfaceItem *i) {