X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/4cf57e6db08da791233d75237f62e74bc88dd427..8f0bedf735fe2b306c11c3f4a168245a05e37ccd:/Parameters.cpp diff --git a/Parameters.cpp b/Parameters.cpp index d3a8dd4..32bec53 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -46,10 +46,12 @@ Parameters::Parameters() { unsaveModif = false; isRstClkShown = false; - - projectPath = QDir::currentPath(); validityExtension = "_enb"; + + projectPath = ""; + projectName = ""; + projectFile = ""; } Parameters::~Parameters() { @@ -81,7 +83,15 @@ ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) { BlockCategory* blockCat = categoryTree->searchCategory(idCategory); if (blockCat == NULL) return NULL; - ReferenceBlock* ref = blockCat->getBlock(idBlock); + ReferenceBlock* ref = blockCat->getBlockById(idBlock); + return ref; +} + +ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) { + + BlockCategory* blockCat = categoryTree->searchCategory(100); + if (blockCat == NULL) return NULL; + ReferenceBlock* ref = blockCat->getBlockByName(blockName); return ref; } @@ -237,6 +247,16 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { GroupBlock *groupBlock = NULL; GroupWidget* topGroup = NULL; + + QString path = root.attribute("project_path","none"); + if (path != "none") { + QDir dir(path); + if (dir.exists()) { + projectPath = path; + + } + cout << "project path set to " << qPrintable(projectPath) << endl; + } /********************************************************** 1 : getting scene and creating associated group widgets ***********************************************************/ @@ -457,23 +477,25 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { QString paramsStr = currentModifierNode.attribute("params","none"); if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); - AbstractInputModifier* mod = NULL; - if (typeStr == "delay") { - int delay = paramsStr.toInt(&ok); - if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); - mod = new DelayInputModifier(delay); - } - /* NB: just adding delays for now. To be cont'd */ InterfaceItem *iface = searchInterfaceItemById(id,topScene); - if(iface != NULL ) { - iface->refInter->setInputModifier(mod); + if ((iface == NULL ) || (iface->refInter == NULL) || (iface->refInter->getAssociatedIface() == NULL)) { + cout << "modified interface not found, modifiers setup canceled!" << endl; + } + else { + ConnectedInterface* connIface = AI_TO_CON(iface->refInter->getAssociatedIface()); - } else { - cout << "interfaces not found, modifiers setup canceled!" << endl; + AbstractInputModifier* mod = NULL; + if (typeStr == "delay") { + int delay = paramsStr.toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + mod = new DelayInputModifier(connIface, delay); + connIface->setInputModifier(mod); + } } } + cout << "modifiers loaded and created succefully!" << endl; return topGroup; @@ -552,10 +574,27 @@ void Parameters::loadBlastConfiguration(QString confFile) throw(Exception) { implPathes.append(path); cout << "impl path : " << qPrintable(path) << endl << endl; } + + QDomElement eltSource = eltImpl.nextSiblingElement("sources"); + nbPathesStr = eltSource.attribute("nb","none"); + nbPathes = nbPathesStr.toInt(&ok); + QDomNodeList listSourceDir = eltSource.elementsByTagName("source_lib"); + if ((!ok) || (nbPathes != listSourceDir.size())) throw(Exception(CONFIGFILE_CORRUPTED)); + + for(int i=0;i // for each child element, initialize the associated attributes of Parameters - QDomElement eltDefaults = eltImpl.nextSiblingElement("defaults"); + QDomElement eltDefaults = eltSource.nextSiblingElement("defaults"); QDomElement eltBlocks = eltDefaults.firstChildElement("blocks"); QString attributeStr = eltBlocks.attribute("width", "none"); @@ -785,6 +824,22 @@ 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); + + QDomNodeList archNode = implRoot.elementsByTagName("architecture"); + + if (archNode.isEmpty()) { + cout << "impl has no architecture" << endl; + return; + } + QDomElement archElt = archNode.at(0).toElement(); + QString compList = archElt.attribute("comp_list","none"); + if (compList != "none") { + QStringList compos = compList.split(","); + foreach(QString s, compos) { + impl->addSource(s); + } + } + try { impl->loadPatterns(implRoot); } @@ -886,6 +941,71 @@ void Parameters::saveImplementationsToLib() throw(Exception) { libFile.close(); } + + +void Parameters::loadSources() throw(Exception) { + + for(int i=0;igetName() == name) return s; + } + return NULL; +} + void Parameters::addAvailableBlock(ReferenceBlock *block) { availableBlocks.append(block); foreach (int id,block->getCategories()) { @@ -1092,8 +1212,13 @@ void Parameters::setArrowPathes() { _inArrow.lineTo(arrowLineLength+arrowWidth,-arrowHeight/2); _inArrow.lineTo(arrowLineLength+arrowWidth,arrowHeight/2); _inArrow.lineTo(arrowLineLength,0); - _inArrow.closeSubpath(); - inArrow = _inArrow; + //_inArrow.closeSubpath(); + dataArrowIn = _inArrow; + + QPainterPath _inArrowC; + _inArrowC.lineTo(arrowLineLength,0); + _inArrowC.addEllipse(arrowLineLength,-arrowHeight/2,arrowHeight-1,arrowHeight-1); + clkrstArrow = _inArrowC; QPainterPath _outArrow; _outArrow.lineTo(arrowLineLength,0); @@ -1101,8 +1226,8 @@ void Parameters::setArrowPathes() { _outArrow.lineTo(arrowLineLength+arrowWidth,0); _outArrow.lineTo(arrowLineLength,arrowHeight/2); _outArrow.lineTo(arrowLineLength,0); - _outArrow.closeSubpath(); - outArrow = _outArrow; + //_outArrow.closeSubpath(); + dataArrowOut = _outArrow; } @@ -1197,3 +1322,10 @@ InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) { } return NULL; } + +QString Parameters::normalizeName(const QString &name) { + QString s = name; + s.replace(QRegularExpression("[^a-zA-Z0-9_]"),"_"); + s.replace(QRegularExpression("[_]+"),"_"); + return s; +}