X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/015e6979cd7d336f6bbebfbdb7916af3ba23c096..HEAD:/Parameters.cpp?ds=sidebyside diff --git a/Parameters.cpp b/Parameters.cpp index 32bec53..ecf69d9 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,13 +71,14 @@ void Parameters::clear() { refPathes.clear(); } -Graph* Parameters::createGraph() { - graph = new Graph(); +Graph* Parameters::initGraph(bool createTopGroupIfaces) { + graph->createTopGroup(createTopGroupIfaces); return graph; } void Parameters::destroyGraph() { delete graph; + graph = new Graph(); } ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) { @@ -95,6 +98,7 @@ ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) { return ref; } + void Parameters::createDelayBlock() { delayRef = new ReferenceBlock("no.xml"); delayRef->addCategory(100); @@ -257,6 +261,64 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { } cout << "project path set to " << qPrintable(projectPath) << endl; } + + /********************************************************** + 0 : getting parameters + ***********************************************************/ + int width = 0; + int height = 0; + int lineLength = 0; + int gapLength = 0; + QString fontName=""; + int fontSize; + QString autoConn=""; + QDomNode paramsNode = root.elementsByTagName("parameters").at(0); + + QDomElement blocksElt = paramsNode.firstChildElement("block_view"); + width = blocksElt.attribute("width","none").toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + height = blocksElt.attribute("height","none").toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + fontName = blocksElt.attribute("font","none"); + if(fontName == "none") throw(Exception(PROJECTFILE_CORRUPTED)); + fontSize = blocksElt.attribute("font_size","none").toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + defaultBlockWidth = width; + defaultBlockHeight = height; + defaultBlockFontName = fontName; + defaultBlockFontSize = fontSize; + defaultBlockFont = QFont(defaultBlockFontName, defaultBlockFontSize); + + QDomElement ifacesElt = paramsNode.firstChildElement("interface_view"); + lineLength = ifacesElt.attribute("line_length","none").toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + width = ifacesElt.attribute("width","none").toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + height = ifacesElt.attribute("height","none").toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + fontName = ifacesElt.attribute("font","none"); + if(fontName == "none") throw(Exception(PROJECTFILE_CORRUPTED)); + fontSize = ifacesElt.attribute("font_size","none").toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + arrowLineLength = lineLength; + arrowWidth = width; + arrowHeight = height; + defaultIfaceFontName = fontName; + defaultIfaceFontSize = fontSize; + defaultIfaceFont = QFont(defaultIfaceFontName, defaultIfaceFontSize); + + QDomElement connsElt = paramsNode.firstChildElement("connection_view"); + gapLength = connsElt.attribute("gap_length","none").toInt(&ok); + if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + autoConn = connsElt.attribute("auto_conn","none"); + if (autoConn == "false") { + autoConnMainClk = false; + } + else { + autoConnMainClk = true; + } + connGapLength = gapLength; + /********************************************************** 1 : getting scene and creating associated group widgets ***********************************************************/ @@ -272,7 +334,15 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); if (idUpperScene == -1) { - topGroup = dispatcher->createTopScene(); + QString clkList = currentSceneNode.attribute("clklist","none"); + if (clkList == "none") throw(Exception(PROJECTFILE_CORRUPTED)); + QStringList clks = clkList.split(","); + for(int j=0;jaddClock(freq); + } + topGroup = dispatcher->createTopScene(Dispatcher::Load); topScene->setId(idScene); groupItem = topScene->getGroupItem(); cout << "top group added to scene n°" << idScene << endl; @@ -280,7 +350,12 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { else { cout << "trying to create scene n°" << idScene << " with upper scene n°" <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 +377,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 +400,7 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { cout << "top scene has " << sourceNodes.length() << " sources" << endl; for(int j=0; jload(currentSBNode); } @@ -334,7 +409,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); } } /********************************************************** @@ -452,12 +527,16 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { int to = currentConnectionNode.attribute("to","none").toInt(&ok); if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); - + bool showConn = true; + QString visStr = currentConnectionNode.attribute("visible","none"); + if (visStr == "false") { + showConn = false; + } InterfaceItem *iface1 = searchInterfaceItemById(from,topScene); InterfaceItem *iface2 = searchInterfaceItemById(to,topScene); if(iface1 != NULL && iface2 != NULL){ - dispatcher->createConnection(iface1,iface2); + dispatcher->createConnection(Dispatcher::Load, iface1,iface2,showConn); } else { cout << "interfaces not found, connect canceled!" << endl; } @@ -618,7 +697,7 @@ void Parameters::loadBlastConfiguration(QString confFile) throw(Exception) { attributeStr = eltInterfaces.attribute("height", "none"); arrowHeight = attributeStr.toInt(&ok); if (!ok || arrowHeight < 1) throw(Exception(CONFIGFILE_CORRUPTED)); - attributeStr = eltInterfaces.attribute("linelength", "none"); + attributeStr = eltInterfaces.attribute("line_length", "none"); arrowLineLength = attributeStr.toInt(&ok); if (!ok || arrowLineLength < 1) throw(Exception(CONFIGFILE_CORRUPTED)); attributeStr = eltInterfaces.attribute("font_size", "none"); @@ -630,7 +709,7 @@ void Parameters::loadBlastConfiguration(QString confFile) throw(Exception) { defaultIfaceFont = QFont(defaultIfaceFontName, defaultIfaceFontSize); QDomElement eltConnections = eltInterfaces.nextSiblingElement("connections"); - attributeStr = eltConnections.attribute("gaplength", "none"); + attributeStr = eltConnections.attribute("gap_length", "none"); connGapLength = attributeStr.toInt(&ok); if (!ok || connGapLength < 1) throw(Exception(CONFIGFILE_CORRUPTED)); } @@ -836,7 +915,7 @@ void Parameters::loadImplementationsFromXml() throw(Exception) { if (compList != "none") { QStringList compos = compList.split(","); foreach(QString s, compos) { - impl->addSource(s); + impl->addResource(s); } } @@ -960,7 +1039,7 @@ void Parameters::loadSources() throw(Exception) { QString netName = list.at(j); netName.truncate(list.at(j).size() -4); cout << "found netlist " << qPrintable(netName) << endl; - availableSources.append(new ExternalSource(netName,fileName,ExternalSource::Netlist)); + availableResources.append(new ExternalResource(netName,fileName,ExternalResource::Netlist)); } else { cout << "parsing " << qPrintable(fileName) << " ... "; @@ -978,7 +1057,7 @@ void Parameters::loadSources() throw(Exception) { if (matchPack.hasMatch()) { QString packName = matchPack.captured(1); cout << "found package " << qPrintable(packName) << endl; - availableSources.append(new ExternalSource(packName,fileName,ExternalSource::Package)); + availableResources.append(new ExternalResource(packName,fileName,ExternalResource::Package)); } } else if (line.contains("entity", Qt::CaseInsensitive)) { @@ -987,7 +1066,7 @@ void Parameters::loadSources() throw(Exception) { if (matchEnt.hasMatch()) { QString entityName = matchEnt.captured(1); cout << "found entity " << qPrintable(entityName) << endl; - availableSources.append(new ExternalSource(entityName,fileName,ExternalSource::Code)); + availableResources.append(new ExternalResource(entityName,fileName,ExternalResource::Code)); } } line = in.readLine(); @@ -999,11 +1078,14 @@ void Parameters::loadSources() throw(Exception) { } } -ExternalSource* Parameters::searchSourceByName(const QString& name) { - foreach(ExternalSource* s, availableSources) { - if (s->getName() == name) return s; +QList Parameters::searchResourceByName(const QString& name) { + QList listRes; + foreach(ExternalResource* s, availableResources) { + if (s->getName() == name) { + listRes.append(s); + } } - return NULL; + return listRes; } void Parameters::addAvailableBlock(ReferenceBlock *block) { @@ -1133,6 +1215,33 @@ void Parameters::save(QString confFile) { writer.writeStartDocument(); writer.writeStartElement("blast_project"); + + writer.writeStartElement("parameters"); + writer.writeStartElement("block_view"); + writer.writeAttribute("width",QString::number(defaultBlockWidth)); + writer.writeAttribute("height",QString::number(defaultBlockHeight)); + writer.writeAttribute("font",defaultBlockFontName); + writer.writeAttribute("font_size",QString::number(defaultBlockFontSize)); + writer.writeEndElement(); // + writer.writeStartElement("interface_view"); + writer.writeAttribute("line_length",QString::number(arrowLineLength)); + writer.writeAttribute("width",QString::number(arrowWidth)); + writer.writeAttribute("height",QString::number(arrowHeight)); + writer.writeAttribute("font",defaultIfaceFontName); + writer.writeAttribute("font_size",QString::number(defaultIfaceFontSize)); + writer.writeEndElement(); // + writer.writeStartElement("connection_view"); + writer.writeAttribute("gap_length",QString::number(connGapLength)); + if (autoConnMainClk) { + writer.writeAttribute("auto_conn","true"); + } + else { + writer.writeAttribute("auto_conn","false"); + } + writer.writeEndElement(); // + + writer.writeEndElement(); // + writer.writeStartElement("scenes"); writer.writeAttribute("count",QString::number(dispatcher->getNumberOfScenes())); @@ -1162,7 +1271,9 @@ void Parameters::save(QString confFile) { writer.writeAttribute("from",QString::number(item->getFromInterfaceItem()->getId())); writer.writeAttribute("to", QString::number(item->getToInterfaceItem()->getId())); - + if (!item->isVisible()) { + writer.writeAttribute("visible","false"); + } writer.writeEndElement(); } @@ -1300,7 +1411,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;