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

Private GIT Repository
moved generate vhdl methods
[blast.git] / Parameters.cpp
index d3a8dd4f7c669328a4ec87fad7fb880680d77872..46437c34bc0dcd1aa3cd36bca0ce9cf98379648f 100644 (file)
@@ -46,10 +46,12 @@ Parameters::Parameters() {
 \r
   unsaveModif = false;\r
   isRstClkShown = false;\r
-\r
-  projectPath = QDir::currentPath();\r
   \r
   validityExtension = "_enb";\r
+\r
+  projectPath = "";\r
+  projectName = "";\r
+  projectFile = "";\r
 }\r
 \r
 Parameters::~Parameters() {\r
@@ -81,7 +83,15 @@ ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) {
   BlockCategory* blockCat = categoryTree->searchCategory(idCategory);\r
 \r
   if (blockCat == NULL) return NULL;\r
-  ReferenceBlock* ref = blockCat->getBlock(idBlock);\r
+  ReferenceBlock* ref = blockCat->getBlockById(idBlock);\r
+  return ref;\r
+}\r
+\r
+ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) {\r
+\r
+  BlockCategory* blockCat = categoryTree->searchCategory(100);\r
+  if (blockCat == NULL) return NULL;\r
+  ReferenceBlock* ref = blockCat->getBlockByName(blockName);\r
   return ref;\r
 }\r
 \r
@@ -237,6 +247,16 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
   GroupBlock *groupBlock = NULL;\r
 \r
   GroupWidget* topGroup = NULL;\r
+\r
+  QString path = root.attribute("project_path","none");\r
+  if (path != "none") {\r
+    QDir dir(path);\r
+    if (dir.exists()) {\r
+      projectPath = path;\r
+\r
+    }\r
+    cout << "project path set to " << qPrintable(projectPath) << endl;\r
+  }\r
   /**********************************************************\r
    1 : getting scene and creating associated group widgets\r
   ***********************************************************/\r
@@ -457,23 +477,25 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     QString paramsStr = currentModifierNode.attribute("params","none");\r
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
 \r
-    AbstractInputModifier* mod = NULL;\r
-    if (typeStr == "delay") {\r
-      int delay = paramsStr.toInt(&ok);\r
-      if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-      mod = new DelayInputModifier(delay);\r
-    }\r
-\r
     /* NB: just adding delays for now. To be cont'd */\r
     InterfaceItem *iface = searchInterfaceItemById(id,topScene);\r
 \r
-    if(iface != NULL ) {\r
-      iface->refInter->setInputModifier(mod);\r
+    if ((iface == NULL ) || (iface->refInter == NULL) || (iface->refInter->getAssociatedIface() == NULL)) {\r
+      cout << "modified interface not found, modifiers setup canceled!" << endl;\r
+    }\r
+    else {\r
+      ConnectedInterface* connIface = AI_TO_CON(iface->refInter->getAssociatedIface());\r
 \r
-    } else {\r
-      cout << "interfaces not found, modifiers setup canceled!" << endl;\r
+      AbstractInputModifier* mod = NULL;\r
+      if (typeStr == "delay") {\r
+        int delay = paramsStr.toInt(&ok);\r
+        if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+        mod = new DelayInputModifier(connIface, delay);\r
+        connIface->setInputModifier(mod);\r
+      }\r
     }\r
   }\r
+\r
   cout << "modifiers loaded and created succefully!" << endl;\r
 \r
   return topGroup;\r
@@ -1092,8 +1114,13 @@ void Parameters::setArrowPathes() {
   _inArrow.lineTo(arrowLineLength+arrowWidth,-arrowHeight/2);\r
   _inArrow.lineTo(arrowLineLength+arrowWidth,arrowHeight/2);\r
   _inArrow.lineTo(arrowLineLength,0);\r
-  _inArrow.closeSubpath();\r
-  inArrow = _inArrow;\r
+  //_inArrow.closeSubpath();\r
+  dataArrowIn = _inArrow;\r
+\r
+  QPainterPath _inArrowC;\r
+  _inArrowC.lineTo(arrowLineLength,0);\r
+  _inArrowC.addEllipse(arrowLineLength,-arrowHeight/2,arrowHeight-1,arrowHeight-1);\r
+  clkrstArrow = _inArrowC;\r
 \r
   QPainterPath _outArrow;\r
   _outArrow.lineTo(arrowLineLength,0);\r
@@ -1101,8 +1128,8 @@ void Parameters::setArrowPathes() {
   _outArrow.lineTo(arrowLineLength+arrowWidth,0);\r
   _outArrow.lineTo(arrowLineLength,arrowHeight/2);\r
   _outArrow.lineTo(arrowLineLength,0);\r
-  _outArrow.closeSubpath();\r
-  outArrow = _outArrow;\r
+  //_outArrow.closeSubpath();\r
+  dataArrowOut = _outArrow;\r
 \r
 }\r
 \r
@@ -1197,3 +1224,10 @@ InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) {
   }\r
   return NULL;\r
 }\r
+\r
+QString Parameters::normalizeName(const QString &name) {\r
+  QString s = name;\r
+  s.replace(QRegularExpression("[^a-zA-Z0-9_]"),"_");\r
+  s.replace(QRegularExpression("[_]+"),"_");\r
+  return s;\r
+}\r