X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/14cd6d834ab531525a51c6a6992583b3e9143e02..a13795fc34cd1e74f94695d35253c3d00abec9bc:/Parameters.cpp?ds=inline

diff --git a/Parameters.cpp b/Parameters.cpp
index 2ee6255..ec0041f 100644
--- a/Parameters.cpp
+++ b/Parameters.cpp
@@ -9,7 +9,7 @@
 #include "GroupScene.h"
 #include "GroupItem.h"
 #include "BoxItem.h"
-#include "SourceItem.h"
+#include "StimuliItem.h"
 #include "InterfaceItem.h"
 #include "ConnectionItem.h"
 
@@ -52,6 +52,8 @@ Parameters::Parameters() {
   projectPath = "";
   projectName = "";
   projectFile = "";
+
+  graph = new Graph();
 }
 
 Parameters::~Parameters() {
@@ -69,8 +71,8 @@ void Parameters::clear() {
   refPathes.clear();
 }
 
-Graph* Parameters::createGraph() {
-  graph = new Graph();
+Graph* Parameters::initGraph(bool createTopGroupIfaces) {
+  graph->createTopGroup(createTopGroupIfaces);
   return graph;
 }
 
@@ -95,6 +97,7 @@ ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) {
   return ref;
 }
 
+
 void Parameters::createDelayBlock() {
   delayRef = new ReferenceBlock("no.xml");
   delayRef->addCategory(100);
@@ -272,7 +275,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
 
     if (idUpperScene == -1) {
-      topGroup = dispatcher->createTopScene();
+      topGroup = dispatcher->createTopScene(Dispatcher::Load);
       topScene->setId(idScene);
       groupItem = topScene->getGroupItem();      
       cout << "top group added to scene n°" << idScene << endl;
@@ -280,7 +283,12 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     else {
       cout << "trying to create scene n°" << idScene << " with upper scene n°" <<idUpperScene << endl;
       GroupScene* upperScene = searchSceneById(idUpperScene, topScene);
-      groupWidget = dispatcher->addNewEmptyGroup(upperScene,false);
+      /* IMPORTANT: calling addNewEmptyGroup() leads to create a new GroupWidget
+       *            AND a BoxItem in upperScene that represents the GroupItem in the
+       *            newly created child scene. Thus, it has not to be created when
+       *            reading bi_group tags in the following but just searched
+       */
+      groupWidget = dispatcher->addNewEmptyGroup(Dispatcher::Load, upperScene,false);
       groupWidget->getScene()->setId(idScene);
       groupItem = groupWidget->getScene()->getGroupItem();      
     }
@@ -302,7 +310,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
       cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;
     }    
   }
-  dispatcher->setSceneCounter(maxIdScene+1);
+  dispatcher->setSceneCounter(Dispatcher::Load, maxIdScene+1);
   cout << "groupItems loaded and windows created succefully!" << endl;
 
   /**********************************************************
@@ -325,7 +333,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
       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);
+        StimuliItem* sourceItem = new StimuliItem(dispatcher,this);
         try {
           sourceItem->load(currentSBNode);
         }
@@ -334,7 +342,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
         }
         cout << "source item has been read, add it to the scene" << endl;
         // add the block to the GroupScene
-        currentScene->addSourceItem(sourceItem);
+        currentScene->addStimuliItem(sourceItem);
       } 
     }
     /**********************************************************
@@ -457,7 +465,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
     InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);
 
     if(iface1 != NULL && iface2 != NULL){
-      dispatcher->createConnection(iface1,iface2);
+      dispatcher->createConnection(Dispatcher::Load, iface1,iface2);
     } else {
       cout << "interfaces not found, connect canceled!" << endl;
     }
@@ -1303,7 +1311,7 @@ InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) {
     }
   }
   if (scene->isTopScene()) {
-    foreach(SourceItem *block, scene->getSourceItems()){
+    foreach(StimuliItem *block, scene->getSourceItems()){
       foreach(InterfaceItem *item, block->getInterfaces()){
         if(item->getId() == id){
           return item;