X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/3bbc311e444c1ef9ac66dd6861fb0acb13ddb72a..df84660fd98b39737692d57b68c8b2c2d34af0f1:/Parameters.cpp?ds=inline diff --git a/Parameters.cpp b/Parameters.cpp index 848ef7f..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; jload(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 lst = currentScene->getBoxItems(); foreach(BoxItem* item, lst) { @@ -342,10 +366,10 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { double position = currentInterfaceNode.attribute("position","none").toDouble(&ok); if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); - ConnectedInterface *refInter = insideGroup->searchInterfaceByName(refName)->refInter; + ConnectedInterface *refInter = insideGroup->searchInterfaceItemByName(refName)->refInter; InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this); ifaceItem->setId(id); - upperItem->addInterface(ifaceItem); + upperItem->addInterfaceItem(ifaceItem); } } } @@ -683,6 +707,12 @@ void Parameters::loadImplementationsFromXml() throw(Exception) { QString refXml = implRoot.attribute("ref_name","none"); QString refMd5 = implRoot.attribute("ref_md5","none"); BlockImplementation* impl = new BlockImplementation(fileName,refXml,refMd5); + try { + impl->loadPatterns(implRoot); + } + catch(int err) { + throw(err); + } availableImplementations.append(impl); ReferenceBlock* ref = NULL; @@ -694,9 +724,12 @@ void Parameters::loadImplementationsFromXml() throw(Exception) { } if (ref == NULL) { cout << "Cannot find a reference block for impl :" << qPrintable(fileName) << endl; - } - ref->addImplementation(impl); - impl->setReference(ref); + } + else { + ref->addImplementation(impl); + impl->setReference(ref); + if (! impl->checkPatterns()) throw(Exception(IMPLFILE_CORRUPTED)); + } cout << "OK" << endl; } } @@ -741,8 +774,11 @@ void Parameters::loadImplementationsFromLib() throw(Exception) { if (ref == NULL) { cout << "Cannot find a reference block for impl :" << qPrintable(impl->getXmlFile()) << endl; } - ref->addImplementation(impl); - impl->setReference(ref); + else { + ref->addImplementation(impl); + impl->setReference(ref); + if (! impl->checkPatterns()) throw(Exception(IMPLFILE_CORRUPTED)); + } } libFile.close(); } @@ -1010,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){