1 #include "Parameters.h"
\r
3 #include "Dispatcher.h"
\r
4 #include "BlockLibraryTree.h"
\r
6 #include "BlockCategory.h"
\r
8 #include "GroupWidget.h"
\r
9 #include "GroupScene.h"
\r
10 #include "GroupItem.h"
\r
11 #include "BoxItem.h"
\r
12 #include "StimuliItem.h"
\r
13 #include "InterfaceItem.h"
\r
14 #include "ConnectionItem.h"
\r
17 #include "ReferenceBlock.h"
\r
18 #include "GroupBlock.h"
\r
19 #include "FunctionalBlock.h"
\r
20 #include "ReferenceInterface.h"
\r
21 #include "GroupInterface.h"
\r
22 #include "FunctionalInterface.h"
\r
24 #include "Exception.h"
\r
25 #include "BlocksToConfigureWidget.h"
\r
27 #include "BlockParameterGeneric.h"
\r
29 #include "DelayInputModifier.h"
\r
31 Parameters::Parameters() {
\r
32 categoryTree = NULL;
\r
35 arrowLineLength = 10;
\r
37 defaultBlockWidth = 100;
\r
38 defaultBlockHeight = 100;
\r
39 defaultBlockFont = QFont("Arial");
\r
40 defaultBlockFontSize = 12;
\r
44 sceneMode = MODE_EDITION; // default mode
\r
45 editState = Parameters::EditNoOperation;
\r
47 unsaveModif = false;
\r
48 isRstClkShown = false;
\r
50 validityExtension = "_enb";
\r
56 graph = new Graph();
\r
59 Parameters::~Parameters() {
\r
63 void Parameters::clear() {
\r
64 delete categoryTree;
\r
65 QListIterator<ReferenceBlock *> iter(availableBlocks);
\r
66 while(iter.hasNext()) {
\r
67 ReferenceBlock* item = iter.next();
\r
70 availableBlocks.clear();
\r
74 Graph* Parameters::initGraph(bool createTopGroupIfaces) {
\r
75 graph->createTopGroup(createTopGroupIfaces);
\r
79 void Parameters::destroyGraph() {
\r
83 ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) {
\r
85 BlockCategory* blockCat = categoryTree->searchCategory(idCategory);
\r
87 if (blockCat == NULL) return NULL;
\r
88 ReferenceBlock* ref = blockCat->getBlockById(idBlock);
\r
92 ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) {
\r
94 BlockCategory* blockCat = categoryTree->searchCategory(100);
\r
95 if (blockCat == NULL) return NULL;
\r
96 ReferenceBlock* ref = blockCat->getBlockByName(blockName);
\r
101 void Parameters::createDelayBlock() {
\r
102 delayRef = new ReferenceBlock("no.xml");
\r
103 delayRef->addCategory(100);
\r
104 delayRef->setName("delay");
\r
106 BlockCategory* cat = categoryTree->searchCategory(100);
\r
107 cat->blocks.append(delayRef);
\r
109 AbstractInterface* interIn = new ReferenceInterface(delayRef,"data_in",AbstractInterface::Input, AbstractInterface::Data, "expression","$in_width");
\r
110 delayRef->addInterface(interIn);
\r
111 AbstractInterface* interInCtl = new ReferenceInterface(delayRef,"data_in_enb",AbstractInterface::Input, AbstractInterface::Control, "boolean","1");
\r
112 delayRef->addInterface(interInCtl);
\r
113 interInCtl->setAssociatedIface(interIn);
\r
114 AbstractInterface* interOut = new ReferenceInterface(delayRef,"data_out",AbstractInterface::Output, AbstractInterface::Data, "expression","$in_width");
\r
115 delayRef->addInterface(interOut);
\r
116 AbstractInterface* interOutCtl = new ReferenceInterface(delayRef,"data_out_enb",AbstractInterface::Output, AbstractInterface::Control, "boolean","1");
\r
117 delayRef->addInterface(interOutCtl);
\r
118 interOutCtl->setAssociatedIface(interOut);
\r
119 BlockParameter* param1 = new BlockParameterGeneric(delayRef,"in_width","natural","8");
\r
120 BlockParameter* param2 = new BlockParameterGeneric(delayRef,"dly_length","natural","1");
\r
121 delayRef->addParameter(param1);
\r
122 delayRef->addParameter(param2);
\r
123 delayImpl = new BlockImplementation("no.xml");
\r
124 delayImpl->setDelta("1");
\r
125 QHash<QString,QString> consPattern;
\r
126 consPattern.insert("data_in_enb","1");
\r
127 delayImpl->setConsumptionPattern(consPattern);
\r
128 QHash<QString,QString> prodPattern;
\r
129 prodPattern.insert("data_out_enb","O{$dly_length}1");
\r
130 delayImpl->setProductionPattern(prodPattern);
\r
131 delayImpl->setProductionCounter("1");
\r
132 delayRef->addImplementation(delayImpl);
\r
133 delayImpl->setReference(delayRef);
\r
134 if (! delayImpl->checkPatterns()) {
\r
135 cout << "Delay block creation: failure" << endl;
\r
138 cout << "Delay block creation: success" << endl;
\r
145 void Parameters::validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception) {
\r
146 // opening configFile
\r
147 QFile xmlFile(xmlFileName);
\r
148 if (!xmlFile.open(QIODevice::ReadOnly)) {
\r
149 if (fileType == Configuration) {
\r
150 throw(Exception(CONFIGFILE_NOACCESS));
\r
152 else if (fileType == Reference) {
\r
153 throw(Exception(BLOCKFILE_NOACCESS));
\r
155 else if (fileType == Implementation) {
\r
156 throw(Exception(IMPLFILE_NOACCESS));
\r
158 else if (fileType == Project) {
\r
159 throw(Exception(PROJECTFILE_NOACCESS));
\r
163 QFile xsdFile(xsdFileName);
\r
164 if (!xsdFile.open(QIODevice::ReadOnly)) {
\r
166 if (fileType == Configuration) {
\r
167 throw(Exception(CONFIGFILE_NOACCESS));
\r
169 else if (fileType == Reference) {
\r
170 throw(Exception(BLOCKFILE_NOACCESS));
\r
172 else if (fileType == Implementation) {
\r
173 throw(Exception(IMPLFILE_NOACCESS));
\r
175 else if (fileType == Project) {
\r
176 throw(Exception(PROJECTFILE_NOACCESS));
\r
180 if(validate(xmlFile,xsdFile) == false) {
\r
183 if (fileType == Configuration) {
\r
184 throw(Exception(CONFIGFILE_CORRUPTED));
\r
186 else if (fileType == Reference) {
\r
187 throw(Exception(BLOCKFILE_CORRUPTED));
\r
189 else if (fileType == Implementation) {
\r
190 throw(Exception(IMPLFILE_CORRUPTED));
\r
192 else if (fileType == Project) {
\r
193 throw(Exception(PROJECTFILE_CORRUPTED));
\r
200 bool Parameters::validate(QFile& fileXml, QFile& fileSchema) {
\r
202 // 2 files are supposed to be already opened
\r
205 if(! schema.load(&fileSchema)){
\r
206 cout << "invalid schema" << endl;
\r
210 QXmlSchemaValidator validator(schema);
\r
212 if(! validator.validate(&fileXml)){
\r
213 cout << "invalid xml" << endl;
\r
219 QDomElement Parameters::openProjectFile(const QString& projectFileName) throw(Exception) {
\r
222 validateXmlFile(projectFileName,"projectfile.xsd",Project);
\r
224 catch(Exception err) {
\r
228 QFile projectFile(projectFileName);
\r
229 QDomDocument doc("projectFile");
\r
231 if(!projectFile.open(QIODevice::ReadOnly)) {
\r
232 throw(Exception(PROJECTFILE_NOACCESS));
\r
234 if(!doc.setContent(&projectFile)) {
\r
235 projectFile.close();
\r
236 throw(Exception(PROJECTFILE_CORRUPTED));
\r
238 projectFile.close();
\r
240 QDomElement root = doc.documentElement();
\r
245 GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
\r
248 GroupWidget* groupWidget = NULL;
\r
249 GroupItem *groupItem = NULL;
\r
250 GroupBlock *groupBlock = NULL;
\r
252 GroupWidget* topGroup = NULL;
\r
254 QString path = root.attribute("project_path","none");
\r
255 if (path != "none") {
\r
257 if (dir.exists()) {
\r
258 projectPath = path;
\r
261 cout << "project path set to " << qPrintable(projectPath) << endl;
\r
263 /**********************************************************
\r
264 1 : getting scene and creating associated group widgets
\r
265 ***********************************************************/
\r
266 QDomNodeList scenesNodes = root.elementsByTagName("scene");
\r
268 int maxIdScene = -1;
\r
269 for(int i=0; i<scenesNodes.length(); i++) {
\r
270 QDomElement currentSceneNode = scenesNodes.at(i).toElement();
\r
271 int idScene = currentSceneNode.attribute("id","none").toInt(&ok);
\r
272 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
273 if (idScene > maxIdScene) maxIdScene = idScene;
\r
274 int idUpperScene = currentSceneNode.attribute("upper_scene","none").toInt(&ok);
\r
275 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
277 if (idUpperScene == -1) {
\r
278 topGroup = dispatcher->createTopScene(Dispatcher::Load);
\r
279 topScene->setId(idScene);
\r
280 groupItem = topScene->getGroupItem();
\r
281 cout << "top group added to scene n°" << idScene << endl;
\r
284 cout << "trying to create scene n°" << idScene << " with upper scene n°" <<idUpperScene << endl;
\r
285 GroupScene* upperScene = searchSceneById(idUpperScene, topScene);
\r
286 /* IMPORTANT: calling addNewEmptyGroup() leads to create a new GroupWidget
\r
287 * AND a BoxItem in upperScene that represents the GroupItem in the
\r
288 * newly created child scene. Thus, it has not to be created when
\r
289 * reading bi_group tags in the following but just searched
\r
291 groupWidget = dispatcher->addNewEmptyGroup(Dispatcher::Load, upperScene,false);
\r
292 groupWidget->getScene()->setId(idScene);
\r
293 groupItem = groupWidget->getScene()->getGroupItem();
\r
295 groupBlock = AB_TO_GRP(groupItem->getRefBlock());
\r
296 /**********************************************************
\r
297 1.1 : getting the group item of each scene
\r
298 ***********************************************************/
\r
299 QDomElement groupItemNode = currentSceneNode.firstChildElement("group_item");
\r
301 groupItem->load(groupItemNode);
\r
303 catch(Exception err) {
\r
307 if (idUpperScene != -1) {
\r
308 groupWidget->setWindowTitle(groupBlock->getName());
\r
309 groupWidget->show();
\r
310 cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;
\r
313 dispatcher->setSceneCounter(Dispatcher::Load, maxIdScene+1);
\r
314 cout << "groupItems loaded and windows created succefully!" << endl;
\r
316 /**********************************************************
\r
317 2 : getting the functional blocks of each scene
\r
318 ***********************************************************/
\r
320 for(int i=0; i<scenesNodes.length(); i++){
\r
321 QDomElement currentSceneNode = scenesNodes.at(i).toElement();
\r
322 int idScene = currentSceneNode.attribute("id","none").toInt(&ok);
\r
323 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
324 cout << "SCENE : " << idScene << endl;
\r
325 GroupScene *currentScene = searchSceneById(idScene,topScene);
\r
327 if(currentScene == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
\r
328 /**********************************************************
\r
329 2.1 : getting sources if it is top scene
\r
330 ***********************************************************/
\r
331 if (currentScene->isTopScene()) {
\r
332 QDomNodeList sourceNodes = currentSceneNode.elementsByTagName("source_item");
\r
333 cout << "top scene has " << sourceNodes.length() << " sources" << endl;
\r
334 for(int j=0; j<sourceNodes.length(); j++) {
\r
335 QDomElement currentSBNode = sourceNodes.at(j).toElement();
\r
336 StimuliItem* sourceItem = new StimuliItem(dispatcher,this);
\r
338 sourceItem->load(currentSBNode);
\r
340 catch(Exception err) {
\r
343 cout << "source item has been read, add it to the scene" << endl;
\r
344 // add the block to the GroupScene
\r
345 currentScene->addStimuliItem(sourceItem);
\r
348 /**********************************************************
\r
349 2.2 : getting functional blocks
\r
350 ***********************************************************/
\r
351 QDomNodeList functionalBlockNodes = currentSceneNode.elementsByTagName("bi_functional");
\r
353 for(int j=0; j<functionalBlockNodes.length(); j++) {
\r
354 QDomElement currentFBNode = functionalBlockNodes.at(j).toElement();
\r
355 BoxItem* funcItem = new BoxItem(dispatcher,this, currentScene->getGroupItem());
\r
357 funcItem->loadFunctional(currentFBNode);
\r
359 catch(Exception err) {
\r
362 // add the block to the GroupScene
\r
363 currentScene->addBoxItem(funcItem);
\r
366 cout << "functional blocks loaded and created succefully!" << endl;
\r
368 /**********************************************************
\r
369 3 : set the BoxItem that represents a GroupItem in a child scene
\r
370 ***********************************************************/
\r
372 for(int i=0; i<scenesNodes.length(); i++){
\r
373 QDomElement currentSceneNode = scenesNodes.at(i).toElement();
\r
374 int idScene = currentSceneNode.attribute("id","none").toInt(&ok);
\r
375 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
376 GroupScene *currentScene = searchSceneById(idScene, topScene);
\r
377 if(currentScene == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
\r
379 QDomNodeList biGroupNodes = currentSceneNode.elementsByTagName("bi_group");
\r
381 for(int j=0; j<biGroupNodes.length(); j++){
\r
382 QDomElement currentBiGroup = biGroupNodes.at(j).toElement();
\r
384 int id = currentBiGroup.attribute("id","none").toInt(&ok);
\r
385 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
387 int idGroup = currentBiGroup.attribute("inside_group","none").toInt(&ok);
\r
388 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
390 QStringList positionStr = currentBiGroup.attribute("position","none").split(",");
\r
391 if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));
\r
392 int posX = positionStr.at(0).toInt(&ok);
\r
393 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
394 int posY = positionStr.at(1).toInt(&ok);
\r
395 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
397 QStringList dimensionStr = currentBiGroup.attribute("dimension","none").split(",");
\r
398 if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));
\r
399 int dimX = dimensionStr.at(0).toInt(&ok);
\r
400 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
401 int dimY = dimensionStr.at(1).toInt(&ok);
\r
402 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
404 // get the GroupItem already created and set at phase 1
\r
405 GroupItem *insideGroup = searchGroupItemById(idGroup, topScene);
\r
406 BoxItem* upperItem = NULL;
\r
407 if(insideGroup == NULL) cout << "group null" << endl;
\r
408 // now search within the scene which BoxItem has a childItem that is = to insideGroup
\r
409 QList<BoxItem *> lst = currentScene->getBoxItems();
\r
410 foreach(BoxItem* item, lst) {
\r
411 if (item->getChildGroupItem() == insideGroup) {
\r
416 if (upperItem == NULL) {
\r
417 throw(Exception(PROJECTFILE_CORRUPTED));
\r
420 upperItem->setId(id);
\r
421 upperItem->setPos(posX,posY);
\r
422 upperItem->setDimension(dimX,dimY);
\r
424 // set interfaces of this BoxItem
\r
425 QDomNodeList interfaceNodes = currentBiGroup.elementsByTagName("big_iface");
\r
427 for(int k=0; k<interfaceNodes.length(); k++){
\r
428 QDomElement currentInterfaceNode = interfaceNodes.at(k).toElement();
\r
430 int id = currentInterfaceNode.attribute("id","none").toInt(&ok);
\r
431 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
433 QString refName = currentInterfaceNode.attribute("ref_name","none");
\r
434 if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));
\r
436 QString orientationStr = currentInterfaceNode.attribute("orientation","none");
\r
437 int orientation = InterfaceItem::getIntOrientation(orientationStr);
\r
438 if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));
\r
440 double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);
\r
441 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
443 ConnectedInterface *refInter = insideGroup->searchInterfaceItemByName(refName)->refInter;
\r
444 InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this);
\r
445 ifaceItem->setId(id);
\r
446 upperItem->addInterfaceItem(ifaceItem);
\r
450 cout << "blockItems \"group\" loaded and created succefully!" << endl;
\r
452 QDomNodeList connectionNodes = root.elementsByTagName("connection");
\r
454 for(int i=0; i<connectionNodes.length(); i++){
\r
455 QDomElement currentConnectionNode = connectionNodes.at(i).toElement();
\r
457 int from = currentConnectionNode.attribute("from","none").toInt(&ok);
\r
458 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
460 int to = currentConnectionNode.attribute("to","none").toInt(&ok);
\r
461 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
464 InterfaceItem *iface1 = searchInterfaceItemById(from,topScene);
\r
465 InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);
\r
467 if(iface1 != NULL && iface2 != NULL){
\r
468 dispatcher->createConnection(Dispatcher::Load, iface1,iface2);
\r
470 cout << "interfaces not found, connect canceled!" << endl;
\r
473 cout << "connections loaded and created succefully!" << endl;
\r
475 QDomNodeList modifierNodes = root.elementsByTagName("modifier");
\r
477 for(int i=0; i<modifierNodes.length(); i++){
\r
478 QDomElement currentModifierNode = modifierNodes.at(i).toElement();
\r
480 int id = currentModifierNode.attribute("id","none").toInt(&ok);
\r
481 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
483 QString typeStr = currentModifierNode.attribute("type","none");
\r
484 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
485 QString paramsStr = currentModifierNode.attribute("params","none");
\r
486 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
488 /* NB: just adding delays for now. To be cont'd */
\r
489 InterfaceItem *iface = searchInterfaceItemById(id,topScene);
\r
491 if ((iface == NULL ) || (iface->refInter == NULL) || (iface->refInter->getAssociatedIface() == NULL)) {
\r
492 cout << "modified interface not found, modifiers setup canceled!" << endl;
\r
495 ConnectedInterface* connIface = AI_TO_CON(iface->refInter->getAssociatedIface());
\r
497 AbstractInputModifier* mod = NULL;
\r
498 if (typeStr == "delay") {
\r
499 int delay = paramsStr.toInt(&ok);
\r
500 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
501 mod = new DelayInputModifier(connIface, delay);
\r
502 connIface->setInputModifier(mod);
\r
507 cout << "modifiers loaded and created succefully!" << endl;
\r
512 void Parameters::loadBlastConfiguration(QString confFile) throw(Exception) {
\r
515 validateXmlFile("blastconfig.xml", "blastconfig.xsd",Configuration);
\r
517 catch(Exception err) {
\r
522 // opening configFile
\r
523 QFile configFile(confFile);
\r
524 // reading in into QDomDocument
\r
525 QDomDocument document("configFile");
\r
527 if (!configFile.open(QIODevice::ReadOnly)) {
\r
528 throw(Exception(CONFIGFILE_NOACCESS));
\r
530 if (!document.setContent(&configFile)) {
\r
531 configFile.close();
\r
532 throw(Exception(CONFIGFILE_NOACCESS));
\r
534 configFile.close();
\r
536 //Get the root element
\r
537 QDomElement config = document.documentElement();
\r
539 QDomElement eltCat = config.firstChildElement("categories");
\r
541 categoryTree = new BlockLibraryTree();
\r
542 categoryTree->load(eltCat);
\r
544 catch(Exception err) {
\r
548 QDomElement eltReferences = eltCat.nextSiblingElement("references");
\r
549 refLib = eltReferences.attribute("lib_file","none");
\r
550 cout << "references lib : " << qPrintable(refLib) << endl;
\r
552 QString nbPathesStr;
\r
553 nbPathesStr = eltReferences.attribute("nb","none");
\r
554 nbPathes = nbPathesStr.toInt(&ok);
\r
555 QDomNodeList listBlockDir = eltReferences.elementsByTagName("reference_lib");
\r
556 if ((!ok) || (nbPathes != listBlockDir.size())) throw(Exception(CONFIGFILE_CORRUPTED));
\r
558 for(int i=0;i<listBlockDir.size();i++) {
\r
559 QDomNode nodeBlockDir = listBlockDir.at(i);
\r
560 QDomElement eltBlockDir = nodeBlockDir.toElement();
\r
561 if (eltBlockDir.isNull()) throw(Exception(CONFIGFILE_CORRUPTED));
\r
562 QString path = eltBlockDir.attribute("path","none");
\r
563 if (path == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
564 refPathes.append(path);
\r
565 cout << "references path : " << qPrintable(path) << endl;
\r
568 QDomElement eltImpl = eltReferences.nextSiblingElement("implementations");
\r
569 implLib = eltImpl.attribute("lib_file","none");
\r
570 cout << "implementation lib : " << qPrintable(implLib) << endl;
\r
571 nbPathesStr = eltImpl.attribute("nb","none");
\r
572 nbPathes = nbPathesStr.toInt(&ok);
\r
573 QDomNodeList listImplDir = eltImpl.elementsByTagName("impl_lib");
\r
574 if ((!ok) || (nbPathes != listImplDir.size())) throw(Exception(CONFIGFILE_CORRUPTED));
\r
576 for(int i=0;i<listImplDir.size();i++) {
\r
577 QDomNode nodeImplDir = listImplDir.at(i);
\r
578 QDomElement eltImplDir = nodeImplDir.toElement();
\r
579 if (eltImplDir.isNull()) throw(Exception(CONFIGFILE_CORRUPTED));
\r
580 QString path = eltImplDir.attribute("path","none");
\r
581 if (path == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
582 implPathes.append(path);
\r
583 cout << "impl path : " << qPrintable(path) << endl << endl;
\r
586 QDomElement eltSource = eltImpl.nextSiblingElement("sources");
\r
587 nbPathesStr = eltSource.attribute("nb","none");
\r
588 nbPathes = nbPathesStr.toInt(&ok);
\r
589 QDomNodeList listSourceDir = eltSource.elementsByTagName("source_lib");
\r
590 if ((!ok) || (nbPathes != listSourceDir.size())) throw(Exception(CONFIGFILE_CORRUPTED));
\r
592 for(int i=0;i<listSourceDir.size();i++) {
\r
593 QDomNode nodeSourceDir = listSourceDir.at(i);
\r
594 QDomElement eltSourceDir = nodeSourceDir.toElement();
\r
595 if (eltSourceDir.isNull()) throw(Exception(CONFIGFILE_CORRUPTED));
\r
596 QString path = eltSourceDir.attribute("path","none");
\r
597 if (path == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
598 sourcePathes.append(path);
\r
599 cout << "core path : " << qPrintable(path) << endl << endl;
\r
602 // getting elt = the element <defaults>
\r
603 // for each child element, initialize the associated attributes of Parameters
\r
605 QDomElement eltDefaults = eltSource.nextSiblingElement("defaults");
\r
607 QDomElement eltBlocks = eltDefaults.firstChildElement("blocks");
\r
608 QString attributeStr = eltBlocks.attribute("width", "none");
\r
609 defaultBlockWidth = attributeStr.toInt(&ok);
\r
610 if (!ok || defaultBlockWidth < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
611 attributeStr = eltBlocks.attribute("height", "none");
\r
612 defaultBlockHeight = attributeStr.toInt(&ok);
\r
613 if (!ok || defaultBlockHeight < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
614 attributeStr = eltBlocks.attribute("font_size", "none");
\r
615 defaultBlockFontSize = attributeStr.toFloat(&ok);
\r
616 if (!ok || defaultBlockFontSize < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
617 attributeStr = eltBlocks.attribute("font", "none");
\r
618 if (attributeStr == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
619 defaultBlockFontName = attributeStr;
\r
620 defaultBlockFont = QFont(defaultBlockFontName, defaultBlockFontSize);
\r
622 QDomElement eltInterfaces = eltBlocks.nextSiblingElement("interfaces");
\r
623 attributeStr = eltInterfaces.attribute("width", "none");
\r
624 arrowWidth = attributeStr.toInt(&ok);
\r
625 if (!ok || arrowWidth < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
626 attributeStr = eltInterfaces.attribute("height", "none");
\r
627 arrowHeight = attributeStr.toInt(&ok);
\r
628 if (!ok || arrowHeight < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
629 attributeStr = eltInterfaces.attribute("linelength", "none");
\r
630 arrowLineLength = attributeStr.toInt(&ok);
\r
631 if (!ok || arrowLineLength < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
632 attributeStr = eltInterfaces.attribute("font_size", "none");
\r
633 defaultIfaceFontSize = attributeStr.toFloat(&ok);
\r
634 if (!ok || defaultIfaceFontSize < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
635 attributeStr = eltInterfaces.attribute("font", "none");
\r
636 if (attributeStr == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
637 defaultIfaceFontName = attributeStr;
\r
638 defaultIfaceFont = QFont(defaultIfaceFontName, defaultIfaceFontSize);
\r
640 QDomElement eltConnections = eltInterfaces.nextSiblingElement("connections");
\r
641 attributeStr = eltConnections.attribute("gaplength", "none");
\r
642 connGapLength = attributeStr.toInt(&ok);
\r
643 if (!ok || connGapLength < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
646 void Parameters::loadReferencesFromXml() throw(Exception) {
\r
647 cout << "load references from xml" << endl;
\r
648 for(int i=0;i<refPathes.size();i++) {
\r
649 cout << "analyzing " << qPrintable(refPathes.at(i)) << endl;
\r
650 QDir dir(refPathes.at(i));
\r
651 QStringList filter;
\r
653 dir.setNameFilters(filter);
\r
654 QStringList list = dir.entryList();
\r
655 for(int j=0;j<list.size();j++) {
\r
656 QString fileName = dir.absolutePath();
\r
657 fileName.append("/"+list.at(j));
\r
659 QFile blockXML(fileName);
\r
660 if (!blockXML.open(QIODevice::ReadOnly)) {
\r
661 throw(Exception(BLOCKFILE_NOACCESS));
\r
663 QTextStream in(&blockXML);
\r
664 QString line = in.readLine();
\r
665 line = in.readLine();
\r
667 if (!line.contains("<block")) {
\r
674 validateXmlFile(fileName,"reference.xsd",Reference);
\r
676 catch(Exception err) {
\r
680 // reading in into QDomDocument
\r
681 QDomDocument document ("FileXML");
\r
682 if (!blockXML.open(QIODevice::ReadOnly)) {
\r
683 throw(Exception(BLOCKFILE_NOACCESS));
\r
685 if (!document.setContent(&blockXML)) {
\r
687 throw(Exception(BLOCKFILE_NOACCESS));
\r
691 QDomElement blockRoot = document.documentElement();
\r
692 QString name = blockRoot.tagName();
\r
693 if (name == "block") {
\r
695 cout << "xml:" << fileName.toStdString() << endl;
\r
696 ReferenceBlock* b = new ReferenceBlock(fileName);
\r
698 b->load(blockRoot);
\r
704 cout << "xml:" << b->getXmlFile().toStdString() << endl;
\r
706 availableBlocks.append(b);
\r
707 foreach (int id,b->getCategories()) {
\r
708 cout << "ajout du bloc dans cat n° : " << id << endl;
\r
709 BlockCategory* cat = categoryTree->searchCategory(id);
\r
710 cat->blocks.append(b);
\r
717 void Parameters::loadReferencesFromLib() throw(Exception) {
\r
719 cout << "loading references from lib" << endl;
\r
721 // removing blocks from category tree if they exist
\r
722 categoryTree->clearBlocks();
\r
723 // deleting existings blocks
\r
724 ReferenceBlock* b = NULL;
\r
725 for(int i=0;i<availableBlocks.size();i++) {
\r
726 b = availableBlocks.at(i);
\r
729 availableBlocks.clear();
\r
731 QFile libFile(refLib);
\r
732 if (!libFile.open(QIODevice::ReadOnly)) {
\r
733 throw(Exception(BLOCKFILE_NOACCESS));
\r
735 QDataStream in(&libFile);
\r
742 for(int i=0;i<nbBlocks;i++) {
\r
743 b = new ReferenceBlock("");
\r
745 availableBlocks.append(b);
\r
746 foreach (int id,b->getCategories()) {
\r
747 BlockCategory* cat = categoryTree->searchCategory(id);
\r
748 cat->blocks.append(b);
\r
754 void Parameters::saveReferencesToLib() throw(Exception) {
\r
756 cout << "saving blocks in " << qPrintable(refLib) << endl;
\r
757 QFile libFile(refLib);
\r
758 if (!libFile.open(QIODevice::WriteOnly)) {
\r
759 throw(Exception(BLOCKFILE_NOACCESS));
\r
761 QDataStream out(&libFile);
\r
763 out.setVersion(QDataStream::Qt_5_0);
\r
765 QByteArray blockData;
\r
766 QDataStream toWrite(&blockData, QIODevice::WriteOnly);
\r
768 toWrite << availableBlocks.size();
\r
769 for(int i=0;i<availableBlocks.size();i++) {
\r
770 ReferenceBlock* b = availableBlocks.at(i);
\r
780 void Parameters::loadImplementationsFromXml() throw(Exception) {
\r
782 for(int i=0;i<implPathes.size();i++) {
\r
783 cout << "analyzing " << qPrintable(implPathes.at(i)) << endl;
\r
784 QDir dir(implPathes.at(i));
\r
785 QStringList filter;
\r
787 dir.setNameFilters(filter);
\r
788 QStringList list = dir.entryList();
\r
789 for(int j=0;j<list.size();j++) {
\r
790 QString fileName = dir.absolutePath();
\r
791 fileName.append("/"+list.at(j));
\r
793 cout << "checking " << qPrintable(fileName) << " is an implementation file ...";
\r
794 QFile implXML(fileName);
\r
795 if (!implXML.open(QIODevice::ReadOnly)) {
\r
796 throw(Exception(IMPLFILE_NOACCESS));
\r
798 QTextStream in(&implXML);
\r
799 QString line = in.readLine();
\r
800 line = in.readLine();
\r
802 if (!line.contains("<block_impl")) {
\r
808 cout << "OK" << endl;
\r
809 cout << "reading " << qPrintable(fileName) << " content ...";
\r
812 validateXmlFile(fileName,"implementation.xsd",Implementation);
\r
814 catch(Exception e) {
\r
818 // reading in into QDomDocument
\r
819 QDomDocument document ("FileXML");
\r
820 if (!implXML.open(QIODevice::ReadOnly)) {
\r
821 throw(Exception(IMPLFILE_NOACCESS));
\r
823 cout << "OK" << endl;
\r
824 cout << "convert " << qPrintable(fileName) << " content into document...";
\r
825 if (!document.setContent(&implXML)) {
\r
827 throw(Exception(IMPLFILE_NOACCESS));
\r
831 QDomElement implRoot = document.documentElement();
\r
832 QString refXml = implRoot.attribute("ref_name","none");
\r
833 QString refMd5 = implRoot.attribute("ref_md5","none");
\r
834 BlockImplementation* impl = new BlockImplementation(fileName,refXml,refMd5);
\r
836 QDomNodeList archNode = implRoot.elementsByTagName("architecture");
\r
838 if (archNode.isEmpty()) {
\r
839 cout << "impl has no architecture" << endl;
\r
842 QDomElement archElt = archNode.at(0).toElement();
\r
843 QString compList = archElt.attribute("comp_list","none");
\r
844 if (compList != "none") {
\r
845 QStringList compos = compList.split(",");
\r
846 foreach(QString s, compos) {
\r
847 impl->addResource(s);
\r
852 impl->loadPatterns(implRoot);
\r
857 availableImplementations.append(impl);
\r
859 ReferenceBlock* ref = NULL;
\r
860 if (! refMd5.isEmpty()) {
\r
861 ref = searchBlockByMd5(refMd5);
\r
864 ref = searchBlockByXml(refXml);
\r
867 cout << "Cannot find a reference block for impl :" << qPrintable(fileName) << endl;
\r
870 ref->addImplementation(impl);
\r
871 impl->setReference(ref);
\r
872 if (! impl->checkPatterns()) throw(Exception(IMPLFILE_CORRUPTED));
\r
874 cout << "OK" << endl;
\r
879 void Parameters::loadImplementationsFromLib() throw(Exception) {
\r
881 cout << "loading implementations from lib" << endl;
\r
883 BlockImplementation* impl = NULL;
\r
884 ReferenceBlock* ref = NULL;
\r
885 for(int i=0;i<availableImplementations.size();i++) {
\r
886 impl = availableImplementations.at(i);
\r
889 availableImplementations.clear();
\r
891 QFile libFile(implLib);
\r
892 if (!libFile.open(QIODevice::ReadOnly)) {
\r
893 throw(Exception(IMPLFILE_NOACCESS));
\r
895 QDataStream in(&libFile);
\r
902 for(int i=0;i<nbImpls;i++) {
\r
903 impl = new BlockImplementation("");
\r
905 availableImplementations.append(impl);
\r
906 QString refMd5 = impl->getReferenceMd5();
\r
907 QString refXml = impl->getReferenceXml();
\r
909 if (! refMd5.isEmpty()) {
\r
910 ref = searchBlockByMd5(refMd5);
\r
913 ref = searchBlockByXml(refXml);
\r
916 cout << "Cannot find a reference block for impl :" << qPrintable(impl->getXmlFile()) << endl;
\r
919 ref->addImplementation(impl);
\r
920 impl->setReference(ref);
\r
921 if (! impl->checkPatterns()) throw(Exception(IMPLFILE_CORRUPTED));
\r
927 void Parameters::saveImplementationsToLib() throw(Exception) {
\r
929 cout << "saving implementations in " << qPrintable(implLib) << endl;
\r
930 QFile libFile(implLib);
\r
931 if (!libFile.open(QIODevice::WriteOnly)) {
\r
932 throw(Exception(IMPLFILE_NOACCESS));
\r
934 QDataStream out(&libFile);
\r
936 out.setVersion(QDataStream::Qt_5_0);
\r
938 QByteArray blockData;
\r
939 QDataStream toWrite(&blockData, QIODevice::WriteOnly);
\r
941 toWrite << availableImplementations.size();
\r
942 for(int i=0;i<availableImplementations.size();i++) {
\r
943 BlockImplementation* impl = availableImplementations.at(i);
\r
954 void Parameters::loadSources() throw(Exception) {
\r
956 for(int i=0;i<sourcePathes.size();i++) {
\r
957 cout << "analyzing " << qPrintable(sourcePathes.at(i)) << endl;
\r
958 QDir dir(sourcePathes.at(i));
\r
959 QStringList filter;
\r
960 filter << "*.vhd" << "*.ngc";
\r
961 dir.setNameFilters(filter);
\r
962 QStringList list = dir.entryList();
\r
963 for(int j=0;j<list.size();j++) {
\r
964 QString fileName = dir.absolutePath();
\r
965 fileName.append("/"+list.at(j));
\r
967 if (list.at(j).endsWith(".ngc")) {
\r
968 QString netName = list.at(j);
\r
969 netName.truncate(list.at(j).size() -4);
\r
970 cout << "found netlist " << qPrintable(netName) << endl;
\r
971 availableResources.append(new ExternalResource(netName,fileName,ExternalResource::Netlist));
\r
974 cout << "parsing " << qPrintable(fileName) << " ... ";
\r
975 QFile srcXML(fileName);
\r
976 if (!srcXML.open(QIODevice::ReadOnly)) {
\r
977 throw(Exception(IMPLFILE_NOACCESS));
\r
979 QTextStream in(&srcXML);
\r
981 QString line = in.readLine();
\r
982 while (!line.isNull()) {
\r
983 if (line.contains("package", Qt::CaseInsensitive)) {
\r
984 QRegularExpression rxPack("^package (.+) is$",QRegularExpression::CaseInsensitiveOption);
\r
985 QRegularExpressionMatch matchPack = rxPack.match(line);
\r
986 if (matchPack.hasMatch()) {
\r
987 QString packName = matchPack.captured(1);
\r
988 cout << "found package " << qPrintable(packName) << endl;
\r
989 availableResources.append(new ExternalResource(packName,fileName,ExternalResource::Package));
\r
992 else if (line.contains("entity", Qt::CaseInsensitive)) {
\r
993 QRegularExpression rxEnt("^entity (.+) is$",QRegularExpression::CaseInsensitiveOption);
\r
994 QRegularExpressionMatch matchEnt = rxEnt.match(line);
\r
995 if (matchEnt.hasMatch()) {
\r
996 QString entityName = matchEnt.captured(1);
\r
997 cout << "found entity " << qPrintable(entityName) << endl;
\r
998 availableResources.append(new ExternalResource(entityName,fileName,ExternalResource::Code));
\r
1001 line = in.readLine();
\r
1004 cout << "OK" << endl;
\r
1010 QList<ExternalResource *> Parameters::searchResourceByName(const QString& name) {
\r
1011 QList<ExternalResource*> listRes;
\r
1012 foreach(ExternalResource* s, availableResources) {
\r
1013 if (s->getName() == name) {
\r
1014 listRes.append(s);
\r
1020 void Parameters::addAvailableBlock(ReferenceBlock *block) {
\r
1021 availableBlocks.append(block);
\r
1022 foreach (int id,block->getCategories()) {
\r
1023 cout << "ajout du bloc dans cat n° : " << id << endl;
\r
1024 BlockCategory* cat = categoryTree->searchCategory(id);
\r
1025 cat->blocks.append(block);
\r
1029 void Parameters::parametersValidation() {
\r
1030 QList<AbstractBlock*> blocksToConfigure = getBlocksToConfigure();
\r
1032 if(!blocksToConfigure.isEmpty()){
\r
1033 BlocksToConfigureWidget *widget = new BlocksToConfigureWidget(blocksToConfigure, this, NULL);
\r
1038 void Parameters::connectionsValidation() {
\r
1040 #ifdef DEBUG_INCLFUN
\r
1042 QStack<AbstractInterface*> *interfaceToValidate = new QStack<AbstractInterface*>;
\r
1043 QList<AbstractInterface*> *validatedInterface = new QList<AbstractInterface*>;
\r
1045 foreach(AbstractInterface *inter, topWindow->getScene()->getGroupItem()->getRefBlock()->getInterfaces()){
\r
1046 foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
\r
1048 inter->setWidth(connectedInter->getWidth());
\r
1049 interfaceToValidate->push(connectedInter);
\r
1055 while(!interfaceToValidate->isEmpty()){
\r
1056 interfaceToValidate->pop()->connectionsValidation(interfaceToValidate, validatedInterface);
\r
1059 catch(Exception e){
\r
1060 cerr << e.getMessage().toStdString() << endl;
\r
1065 QList<AbstractBlock *> Parameters::getBlocksToConfigure() {
\r
1067 #ifdef DEBUG_INCLFUN
\r
1069 QList<AbstractBlock*> *checkedBlocks = new QList<AbstractBlock*>;
\r
1070 QList<AbstractBlock*> *blocksToConfigure = new QList<AbstractBlock*>;
\r
1072 foreach(AbstractInterface *inter, topWindow->getScene()->getGroupItem()->getRefBlock()->getInterfaces()){
\r
1073 foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
\r
1074 if(!checkedBlocks->contains(connectedInter->getOwner())){
\r
1075 connectedInter->getOwner()->parametersValidation(checkedBlocks, blocksToConfigure);
\r
1079 return *blocksToConfigure;
\r
1084 void Parameters::updateToolbar() {
\r
1085 int nb = currentScene->getBoxItems().length();
\r
1086 for(int i = 0; i<nb; i++){
\r
1087 if(currentScene->getBoxItems().at(i)->isSelected()){
\r
1088 currentScene->getGroupWidget()->enableGroupButton(true);
\r
1092 currentScene->getGroupWidget()->enableGroupButton(false);
\r
1096 void Parameters::updateIds() {
\r
1098 /* a in-width cross of the graph must be done so that ids of GroupItem
\r
1099 are in the correct ordre when saving/loading a project
\r
1101 int countItem = 1;
\r
1102 int countIface = 1;
\r
1103 QList<GroupScene *> fifo;
\r
1104 fifo.append(topScene);
\r
1105 while (!fifo.isEmpty()) {
\r
1106 GroupScene* scene = fifo.takeFirst();
\r
1107 countItem = scene->setItemsId(countItem);
\r
1108 countIface = scene->setInterfacesId(countIface);
\r
1109 foreach(GroupScene* s, scene->getChildrenScene()) {
\r
1116 ReferenceBlock *Parameters::searchBlockByXml(QString xmlName) {
\r
1117 foreach(ReferenceBlock *block, availableBlocks){
\r
1118 if(block->getXmlFile().contains(xmlName))
\r
1124 ReferenceBlock *Parameters::searchBlockByMd5(QString sumMd5) {
\r
1125 foreach(ReferenceBlock *block, availableBlocks){
\r
1126 if(block->getHashMd5() == sumMd5)
\r
1132 void Parameters::save(QString confFile) {
\r
1134 //#ifdef DEBUG_INCLFUN
\r
1137 QList<ConnectionItem*> allConnections;
\r
1138 QFile file(confFile);
\r
1139 if(file.open(QIODevice::WriteOnly)){
\r
1141 QXmlStreamWriter writer(&file);
\r
1143 writer.setAutoFormatting(true);
\r
1144 writer.writeStartDocument();
\r
1146 writer.writeStartElement("blast_project");
\r
1147 writer.writeStartElement("scenes");
\r
1149 writer.writeAttribute("count",QString::number(dispatcher->getNumberOfScenes()));
\r
1151 // cross the scene level by level using a FIFO
\r
1152 QList<GroupScene*> fifoScene;
\r
1153 fifoScene.append(topScene);
\r
1155 GroupScene *scene;
\r
1156 while (!fifoScene.isEmpty()) {
\r
1157 scene = fifoScene.takeFirst();
\r
1158 scene->save(writer);
\r
1159 foreach(GroupScene* s, scene->getChildrenScene()) {
\r
1160 fifoScene.append(s);
\r
1163 foreach(ConnectionItem* item, scene->getConnectionItems()) {
\r
1164 allConnections.append(item);
\r
1167 writer.writeEndElement(); //</scenes>
\r
1169 writer.writeStartElement("connections");
\r
1170 foreach(ConnectionItem* item, allConnections) {
\r
1172 writer.writeStartElement("connection");
\r
1174 writer.writeAttribute("from",QString::number(item->getFromInterfaceItem()->getId()));
\r
1175 writer.writeAttribute("to", QString::number(item->getToInterfaceItem()->getId()));
\r
1177 writer.writeEndElement();
\r
1180 writer.writeEndElement(); //</connections>
\r
1182 QList<InterfaceItem *> lstIfaceItem;
\r
1183 // search for modifiers
\r
1184 foreach(ConnectionItem* item, allConnections) {
\r
1185 InterfaceItem* fromIfaceItem = item->getFromInterfaceItem();
\r
1186 AbstractInputModifier* mod = fromIfaceItem->refInter->getInputModifier();
\r
1187 if (mod != NULL) {
\r
1188 if (!lstIfaceItem.contains(fromIfaceItem)) lstIfaceItem.append(fromIfaceItem);
\r
1190 InterfaceItem* toIfaceItem = item->getToInterfaceItem();
\r
1191 mod = toIfaceItem->refInter->getInputModifier();
\r
1192 if (mod != NULL) {
\r
1193 if (!lstIfaceItem.contains(toIfaceItem)) lstIfaceItem.append(toIfaceItem);
\r
1196 // write input modifiers
\r
1197 writer.writeStartElement("modifiers");
\r
1198 foreach(InterfaceItem* item, lstIfaceItem) {
\r
1199 AbstractInputModifier* mod = item->refInter->getInputModifier();
\r
1200 if (mod != NULL) {
\r
1201 writer.writeStartElement("modifier");
\r
1202 writer.writeAttribute("id", QString::number(item->getId()));
\r
1203 writer.writeAttribute("type",mod->getTypeStr());
\r
1204 writer.writeAttribute("params", mod->getParametersStr());
\r
1205 writer.writeEndElement();
\r
1209 writer.writeEndElement(); //</modifiers>
\r
1210 writer.writeEndElement(); //</blast_project
\r
1212 writer.writeEndDocument();
\r
1215 unsaveModif = false;
\r
1220 void Parameters::setArrowPathes() {
\r
1221 QPainterPath _inArrow;
\r
1222 _inArrow.lineTo(arrowLineLength,0);
\r
1223 _inArrow.lineTo(arrowLineLength+arrowWidth,-arrowHeight/2);
\r
1224 _inArrow.lineTo(arrowLineLength+arrowWidth,arrowHeight/2);
\r
1225 _inArrow.lineTo(arrowLineLength,0);
\r
1226 //_inArrow.closeSubpath();
\r
1227 dataArrowIn = _inArrow;
\r
1229 QPainterPath _inArrowC;
\r
1230 _inArrowC.lineTo(arrowLineLength,0);
\r
1231 _inArrowC.addEllipse(arrowLineLength,-arrowHeight/2,arrowHeight-1,arrowHeight-1);
\r
1232 clkrstArrow = _inArrowC;
\r
1234 QPainterPath _outArrow;
\r
1235 _outArrow.lineTo(arrowLineLength,0);
\r
1236 _outArrow.lineTo(arrowLineLength,-arrowHeight/2);
\r
1237 _outArrow.lineTo(arrowLineLength+arrowWidth,0);
\r
1238 _outArrow.lineTo(arrowLineLength,arrowHeight/2);
\r
1239 _outArrow.lineTo(arrowLineLength,0);
\r
1240 //_outArrow.closeSubpath();
\r
1241 dataArrowOut = _outArrow;
\r
1245 GroupScene* Parameters::searchSceneById(int id, GroupScene *scene) {
\r
1247 if (scene->getId() == id) return scene;
\r
1248 GroupScene* sc = NULL;
\r
1250 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1251 sc = searchSceneById(id,s);
\r
1252 if (sc != NULL) return sc;
\r
1257 GroupItem* Parameters::searchGroupItemById(int id, GroupScene *scene) {
\r
1259 if (scene->getGroupItem()->getId() == id) return scene->getGroupItem();
\r
1261 GroupItem* item = NULL;
\r
1262 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1263 item = searchGroupItemById(id,s);
\r
1264 if (item != NULL) return item;
\r
1269 BoxItem* Parameters::searchBlockItemById(int id, GroupScene *scene) {
\r
1271 foreach(BoxItem *item, scene->getBoxItems()){
\r
1272 if(item->getId() == id){
\r
1277 BoxItem* item = NULL;
\r
1278 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1279 item = searchBlockItemById(id,s);
\r
1280 if (item != NULL) return item;
\r
1285 BoxItem* Parameters::searchFunctionalBlock(AbstractBlock* block) {
\r
1287 return searchFunctionalBlockRecur(block,topScene);
\r
1290 BoxItem* Parameters::searchFunctionalBlockRecur(AbstractBlock* block, GroupScene* scene) {
\r
1292 foreach(BoxItem *item, scene->getBoxItems()){
\r
1293 if(item->getRefBlock() == block) {
\r
1298 BoxItem* item = NULL;
\r
1299 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1300 item = searchFunctionalBlockRecur(block,s);
\r
1301 if (item != NULL) return item;
\r
1306 InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) {
\r
1308 foreach(InterfaceItem *item, scene->getGroupItem()->getInterfaces()){
\r
1309 if(item->getId() == id){
\r
1313 if (scene->isTopScene()) {
\r
1314 foreach(StimuliItem *block, scene->getSourceItems()){
\r
1315 foreach(InterfaceItem *item, block->getInterfaces()){
\r
1316 if(item->getId() == id){
\r
1322 foreach(BoxItem *block, scene->getBoxItems()){
\r
1323 foreach(InterfaceItem *item, block->getInterfaces()){
\r
1324 if(item->getId() == id){
\r
1329 InterfaceItem* item = NULL;
\r
1330 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1331 item = searchInterfaceItemById(id,s);
\r
1332 if (item != NULL) return item;
\r
1337 QString Parameters::normalizeName(const QString &name) {
\r
1339 s.replace(QRegularExpression("[^a-zA-Z0-9_]"),"_");
\r
1340 s.replace(QRegularExpression("[_]+"),"_");
\r