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
57 Parameters::~Parameters() {
\r
61 void Parameters::clear() {
\r
62 delete categoryTree;
\r
63 QListIterator<ReferenceBlock *> iter(availableBlocks);
\r
64 while(iter.hasNext()) {
\r
65 ReferenceBlock* item = iter.next();
\r
68 availableBlocks.clear();
\r
72 Graph* Parameters::createGraph(bool createTopGroupIfaces) {
\r
73 graph = new Graph(createTopGroupIfaces);
\r
77 void Parameters::destroyGraph() {
\r
81 ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) {
\r
83 BlockCategory* blockCat = categoryTree->searchCategory(idCategory);
\r
85 if (blockCat == NULL) return NULL;
\r
86 ReferenceBlock* ref = blockCat->getBlockById(idBlock);
\r
90 ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) {
\r
92 BlockCategory* blockCat = categoryTree->searchCategory(100);
\r
93 if (blockCat == NULL) return NULL;
\r
94 ReferenceBlock* ref = blockCat->getBlockByName(blockName);
\r
98 void Parameters::createDelayBlock() {
\r
99 delayRef = new ReferenceBlock("no.xml");
\r
100 delayRef->addCategory(100);
\r
101 delayRef->setName("delay");
\r
103 BlockCategory* cat = categoryTree->searchCategory(100);
\r
104 cat->blocks.append(delayRef);
\r
106 AbstractInterface* interIn = new ReferenceInterface(delayRef,"data_in",AbstractInterface::Input, AbstractInterface::Data, "expression","$in_width");
\r
107 delayRef->addInterface(interIn);
\r
108 AbstractInterface* interInCtl = new ReferenceInterface(delayRef,"data_in_enb",AbstractInterface::Input, AbstractInterface::Control, "boolean","1");
\r
109 delayRef->addInterface(interInCtl);
\r
110 interInCtl->setAssociatedIface(interIn);
\r
111 AbstractInterface* interOut = new ReferenceInterface(delayRef,"data_out",AbstractInterface::Output, AbstractInterface::Data, "expression","$in_width");
\r
112 delayRef->addInterface(interOut);
\r
113 AbstractInterface* interOutCtl = new ReferenceInterface(delayRef,"data_out_enb",AbstractInterface::Output, AbstractInterface::Control, "boolean","1");
\r
114 delayRef->addInterface(interOutCtl);
\r
115 interOutCtl->setAssociatedIface(interOut);
\r
116 BlockParameter* param1 = new BlockParameterGeneric(delayRef,"in_width","natural","8");
\r
117 BlockParameter* param2 = new BlockParameterGeneric(delayRef,"dly_length","natural","1");
\r
118 delayRef->addParameter(param1);
\r
119 delayRef->addParameter(param2);
\r
120 delayImpl = new BlockImplementation("no.xml");
\r
121 delayImpl->setDelta("1");
\r
122 QHash<QString,QString> consPattern;
\r
123 consPattern.insert("data_in_enb","1");
\r
124 delayImpl->setConsumptionPattern(consPattern);
\r
125 QHash<QString,QString> prodPattern;
\r
126 prodPattern.insert("data_out_enb","O{$dly_length}1");
\r
127 delayImpl->setProductionPattern(prodPattern);
\r
128 delayImpl->setProductionCounter("1");
\r
129 delayRef->addImplementation(delayImpl);
\r
130 delayImpl->setReference(delayRef);
\r
131 if (! delayImpl->checkPatterns()) {
\r
132 cout << "Delay block creation: failure" << endl;
\r
135 cout << "Delay block creation: success" << endl;
\r
142 void Parameters::validateXmlFile(const QString& xmlFileName, const QString& xsdFileName, XmlFileType fileType) throw(Exception) {
\r
143 // opening configFile
\r
144 QFile xmlFile(xmlFileName);
\r
145 if (!xmlFile.open(QIODevice::ReadOnly)) {
\r
146 if (fileType == Configuration) {
\r
147 throw(Exception(CONFIGFILE_NOACCESS));
\r
149 else if (fileType == Reference) {
\r
150 throw(Exception(BLOCKFILE_NOACCESS));
\r
152 else if (fileType == Implementation) {
\r
153 throw(Exception(IMPLFILE_NOACCESS));
\r
155 else if (fileType == Project) {
\r
156 throw(Exception(PROJECTFILE_NOACCESS));
\r
160 QFile xsdFile(xsdFileName);
\r
161 if (!xsdFile.open(QIODevice::ReadOnly)) {
\r
163 if (fileType == Configuration) {
\r
164 throw(Exception(CONFIGFILE_NOACCESS));
\r
166 else if (fileType == Reference) {
\r
167 throw(Exception(BLOCKFILE_NOACCESS));
\r
169 else if (fileType == Implementation) {
\r
170 throw(Exception(IMPLFILE_NOACCESS));
\r
172 else if (fileType == Project) {
\r
173 throw(Exception(PROJECTFILE_NOACCESS));
\r
177 if(validate(xmlFile,xsdFile) == false) {
\r
180 if (fileType == Configuration) {
\r
181 throw(Exception(CONFIGFILE_CORRUPTED));
\r
183 else if (fileType == Reference) {
\r
184 throw(Exception(BLOCKFILE_CORRUPTED));
\r
186 else if (fileType == Implementation) {
\r
187 throw(Exception(IMPLFILE_CORRUPTED));
\r
189 else if (fileType == Project) {
\r
190 throw(Exception(PROJECTFILE_CORRUPTED));
\r
197 bool Parameters::validate(QFile& fileXml, QFile& fileSchema) {
\r
199 // 2 files are supposed to be already opened
\r
202 if(! schema.load(&fileSchema)){
\r
203 cout << "invalid schema" << endl;
\r
207 QXmlSchemaValidator validator(schema);
\r
209 if(! validator.validate(&fileXml)){
\r
210 cout << "invalid xml" << endl;
\r
216 QDomElement Parameters::openProjectFile(const QString& projectFileName) throw(Exception) {
\r
219 validateXmlFile(projectFileName,"projectfile.xsd",Project);
\r
221 catch(Exception err) {
\r
225 QFile projectFile(projectFileName);
\r
226 QDomDocument doc("projectFile");
\r
228 if(!projectFile.open(QIODevice::ReadOnly)) {
\r
229 throw(Exception(PROJECTFILE_NOACCESS));
\r
231 if(!doc.setContent(&projectFile)) {
\r
232 projectFile.close();
\r
233 throw(Exception(PROJECTFILE_CORRUPTED));
\r
235 projectFile.close();
\r
237 QDomElement root = doc.documentElement();
\r
242 GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) {
\r
245 GroupWidget* groupWidget = NULL;
\r
246 GroupItem *groupItem = NULL;
\r
247 GroupBlock *groupBlock = NULL;
\r
249 GroupWidget* topGroup = NULL;
\r
251 QString path = root.attribute("project_path","none");
\r
252 if (path != "none") {
\r
254 if (dir.exists()) {
\r
255 projectPath = path;
\r
258 cout << "project path set to " << qPrintable(projectPath) << endl;
\r
260 /**********************************************************
\r
261 1 : getting scene and creating associated group widgets
\r
262 ***********************************************************/
\r
263 QDomNodeList scenesNodes = root.elementsByTagName("scene");
\r
265 int maxIdScene = -1;
\r
266 for(int i=0; i<scenesNodes.length(); i++) {
\r
267 QDomElement currentSceneNode = scenesNodes.at(i).toElement();
\r
268 int idScene = currentSceneNode.attribute("id","none").toInt(&ok);
\r
269 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
270 if (idScene > maxIdScene) maxIdScene = idScene;
\r
271 int idUpperScene = currentSceneNode.attribute("upper_scene","none").toInt(&ok);
\r
272 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
274 if (idUpperScene == -1) {
\r
275 topGroup = dispatcher->createTopScene(Dispatcher::Load);
\r
276 topScene->setId(idScene);
\r
277 groupItem = topScene->getGroupItem();
\r
278 cout << "top group added to scene n°" << idScene << endl;
\r
281 cout << "trying to create scene n°" << idScene << " with upper scene n°" <<idUpperScene << endl;
\r
282 GroupScene* upperScene = searchSceneById(idUpperScene, topScene);
\r
283 groupWidget = dispatcher->addNewEmptyGroup(Dispatcher::Load, upperScene,false);
\r
284 groupWidget->getScene()->setId(idScene);
\r
285 groupItem = groupWidget->getScene()->getGroupItem();
\r
287 groupBlock = AB_TO_GRP(groupItem->getRefBlock());
\r
288 /**********************************************************
\r
289 1.1 : getting the group item of each scene
\r
290 ***********************************************************/
\r
291 QDomElement groupItemNode = currentSceneNode.firstChildElement("group_item");
\r
293 groupItem->load(groupItemNode);
\r
295 catch(Exception err) {
\r
299 if (idUpperScene != -1) {
\r
300 groupWidget->setWindowTitle(groupBlock->getName());
\r
301 groupWidget->show();
\r
302 cout << qPrintable(groupItem->getRefBlock()->getName()) << " has upper box item in " << qPrintable(groupItem->getParentItem()->getScene()->getGroupItem()->getRefBlock()->getName()) << endl;
\r
305 dispatcher->setSceneCounter(Dispatcher::Load, maxIdScene+1);
\r
306 cout << "groupItems loaded and windows created succefully!" << endl;
\r
308 /**********************************************************
\r
309 2 : getting the functional blocks of each scene
\r
310 ***********************************************************/
\r
312 for(int i=0; i<scenesNodes.length(); i++){
\r
313 QDomElement currentSceneNode = scenesNodes.at(i).toElement();
\r
314 int idScene = currentSceneNode.attribute("id","none").toInt(&ok);
\r
315 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
316 cout << "SCENE : " << idScene << endl;
\r
317 GroupScene *currentScene = searchSceneById(idScene,topScene);
\r
319 if(currentScene == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
\r
320 /**********************************************************
\r
321 2.1 : getting sources if it is top scene
\r
322 ***********************************************************/
\r
323 if (currentScene->isTopScene()) {
\r
324 QDomNodeList sourceNodes = currentSceneNode.elementsByTagName("source_item");
\r
325 cout << "top scene has " << sourceNodes.length() << " sources" << endl;
\r
326 for(int j=0; j<sourceNodes.length(); j++) {
\r
327 QDomElement currentSBNode = sourceNodes.at(j).toElement();
\r
328 StimuliItem* sourceItem = new StimuliItem(dispatcher,this);
\r
330 sourceItem->load(currentSBNode);
\r
332 catch(Exception err) {
\r
335 cout << "source item has been read, add it to the scene" << endl;
\r
336 // add the block to the GroupScene
\r
337 currentScene->addStimuliItem(sourceItem);
\r
340 /**********************************************************
\r
341 2.2 : getting functional blocks
\r
342 ***********************************************************/
\r
343 QDomNodeList functionalBlockNodes = currentSceneNode.elementsByTagName("bi_functional");
\r
345 for(int j=0; j<functionalBlockNodes.length(); j++) {
\r
346 QDomElement currentFBNode = functionalBlockNodes.at(j).toElement();
\r
347 BoxItem* funcItem = new BoxItem(dispatcher,this, currentScene->getGroupItem());
\r
349 funcItem->loadFunctional(currentFBNode);
\r
351 catch(Exception err) {
\r
354 // add the block to the GroupScene
\r
355 currentScene->addBoxItem(funcItem);
\r
358 cout << "functional blocks loaded and created succefully!" << endl;
\r
360 /**********************************************************
\r
361 3 : set the BoxItem that represents a GroupItem in a child scene
\r
362 ***********************************************************/
\r
364 for(int i=0; i<scenesNodes.length(); i++){
\r
365 QDomElement currentSceneNode = scenesNodes.at(i).toElement();
\r
366 int idScene = currentSceneNode.attribute("id","none").toInt(&ok);
\r
367 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
368 GroupScene *currentScene = searchSceneById(idScene, topScene);
\r
369 if(currentScene == NULL) throw(Exception(PROJECTFILE_CORRUPTED));
\r
371 QDomNodeList biGroupNodes = currentSceneNode.elementsByTagName("bi_group");
\r
373 for(int j=0; j<biGroupNodes.length(); j++){
\r
374 QDomElement currentBiGroup = biGroupNodes.at(j).toElement();
\r
376 int id = currentBiGroup.attribute("id","none").toInt(&ok);
\r
377 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
379 int idGroup = currentBiGroup.attribute("inside_group","none").toInt(&ok);
\r
380 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
382 QStringList positionStr = currentBiGroup.attribute("position","none").split(",");
\r
383 if(positionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));
\r
384 int posX = positionStr.at(0).toInt(&ok);
\r
385 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
386 int posY = positionStr.at(1).toInt(&ok);
\r
387 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
389 QStringList dimensionStr = currentBiGroup.attribute("dimension","none").split(",");
\r
390 if(dimensionStr.length() != 2) throw(Exception(PROJECTFILE_CORRUPTED));
\r
391 int dimX = dimensionStr.at(0).toInt(&ok);
\r
392 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
393 int dimY = dimensionStr.at(1).toInt(&ok);
\r
394 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
396 // get the GroupItem already created and set at phase 1
\r
397 GroupItem *insideGroup = searchGroupItemById(idGroup, topScene);
\r
398 BoxItem* upperItem = NULL;
\r
399 if(insideGroup == NULL) cout << "group null" << endl;
\r
400 // now search within the scene which BoxItem has a childItem that is = to insideGroup
\r
401 QList<BoxItem *> lst = currentScene->getBoxItems();
\r
402 foreach(BoxItem* item, lst) {
\r
403 if (item->getChildGroupItem() == insideGroup) {
\r
408 if (upperItem == NULL) {
\r
409 throw(Exception(PROJECTFILE_CORRUPTED));
\r
412 upperItem->setId(id);
\r
413 upperItem->setPos(posX,posY);
\r
414 upperItem->setDimension(dimX,dimY);
\r
416 // set interfaces of this BoxItem
\r
417 QDomNodeList interfaceNodes = currentBiGroup.elementsByTagName("big_iface");
\r
419 for(int k=0; k<interfaceNodes.length(); k++){
\r
420 QDomElement currentInterfaceNode = interfaceNodes.at(k).toElement();
\r
422 int id = currentInterfaceNode.attribute("id","none").toInt(&ok);
\r
423 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
425 QString refName = currentInterfaceNode.attribute("ref_name","none");
\r
426 if(refName == "none") throw(Exception(PROJECTFILE_CORRUPTED));
\r
428 QString orientationStr = currentInterfaceNode.attribute("orientation","none");
\r
429 int orientation = InterfaceItem::getIntOrientation(orientationStr);
\r
430 if(orientation == -1) throw(Exception(PROJECTFILE_CORRUPTED));
\r
432 double position = currentInterfaceNode.attribute("position","none").toDouble(&ok);
\r
433 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
435 ConnectedInterface *refInter = insideGroup->searchInterfaceItemByName(refName)->refInter;
\r
436 InterfaceItem *ifaceItem = new InterfaceItem(position, orientation, refInter, upperItem, this);
\r
437 ifaceItem->setId(id);
\r
438 upperItem->addInterfaceItem(ifaceItem);
\r
442 cout << "blockItems \"group\" loaded and created succefully!" << endl;
\r
444 QDomNodeList connectionNodes = root.elementsByTagName("connection");
\r
446 for(int i=0; i<connectionNodes.length(); i++){
\r
447 QDomElement currentConnectionNode = connectionNodes.at(i).toElement();
\r
449 int from = currentConnectionNode.attribute("from","none").toInt(&ok);
\r
450 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
452 int to = currentConnectionNode.attribute("to","none").toInt(&ok);
\r
453 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
456 InterfaceItem *iface1 = searchInterfaceItemById(from,topScene);
\r
457 InterfaceItem *iface2 = searchInterfaceItemById(to,topScene);
\r
459 if(iface1 != NULL && iface2 != NULL){
\r
460 dispatcher->createConnection(Dispatcher::Load, iface1,iface2);
\r
462 cout << "interfaces not found, connect canceled!" << endl;
\r
465 cout << "connections loaded and created succefully!" << endl;
\r
467 QDomNodeList modifierNodes = root.elementsByTagName("modifier");
\r
469 for(int i=0; i<modifierNodes.length(); i++){
\r
470 QDomElement currentModifierNode = modifierNodes.at(i).toElement();
\r
472 int id = currentModifierNode.attribute("id","none").toInt(&ok);
\r
473 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
475 QString typeStr = currentModifierNode.attribute("type","none");
\r
476 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
477 QString paramsStr = currentModifierNode.attribute("params","none");
\r
478 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
480 /* NB: just adding delays for now. To be cont'd */
\r
481 InterfaceItem *iface = searchInterfaceItemById(id,topScene);
\r
483 if ((iface == NULL ) || (iface->refInter == NULL) || (iface->refInter->getAssociatedIface() == NULL)) {
\r
484 cout << "modified interface not found, modifiers setup canceled!" << endl;
\r
487 ConnectedInterface* connIface = AI_TO_CON(iface->refInter->getAssociatedIface());
\r
489 AbstractInputModifier* mod = NULL;
\r
490 if (typeStr == "delay") {
\r
491 int delay = paramsStr.toInt(&ok);
\r
492 if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
\r
493 mod = new DelayInputModifier(connIface, delay);
\r
494 connIface->setInputModifier(mod);
\r
499 cout << "modifiers loaded and created succefully!" << endl;
\r
504 void Parameters::loadBlastConfiguration(QString confFile) throw(Exception) {
\r
507 validateXmlFile("blastconfig.xml", "blastconfig.xsd",Configuration);
\r
509 catch(Exception err) {
\r
514 // opening configFile
\r
515 QFile configFile(confFile);
\r
516 // reading in into QDomDocument
\r
517 QDomDocument document("configFile");
\r
519 if (!configFile.open(QIODevice::ReadOnly)) {
\r
520 throw(Exception(CONFIGFILE_NOACCESS));
\r
522 if (!document.setContent(&configFile)) {
\r
523 configFile.close();
\r
524 throw(Exception(CONFIGFILE_NOACCESS));
\r
526 configFile.close();
\r
528 //Get the root element
\r
529 QDomElement config = document.documentElement();
\r
531 QDomElement eltCat = config.firstChildElement("categories");
\r
533 categoryTree = new BlockLibraryTree();
\r
534 categoryTree->load(eltCat);
\r
536 catch(Exception err) {
\r
540 QDomElement eltReferences = eltCat.nextSiblingElement("references");
\r
541 refLib = eltReferences.attribute("lib_file","none");
\r
542 cout << "references lib : " << qPrintable(refLib) << endl;
\r
544 QString nbPathesStr;
\r
545 nbPathesStr = eltReferences.attribute("nb","none");
\r
546 nbPathes = nbPathesStr.toInt(&ok);
\r
547 QDomNodeList listBlockDir = eltReferences.elementsByTagName("reference_lib");
\r
548 if ((!ok) || (nbPathes != listBlockDir.size())) throw(Exception(CONFIGFILE_CORRUPTED));
\r
550 for(int i=0;i<listBlockDir.size();i++) {
\r
551 QDomNode nodeBlockDir = listBlockDir.at(i);
\r
552 QDomElement eltBlockDir = nodeBlockDir.toElement();
\r
553 if (eltBlockDir.isNull()) throw(Exception(CONFIGFILE_CORRUPTED));
\r
554 QString path = eltBlockDir.attribute("path","none");
\r
555 if (path == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
556 refPathes.append(path);
\r
557 cout << "references path : " << qPrintable(path) << endl;
\r
560 QDomElement eltImpl = eltReferences.nextSiblingElement("implementations");
\r
561 implLib = eltImpl.attribute("lib_file","none");
\r
562 cout << "implementation lib : " << qPrintable(implLib) << endl;
\r
563 nbPathesStr = eltImpl.attribute("nb","none");
\r
564 nbPathes = nbPathesStr.toInt(&ok);
\r
565 QDomNodeList listImplDir = eltImpl.elementsByTagName("impl_lib");
\r
566 if ((!ok) || (nbPathes != listImplDir.size())) throw(Exception(CONFIGFILE_CORRUPTED));
\r
568 for(int i=0;i<listImplDir.size();i++) {
\r
569 QDomNode nodeImplDir = listImplDir.at(i);
\r
570 QDomElement eltImplDir = nodeImplDir.toElement();
\r
571 if (eltImplDir.isNull()) throw(Exception(CONFIGFILE_CORRUPTED));
\r
572 QString path = eltImplDir.attribute("path","none");
\r
573 if (path == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
574 implPathes.append(path);
\r
575 cout << "impl path : " << qPrintable(path) << endl << endl;
\r
578 QDomElement eltSource = eltImpl.nextSiblingElement("sources");
\r
579 nbPathesStr = eltSource.attribute("nb","none");
\r
580 nbPathes = nbPathesStr.toInt(&ok);
\r
581 QDomNodeList listSourceDir = eltSource.elementsByTagName("source_lib");
\r
582 if ((!ok) || (nbPathes != listSourceDir.size())) throw(Exception(CONFIGFILE_CORRUPTED));
\r
584 for(int i=0;i<listSourceDir.size();i++) {
\r
585 QDomNode nodeSourceDir = listSourceDir.at(i);
\r
586 QDomElement eltSourceDir = nodeSourceDir.toElement();
\r
587 if (eltSourceDir.isNull()) throw(Exception(CONFIGFILE_CORRUPTED));
\r
588 QString path = eltSourceDir.attribute("path","none");
\r
589 if (path == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
590 sourcePathes.append(path);
\r
591 cout << "core path : " << qPrintable(path) << endl << endl;
\r
594 // getting elt = the element <defaults>
\r
595 // for each child element, initialize the associated attributes of Parameters
\r
597 QDomElement eltDefaults = eltSource.nextSiblingElement("defaults");
\r
599 QDomElement eltBlocks = eltDefaults.firstChildElement("blocks");
\r
600 QString attributeStr = eltBlocks.attribute("width", "none");
\r
601 defaultBlockWidth = attributeStr.toInt(&ok);
\r
602 if (!ok || defaultBlockWidth < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
603 attributeStr = eltBlocks.attribute("height", "none");
\r
604 defaultBlockHeight = attributeStr.toInt(&ok);
\r
605 if (!ok || defaultBlockHeight < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
606 attributeStr = eltBlocks.attribute("font_size", "none");
\r
607 defaultBlockFontSize = attributeStr.toFloat(&ok);
\r
608 if (!ok || defaultBlockFontSize < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
609 attributeStr = eltBlocks.attribute("font", "none");
\r
610 if (attributeStr == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
611 defaultBlockFontName = attributeStr;
\r
612 defaultBlockFont = QFont(defaultBlockFontName, defaultBlockFontSize);
\r
614 QDomElement eltInterfaces = eltBlocks.nextSiblingElement("interfaces");
\r
615 attributeStr = eltInterfaces.attribute("width", "none");
\r
616 arrowWidth = attributeStr.toInt(&ok);
\r
617 if (!ok || arrowWidth < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
618 attributeStr = eltInterfaces.attribute("height", "none");
\r
619 arrowHeight = attributeStr.toInt(&ok);
\r
620 if (!ok || arrowHeight < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
621 attributeStr = eltInterfaces.attribute("linelength", "none");
\r
622 arrowLineLength = attributeStr.toInt(&ok);
\r
623 if (!ok || arrowLineLength < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
624 attributeStr = eltInterfaces.attribute("font_size", "none");
\r
625 defaultIfaceFontSize = attributeStr.toFloat(&ok);
\r
626 if (!ok || defaultIfaceFontSize < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
627 attributeStr = eltInterfaces.attribute("font", "none");
\r
628 if (attributeStr == "none") throw(Exception(CONFIGFILE_CORRUPTED));
\r
629 defaultIfaceFontName = attributeStr;
\r
630 defaultIfaceFont = QFont(defaultIfaceFontName, defaultIfaceFontSize);
\r
632 QDomElement eltConnections = eltInterfaces.nextSiblingElement("connections");
\r
633 attributeStr = eltConnections.attribute("gaplength", "none");
\r
634 connGapLength = attributeStr.toInt(&ok);
\r
635 if (!ok || connGapLength < 1) throw(Exception(CONFIGFILE_CORRUPTED));
\r
638 void Parameters::loadReferencesFromXml() throw(Exception) {
\r
639 cout << "load references from xml" << endl;
\r
640 for(int i=0;i<refPathes.size();i++) {
\r
641 cout << "analyzing " << qPrintable(refPathes.at(i)) << endl;
\r
642 QDir dir(refPathes.at(i));
\r
643 QStringList filter;
\r
645 dir.setNameFilters(filter);
\r
646 QStringList list = dir.entryList();
\r
647 for(int j=0;j<list.size();j++) {
\r
648 QString fileName = dir.absolutePath();
\r
649 fileName.append("/"+list.at(j));
\r
651 QFile blockXML(fileName);
\r
652 if (!blockXML.open(QIODevice::ReadOnly)) {
\r
653 throw(Exception(BLOCKFILE_NOACCESS));
\r
655 QTextStream in(&blockXML);
\r
656 QString line = in.readLine();
\r
657 line = in.readLine();
\r
659 if (!line.contains("<block")) {
\r
666 validateXmlFile(fileName,"reference.xsd",Reference);
\r
668 catch(Exception err) {
\r
672 // reading in into QDomDocument
\r
673 QDomDocument document ("FileXML");
\r
674 if (!blockXML.open(QIODevice::ReadOnly)) {
\r
675 throw(Exception(BLOCKFILE_NOACCESS));
\r
677 if (!document.setContent(&blockXML)) {
\r
679 throw(Exception(BLOCKFILE_NOACCESS));
\r
683 QDomElement blockRoot = document.documentElement();
\r
684 QString name = blockRoot.tagName();
\r
685 if (name == "block") {
\r
687 cout << "xml:" << fileName.toStdString() << endl;
\r
688 ReferenceBlock* b = new ReferenceBlock(fileName);
\r
690 b->load(blockRoot);
\r
696 cout << "xml:" << b->getXmlFile().toStdString() << endl;
\r
698 availableBlocks.append(b);
\r
699 foreach (int id,b->getCategories()) {
\r
700 cout << "ajout du bloc dans cat n° : " << id << endl;
\r
701 BlockCategory* cat = categoryTree->searchCategory(id);
\r
702 cat->blocks.append(b);
\r
709 void Parameters::loadReferencesFromLib() throw(Exception) {
\r
711 cout << "loading references from lib" << endl;
\r
713 // removing blocks from category tree if they exist
\r
714 categoryTree->clearBlocks();
\r
715 // deleting existings blocks
\r
716 ReferenceBlock* b = NULL;
\r
717 for(int i=0;i<availableBlocks.size();i++) {
\r
718 b = availableBlocks.at(i);
\r
721 availableBlocks.clear();
\r
723 QFile libFile(refLib);
\r
724 if (!libFile.open(QIODevice::ReadOnly)) {
\r
725 throw(Exception(BLOCKFILE_NOACCESS));
\r
727 QDataStream in(&libFile);
\r
734 for(int i=0;i<nbBlocks;i++) {
\r
735 b = new ReferenceBlock("");
\r
737 availableBlocks.append(b);
\r
738 foreach (int id,b->getCategories()) {
\r
739 BlockCategory* cat = categoryTree->searchCategory(id);
\r
740 cat->blocks.append(b);
\r
746 void Parameters::saveReferencesToLib() throw(Exception) {
\r
748 cout << "saving blocks in " << qPrintable(refLib) << endl;
\r
749 QFile libFile(refLib);
\r
750 if (!libFile.open(QIODevice::WriteOnly)) {
\r
751 throw(Exception(BLOCKFILE_NOACCESS));
\r
753 QDataStream out(&libFile);
\r
755 out.setVersion(QDataStream::Qt_5_0);
\r
757 QByteArray blockData;
\r
758 QDataStream toWrite(&blockData, QIODevice::WriteOnly);
\r
760 toWrite << availableBlocks.size();
\r
761 for(int i=0;i<availableBlocks.size();i++) {
\r
762 ReferenceBlock* b = availableBlocks.at(i);
\r
772 void Parameters::loadImplementationsFromXml() throw(Exception) {
\r
774 for(int i=0;i<implPathes.size();i++) {
\r
775 cout << "analyzing " << qPrintable(implPathes.at(i)) << endl;
\r
776 QDir dir(implPathes.at(i));
\r
777 QStringList filter;
\r
779 dir.setNameFilters(filter);
\r
780 QStringList list = dir.entryList();
\r
781 for(int j=0;j<list.size();j++) {
\r
782 QString fileName = dir.absolutePath();
\r
783 fileName.append("/"+list.at(j));
\r
785 cout << "checking " << qPrintable(fileName) << " is an implementation file ...";
\r
786 QFile implXML(fileName);
\r
787 if (!implXML.open(QIODevice::ReadOnly)) {
\r
788 throw(Exception(IMPLFILE_NOACCESS));
\r
790 QTextStream in(&implXML);
\r
791 QString line = in.readLine();
\r
792 line = in.readLine();
\r
794 if (!line.contains("<block_impl")) {
\r
800 cout << "OK" << endl;
\r
801 cout << "reading " << qPrintable(fileName) << " content ...";
\r
804 validateXmlFile(fileName,"implementation.xsd",Implementation);
\r
806 catch(Exception e) {
\r
810 // reading in into QDomDocument
\r
811 QDomDocument document ("FileXML");
\r
812 if (!implXML.open(QIODevice::ReadOnly)) {
\r
813 throw(Exception(IMPLFILE_NOACCESS));
\r
815 cout << "OK" << endl;
\r
816 cout << "convert " << qPrintable(fileName) << " content into document...";
\r
817 if (!document.setContent(&implXML)) {
\r
819 throw(Exception(IMPLFILE_NOACCESS));
\r
823 QDomElement implRoot = document.documentElement();
\r
824 QString refXml = implRoot.attribute("ref_name","none");
\r
825 QString refMd5 = implRoot.attribute("ref_md5","none");
\r
826 BlockImplementation* impl = new BlockImplementation(fileName,refXml,refMd5);
\r
828 QDomNodeList archNode = implRoot.elementsByTagName("architecture");
\r
830 if (archNode.isEmpty()) {
\r
831 cout << "impl has no architecture" << endl;
\r
834 QDomElement archElt = archNode.at(0).toElement();
\r
835 QString compList = archElt.attribute("comp_list","none");
\r
836 if (compList != "none") {
\r
837 QStringList compos = compList.split(",");
\r
838 foreach(QString s, compos) {
\r
839 impl->addResource(s);
\r
844 impl->loadPatterns(implRoot);
\r
849 availableImplementations.append(impl);
\r
851 ReferenceBlock* ref = NULL;
\r
852 if (! refMd5.isEmpty()) {
\r
853 ref = searchBlockByMd5(refMd5);
\r
856 ref = searchBlockByXml(refXml);
\r
859 cout << "Cannot find a reference block for impl :" << qPrintable(fileName) << endl;
\r
862 ref->addImplementation(impl);
\r
863 impl->setReference(ref);
\r
864 if (! impl->checkPatterns()) throw(Exception(IMPLFILE_CORRUPTED));
\r
866 cout << "OK" << endl;
\r
871 void Parameters::loadImplementationsFromLib() throw(Exception) {
\r
873 cout << "loading implementations from lib" << endl;
\r
875 BlockImplementation* impl = NULL;
\r
876 ReferenceBlock* ref = NULL;
\r
877 for(int i=0;i<availableImplementations.size();i++) {
\r
878 impl = availableImplementations.at(i);
\r
881 availableImplementations.clear();
\r
883 QFile libFile(implLib);
\r
884 if (!libFile.open(QIODevice::ReadOnly)) {
\r
885 throw(Exception(IMPLFILE_NOACCESS));
\r
887 QDataStream in(&libFile);
\r
894 for(int i=0;i<nbImpls;i++) {
\r
895 impl = new BlockImplementation("");
\r
897 availableImplementations.append(impl);
\r
898 QString refMd5 = impl->getReferenceMd5();
\r
899 QString refXml = impl->getReferenceXml();
\r
901 if (! refMd5.isEmpty()) {
\r
902 ref = searchBlockByMd5(refMd5);
\r
905 ref = searchBlockByXml(refXml);
\r
908 cout << "Cannot find a reference block for impl :" << qPrintable(impl->getXmlFile()) << endl;
\r
911 ref->addImplementation(impl);
\r
912 impl->setReference(ref);
\r
913 if (! impl->checkPatterns()) throw(Exception(IMPLFILE_CORRUPTED));
\r
919 void Parameters::saveImplementationsToLib() throw(Exception) {
\r
921 cout << "saving implementations in " << qPrintable(implLib) << endl;
\r
922 QFile libFile(implLib);
\r
923 if (!libFile.open(QIODevice::WriteOnly)) {
\r
924 throw(Exception(IMPLFILE_NOACCESS));
\r
926 QDataStream out(&libFile);
\r
928 out.setVersion(QDataStream::Qt_5_0);
\r
930 QByteArray blockData;
\r
931 QDataStream toWrite(&blockData, QIODevice::WriteOnly);
\r
933 toWrite << availableImplementations.size();
\r
934 for(int i=0;i<availableImplementations.size();i++) {
\r
935 BlockImplementation* impl = availableImplementations.at(i);
\r
946 void Parameters::loadSources() throw(Exception) {
\r
948 for(int i=0;i<sourcePathes.size();i++) {
\r
949 cout << "analyzing " << qPrintable(sourcePathes.at(i)) << endl;
\r
950 QDir dir(sourcePathes.at(i));
\r
951 QStringList filter;
\r
952 filter << "*.vhd" << "*.ngc";
\r
953 dir.setNameFilters(filter);
\r
954 QStringList list = dir.entryList();
\r
955 for(int j=0;j<list.size();j++) {
\r
956 QString fileName = dir.absolutePath();
\r
957 fileName.append("/"+list.at(j));
\r
959 if (list.at(j).endsWith(".ngc")) {
\r
960 QString netName = list.at(j);
\r
961 netName.truncate(list.at(j).size() -4);
\r
962 cout << "found netlist " << qPrintable(netName) << endl;
\r
963 availableResources.append(new ExternalResource(netName,fileName,ExternalResource::Netlist));
\r
966 cout << "parsing " << qPrintable(fileName) << " ... ";
\r
967 QFile srcXML(fileName);
\r
968 if (!srcXML.open(QIODevice::ReadOnly)) {
\r
969 throw(Exception(IMPLFILE_NOACCESS));
\r
971 QTextStream in(&srcXML);
\r
973 QString line = in.readLine();
\r
974 while (!line.isNull()) {
\r
975 if (line.contains("package", Qt::CaseInsensitive)) {
\r
976 QRegularExpression rxPack("^package (.+) is$",QRegularExpression::CaseInsensitiveOption);
\r
977 QRegularExpressionMatch matchPack = rxPack.match(line);
\r
978 if (matchPack.hasMatch()) {
\r
979 QString packName = matchPack.captured(1);
\r
980 cout << "found package " << qPrintable(packName) << endl;
\r
981 availableResources.append(new ExternalResource(packName,fileName,ExternalResource::Package));
\r
984 else if (line.contains("entity", Qt::CaseInsensitive)) {
\r
985 QRegularExpression rxEnt("^entity (.+) is$",QRegularExpression::CaseInsensitiveOption);
\r
986 QRegularExpressionMatch matchEnt = rxEnt.match(line);
\r
987 if (matchEnt.hasMatch()) {
\r
988 QString entityName = matchEnt.captured(1);
\r
989 cout << "found entity " << qPrintable(entityName) << endl;
\r
990 availableResources.append(new ExternalResource(entityName,fileName,ExternalResource::Code));
\r
993 line = in.readLine();
\r
996 cout << "OK" << endl;
\r
1002 QList<ExternalResource *> Parameters::searchResourceByName(const QString& name) {
\r
1003 QList<ExternalResource*> listRes;
\r
1004 foreach(ExternalResource* s, availableResources) {
\r
1005 if (s->getName() == name) {
\r
1006 listRes.append(s);
\r
1012 void Parameters::addAvailableBlock(ReferenceBlock *block) {
\r
1013 availableBlocks.append(block);
\r
1014 foreach (int id,block->getCategories()) {
\r
1015 cout << "ajout du bloc dans cat n° : " << id << endl;
\r
1016 BlockCategory* cat = categoryTree->searchCategory(id);
\r
1017 cat->blocks.append(block);
\r
1021 void Parameters::parametersValidation() {
\r
1022 QList<AbstractBlock*> blocksToConfigure = getBlocksToConfigure();
\r
1024 if(!blocksToConfigure.isEmpty()){
\r
1025 BlocksToConfigureWidget *widget = new BlocksToConfigureWidget(blocksToConfigure, this, NULL);
\r
1030 void Parameters::connectionsValidation() {
\r
1032 #ifdef DEBUG_INCLFUN
\r
1034 QStack<AbstractInterface*> *interfaceToValidate = new QStack<AbstractInterface*>;
\r
1035 QList<AbstractInterface*> *validatedInterface = new QList<AbstractInterface*>;
\r
1037 foreach(AbstractInterface *inter, topWindow->getScene()->getGroupItem()->getRefBlock()->getInterfaces()){
\r
1038 foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
\r
1040 inter->setWidth(connectedInter->getWidth());
\r
1041 interfaceToValidate->push(connectedInter);
\r
1047 while(!interfaceToValidate->isEmpty()){
\r
1048 interfaceToValidate->pop()->connectionsValidation(interfaceToValidate, validatedInterface);
\r
1051 catch(Exception e){
\r
1052 cerr << e.getMessage().toStdString() << endl;
\r
1057 QList<AbstractBlock *> Parameters::getBlocksToConfigure() {
\r
1059 #ifdef DEBUG_INCLFUN
\r
1061 QList<AbstractBlock*> *checkedBlocks = new QList<AbstractBlock*>;
\r
1062 QList<AbstractBlock*> *blocksToConfigure = new QList<AbstractBlock*>;
\r
1064 foreach(AbstractInterface *inter, topWindow->getScene()->getGroupItem()->getRefBlock()->getInterfaces()){
\r
1065 foreach(AbstractInterface *connectedInter, inter->getConnectedTo()){
\r
1066 if(!checkedBlocks->contains(connectedInter->getOwner())){
\r
1067 connectedInter->getOwner()->parametersValidation(checkedBlocks, blocksToConfigure);
\r
1071 return *blocksToConfigure;
\r
1076 void Parameters::updateToolbar() {
\r
1077 int nb = currentScene->getBoxItems().length();
\r
1078 for(int i = 0; i<nb; i++){
\r
1079 if(currentScene->getBoxItems().at(i)->isSelected()){
\r
1080 currentScene->getGroupWidget()->enableGroupButton(true);
\r
1084 currentScene->getGroupWidget()->enableGroupButton(false);
\r
1088 void Parameters::updateIds() {
\r
1090 /* a in-width cross of the graph must be done so that ids of GroupItem
\r
1091 are in the correct ordre when saving/loading a project
\r
1093 int countItem = 1;
\r
1094 int countIface = 1;
\r
1095 QList<GroupScene *> fifo;
\r
1096 fifo.append(topScene);
\r
1097 while (!fifo.isEmpty()) {
\r
1098 GroupScene* scene = fifo.takeFirst();
\r
1099 countItem = scene->setItemsId(countItem);
\r
1100 countIface = scene->setInterfacesId(countIface);
\r
1101 foreach(GroupScene* s, scene->getChildrenScene()) {
\r
1108 ReferenceBlock *Parameters::searchBlockByXml(QString xmlName) {
\r
1109 foreach(ReferenceBlock *block, availableBlocks){
\r
1110 if(block->getXmlFile().contains(xmlName))
\r
1116 ReferenceBlock *Parameters::searchBlockByMd5(QString sumMd5) {
\r
1117 foreach(ReferenceBlock *block, availableBlocks){
\r
1118 if(block->getHashMd5() == sumMd5)
\r
1124 void Parameters::save(QString confFile) {
\r
1126 //#ifdef DEBUG_INCLFUN
\r
1129 QList<ConnectionItem*> allConnections;
\r
1130 QFile file(confFile);
\r
1131 if(file.open(QIODevice::WriteOnly)){
\r
1133 QXmlStreamWriter writer(&file);
\r
1135 writer.setAutoFormatting(true);
\r
1136 writer.writeStartDocument();
\r
1138 writer.writeStartElement("blast_project");
\r
1139 writer.writeStartElement("scenes");
\r
1141 writer.writeAttribute("count",QString::number(dispatcher->getNumberOfScenes()));
\r
1143 // cross the scene level by level using a FIFO
\r
1144 QList<GroupScene*> fifoScene;
\r
1145 fifoScene.append(topScene);
\r
1147 GroupScene *scene;
\r
1148 while (!fifoScene.isEmpty()) {
\r
1149 scene = fifoScene.takeFirst();
\r
1150 scene->save(writer);
\r
1151 foreach(GroupScene* s, scene->getChildrenScene()) {
\r
1152 fifoScene.append(s);
\r
1155 foreach(ConnectionItem* item, scene->getConnectionItems()) {
\r
1156 allConnections.append(item);
\r
1159 writer.writeEndElement(); //</scenes>
\r
1161 writer.writeStartElement("connections");
\r
1162 foreach(ConnectionItem* item, allConnections) {
\r
1164 writer.writeStartElement("connection");
\r
1166 writer.writeAttribute("from",QString::number(item->getFromInterfaceItem()->getId()));
\r
1167 writer.writeAttribute("to", QString::number(item->getToInterfaceItem()->getId()));
\r
1169 writer.writeEndElement();
\r
1172 writer.writeEndElement(); //</connections>
\r
1174 QList<InterfaceItem *> lstIfaceItem;
\r
1175 // search for modifiers
\r
1176 foreach(ConnectionItem* item, allConnections) {
\r
1177 InterfaceItem* fromIfaceItem = item->getFromInterfaceItem();
\r
1178 AbstractInputModifier* mod = fromIfaceItem->refInter->getInputModifier();
\r
1179 if (mod != NULL) {
\r
1180 if (!lstIfaceItem.contains(fromIfaceItem)) lstIfaceItem.append(fromIfaceItem);
\r
1182 InterfaceItem* toIfaceItem = item->getToInterfaceItem();
\r
1183 mod = toIfaceItem->refInter->getInputModifier();
\r
1184 if (mod != NULL) {
\r
1185 if (!lstIfaceItem.contains(toIfaceItem)) lstIfaceItem.append(toIfaceItem);
\r
1188 // write input modifiers
\r
1189 writer.writeStartElement("modifiers");
\r
1190 foreach(InterfaceItem* item, lstIfaceItem) {
\r
1191 AbstractInputModifier* mod = item->refInter->getInputModifier();
\r
1192 if (mod != NULL) {
\r
1193 writer.writeStartElement("modifier");
\r
1194 writer.writeAttribute("id", QString::number(item->getId()));
\r
1195 writer.writeAttribute("type",mod->getTypeStr());
\r
1196 writer.writeAttribute("params", mod->getParametersStr());
\r
1197 writer.writeEndElement();
\r
1201 writer.writeEndElement(); //</modifiers>
\r
1202 writer.writeEndElement(); //</blast_project
\r
1204 writer.writeEndDocument();
\r
1207 unsaveModif = false;
\r
1212 void Parameters::setArrowPathes() {
\r
1213 QPainterPath _inArrow;
\r
1214 _inArrow.lineTo(arrowLineLength,0);
\r
1215 _inArrow.lineTo(arrowLineLength+arrowWidth,-arrowHeight/2);
\r
1216 _inArrow.lineTo(arrowLineLength+arrowWidth,arrowHeight/2);
\r
1217 _inArrow.lineTo(arrowLineLength,0);
\r
1218 //_inArrow.closeSubpath();
\r
1219 dataArrowIn = _inArrow;
\r
1221 QPainterPath _inArrowC;
\r
1222 _inArrowC.lineTo(arrowLineLength,0);
\r
1223 _inArrowC.addEllipse(arrowLineLength,-arrowHeight/2,arrowHeight-1,arrowHeight-1);
\r
1224 clkrstArrow = _inArrowC;
\r
1226 QPainterPath _outArrow;
\r
1227 _outArrow.lineTo(arrowLineLength,0);
\r
1228 _outArrow.lineTo(arrowLineLength,-arrowHeight/2);
\r
1229 _outArrow.lineTo(arrowLineLength+arrowWidth,0);
\r
1230 _outArrow.lineTo(arrowLineLength,arrowHeight/2);
\r
1231 _outArrow.lineTo(arrowLineLength,0);
\r
1232 //_outArrow.closeSubpath();
\r
1233 dataArrowOut = _outArrow;
\r
1237 GroupScene* Parameters::searchSceneById(int id, GroupScene *scene) {
\r
1239 if (scene->getId() == id) return scene;
\r
1240 GroupScene* sc = NULL;
\r
1242 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1243 sc = searchSceneById(id,s);
\r
1244 if (sc != NULL) return sc;
\r
1249 GroupItem* Parameters::searchGroupItemById(int id, GroupScene *scene) {
\r
1251 if (scene->getGroupItem()->getId() == id) return scene->getGroupItem();
\r
1253 GroupItem* item = NULL;
\r
1254 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1255 item = searchGroupItemById(id,s);
\r
1256 if (item != NULL) return item;
\r
1261 BoxItem* Parameters::searchBlockItemById(int id, GroupScene *scene) {
\r
1263 foreach(BoxItem *item, scene->getBoxItems()){
\r
1264 if(item->getId() == id){
\r
1269 BoxItem* item = NULL;
\r
1270 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1271 item = searchBlockItemById(id,s);
\r
1272 if (item != NULL) return item;
\r
1277 BoxItem* Parameters::searchFunctionalBlock(AbstractBlock* block) {
\r
1279 return searchFunctionalBlockRecur(block,topScene);
\r
1282 BoxItem* Parameters::searchFunctionalBlockRecur(AbstractBlock* block, GroupScene* scene) {
\r
1284 foreach(BoxItem *item, scene->getBoxItems()){
\r
1285 if(item->getRefBlock() == block) {
\r
1290 BoxItem* item = NULL;
\r
1291 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1292 item = searchFunctionalBlockRecur(block,s);
\r
1293 if (item != NULL) return item;
\r
1298 InterfaceItem* Parameters::searchInterfaceItemById(int id, GroupScene* scene) {
\r
1300 foreach(InterfaceItem *item, scene->getGroupItem()->getInterfaces()){
\r
1301 if(item->getId() == id){
\r
1305 if (scene->isTopScene()) {
\r
1306 foreach(StimuliItem *block, scene->getSourceItems()){
\r
1307 foreach(InterfaceItem *item, block->getInterfaces()){
\r
1308 if(item->getId() == id){
\r
1314 foreach(BoxItem *block, scene->getBoxItems()){
\r
1315 foreach(InterfaceItem *item, block->getInterfaces()){
\r
1316 if(item->getId() == id){
\r
1321 InterfaceItem* item = NULL;
\r
1322 foreach(GroupScene *s, scene->getChildrenScene()) {
\r
1323 item = searchInterfaceItemById(id,s);
\r
1324 if (item != NULL) return item;
\r
1329 QString Parameters::normalizeName(const QString &name) {
\r
1331 s.replace(QRegularExpression("[^a-zA-Z0-9_]"),"_");
\r
1332 s.replace(QRegularExpression("[_]+"),"_");
\r