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

Private GIT Repository
finished testbench generation
[blast.git] / GroupItem.cpp
index c165d029c214f3301c090fb0125ac1aa667d69de..d9e74597cdce7f7113ffcf8d80cb4ea861d80894 100644 (file)
@@ -5,7 +5,7 @@
 #include "Dispatcher.h"
 #include "Parameters.h"
 #include "BoxItem.h"
 #include "Dispatcher.h"
 #include "Parameters.h"
 #include "BoxItem.h"
-#include "SourceItem.h"
+#include "StimuliItem.h"
 #include "AbstractBlock.h"
 #include "AbstractInterface.h"
 #include "ConnectedInterface.h"
 #include "AbstractBlock.h"
 #include "AbstractInterface.h"
 #include "ConnectedInterface.h"
@@ -88,6 +88,9 @@ void GroupItem::setParentItem(BoxItem *_parentItem) {
 }
 
 void GroupItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
 }
 
 void GroupItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+
+  if (!visible) return;
+
   if(boxWidth > 0 && boxHeight > 0){
     if(selected)
       painter->setPen(Qt::red);
   if(boxWidth > 0 && boxHeight > 0){
     if(selected)
       painter->setPen(Qt::red);
@@ -430,7 +433,7 @@ void GroupItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
     if (refBlock->isTopGroupBlock()) {
       QRectF rectGroup = boundingRectInScene();
       rectGroup.moveTo(rectGroup.x()+gapX,rectGroup.y()+gapY);
     if (refBlock->isTopGroupBlock()) {
       QRectF rectGroup = boundingRectInScene();
       rectGroup.moveTo(rectGroup.x()+gapX,rectGroup.y()+gapY);
-      foreach(SourceItem* source, getScene()->getSourceItems()) {
+      foreach(StimuliItem* source, getScene()->getSourceItems()) {
         QRectF rectSource = source->boundingRectInScene();
         if (rectGroup.intersects(rectSource)) canMove = false;
       }
         QRectF rectSource = source->boundingRectInScene();
         if (rectGroup.intersects(rectSource)) canMove = false;
       }
@@ -683,6 +686,7 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
   QAction* removeAction = NULL;
   QAction* renameAction = NULL;
   QAction* showParameters = NULL;
   QAction* removeAction = NULL;
   QAction* renameAction = NULL;
   QAction* showParameters = NULL;
+  QAction* addExtClkAction = NULL;
 
   InterfaceItem* ifaceItem = getInterfaceItemFromCursor(event->pos().x(), event->pos().y());
 
 
   InterfaceItem* ifaceItem = getInterfaceItemFromCursor(event->pos().x(), event->pos().y());
 
@@ -713,6 +717,10 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
       showParameters = menu.addAction("Show parameters");
     }
     renameAction = menu.addAction("Rename");
       showParameters = menu.addAction("Show parameters");
     }
     renameAction = menu.addAction("Rename");
+    if (refBlock->isTopGroupBlock()) {
+      addExtClkAction = menu.addAction("Add new external clock/reset");
+    }
+
   }
   QAction* selectedAction = menu.exec(event->screenPos());
 
   }
   QAction* selectedAction = menu.exec(event->screenPos());
 
@@ -732,7 +740,13 @@ void GroupItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
   }
   else if(selectedAction == showParameters) {
     new ParametersWindow(refBlock, params, NULL);
   }
   else if(selectedAction == showParameters) {
     new ParametersWindow(refBlock, params, NULL);
-  }   
+  }
+  else if (selectedAction == addExtClkAction) {
+    bool ok = false;
+    double freq = QInputDialog::getDouble(NULL,"Adding a clkrstgen","External clock frequency (in MHz)",100,0,100000,1,&ok);
+    if (!ok) return;
+    dispatcher->addClkRstGenBlock(Dispatcher::Design, freq);
+  }
 }
 
 InterfaceItem* GroupItem::isHoverInterface(QPointF point) {
 }
 
 InterfaceItem* GroupItem::isHoverInterface(QPointF point) {
@@ -802,16 +816,22 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) {
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
     
     GroupInterface *groupIface = new GroupInterface(groupBlock,name,direction,purpose);
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
     
     GroupInterface *groupIface = new GroupInterface(groupBlock,name,direction,purpose);
-    GroupInterface *groupCtlIface = new GroupInterface(groupBlock,name+"_enb",direction,AbstractInterface::Control);
-    groupCtlIface->setAssociatedIface(groupIface);
-    
-    InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params);
-    interfaceItem->setId(id);
-
     groupBlock->addInterface(groupIface);
     groupBlock->addInterface(groupIface);
-    groupBlock->addInterface(groupCtlIface);
+    bool show = false;
+    if ((groupBlock->isTopGroupBlock()) && (purpose == AbstractInterface::Clock)) {
+      show = true;
+    }
+
+    InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params,show);
+    interfaceItem->setId(id);
     addInterfaceItem(interfaceItem, false);
     addInterfaceItem(interfaceItem, false);
-    cout << "interface add to " << groupBlock->getName().toStdString() << endl;
+
+    if (purpose == AbstractInterface::Data) {
+      GroupInterface *groupCtlIface = new GroupInterface(groupBlock,name+"_enb",direction,AbstractInterface::Control);
+      groupCtlIface->setAssociatedIface(groupIface);
+      groupBlock->addInterface(groupCtlIface);
+    }
+    cout << "interface " << qPrintable(name) << " added to " << groupBlock->getName().toStdString() << endl;
   }
 
 }
   }
 
 }