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

Private GIT Repository
start modifying read/write blocks and project to take into account control ifaces
[blast.git] / BoxItem.cpp
index a654718ed91877e2fdc3b509e47c3d74293cdc39..a107198654913fdc6badc66bc19ed9b13f784d47 100644 (file)
@@ -207,6 +207,13 @@ bool BoxItem::updateGeometry(ChangeType type) {
   return false;
 }
 
   return false;
 }
 
+void BoxItem::interfaceRenamed() {
+  if (updateGeometry(InterfaceMove)) {
+    //cout << "must recompute group item geometry" << endl;
+    (getScene()->getGroupItem())->updateShape();
+  }  
+}
+
 void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
 
   if(params->editState == Parameters::EditBlockMove) {
 void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
 
   if(params->editState == Parameters::EditBlockMove) {
@@ -282,7 +289,7 @@ void BoxItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
     moveInterfaceTo(event->pos());
     // recompute the geometry of the block
     if (updateGeometry(InterfaceMove)) {
     moveInterfaceTo(event->pos());
     // recompute the geometry of the block
     if (updateGeometry(InterfaceMove)) {
-      cout << "must recompute group item geometry" << endl;
+      //cout << "must recompute group item geometry" << endl;
       (getScene()->getGroupItem())->updateShape();
     }
     // update connection from/to the selected interface
       (getScene()->getGroupItem())->updateShape();
     }
     // update connection from/to the selected interface
@@ -485,7 +492,8 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
   QAction* showProperties = NULL;
   QAction* cloneInterface = NULL;
   QAction* openWindow = NULL;
   QAction* showProperties = NULL;
   QAction* cloneInterface = NULL;
   QAction* openWindow = NULL;
-  QAction* showRstClkInter = NULL;
+  QAction* showRstClkIface = NULL;
+  QAction* showWishboneIface = NULL;
   QAction* showParameters = NULL;
 
   InterfaceItem* ifaceItem = getInterfaceFromCursor(event->pos().x(), event->pos().y());
   QAction* showParameters = NULL;
 
   InterfaceItem* ifaceItem = getInterfaceFromCursor(event->pos().x(), event->pos().y());
@@ -559,9 +567,12 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
     }
     else {
       duplicateAction = menu.addAction("Duplicate");
     }
     else {
       duplicateAction = menu.addAction("Duplicate");
-      showRstClkInter = menu.addAction("Show reset/clock interfaces");
-      showRstClkInter->setCheckable(true);
-      showRstClkInter->setChecked(rstClkVisible);
+      showRstClkIface = menu.addAction("Show reset/clock interfaces");
+      showRstClkIface->setCheckable(true);
+      showRstClkIface->setChecked(rstClkVisible);
+      showWishboneIface = menu.addAction("Show wishbone interfaces");
+      showWishboneIface->setCheckable(true);
+      showWishboneIface->setChecked(wishboneVisible);
     }
     removeAction = menu.addAction("Remove");
   }
     }
     removeAction = menu.addAction("Remove");
   }
@@ -573,7 +584,7 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
 
   if (selectedAction == removeAction) {
     if(ifaceItem != NULL) {
 
   if (selectedAction == removeAction) {
     if(ifaceItem != NULL) {
-     dispatcher->removeBlockInterface(ifaceItem);
+     dispatcher->removeFunctionalInterface(ifaceItem);
     }
     else {
       dispatcher->removeBlock(this);
     }
     else {
       dispatcher->removeBlock(this);
@@ -603,8 +614,11 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
   else if (selectedAction == openWindow){
     dispatcher->showRaiseWindow(this);
   }
   else if (selectedAction == openWindow){
     dispatcher->showRaiseWindow(this);
   }
-  else if(selectedAction == showRstClkInter){
-    dispatcher->showRstClkInter(this);
+  else if(selectedAction == showRstClkIface) {
+    dispatcher->showRstClkIface(this);
+  }
+  else if(selectedAction == showWishboneIface) {
+    dispatcher->showWishboneIface(this);
   }
   else if(selectedAction == showParameters){
     new ParametersWindow(refBlock, params, NULL);
   }
   else if(selectedAction == showParameters){
     new ParametersWindow(refBlock, params, NULL);
@@ -641,7 +655,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
   int dimY = dimensionStr.at(1).toInt(&ok);
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
   int dimY = dimensionStr.at(1).toInt(&ok);
   if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
-
+  
   ReferenceBlock *referenceMd5 = NULL;
   ReferenceBlock *referenceXml = NULL;
   ReferenceBlock *reference = NULL;
   ReferenceBlock *referenceMd5 = NULL;
   ReferenceBlock *referenceXml = NULL;
   ReferenceBlock *reference = NULL;
@@ -660,6 +674,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
   else {
     reference = referenceMd5;
   }
   else {
     reference = referenceMd5;
   }
+  
   GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock());
   FunctionalBlock* functionalBlock = params->getGraph()->addFunctionalBlock(parentGroupBlock, reference);
   /* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when
   GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock());
   FunctionalBlock* functionalBlock = params->getGraph()->addFunctionalBlock(parentGroupBlock, reference);
   /* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when
@@ -688,9 +703,9 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
     blockParam = functionalBlock->getParameterFromName(name);
     if (blockParam == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
     blockParam->setValue(value);
     blockParam = functionalBlock->getParameterFromName(name);
     if (blockParam == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
     blockParam->setValue(value);
-  }
+  }  
 
 
-  // recreate all interface because of some may have a multiplicity>1 with several examplars
+  // recreate all (non-control) interfaces because of some may have a multiplicity>1 with several examplars
   functionalBlock->removeAllInterfaces();
   QDomNodeList interfaceNodes = funcElement.elementsByTagName("bif_iface");
   // setting interfaces (user name, and for multiplicity>1 may be create some new ones)
   functionalBlock->removeAllInterfaces();
   QDomNodeList interfaceNodes = funcElement.elementsByTagName("bif_iface");
   // setting interfaces (user name, and for multiplicity>1 may be create some new ones)
@@ -705,10 +720,26 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) {
     if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));
 
     ReferenceInterface* refInter = AI_TO_REF(reference->getIfaceFromName(refName));
     if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));
 
     ReferenceInterface* refInter = AI_TO_REF(reference->getIfaceFromName(refName));
+    cout << "creating iface from reference named " << qPrintable(refName) << endl;
     FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);
     functionalInterface->setName(name);
     functionalBlock->addInterface(functionalInterface);
     FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);
     functionalInterface->setName(name);
     functionalBlock->addInterface(functionalInterface);
+    
+    // searching for control interface
+    QString ctlRefName = refName+"_ctl";
+    ReferenceInterface* ctlRefIface = AI_TO_REF(reference->getIfaceFromName(ctlRefName));
+    
+    if (ctlRefIface != NULL) {
+      cout << "found a control iface:" << qPrintable(ctlRefName) << endl;
+      FunctionalInterface *ctlIface = new FunctionalInterface(functionalBlock,ctlRefIface);      
+      if (! ctlIface->setAssociatedIface(functionalInterface)) {
+        throw(Exception(PROJECTFILE_CORRUPTED));
+      }      
+      ctlIface->setName(name+"_ctl");
+      functionalBlock->addInterface(ctlIface);
+    }    
   }
   }
+  
   // creating InterfaceItem
   initInterfaces();
   // setting them with saved values
   // creating InterfaceItem
   initInterfaces();
   // setting them with saved values
@@ -745,7 +776,7 @@ void BoxItem::save(QXmlStreamWriter &writer) {
     writer.writeAttribute("ref_xml", ((FunctionalBlock*)refBlock)->getReferenceXmlFile());
     writer.writeAttribute("ref_md5", ((FunctionalBlock*)refBlock)->getReferenceHashMd5());
     writer.writeAttribute("name",refBlock->getName());
     writer.writeAttribute("ref_xml", ((FunctionalBlock*)refBlock)->getReferenceXmlFile());
     writer.writeAttribute("ref_md5", ((FunctionalBlock*)refBlock)->getReferenceHashMd5());
     writer.writeAttribute("name",refBlock->getName());
-    QString attrPos = QString::number(pos().x()).append(",").append(QString::number(pos().y()));
+    QString attrPos = QString::number((int)(pos().x())).append(",").append(QString::number((int)(pos().y())));
     writer.writeAttribute("position",attrPos);
     QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
     writer.writeAttribute("dimension",attrDim);
     writer.writeAttribute("position",attrPos);
     QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight()));
     writer.writeAttribute("dimension",attrDim);