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

Private GIT Repository
adding show/hide wb ifaces
authorstephane Domas <stephane.domas@univ-fcomte.fr>
Thu, 4 May 2017 19:31:01 +0000 (21:31 +0200)
committerstephane Domas <stephane.domas@univ-fcomte.fr>
Thu, 4 May 2017 19:31:01 +0000 (21:31 +0200)
AbstractBoxItem.cpp
AbstractBoxItem.h
BoxItem.cpp
Dispatcher.cpp
Dispatcher.h
MainWindow.cpp
ReferenceBlock.cpp
blast.creator.user
lib/references/multadd.xml
lib/references/references.bmf

index c4cdae9272ab244d220ef0f27d3d5de8a4f3f73f..a05247f0ffbc0ce8d627d91c65218b3955e51e4e 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "AbstractBlock.h"
 #include "GroupScene.h"
+#include "GroupItem.h"
 #include "AbstractInterface.h"
 #include "ConnectedInterface.h"
 
@@ -35,6 +36,7 @@ AbstractBoxItem::  AbstractBoxItem(AbstractBlock *_refBlock, Dispatcher *_dispat
   selected = false;
   currentInterface = NULL;
   rstClkVisible = false;
+  wishboneVisible = false;
 
   setAcceptHoverEvents(true);
 
@@ -63,7 +65,8 @@ AbstractBoxItem::AbstractBoxItem(Dispatcher *_dispatcher, Parameters *_params, Q
   selected = false;
   currentInterface = NULL;
   rstClkVisible = false;
-
+  wishboneVisible = false;
+  
   setAcceptHoverEvents(true);
 
   // NOTE : initInterfaces() is only called in subclasses
@@ -83,6 +86,35 @@ bool AbstractBoxItem::isBoxItem() {
 bool AbstractBoxItem::isGroupItem() {
   return false;
 }
+void AbstractBoxItem::setRstClkVisible(bool b) { 
+  rstClkVisible = b;
+  foreach(InterfaceItem* ifaceItem, interfaces) {
+    if ((ifaceItem->refInter->getPurpose() == AbstractInterface::Clock) ||
+        (ifaceItem->refInter->getPurpose() == AbstractInterface::Reset) ) {
+      ifaceItem->visible = b;
+    }
+  }
+  resetInterfacesPosition();
+  updateGeometry(InterfaceMove);
+  update();
+  getScene()->updateConnectionItemsShape();
+  (getScene()->getGroupItem())->updateShape();
+  
+}
+
+void AbstractBoxItem::setWishboneVisible(bool b) { 
+  wishboneVisible = b;
+  foreach(InterfaceItem* ifaceItem, interfaces) {
+    if (ifaceItem->refInter->getPurpose() == AbstractInterface::Wishbone) {
+      ifaceItem->visible = b;
+    }
+  }
+  resetInterfacesPosition();
+  updateGeometry(InterfaceMove);
+  update();
+  getScene()->updateConnectionItemsShape();
+  (getScene()->getGroupItem())->updateShape();
+}
 
 void AbstractBoxItem::setRefBlock(AbstractBlock* _refBlock) {
   refBlock = _refBlock;
@@ -96,18 +128,17 @@ void AbstractBoxItem::initInterfaces() {
   int orientation = Parameters::West;
 
   foreach(AbstractInterface *inter, refBlock->getInterfaces()){
-    if(inter->getPurpose() != AbstractInterface::Wishbone){
-      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);
+    
+    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);    
   }  
 }
 
@@ -155,7 +186,7 @@ void AbstractBoxItem::resetInterfacesPosition() {
 
   foreach(InterfaceItem* inter, interfaces) {
     // only data interfaces and if needed time and reset
-    if(inter->refInter->getPurpose() == AbstractInterface::Data || inter->getOwner()->isRstClkVisible()){
+    if(inter->visible) {
       if(inter->getOrientation() == Parameters::North){
         nbNorth++;
       } else if(inter->getOrientation() == Parameters::South){
@@ -170,7 +201,7 @@ void AbstractBoxItem::resetInterfacesPosition() {
 
   foreach(InterfaceItem* inter, interfaces) {
 
-    if(inter->refInter->getPurpose() == AbstractInterface::Data || inter->getOwner()->isRstClkVisible()){
+    if(inter->visible){
 
       if(inter->getOrientation() == Parameters::North){
         positionRatio = cntNorth/(double)(nbNorth+1);
index 98cec586cb3f35e73dd0777200f72f988e95736b..c061487af5f42781da17de45ab80916cf4a49bc5 100644 (file)
@@ -44,7 +44,8 @@ public:
   void setRefBlock(AbstractBlock* _refBlock);
   inline void setId(int _id){ id = _id; }
   inline void setSelected(bool _selected) { selected = _selected; }  
-  inline void setRstClkVisible(bool b){ rstClkVisible = b;}
+  void setRstClkVisible(bool b);
+  void setWishboneVisible(bool b);
   void setDimension(int x, int y);
   inline void setCurrentInterface(InterfaceItem* iface) { currentInterface = iface; }
 
@@ -53,6 +54,7 @@ public:
   virtual bool isGroupItem();  
   inline bool isSelected() { return selected; }
   inline bool isRstClkVisible(){ return rstClkVisible;}
+  inline bool isWishboneVisible(){ return wishboneVisible;}
   bool isInterfaces(int orientation) const;
 
   // others
@@ -116,7 +118,8 @@ protected:
   QPointF originPoint; // the left-top point that is the origin of the bounding box
 
   bool selected;
-  bool rstClkVisible;
+  bool rstClkVisible; //! true if clock/reset interfaces are visible
+  bool wishboneVisible; //! true if wishbone interfaces are visible
 
   QPointF currentPosition; // the start point for resize
 
index a654718ed91877e2fdc3b509e47c3d74293cdc39..de22f19ce472c4ca8c651e23fe233f5fcb9a13c9 100644 (file)
@@ -485,7 +485,8 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
   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());
@@ -559,9 +560,12 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
     }
     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");
   }
@@ -603,8 +607,11 @@ void BoxItem::contextMenuEvent(QGraphicsSceneContextMenuEvent * event) {
   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);
index 73577b2a5fed6a991a55e760c10ea2436db8a01f..b6495bb4b536cb03706dc9acdb108b1f27958506 100644 (file)
@@ -449,16 +449,23 @@ void Dispatcher::showRaiseWindow(BoxItem *item) {
   params->setCurrentScene(currentGroup->getScene());
 }
 
-void Dispatcher::showRstClkInter(AbstractBoxItem *item) {
-  static QString fctName = "Dispatcher::showRstClkInter()";
+void Dispatcher::showRstClkIface(AbstractBoxItem *item) {
+  static QString fctName = "Dispatcher::showRstClkIface()";
 #ifdef DEBUG_FCTNAME
   cout << "call to " << qPrintable(fctName) << endl;
 #endif
 
   item->setRstClkVisible(!item->isRstClkVisible());
-  item->resetInterfacesPosition();
+  
+}
+
+void Dispatcher::showWishboneIface(AbstractBoxItem *item) {
+  static QString fctName = "Dispatcher::showWishboneIface()";
+#ifdef DEBUG_FCTNAME
+  cout << "call to " << qPrintable(fctName) << endl;
+#endif
 
-  item->getScene()->updateConnectionItemsShape();
+  item->setWishboneVisible(!item->isWishboneVisible());  
 }
 
 void Dispatcher::addNewFullGroup() {
index e79ad60c30dcd52093f398f0d0cc26dda6563750..61c41cb6cf1a6f84df00e44753e1d11972347c33 100644 (file)
@@ -43,7 +43,8 @@ public:
   GroupWidget* createChildScene(GroupWidget* parentWidget, BoxItem* upperItemOfGroupItem = NULL);
   void destroyScene(GroupScene* scene);
   void showRaiseWindow(BoxItem *item);
-  void showRstClkInter(AbstractBoxItem *item);
+  void showRstClkIface(AbstractBoxItem *item);
+  void showWishboneIface(AbstractBoxItem *item);
   GroupWidget *addNewEmptyGroup(GroupScene *scene, bool show = true);
   void addNewFullGroup();  
 
index 6afabcdcf21aabdb040159e13bec859acf1e6567..4be284b68cb1d8d4b738f81f47bf92f1683ffe3b 100644 (file)
@@ -292,6 +292,7 @@ void MainWindow::slotNewProject(){
   GroupWidget* topGroup = dispatcher->createTopScene();
   addTopGroup(topGroup);
   library->updateComboScene();
+  library->show();
   params->isCurrentProject = true;
 }
 
@@ -319,6 +320,9 @@ bool MainWindow::slotCloseProject(){
         break;
       }
     }
+    else {
+      doClose = true;
+    }
     if (doClose) {
       // removing the GroupWidget from stack
       QWidget *widget = stackedWidget->widget(1);
@@ -390,6 +394,9 @@ void MainWindow::closeEvent(QCloseEvent *event) {
     slotCloseProject();
     event->ignore();
   }
+  else {
+    library->deleteLater();
+  }
 
 }
 
index a0a8220d297e10043a7a4d975999e4676f0419e1..722fc12186da982f691d33db7a402b1b9cb9803b 100644 (file)
@@ -169,11 +169,16 @@ void ReferenceBlock::loadParameters(QDomElement &elt) throw(Exception) {
       int duration = 0;
       QString wbValue = "";
       QStringList listWb = wbStr.split(",");
+      cout << "wb param has:";
+      foreach(QString s, listWb) {
+        cout << qPrintable(s) << " | ";
+      }
+      cout << endl;
 
       if (listWb.at(0) == "r") {
         access = BlockParameter::Read;
       }
-      else if (wbStr == "w") {
+      else if (listWb.at(0) == "w") {
         access = BlockParameter::Write;
         bool ok;
         wbValue = listWb.at(1).toInt(&ok);
@@ -246,7 +251,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     nameStr = eltOutput.attribute("name","none");
     typeStr = eltOutput.attribute("type","none");
     widthStr = eltOutput.attribute("width","none");
-    purposeStr = eltOutput.attribute("type","none");
+    purposeStr = eltOutput.attribute("purpose","none");
     purpose = ReferenceInterface::translatePurpose(purposeStr);
     multStr = eltOutput.attribute("multiplicity","none");
     mult = ReferenceInterface::translateMultiplicity(multStr);
@@ -263,7 +268,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) {
     nameStr = eltBidir.attribute("name","none");
     typeStr = eltBidir.attribute("type","none");
     widthStr = eltBidir.attribute("width","none");
-    purposeStr = eltBidir.attribute("type","none");
+    purposeStr = eltBidir.attribute("purpose","none");
     purpose = ReferenceInterface::translatePurpose(purposeStr);
     multStr = eltBidir.attribute("multiplicity","none");
     mult = ReferenceInterface::translateMultiplicity(multStr);
@@ -278,17 +283,21 @@ void ReferenceBlock::createInterfaceForParameters() throw(Exception){
   foreach(BlockParameter* param, params) {
     
     if (param->isWishboneParameter()) {
-      BlockParameterWishbone* p = (BlockParameterWishbone*)param;
-      int orientation = -1;
+      
+      BlockParameterWishbone* p = (BlockParameterWishbone*)param;      
+      cout << "creating interface for parameter wb " << qPrintable(p->getName()) << endl;
+      
       if (p->getWBAccess() == BlockParameter::Read) {
-        iface = new ReferenceInterface(this,p->getName(),p->getType(),p->getWidth(), AbstractInterface::Output, AbstractInterface::Wishbone,1);
+        iface = new ReferenceInterface(this,p->getName(),p->getTypeString(),p->getWidth(), AbstractInterface::Output, AbstractInterface::Wishbone,1);
         outputs.append(iface);        
       }
       else if (p->getWBAccess() == BlockParameter::Write) {
-        iface = new ReferenceInterface(this,p->getName(),p->getType(),p->getWidth(), AbstractInterface::Input, AbstractInterface::Wishbone,1);
+        iface = new ReferenceInterface(this,p->getName(),p->getTypeString(),p->getWidth(), AbstractInterface::Input, AbstractInterface::Wishbone,1);
         inputs.append(iface);                
       }
-      ReferenceInterface* iface = new ReferenceInterface(this,p->getName(),p->getType(),p->getWidth(), orientation, AbstractInterface::Wishbone,1);
+      else {
+        throw (Exception(BLOCKFILE_CORRUPTED));
+      }
     }
   }
 }
index 5ea7a3a40ba8926476f7c96672539d13287d3ab6..95c4b8a9922fbca765b79fdda0ef4b4dee4177af 100755 (executable)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.2.1, 2017-05-04T17:29:00. -->
+<!-- Written by QtCreator 3.2.1, 2017-05-04T21:30:29. -->
 <qtcreator>
  <data>
   <variable>EnvironmentId</variable>
-  <value type="QByteArray">{1d077e47-e3a1-47fd-8b12-4de650e39df5}</value>
+  <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</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">{451ee8a3-56ff-4aba-8a8e-3da882cc142e}</value>
+   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2c9bf876-3476-44eb-8065-1f0844704dda}</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">/localhome/sdomas/Projet/Blast/code/blast</value>
+    <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/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">
index 7ef16bdaac4f62ab6f50294c7f8a60ea64c670f1..873216eb1e790241a12d94a72e6691279019c17c 100644 (file)
@@ -4,7 +4,7 @@
     <name>\r
       block multiply/add\r
     </name>\r
-    <category ids="2,5" />  \r
+    <category ids="1,4" />  \r
     <description>\r
       <brief>\r
        This block multiplies 2 input values, adding the result to a third one.\r
index 9bc3ec7bc6825962deb0dcc9e809f0036b5d4f69..a5ec5ae4323a138aa8e519fea0d953fca3da8a5b 100644 (file)
Binary files a/lib/references/references.bmf and b/lib/references/references.bmf differ