X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/60c13e8b4c7ea3d595969c1e7c0a28b068a17ca6..e0eaffd44fc9733bc230a803c80d8d5efd0faca6:/Parameters.cpp diff --git a/Parameters.cpp b/Parameters.cpp index 1195f51..ecf69d9 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -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(bool createTopGroupIfaces) { - graph = new Graph(createTopGroupIfaces); +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,71 +98,6 @@ ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) { return ref; } -double Parameters::getFeedingClockFrequency(AbstractInterface *iface) { - - int idClock = 0; - - if (iface->isReferenceInterface()) return 0.0; - - if (iface->getClockIfaceType() == AbstractInterface::ParameterName) { - BlockParameter* param = iface->getOwner()->getParameterFromName(iface->getClockIfaceString()); - if (!param->isUserParameter()) return 0.0; - bool ok; - double freq = param->getDoubleValue(&ok); - if (!ok) { - cerr << "Abnormal case: cannot retrieve clock id from parameter " << qPrintable(param->getName()) << endl; - } - return freq; - } - else if ( (iface->getClockIfaceType() == AbstractInterface::ClockName) || ((iface->getDirection() == AbstractInterface::Input) && (iface->getPurpose() == AbstractInterface::Clock))) { - - // if iface is not clock, retrieve the clock related to it - if (iface->getClockIfaceType() == AbstractInterface::ClockName) { - iface = iface->getClockIface(); - } - // if iface is a group interface, then iface name is ext_clk_X, thus extract the X - if (iface->isGroupInterface()) { - QString name = iface->getName(); - name.remove(0,8); - bool ok; - idClock = name.toInt(&ok); - if (!ok) { - cerr << "Abnormal case: cannot retrieve clock id from iface name " << qPrintable(iface->getName()) << endl; - return 0.0; - } - } - // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup) - else if (iface->isFunctionalInterface()) { - FunctionalInterface* funIface = AI_TO_FUN(iface); - ConnectedInterface* connFrom = funIface->getConnectedFrom(); - if (connFrom == NULL) { - cerr << "Abnormal case: input clock " << qPrintable(iface->getName()) << " is not connected" << endl; - return 0.0; - } - if (iface->getOwner()->isTopGroupBlock()) { - QString name = connFrom->getOwner()->getName(); - name.remove(0,10); - bool ok; - idClock = name.toInt(&ok); - if (!ok) { - cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl; - return 0.0; - } - } - else { - QString name = connFrom->getName(); - name.remove(0,8); - bool ok; - idClock = name.toInt(&ok); - if (!ok) { - cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl; - return 0.0; - } - } - } - } - return clocks.at(idClock); -} void Parameters::createDelayBlock() { delayRef = new ReferenceBlock("no.xml"); @@ -323,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 ***********************************************************/ @@ -338,6 +334,14 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); if (idUpperScene == -1) { + 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(); @@ -346,6 +350,11 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { else { cout << "trying to create scene n°" << idScene << " with upper scene n°" <addNewEmptyGroup(Dispatcher::Load, upperScene,false); groupWidget->getScene()->setId(idScene); groupItem = groupWidget->getScene()->getGroupItem(); @@ -518,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(Dispatcher::Load, iface1,iface2); + dispatcher->createConnection(Dispatcher::Load, iface1,iface2,showConn); } else { cout << "interfaces not found, connect canceled!" << endl; } @@ -684,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"); @@ -696,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)); } @@ -1202,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())); @@ -1231,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(); }