return root;\r
}\r
\r
-void Parameters::loadProject(QDomElement root) {\r
-\r
-#ifdef DEBUG_INCLFUN\r
+GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {\r
\r
bool ok = false;\r
GroupWidget* groupWidget = NULL;\r
GroupItem *groupItem = NULL;\r
GroupBlock *groupBlock = NULL;\r
\r
+ GroupWidget* topGroup = NULL;\r
/**********************************************************\r
1 : getting scene and creating associated group widgets\r
***********************************************************/\r
QDomNodeList scenesNodes = root.elementsByTagName("scene");\r
\r
+ int maxIdScene = -1;\r
for(int i=0; i<scenesNodes.length(); i++) {\r
QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
int idScene = currentSceneNode.attribute("id","none").toInt(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
+ if (idScene > maxIdScene) maxIdScene = idScene;\r
int idUpperScene = currentSceneNode.attribute("upper_scene","none").toInt(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
if (idUpperScene == -1) {\r
- dispatcher->createTopScene();\r
+ topGroup = dispatcher->createTopScene();\r
topScene->setId(idScene);\r
- groupItem = topScene->getGroupItem();\r
- groupBlock = AB_TO_GRP(groupItem->getRefBlock());\r
+ groupItem = topScene->getGroupItem(); \r
cout << "top group added to scene n°" << idScene << endl;\r
}\r
else {\r
- GroupScene* scene = searchSceneById(idUpperScene, topScene);\r
- GroupWidget* parent = scene->getGroupWindow();\r
- groupWidget = dispatcher->createChildScene(parent);\r
- groupItem = groupWidget->getScene()->getGroupItem();\r
- groupBlock = AB_TO_GRP(groupItem->getRefBlock());\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
+ groupWidget->getScene()->setId(idScene);\r
+ groupItem = groupWidget->getScene()->getGroupItem(); \r
}\r
+ groupBlock = AB_TO_GRP(groupItem->getRefBlock());\r
/**********************************************************\r
- 1.1 : getting the group item\r
+ 1.1 : getting the group item of each scene\r
***********************************************************/\r
QDomElement groupItemNode = currentSceneNode.firstChildElement("group_item");\r
-\r
- int id = groupItemNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString name = groupItemNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QStringList positionStr = groupItemNode.attribute("position","none").split(",");\r
- if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int posX = positionStr.at(0).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int posY = positionStr.at(1).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QStringList dimensionStr = groupItemNode.attribute("dimension","none").split(",");\r
- if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int dimX = dimensionStr.at(0).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int dimY = dimensionStr.at(1).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- groupItem->setId(id);\r
- groupItem->setPos(posX,posY);\r
- groupItem->setDimension(dimX,dimY);\r
- groupBlock->setName(name);\r
+ try {\r
+ groupItem->load(groupItemNode);\r
+ }\r
+ catch(Exception err) {\r
+ throw(err);\r
+ }\r
\r
if (idUpperScene != -1) {\r
groupWidget->setWindowTitle(groupBlock->getName());\r
groupWidget->show();\r
- }\r
- cout << "group info : \n-id : " << id << "\n-pos : " << posX << ", " << posY << "\n-dim : " << dimX << ", " << dimY << "\n-name : " << name.toStdString() << endl;\r
-\r
- QDomNodeList interfaces = groupItemNode.elementsByTagName("group_iface");\r
- for(int j=0; j<interfaces.length(); j++){\r
- QDomElement currentInterfaceNode = interfaces.at(j).toElement();\r
-\r
- int id = currentInterfaceNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString name = currentInterfaceNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString levelStr = currentInterfaceNode.attribute("level","none");\r
- int level = AbstractInterface::getIntLevel(levelStr);\r
- if(level == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString directionStr = currentInterfaceNode.attribute("direction","none");\r
- int direction = AbstractInterface::getIntDirection(directionStr);\r
- if(direction == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString orientationStr = currentInterfaceNode.attribute("orientation","none");\r
- int orientation = InterfaceItem::getIntOrientation(orientationStr);\r
- if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- GroupInterface *groupInterface = new GroupInterface(groupBlock,name,direction,level);\r
-\r
- InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupInterface,groupItem,this);\r
- interfaceItem->setId(id);\r
-\r
- groupBlock->addInterface(groupInterface);\r
- groupItem->addInterface(interfaceItem);\r
- cout << "interface add to " << groupBlock->getName().toStdString() << endl;\r
- }\r
+ } \r
}\r
-\r
+ dispatcher->setSceneCounter(maxIdScene+1);\r
cout << "groupItems loaded and windows created succefully!" << endl;\r
\r
+ /**********************************************************\r
+ 2 : getting the functional blocks of each scene\r
+ ***********************************************************/\r
\r
for(int i=0; i<scenesNodes.length(); i++){\r
QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
\r
QDomNodeList functionalBlockNodes = currentSceneNode.elementsByTagName("bi_functional");\r
\r
- for(int j=0; j<functionalBlockNodes.length(); j++){\r
- QDomElement currentFBNode = functionalBlockNodes.at(j).toElement();\r
-\r
- int id = currentFBNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString refXml = currentFBNode.attribute("ref_xml","none");\r
- if(refXml == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString refMd5 = currentFBNode.attribute("ref_md5","none");\r
- if(refMd5 == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- cout << "ref md5 : " << refMd5.toStdString() << "\nref xml : " << refXml.toStdString() << endl;\r
-\r
- QString name = currentFBNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QStringList positionStr = currentFBNode.attribute("position","none").split(",");\r
- if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int posX = positionStr.at(0).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int posY = positionStr.at(1).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QStringList dimensionStr = currentFBNode.attribute("dimension","none").split(",");\r
- if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int dimX = dimensionStr.at(0).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int dimY = dimensionStr.at(1).toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- AbstractBlock *reference;\r
- /*if(refMd5 != "none"){\r
- cout << "md5" << endl;\r
- reference = searchBlockByMd5(refMd5);\r
- }\r
- else */if(refXml != "none"){\r
- cout << "xml" << endl;\r
- reference = searchBlockByXml(refXml);\r
- }\r
- else {\r
- throw(Exception(PROJECTFILE_CORRUPTED));\r
- }\r
-\r
- FunctionalBlock *functionalBlock = new FunctionalBlock(currentScene->getGroupItem()->getRefBlock(),reference);\r
- functionalBlock->setName(name);\r
-\r
- ((GroupBlock*)currentScene->getGroupItem()->getRefBlock())->addBlock(functionalBlock);\r
-\r
-\r
- BlockItem *blockItem = new BlockItem(currentScene->getGroupItem(),functionalBlock,dispatcher,this);\r
- blockItem->setPos(posX,posY);\r
- blockItem->setDimension(dimX,dimY);\r
- blockItem->setId(id);\r
- ((GroupItem*)currentScene->getGroupItem())->addBlockItem(blockItem);\r
- currentScene->addItem(blockItem);\r
- currentScene->addBlockItem(blockItem);\r
-\r
- QDomNodeList blockParamNodes = currentFBNode.elementsByTagName("bif_parameter");\r
-\r
- for(int i=0; i<blockParamNodes.length(); i++){\r
- QDomElement currentBlockParamNode = blockParamNodes.at(i).toElement();\r
-\r
- QString name = currentBlockParamNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString value = currentBlockParamNode.attribute("value","none");\r
- if(value == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString context = currentBlockParamNode.attribute("context","none");\r
- if(context == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString type = currentBlockParamNode.attribute("type","none");\r
- if(type == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
-\r
- BlockParameter *blockParam = new BlockParameter;\r
- blockParam->setName(name);\r
- blockParam->setValue(value);\r
- blockParam->setType(type);\r
- if(context == "constant") blockParam->setContext(BlockParameter::Constant);\r
- if(context == "user") blockParam->setContext(BlockParameter::User);\r
- if(context == "generic") blockParam->setContext(BlockParameter::Generic);\r
- if(context == "wb") blockParam->setContext(BlockParameter::Wishbone);\r
- if(context == "port") blockParam->setContext(BlockParameter::Port);\r
-\r
- functionalBlock->addParameter(blockParam);\r
+ for(int j=0; j<functionalBlockNodes.length(); j++) {\r
+ QDomElement currentFBNode = functionalBlockNodes.at(j).toElement(); \r
+ BoxItem* funcItem = new BoxItem(dispatcher,this, currentScene->getGroupItem());\r
+ try {\r
+ funcItem->loadFunctional(currentFBNode);\r
}\r
-\r
-\r
- QDomNodeList interfaceNodes = currentFBNode.elementsByTagName("bif_iface");\r
-\r
- for(int i=0; i<interfaceNodes.length(); i++){\r
-\r
- QDomElement currentInterfaceNode = interfaceNodes.at(i).toElement();\r
-\r
- int id = currentInterfaceNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString name = currentInterfaceNode.attribute("name","none");\r
- if(name == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString refName = currentInterfaceNode.attribute("ref_name","none");\r
- if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- QString orientationStr = currentInterfaceNode.attribute("orientation","none");\r
- int orientation = InterfaceItem::getIntOrientation(orientationStr);\r
- if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- ReferenceInterface *refInter = (ReferenceInterface*)reference->getIfaceFromName(refName);\r
- FunctionalInterface *functionalInterface = new FunctionalInterface(functionalBlock,refInter);\r
- functionalBlock->addInterface(functionalInterface);\r
- functionalInterface->setName(refName);\r
-\r
- InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,functionalInterface,blockItem,this);\r
- interfaceItem->setId(id);\r
- interfaceItem->setName(name);\r
-\r
- blockItem->addInterface(interfaceItem);\r
-\r
+ catch(Exception err) {\r
+ throw(err);\r
}\r
+ // add the block to the GroupScene\r
+ currentScene->addBlockItem(funcItem);\r
}\r
}\r
- cout << "functionalBlocks loaded and created succefully!" << endl;\r
+ cout << "functional blocks loaded and created succefully!" << endl;\r
\r
+ /**********************************************************\r
+ 3 : set the BoxItem that represents a GroupItem in a child scene\r
+ ***********************************************************/\r
\r
for(int i=0; i<scenesNodes.length(); i++){\r
QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
int dimY = dimensionStr.at(1).toInt(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
-\r
+ // get the GroupItem already created and set at phase 1\r
GroupItem *insideGroup = searchGroupItemById(idGroup, topScene);\r
+ BoxItem* upperItem = NULL;\r
if(insideGroup == NULL) cout << "group null" << endl;\r
- BlockItem *blockItem = new BlockItem(insideGroup->getRefBlock(), dispatcher, this);\r
- blockItem->setChildGroupItem(insideGroup);\r
- blockItem->setId(id);\r
- blockItem->setPos(posX,posY);\r
- blockItem->setDimension(dimX,dimY);\r
+ // now search within the scene which BoxItem has a childItem that is = to insideGroup\r
+ QList<BoxItem *> lst = currentScene->getBlockItems();\r
+ foreach(BoxItem* item, lst) {\r
+ if (item->getChildGroupItem() == insideGroup) {\r
+ upperItem = item;\r
+ break;\r
+ }\r
+ }\r
+ if (upperItem == NULL) {\r
+ throw(Exception(PROJECTFILE_CORRUPTED));\r
+ }\r
\r
- ((GroupItem*)currentScene->getGroupItem())->addBlockItem(blockItem);\r
- currentScene->addItem(blockItem);\r
- currentScene->addBlockItem(blockItem);\r
+ upperItem->setId(id);\r
+ upperItem->setPos(posX,posY);\r
+ upperItem->setDimension(dimX,dimY);\r
\r
+ // set interfaces of this BoxItem\r
QDomNodeList interfaceNodes = currentBiGroup.elementsByTagName("big_iface");\r
\r
for(int k=0; k<interfaceNodes.length(); k++){\r
double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);\r
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
\r
- GroupInterface *refInter = (GroupInterface*)insideGroup->searchInterfaceByName(refName)->refInter;\r
- InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, blockItem, this);\r
+ ConnectedInterface *refInter = insideGroup->searchInterfaceByName(refName)->refInter;\r
+ InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this);\r
ifaceItem->setId(id);\r
- blockItem->addInterface(ifaceItem);\r
+ upperItem->addInterface(ifaceItem);\r
}\r
}\r
}\r
cout << "blockItems \"group\" loaded and created succefully!" << endl;\r
\r
-\r
- for(int i=0; i<scenesNodes.length(); i++){\r
- QDomElement currentSceneNode = scenesNodes.at(i).toElement();\r
-\r
- QDomElement groupItemNode = currentSceneNode.firstChildElement("group_item");\r
-\r
- int id = groupItemNode.attribute("id","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
- int idUpperItem = groupItemNode.attribute("upper_item","none").toInt(&ok);\r
- if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));\r
-\r
- BlockItem *currentItem = searchBlockItemById(id,topScene);\r
- GroupItem *upperItem = searchGroupItemById(idUpperItem, topScene);\r
-\r
- if(currentItem != NULL && upperItem != NULL){\r
- currentItem->setUpperItem(upperItem);\r
- }\r
- }\r
-\r
QDomNodeList connectionNodes = root.elementsByTagName("connection");\r
\r
for(int i=0; i<connectionNodes.length(); i++){\r
cout << "interfaces not found, connect canceled!" << endl;\r
}\r
}\r
+ cout << "connections loaded and created succefully!" << endl;\r
\r
-#endif\r
+ return topGroup;\r
}\r
\r
void Parameters::loadBlastConfiguration(QString confFile) throw(Exception) {\r
\r
blockXML.close();\r
try {\r
- validateXmlFile(fileName,"block.xsd",Reference);\r
+ validateXmlFile(fileName,"reference.xsd",Reference);\r
}\r
catch(Exception err) {\r
throw(err);\r
implXML.close();\r
cout << "OK" << endl;\r
cout << "reading " << qPrintable(fileName) << " content ...";\r
- /*\r
+\r
try {\r
- validateXmlFile(fileName,"block.xsd",Implementation);\r
+ validateXmlFile(fileName,"implementation.xsd",Implementation);\r
}\r
catch(Exception e) {\r
throw(e);\r
}\r
- */\r
+\r
// reading in into QDomDocument\r
QDomDocument document ("FileXML");\r
if (!implXML.open(QIODevice::ReadOnly)) {\r