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

Private GIT Repository
correct relative positionning of source/group
[blast.git] / Parameters.cpp
index c991e5ff86fd033d5470157f7303d67576c0a6be..12f5b2b0e44e73d5cdeae81562323be4db7550d6 100644 (file)
@@ -43,6 +43,8 @@ Parameters::Parameters() {
   isRstClkShown = false;\r
 \r
   projectPath = QDir::currentPath();\r
+  \r
+  validityExtension = "_enb";\r
 }\r
 \r
 Parameters::~Parameters() {\r
@@ -69,39 +71,16 @@ void Parameters::destroyGraph() {
   delete graph;\r
 }\r
 \r
-GroupBlock* Parameters::addGroupBlock() {\r
-  GroupBlock* parent = AB_TO_GRP(currentScene->getGroupItem()->getRefBlock());\r
-  GroupBlock* newOne = graph->createChildBlock(parent);\r
-  return newOne;\r
-}\r
-\r
-FunctionalBlock* Parameters::addFunctionalBlock(int idCategory, int idBlock) {\r
+ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) {\r
 \r
   BlockCategory* blockCat = categoryTree->searchCategory(idCategory);\r
 \r
   if (blockCat == NULL) return NULL;\r
-  GroupBlock* group = AB_TO_GRP(currentScene->getGroupItem()->getRefBlock());\r
   ReferenceBlock* ref = blockCat->getBlock(idBlock);\r
-  if (ref == NULL) return NULL;\r
-\r
-  FunctionalBlock* newOne = graph->addFunctionalBlock(group, ref);\r
-  unsaveModif = true;\r
-\r
-  return newOne;\r
+  return ref;\r
 }\r
 \r
-FunctionalBlock* Parameters::duplicateFunctionalBlock(FunctionalBlock *block) {\r
 \r
-  ReferenceBlock* ref = block->getReference();\r
-  GroupBlock* group = AB_TO_GRP(block->getParent());\r
-\r
-  // adding to the group\r
-  FunctionalBlock* newBlock = new FunctionalBlock(group,ref);\r
-  newBlock->populate();\r
-  group->addBlock(newBlock);\r
-\r
-  return newBlock;\r
-}\r
 \r
 void Parameters::validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception) {\r
   // opening configFile\r
@@ -203,115 +182,64 @@ QDomElement Parameters::openProjectFile(const QString& projectFileName) throw(Ex
   return root;\r
 }\r
 \r
-void Parameters::loadProject(QDomElement root) {\r
-\r
-#ifdef DEBUG_INCLFUN\r
+GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {\r
 \r
   bool ok = false;\r
   GroupWidget* groupWidget = NULL;\r
   GroupItem *groupItem = NULL;\r
   GroupBlock *groupBlock = NULL;\r
 \r
+  GroupWidget* topGroup = NULL;\r
   /**********************************************************\r
    1 : getting scene and creating associated group widgets\r
   ***********************************************************/\r
   QDomNodeList scenesNodes = root.elementsByTagName("scene");\r
 \r
+  int maxIdScene = -1;\r
   for(int i=0; i<scenesNodes.length(); i++) {\r
     QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
     int idScene = currentSceneNode.attribute("id","none").toInt(&ok);\r
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+    if (idScene > maxIdScene) maxIdScene = idScene;\r
     int idUpperScene = currentSceneNode.attribute("upper_scene","none").toInt(&ok);\r
     if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
 \r
     if (idUpperScene == -1) {\r
-      dispatcher->createTopScene();\r
+      topGroup = dispatcher->createTopScene();\r
       topScene->setId(idScene);\r
-      groupItem = topScene->getGroupItem();\r
-      groupBlock = AB_TO_GRP(groupItem->getRefBlock());\r
+      groupItem = topScene->getGroupItem();      \r
       cout << "top group added to scene n°" << idScene << endl;\r
     }\r
     else {\r
-      GroupScene* scene = searchSceneById(idUpperScene, topScene);\r
-      GroupWidget* parent = scene->getGroupWindow();\r
-      groupWidget = dispatcher->createChildScene(parent);\r
-      groupItem = groupWidget->getScene()->getGroupItem();\r
-      groupBlock = AB_TO_GRP(groupItem->getRefBlock());\r
+      cout << "trying to create scene n°" << idScene << " with upper scene n°" <<idUpperScene << endl;\r
+      GroupScene* upperScene = searchSceneById(idUpperScene, topScene);\r
+      groupWidget = dispatcher->addNewEmptyGroup(upperScene,false);\r
+      groupWidget->getScene()->setId(idScene);\r
+      groupItem = groupWidget->getScene()->getGroupItem();      \r
     }\r
+    groupBlock = AB_TO_GRP(groupItem->getRefBlock());\r
     /**********************************************************\r
-     1.1 : getting the group item\r
+     1.1 : getting the group item of each scene\r
     ***********************************************************/\r
     QDomElement groupItemNode = currentSceneNode.firstChildElement("group_item");\r
-\r
-    int id = groupItemNode.attribute("id","none").toInt(&ok);\r
-    if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-    QString name = groupItemNode.attribute("name","none");\r
-    if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-    QStringList positionStr = groupItemNode.attribute("position","none").split(",");\r
-    if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
-    int posX = positionStr.at(0).toInt(&ok);\r
-    if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-    int posY = positionStr.at(1).toInt(&ok);\r
-    if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-    QStringList dimensionStr = groupItemNode.attribute("dimension","none").split(",");\r
-    if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
-    int dimX = dimensionStr.at(0).toInt(&ok);\r
-    if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-    int dimY = dimensionStr.at(1).toInt(&ok);\r
-    if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-    groupItem->setId(id);\r
-    groupItem->setPos(posX,posY);\r
-    groupItem->setDimension(dimX,dimY);\r
-    groupBlock->setName(name);\r
+    try {\r
+      groupItem->load(groupItemNode);\r
+    }\r
+    catch(Exception err) {\r
+      throw(err);\r
+    }\r
 \r
     if (idUpperScene != -1) {\r
       groupWidget->setWindowTitle(groupBlock->getName());\r
       groupWidget->show();\r
-    }\r
-    cout << "group info : \n-id : " << id << "\n-pos : " << posX << ", " << posY << "\n-dim : " << dimX << ", " << dimY << "\n-name : " << name.toStdString() << endl;\r
-\r
-    QDomNodeList interfaces = groupItemNode.elementsByTagName("group_iface");\r
-    for(int j=0; j<interfaces.length(); j++){\r
-      QDomElement currentInterfaceNode = interfaces.at(j).toElement();\r
-\r
-      int id = currentInterfaceNode.attribute("id","none").toInt(&ok);\r
-      if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      QString name = currentInterfaceNode.attribute("name","none");\r
-      if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      QString levelStr = currentInterfaceNode.attribute("level","none");\r
-      int level = AbstractInterface::getIntLevel(levelStr);\r
-      if(level == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      QString directionStr = currentInterfaceNode.attribute("direction","none");\r
-      int direction = AbstractInterface::getIntDirection(directionStr);\r
-      if(direction == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      QString orientationStr = currentInterfaceNode.attribute("orientation","none");\r
-      int orientation = InterfaceItem::getIntOrientation(orientationStr);\r
-      if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
-      if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction,level);\r
-\r
-      InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,groupItem,this);\r
-      interfaceItem->setId(id);\r
-\r
-      groupBlock->addInterface(groupInterface);\r
-      groupItem->addInterface(interfaceItem);\r
-      cout << "interface add to " << groupBlock->getName().toStdString() << endl;\r
-    }\r
+    }    \r
   }\r
-\r
+  dispatcher->setSceneCounter(maxIdScene+1);\r
   cout << "groupItems loaded and windows created succefully!" << endl;\r
 \r
+  /**********************************************************\r
+   2 : getting the functional blocks of each scene\r
+  ***********************************************************/\r
 \r
   for(int i=0; i<scenesNodes.length(); i++){\r
     QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
@@ -324,134 +252,24 @@ void Parameters::loadProject(QDomElement root) {
 \r
     QDomNodeList functionalBlockNodes = currentSceneNode.elementsByTagName("bi_functional");\r
 \r
-    for(int j=0; j<functionalBlockNodes.length(); j++){\r
-      QDomElement currentFBNode = functionalBlockNodes.at(j).toElement();\r
-\r
-      int id = currentFBNode.attribute("id","none").toInt(&ok);\r
-      if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      QString refXml = currentFBNode.attribute("ref_xml","none");\r
-      if(refXml == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      QString refMd5 = currentFBNode.attribute("ref_md5","none");\r
-      if(refMd5 == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      cout << "ref md5 : " << refMd5.toStdString() << "\nref xml : " << refXml.toStdString() << endl;\r
-\r
-      QString name = currentFBNode.attribute("name","none");\r
-      if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      QStringList positionStr = currentFBNode.attribute("position","none").split(",");\r
-      if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
-      int posX = positionStr.at(0).toInt(&ok);\r
-      if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-      int posY = positionStr.at(1).toInt(&ok);\r
-      if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      QStringList dimensionStr = currentFBNode.attribute("dimension","none").split(",");\r
-      if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
-      int dimX = dimensionStr.at(0).toInt(&ok);\r
-      if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-      int dimY = dimensionStr.at(1).toInt(&ok);\r
-      if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-      AbstractBlock *reference;\r
-      /*if(refMd5 != "none"){\r
-        cout << "md5" << endl;\r
-        reference = searchBlockByMd5(refMd5);\r
-      }\r
-      else */if(refXml != "none"){\r
-        cout << "xml" << endl;\r
-        reference = searchBlockByXml(refXml);\r
-      }\r
-      else {\r
-        throw(Exception(PROJECTFILE_CORRUPTED));\r
-      }\r
-\r
-      FunctionalBlock *functionalBlock = new FunctionalBlock(currentScene->getGroupItem()->getRefBlock(),reference);\r
-      functionalBlock->setName(name);\r
-\r
-      ((GroupBlock*)currentScene->getGroupItem()->getRefBlock())->addBlock(functionalBlock);\r
-\r
-\r
-      BlockItem *blockItem = new BlockItem(currentScene->getGroupItem(),functionalBlock,dispatcher,this);\r
-      blockItem->setPos(posX,posY);\r
-      blockItem->setDimension(dimX,dimY);\r
-      blockItem->setId(id);\r
-      ((GroupItem*)currentScene->getGroupItem())->addBlockItem(blockItem);\r
-      currentScene->addItem(blockItem);\r
-      currentScene->addBlockItem(blockItem);\r
-\r
-      QDomNodeList blockParamNodes = currentFBNode.elementsByTagName("bif_parameter");\r
-\r
-      for(int i=0; i<blockParamNodes.length(); i++){\r
-        QDomElement currentBlockParamNode = blockParamNodes.at(i).toElement();\r
-\r
-        QString name = currentBlockParamNode.attribute("name","none");\r
-        if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-        QString value = currentBlockParamNode.attribute("value","none");\r
-        if(value == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-        QString context = currentBlockParamNode.attribute("context","none");\r
-        if(context == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-        QString type = currentBlockParamNode.attribute("type","none");\r
-        if(type == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-\r
-        BlockParameter *blockParam = new BlockParameter;\r
-        blockParam->setName(name);\r
-        blockParam->setValue(value);\r
-        blockParam->setType(type);\r
-        if(context == "constant") blockParam->setContext(BlockParameter::Constant);\r
-        if(context == "user") blockParam->setContext(BlockParameter::User);\r
-        if(context == "generic") blockParam->setContext(BlockParameter::Generic);\r
-        if(context == "wb") blockParam->setContext(BlockParameter::Wishbone);\r
-        if(context == "port") blockParam->setContext(BlockParameter::Port);\r
-\r
-        functionalBlock->addParameter(blockParam);\r
+    for(int j=0; j<functionalBlockNodes.length(); j++) {\r
+      QDomElement currentFBNode = functionalBlockNodes.at(j).toElement();      \r
+      BoxItem* funcItem = new BoxItem(dispatcher,this, currentScene->getGroupItem());\r
+      try {\r
+        funcItem->loadFunctional(currentFBNode);\r
       }\r
-\r
-\r
-      QDomNodeList interfaceNodes = currentFBNode.elementsByTagName("bif_iface");\r
-\r
-      for(int i=0; i<interfaceNodes.length(); i++){\r
-\r
-        QDomElement currentInterfaceNode = interfaceNodes.at(i).toElement();\r
-\r
-        int id = currentInterfaceNode.attribute("id","none").toInt(&ok);\r
-        if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-        QString name = currentInterfaceNode.attribute("name","none");\r
-        if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-        QString refName = currentInterfaceNode.attribute("ref_name","none");\r
-        if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-        QString orientationStr = currentInterfaceNode.attribute("orientation","none");\r
-        int orientation = InterfaceItem::getIntOrientation(orientationStr);\r
-        if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-        double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
-        if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-        ReferenceInterface *refInter = (ReferenceInterface*)reference->getIfaceFromName(refName);\r
-        FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);\r
-        functionalBlock->addInterface(functionalInterface);\r
-        functionalInterface->setName(refName);\r
-\r
-        InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,functionalInterface,blockItem,this);\r
-        interfaceItem->setId(id);\r
-        interfaceItem->setName(name);\r
-\r
-        blockItem->addInterface(interfaceItem);\r
-\r
+      catch(Exception err) {\r
+        throw(err);\r
       }\r
+      // add the block to the GroupScene\r
+      currentScene->addBoxItem(funcItem);\r
     }\r
   }\r
-  cout << "functionalBlocks loaded and created succefully!" << endl;\r
+  cout << "functional blocks loaded and created succefully!" << endl;\r
 \r
+  /**********************************************************\r
+   3 : set the BoxItem that represents a GroupItem in a child scene\r
+  ***********************************************************/\r
 \r
   for(int i=0; i<scenesNodes.length(); i++){\r
     QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
@@ -485,19 +303,27 @@ void Parameters::loadProject(QDomElement root) {
       int dimY = dimensionStr.at(1).toInt(&ok);\r
       if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
 \r
-\r
+      // get the GroupItem already created and set at phase 1\r
       GroupItem *insideGroup = searchGroupItemById(idGroup, topScene);\r
+      BoxItem* upperItem = NULL;\r
       if(insideGroup == NULL) cout << "group null" << endl;\r
-      BlockItem *blockItem = new BlockItem(insideGroup->getRefBlock(), dispatcher, this);\r
-      blockItem->setChildGroupItem(insideGroup);\r
-      blockItem->setId(id);\r
-      blockItem->setPos(posX,posY);\r
-      blockItem->setDimension(dimX,dimY);\r
+      // now search within the scene which BoxItem has a childItem that is = to insideGroup\r
+      QList<BoxItem *> lst = currentScene->getBoxItems();\r
+      foreach(BoxItem* item, lst) {\r
+        if (item->getChildGroupItem() == insideGroup) {\r
+          upperItem = item;\r
+          break;\r
+        }\r
+      }\r
+      if (upperItem == NULL) {\r
+        throw(Exception(PROJECTFILE_CORRUPTED));\r
+      }\r
 \r
-      ((GroupItem*)currentScene->getGroupItem())->addBlockItem(blockItem);\r
-      currentScene->addItem(blockItem);\r
-      currentScene->addBlockItem(blockItem);\r
+      upperItem->setId(id);\r
+      upperItem->setPos(posX,posY);\r
+      upperItem->setDimension(dimX,dimY);\r
 \r
+      // set interfaces of this BoxItem\r
       QDomNodeList interfaceNodes = currentBiGroup.elementsByTagName("big_iface");\r
 \r
       for(int k=0; k<interfaceNodes.length(); k++){\r
@@ -516,34 +342,15 @@ void Parameters::loadProject(QDomElement root) {
         double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
         if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
 \r
-        GroupInterface *refInter = (GroupInterface*)insideGroup->searchInterfaceByName(refName)->refInter;\r
-        InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, blockItem, this);\r
+        ConnectedInterface *refInter = insideGroup->searchInterfaceByName(refName)->refInter;\r
+        InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this);\r
         ifaceItem->setId(id);\r
-        blockItem->addInterface(ifaceItem);\r
+        upperItem->addInterface(ifaceItem);\r
       }\r
     }\r
   }\r
   cout << "blockItems \"group\" loaded and created succefully!" << endl;\r
 \r
-\r
-  for(int i=0; i<scenesNodes.length(); i++){\r
-    QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
-\r
-    QDomElement groupItemNode = currentSceneNode.firstChildElement("group_item");\r
-\r
-    int id = groupItemNode.attribute("id","none").toInt(&ok);\r
-    if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-    int idUpperItem = groupItemNode.attribute("upper_item","none").toInt(&ok);\r
-    if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-    BlockItem *currentItem = searchBlockItemById(id,topScene);\r
-    GroupItem *upperItem = searchGroupItemById(idUpperItem, topScene);\r
-\r
-    if(currentItem != NULL && upperItem != NULL){\r
-      currentItem->setUpperItem(upperItem);\r
-    }\r
-  }\r
-\r
   QDomNodeList connectionNodes = root.elementsByTagName("connection");\r
 \r
   for(int i=0; i<connectionNodes.length(); i++){\r
@@ -560,13 +367,14 @@ void Parameters::loadProject(QDomElement root) {
     InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);\r
 \r
     if(iface1 != NULL && iface2 != NULL){\r
-      dispatcher->connect(iface1,iface2);\r
+      dispatcher->createConnectionItem(iface1,iface2);\r
     } else {\r
       cout << "interfaces not found, connect canceled!" << endl;\r
     }\r
   }\r
+  cout << "connections loaded and created succefully!" << endl;\r
 \r
-#endif\r
+  return topGroup;\r
 }\r
 \r
 void Parameters::loadBlastConfiguration(QString confFile) throw(Exception) {\r
@@ -714,7 +522,7 @@ void Parameters::loadReferencesFromXml() throw(Exception) {
 \r
       blockXML.close();\r
       try {\r
-        validateXmlFile(fileName,"block.xsd",Reference);\r
+        validateXmlFile(fileName,"reference.xsd",Reference);\r
       }\r
       catch(Exception err) {\r
         throw(err);\r
@@ -850,14 +658,14 @@ void Parameters::loadImplementationsFromXml() throw(Exception) {
       implXML.close();\r
       cout << "OK" << endl;\r
       cout << "reading " << qPrintable(fileName) << " content ...";\r
-      /*\r
+\r
       try {\r
-        validateXmlFile(fileName,"block.xsd",Implementation);\r
+        validateXmlFile(fileName,"implementation.xsd",Implementation);\r
       }\r
       catch(Exception e) {\r
         throw(e);\r
       }\r
-      */\r
+\r
       // reading in into QDomDocument\r
       QDomDocument document ("FileXML");\r
       if (!implXML.open(QIODevice::ReadOnly)) {\r
@@ -1029,14 +837,14 @@ QList<AbstractBlock *> Parameters::getBlocksToConfigure() {
 \r
 \r
 void Parameters::updateToolbar() {\r
-  int nb = currentScene->getBlockItems().length();\r
+  int nb = currentScene->getBoxItems().length();\r
   for(int i = 0; i<nb; i++){\r
-    if(currentScene->getBlockItems().at(i)->isSelected()){\r
-      currentScene->getGroupWindow()->enableGroupButton(true);\r
+    if(currentScene->getBoxItems().at(i)->isSelected()){\r
+      currentScene->getGroupWidget()->enableGroupButton(true);\r
       return;\r
     }\r
   }\r
-  currentScene->getGroupWindow()->enableGroupButton(false);\r
+  currentScene->getGroupWidget()->enableGroupButton(false);\r
 }\r
 \r
 \r
@@ -1098,9 +906,6 @@ void Parameters::save(QString confFile) {
     // cross the scene level by level using a FIFO\r
     QList<GroupScene*> fifoScene;\r
     fifoScene.append(topScene);\r
-    foreach(ConnectionItem* item, topScene->getConnectionItems()) {\r
-      allConnections.append(item);\r
-    }\r
 \r
     GroupScene *scene;\r
     while (!fifoScene.isEmpty()) {\r
@@ -1109,11 +914,12 @@ void Parameters::save(QString confFile) {
       foreach(GroupScene* s, scene->getChildrenScene()) {\r
         fifoScene.append(s);\r
       }\r
-      foreach(ConnectionItem* item, topScene->getConnectionItems()) {\r
+\r
+      foreach(ConnectionItem* item, scene->getConnectionItems()) {\r
         allConnections.append(item);\r
       }\r
     }\r
-\r
+    writer.writeEndElement();    //</scenes>\r
 \r
     writer.writeStartElement("connections");\r
     foreach(ConnectionItem* item, allConnections) {\r
@@ -1183,7 +989,7 @@ GroupItem* Parameters::searchGroupItemById(int id, GroupScene *scene) {
 \r
 BoxItem* Parameters::searchBlockItemById(int id, GroupScene *scene) {\r
 \r
-  foreach(BoxItem *item, scene->getBlockItems()){\r
+  foreach(BoxItem *item, scene->getBoxItems()){\r
     if(item->getId() == id){\r
       return item;\r
     }\r
@@ -1204,7 +1010,7 @@ InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) {
       return item;\r
     }\r
   }\r
-  foreach(BoxItem *block, scene->getBlockItems()){\r
+  foreach(BoxItem *block, scene->getBoxItems()){\r
     foreach(InterfaceItem *item, block->getInterfaces()){\r
       if(item->getId() == id){\r
         return item;\r