#include "GroupScene.h"\r
#include "GroupItem.h"\r
#include "BoxItem.h"\r
-#include "SourceItem.h"\r
+#include "StimuliItem.h"\r
#include "InterfaceItem.h"\r
#include "ConnectionItem.h"\r
\r
projectPath = "";\r
projectName = "";\r
projectFile = "";\r
+\r
+ graph = new Graph();\r
}\r
\r
Parameters::~Parameters() {\r
refPathes.clear();\r
}\r
\r
-Graph* Parameters::createGraph() {\r
- graph = new Graph();\r
+Graph* Parameters::initGraph(bool createTopGroupIfaces) {\r
+ graph->createTopGroup(createTopGroupIfaces);\r
return graph;\r
}\r
\r
void Parameters::destroyGraph() {\r
delete graph;\r
+ graph = new Graph();\r
}\r
\r
ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) {\r
return ref;\r
}\r
\r
+\r
void Parameters::createDelayBlock() {\r
delayRef = new ReferenceBlock("no.xml");\r
delayRef->addCategory(100);\r
}\r
cout << "project path set to " << qPrintable(projectPath) << endl;\r
}\r
+\r
+ /**********************************************************\r
+ 0 : getting parameters\r
+ ***********************************************************/\r
+ int width = 0;\r
+ int height = 0;\r
+ int lineLength = 0;\r
+ int gapLength = 0;\r
+ QString fontName="";\r
+ int fontSize;\r
+ QString autoConn="";\r
+ QDomNode paramsNode = root.elementsByTagName("parameters").at(0);\r
+\r
+ QDomElement blocksElt = paramsNode.firstChildElement("block_view");\r
+ width = blocksElt.attribute("width","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ height = blocksElt.attribute("height","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ fontName = blocksElt.attribute("font","none");\r
+ if(fontName == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
+ fontSize = blocksElt.attribute("font_size","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ defaultBlockWidth = width;\r
+ defaultBlockHeight = height;\r
+ defaultBlockFontName = fontName;\r
+ defaultBlockFontSize = fontSize;\r
+ defaultBlockFont = QFont(defaultBlockFontName, defaultBlockFontSize);\r
+\r
+ QDomElement ifacesElt = paramsNode.firstChildElement("interface_view");\r
+ lineLength = ifacesElt.attribute("line_length","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ width = ifacesElt.attribute("width","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ height = ifacesElt.attribute("height","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ fontName = ifacesElt.attribute("font","none");\r
+ if(fontName == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
+ fontSize = ifacesElt.attribute("font_size","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ arrowLineLength = lineLength;\r
+ arrowWidth = width;\r
+ arrowHeight = height;\r
+ defaultIfaceFontName = fontName;\r
+ defaultIfaceFontSize = fontSize;\r
+ defaultIfaceFont = QFont(defaultIfaceFontName, defaultIfaceFontSize);\r
+\r
+ QDomElement connsElt = paramsNode.firstChildElement("connection_view");\r
+ gapLength = connsElt.attribute("gap_length","none").toInt(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ autoConn = connsElt.attribute("auto_conn","none");\r
+ if (autoConn == "false") {\r
+ autoConnMainClk = false;\r
+ }\r
+ else {\r
+ autoConnMainClk = true;\r
+ }\r
+ connGapLength = gapLength;\r
+\r
/**********************************************************\r
1 : getting scene and creating associated group widgets\r
***********************************************************/\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
if (idUpperScene == -1) {\r
- topGroup = dispatcher->createTopScene();\r
+ QString clkList = currentSceneNode.attribute("clklist","none");\r
+ if (clkList == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
+ QStringList clks = clkList.split(",");\r
+ for(int j=0;j<clks.size();j++) {\r
+ double freq = clks.at(j).toDouble(&ok);\r
+ if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ graph->addClock(freq);\r
+ }\r
+ topGroup = dispatcher->createTopScene(Dispatcher::Load);\r
topScene->setId(idScene);\r
groupItem = topScene->getGroupItem(); \r
cout << "top group added to scene n°" << idScene << endl;\r
else {\r
cout << "trying to create scene n°" << idScene << " with upper scene n°" <<idUpperScene << endl;\r
GroupScene* upperScene = searchSceneById(idUpperScene, topScene);\r
- groupWidget = dispatcher->addNewEmptyGroup(upperScene,false);\r
+ /* IMPORTANT: calling addNewEmptyGroup() leads to create a new GroupWidget\r
+ * AND a BoxItem in upperScene that represents the GroupItem in the\r
+ * newly created child scene. Thus, it has not to be created when\r
+ * reading bi_group tags in the following but just searched\r
+ */\r
+ groupWidget = dispatcher->addNewEmptyGroup(Dispatcher::Load, upperScene,false);\r
groupWidget->getScene()->setId(idScene);\r
groupItem = groupWidget->getScene()->getGroupItem(); \r
}\r
cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;\r
} \r
}\r
- dispatcher->setSceneCounter(maxIdScene+1);\r
+ dispatcher->setSceneCounter(Dispatcher::Load, maxIdScene+1);\r
cout << "groupItems loaded and windows created succefully!" << endl;\r
\r
/**********************************************************\r
cout << "top scene has " << sourceNodes.length() << " sources" << endl;\r
for(int j=0; j<sourceNodes.length(); j++) {\r
QDomElement currentSBNode = sourceNodes.at(j).toElement(); \r
- SourceItem* sourceItem = new SourceItem(dispatcher,this);\r
+ StimuliItem* sourceItem = new StimuliItem(dispatcher,this);\r
try {\r
sourceItem->load(currentSBNode);\r
}\r
}\r
cout << "source item has been read, add it to the scene" << endl;\r
// add the block to the GroupScene\r
- currentScene->addSourceItem(sourceItem);\r
+ currentScene->addStimuliItem(sourceItem);\r
} \r
}\r
/**********************************************************\r
int to = currentConnectionNode.attribute("to","none").toInt(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
-\r
+ bool showConn = true;\r
+ QString visStr = currentConnectionNode.attribute("visible","none");\r
+ if (visStr == "false") {\r
+ showConn = false;\r
+ }\r
InterfaceItem *iface1 = searchInterfaceItemById(from,topScene);\r
InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);\r
\r
if(iface1 != NULL && iface2 != NULL){\r
- dispatcher->createConnection(iface1,iface2);\r
+ dispatcher->createConnection(Dispatcher::Load, iface1,iface2,showConn);\r
} else {\r
cout << "interfaces not found, connect canceled!" << endl;\r
}\r
attributeStr = eltInterfaces.attribute("height", "none");\r
arrowHeight = attributeStr.toInt(&ok);\r
if (!ok || arrowHeight < 1) throw(Exception(CONFIGFILE_CORRUPTED));\r
- attributeStr = eltInterfaces.attribute("linelength", "none");\r
+ attributeStr = eltInterfaces.attribute("line_length", "none");\r
arrowLineLength = attributeStr.toInt(&ok);\r
if (!ok || arrowLineLength < 1) throw(Exception(CONFIGFILE_CORRUPTED));\r
attributeStr = eltInterfaces.attribute("font_size", "none");\r
defaultIfaceFont = QFont(defaultIfaceFontName, defaultIfaceFontSize);\r
\r
QDomElement eltConnections = eltInterfaces.nextSiblingElement("connections");\r
- attributeStr = eltConnections.attribute("gaplength", "none");\r
+ attributeStr = eltConnections.attribute("gap_length", "none");\r
connGapLength = attributeStr.toInt(&ok);\r
if (!ok || connGapLength < 1) throw(Exception(CONFIGFILE_CORRUPTED));\r
}\r
if (compList != "none") {\r
QStringList compos = compList.split(",");\r
foreach(QString s, compos) {\r
- impl->addSource(s);\r
+ impl->addResource(s);\r
}\r
}\r
\r
QString netName = list.at(j);\r
netName.truncate(list.at(j).size() -4);\r
cout << "found netlist " << qPrintable(netName) << endl;\r
- availableSources.append(new ExternalSource(netName,fileName,ExternalSource::Netlist));\r
+ availableResources.append(new ExternalResource(netName,fileName,ExternalResource::Netlist));\r
}\r
else {\r
cout << "parsing " << qPrintable(fileName) << " ... ";\r
if (matchPack.hasMatch()) {\r
QString packName = matchPack.captured(1);\r
cout << "found package " << qPrintable(packName) << endl;\r
- availableSources.append(new ExternalSource(packName,fileName,ExternalSource::Package));\r
+ availableResources.append(new ExternalResource(packName,fileName,ExternalResource::Package));\r
}\r
}\r
else if (line.contains("entity", Qt::CaseInsensitive)) {\r
if (matchEnt.hasMatch()) {\r
QString entityName = matchEnt.captured(1);\r
cout << "found entity " << qPrintable(entityName) << endl;\r
- availableSources.append(new ExternalSource(entityName,fileName,ExternalSource::Code));\r
+ availableResources.append(new ExternalResource(entityName,fileName,ExternalResource::Code));\r
}\r
}\r
line = in.readLine();\r
}\r
}\r
\r
-ExternalSource* Parameters::searchSourceByName(const QString& name) {\r
- foreach(ExternalSource* s, availableSources) {\r
- if (s->getName() == name) return s;\r
+QList<ExternalResource *> Parameters::searchResourceByName(const QString& name) {\r
+ QList<ExternalResource*> listRes;\r
+ foreach(ExternalResource* s, availableResources) {\r
+ if (s->getName() == name) {\r
+ listRes.append(s);\r
+ }\r
}\r
- return NULL;\r
+ return listRes;\r
}\r
\r
void Parameters::addAvailableBlock(ReferenceBlock *block) {\r
writer.writeStartDocument();\r
\r
writer.writeStartElement("blast_project");\r
+\r
+ writer.writeStartElement("parameters");\r
+ writer.writeStartElement("block_view");\r
+ writer.writeAttribute("width",QString::number(defaultBlockWidth));\r
+ writer.writeAttribute("height",QString::number(defaultBlockHeight));\r
+ writer.writeAttribute("font",defaultBlockFontName);\r
+ writer.writeAttribute("font_size",QString::number(defaultBlockFontSize));\r
+ writer.writeEndElement(); //</blocks>\r
+ writer.writeStartElement("interface_view");\r
+ writer.writeAttribute("line_length",QString::number(arrowLineLength));\r
+ writer.writeAttribute("width",QString::number(arrowWidth));\r
+ writer.writeAttribute("height",QString::number(arrowHeight));\r
+ writer.writeAttribute("font",defaultIfaceFontName);\r
+ writer.writeAttribute("font_size",QString::number(defaultIfaceFontSize));\r
+ writer.writeEndElement(); //</interfaces>\r
+ writer.writeStartElement("connection_view");\r
+ writer.writeAttribute("gap_length",QString::number(connGapLength));\r
+ if (autoConnMainClk) {\r
+ writer.writeAttribute("auto_conn","true");\r
+ }\r
+ else {\r
+ writer.writeAttribute("auto_conn","false");\r
+ }\r
+ writer.writeEndElement(); //</connections>\r
+\r
+ writer.writeEndElement(); //</parameters>\r
+\r
writer.writeStartElement("scenes");\r
\r
writer.writeAttribute("count",QString::number(dispatcher->getNumberOfScenes()));\r
\r
writer.writeAttribute("from",QString::number(item->getFromInterfaceItem()->getId()));\r
writer.writeAttribute("to", QString::number(item->getToInterfaceItem()->getId()));\r
-\r
+ if (!item->isVisible()) {\r
+ writer.writeAttribute("visible","false");\r
+ }\r
writer.writeEndElement();\r
}\r
\r
}\r
}\r
if (scene->isTopScene()) {\r
- foreach(SourceItem *block, scene->getSourceItems()){\r
+ foreach(StimuliItem *block, scene->getSourceItems()){\r
foreach(InterfaceItem *item, block->getInterfaces()){\r
if(item->getId() == id){\r
return item;\r