X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/4327c2b8817b627249d98d889835726217c81a4e..bc5d59217a24b25c1b913bec4a41dd026d02720c:/Parameters.cpp diff --git a/Parameters.cpp b/Parameters.cpp index 23b798f..ecf69d9 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -261,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 ***********************************************************/ @@ -639,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"); @@ -651,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)); } @@ -1157,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()));