X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/5d4e709cb8d460b2efc083e6e7999f1c3a0eb602..c8c1e24dac94abfacb78fb3b661c9a5dbbb0d86a:/Parameters.cpp?ds=sidebyside

diff --git a/Parameters.cpp b/Parameters.cpp
index 3cc8c14..322046d 100644
--- a/Parameters.cpp
+++ b/Parameters.cpp
@@ -9,6 +9,7 @@
 #include "GroupScene.h"
 #include "GroupItem.h"
 #include "BoxItem.h"
+#include "SourceItem.h"
 #include "InterfaceItem.h"
 #include "ConnectionItem.h"
 
@@ -232,6 +233,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     if (idUpperScene != -1) {
       groupWidget->setWindowTitle(groupBlock->getName());
       groupWidget->show();
+      cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;
     }    
   }
   dispatcher->setSceneCounter(maxIdScene+1);
@@ -249,7 +251,29 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     GroupScene *currentScene = searchSceneById(idScene,topScene);
 
     if(currentScene == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
-
+    /**********************************************************
+     2.1 : getting sources if it is top scene
+    ***********************************************************/
+    if (currentScene->isTopScene()) {
+      QDomNodeList sourceNodes = currentSceneNode.elementsByTagName("source_item");
+      cout << "top scene has " << sourceNodes.length() << " sources" << endl;
+      for(int j=0; j<sourceNodes.length(); j++) {
+        QDomElement currentSBNode = sourceNodes.at(j).toElement();      
+        SourceItem* sourceItem = new SourceItem(dispatcher,this);
+        try {
+          sourceItem->load(currentSBNode);
+        }
+        catch(Exception err) {
+          throw(err);
+        }
+        cout << "source item has been read, add it to the scene" << endl;
+        // add the block to the GroupScene
+        currentScene->addSourceItem(sourceItem);
+      } 
+    }
+    /**********************************************************
+     2.2 : getting functional blocks
+    ***********************************************************/
     QDomNodeList functionalBlockNodes = currentSceneNode.elementsByTagName("bi_functional");
 
     for(int j=0; j<functionalBlockNodes.length(); j++) {
@@ -306,7 +330,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
       // get the GroupItem already created and set at phase 1
       GroupItem *insideGroup = searchGroupItemById(idGroup, topScene);
       BoxItem* upperItem = NULL;
-      if(insideGroup == NULL) cout << "group null" << endl;
+      if(insideGroup == NULL) cout << "group null" << endl;      
       // now search within the scene which BoxItem has a childItem that is = to insideGroup
       QList<BoxItem *> lst = currentScene->getBoxItems();
       foreach(BoxItem* item, lst) {
@@ -1022,6 +1046,15 @@ InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) {
       return item;
     }
   }
+  if (scene->isTopScene()) {
+    foreach(SourceItem *block, scene->getSourceItems()){
+      foreach(InterfaceItem *item, block->getInterfaces()){
+        if(item->getId() == id){
+          return item;
+        }
+      }
+    } 
+  }
   foreach(BoxItem *block, scene->getBoxItems()){
     foreach(InterfaceItem *item, block->getInterfaces()){
       if(item->getId() == id){