1 #include "Dispatcher.h"
2 #include "Parameters.h"
3 #include "MainWindow.h"
6 #include "ReferenceBlock.h"
7 #include "GroupBlock.h"
8 #include "FunctionalBlock.h"
10 #include "ConnectedInterface.h"
11 #include "ReferenceInterface.h"
12 #include "GroupInterface.h"
13 #include "FunctionalInterface.h"
15 #include "GroupWidget.h"
16 #include "GroupScene.h"
17 #include "GroupItem.h"
19 #include "InterfaceItem.h"
20 #include "ConnectionItem.h"
22 #include "BlockLibraryWidget.h"
23 #include "BlockLibraryTree.h"
25 #include "InterfacePropertiesWindow.h"
27 int Dispatcher::sceneCounter = 0;
29 Dispatcher::Dispatcher(Parameters* _params, MainWindow* _window) {
32 params->setDispatcher(this);
37 GroupWidget *Dispatcher::loadProject(const QString& filename) {
41 root = params->openProjectFile(filename);
43 catch(Exception err) {
47 // creating the top widget/scene
48 topGroup = new GroupWidget(NULL,this,params);
49 currentGroup = topGroup;
50 // getting the newly created scene
51 GroupScene *scene = topGroup->getScene();
53 params->setTopScene(scene);
54 params->setCurrentScene(scene);
57 params->loadProject(root);
60 cerr << qPrintable(e.getDefaultMessage()) << endl;
61 cerr << "Aborting ..." << endl;
62 // TO DO : deleteting topGroup and all
66 groupList.append(topGroup);
70 void Dispatcher::closeCurrentProject() {
72 foreach(GroupWidget* win, groupList) {
75 params->destroyGraph();
78 bool Dispatcher::connect(InterfaceItem *iface1, InterfaceItem *iface2) {
80 ConnectedInterface* ref1 = iface1->refInter;
81 ConnectedInterface* ref2 = iface2->refInter;
82 // connect both interface
87 if (ref1->canConnectTo(ref2)) {
88 ok1 = ref1->connectTo(ref2);
89 ok1 = ok1 & ref2->connectFrom(ref1);
91 if (ref2->canConnectTo(ref1)) {
92 ok2 = ref2->connectTo(ref1);
93 ok2 = ok2 & ref1->connectFrom(ref2);
95 if ((ok1 == true) || (ok2 == true)) {
97 iface1->getOwner()->getScene()->createConnectionItem(iface1,iface2);
100 params->unsaveModif = true;
106 void Dispatcher::checkSelection(){
107 InterfaceItem *iface1 = NULL;
108 InterfaceItem *iface2 = NULL;
110 GroupScene *scene = params->getCurrentScene();
111 QList<AbstractBoxItem*> list = scene->getGroupAndBlocks();
112 foreach(AbstractBoxItem *block, list){
113 InterfaceItem *tmp = block->getCurrentInterface();
115 if (iface1 == NULL) {
123 if(iface1 != NULL && iface2 != NULL){
124 connect(iface1,iface2);
128 void Dispatcher::unselectAllItems(int direction){
130 GroupScene *scene = params->getCurrentScene();
132 foreach(BoxItem* block, scene->getBlockItems()) {
133 block->setSelected(false);
134 block->setCurrentInterface(NULL);
136 scene->unselecteInterfaces();
140 void Dispatcher::setCurrentGroupWidget(GroupWidget *win){
142 win->changeConnectionMode(-1);
144 params->setCurrentScene(win->getScene());
147 void Dispatcher::changeConnectionMode(int mode){
150 foreach(GroupWidget* win, groupList){
152 QToolButton* buttonNewConnection = win->getButtonNewConnection();
154 QPalette pal = buttonNewConnection->palette();
157 if(params->sceneMode != Parameters::EditOnConnection){
158 params->sceneMode = Parameters::EditOnConnection;
159 pal.setColor(QPalette::Button, QColor(Qt::lightGray));
161 params->sceneMode = Parameters::EditNoOperation;
162 pal.setColor(QPalette::Button, QColor("#edeceb"));
165 else if(mode == Parameters::EditOnConnection){
166 params->sceneMode = Parameters::EditOnConnection;
167 pal.setColor(QPalette::Button, QColor(Qt::lightGray));
170 params->sceneMode = Parameters::EditNoOperation;
171 pal.setColor(QPalette::Button, QColor("#edeceb"));
173 unselectAllInterfaces();
175 buttonNewConnection->setAutoFillBackground(true);
176 buttonNewConnection->setPalette(pal);
177 buttonNewConnection->update();
182 void Dispatcher::rename(AbstractBoxItem *item){
185 QString text = QInputDialog::getText(NULL, "Rename an element",
186 "New name:", QLineEdit::Normal,
187 item->getRefBlock()->getName(), &ok);
190 if(!text.isEmpty() && text.length() < 30){
191 item->getRefBlock()->setName(text);
192 if(item->isGroupItem()){
193 if (currentGroup->isTopGroup()) {
194 mainWindow->setWindowTitle("blast - "+text);
197 currentGroup->setWindowTitle("blast - "+text);
201 mainWindow->getLibrary()->updateComboScene();
204 QMessageBox::warning(NULL,"Error in given name",
205 "the element name must be shorter than 30 characters and can't be empty!",
212 void Dispatcher::rename(InterfaceItem *item){
214 QString text = QInputDialog::getText(NULL, "Rename an interface",
215 "New name:", QLineEdit::Normal,
216 item->refInter->getName(), &ok);
218 /* CAUTION: when renaming an interface item, there are two cases :
219 - it refers to a functional block interface (fbi): the fbi keeps its name
220 and the new name is given to item
221 - it refers to a group block interface (gbi) : both gbi and item store the new name
224 if(ok && !text.isEmpty() && text.length() < 30) {
225 if (item->refInter->getOwner()->isGroupBlock()) {
226 item->refInter->setName(text);
232 QMessageBox::warning(NULL,"Error in given name",
233 "the interface name must be shorter than 30 characters and can't be empty!",
239 void Dispatcher::duplicateBlock(BoxItem *item){
241 GroupScene *scene = params->getCurrentScene();
242 AbstractBlock* block = item->getRefBlock();
243 AbstractBlock *newBlock;
245 // only duplicate functional blocks
246 if(block->isFunctionalBlock()) {
248 // adding to the model
249 FunctionalBlock* funBlock = (FunctionalBlock*)block;
250 newBlock = params->duplicateFunctionalBlock(funBlock);
251 // adding to the view
252 scene->createBlockItem(newBlock);
254 params->unsaveModif = true;
258 void Dispatcher::duplicateInterface(InterfaceItem *item){
259 AbstractInterface *refI = item->refInter;
260 if (! refI->isFunctionalInterface()) return;
262 AbstractBlock *refB = refI->getOwner();
263 if(! refB->isFunctionalBlock()) return;
265 FunctionalInterface* iface = (FunctionalInterface*)refI;
266 AbstractInterface *otherRef = iface->clone();
267 if (otherRef == NULL) {
268 QMessageBox::warning(NULL,"Error while cloning an interface","the interface cannot be cloned because its maximum multiplicity is reached", QMessageBox::Ok);
272 refB->addInterface(otherRef);
274 InterfaceItem *otherIface = new InterfaceItem(item->getPosition(),item->getOrientation(),(ConnectedInterface*)otherRef,item->getOwner(),params);
275 item->getOwner()->addInterface(otherIface,true);
279 void Dispatcher::addBlock(int idCategory, int idBlock, int idScene) {
281 GroupScene *scene = searchSceneById(idScene);
282 FunctionalBlock* newOne = params->addFunctionalBlock(idCategory, idBlock);
283 scene->createBlockItem(newOne);
287 GroupWidget *Dispatcher::createTopScene(){
289 // creating the model part of the group
290 Graph* graph = params->createGraph();
291 GroupBlock *refBlock = graph->getTopGroup();
293 // creating a fake and not connected interface
294 //AbstractInterface* iface = new GroupInterface(refBlock,"grp_iface",AbstractInterface::Input,AbstractInterface::Top);
296 // creating the group widget
297 topGroup = new GroupWidget(NULL,this,params);
298 currentGroup = topGroup;
299 // getting the newly created scene
300 GroupScene *scene = topGroup->getScene();
301 scene->setId(sceneCounter++);
302 params->setTopScene(scene);
303 params->setCurrentScene(scene);
304 // creating the view part of the group
305 GroupItem *group = new GroupItem(NULL,refBlock,this,params);
307 // adding the fake interface to the top group item
308 //InterfaceItem* item = new InterfaceItem(0.0 , Parameters::West, (ConnectedInterface*)iface, group, params);
309 //group->addInterface(item,true);
311 scene->setGroupItem(group);
313 groupList.append(topGroup);
317 GroupWidget *Dispatcher::createChildScene(GroupWidget* parentWidget, BoxItem *upperItemOfGroupItem) {
319 // getting back the goup block already created
320 GroupBlock* groupBlock = NULL;
321 if (upperItemOfGroupItem != NULL) {
322 groupBlock = AB_TO_GRP(upperItemOfGroupItem->getRefBlock());
324 // creating the view part of the group
325 GroupItem *groupItem = new GroupItem(upperItemOfGroupItem,groupBlock,this,params);
326 // creating the group widget
327 GroupWidget* group = new GroupWidget(parentWidget, this, params);
328 // getting the newly created scene
329 GroupScene *scene = group->getScene();
330 scene->setId(sceneCounter++);
331 // affecting group item to the scene
332 scene->setGroupItem(groupItem);
333 groupList.append(group);
335 mainWindow->getLibrary()->updateComboScene();
340 void Dispatcher::showRaiseWindow(AbstractBoxItem *item) {
341 GroupWidget* win = item->getScene()->getGroupWindow();
342 if (win->isTopGroup()) {
351 params->setCurrentScene(currentGroup->getScene());
354 void Dispatcher::showRstClkInter(AbstractBoxItem *item) {
356 item->setRstClkVisible(!item->isRstClkVisible());
357 item->resetInterfacesPosition();
359 item->getScene()->updateConnectionItemsShape();
362 void Dispatcher::addNewFullGroup() {
366 QList<BlockItem*> listBlocks = params->getCurrentScene()->getSelectedBlocks(); //selected blocks in the current scene
367 QList<AbstractBlock*> listAbstractBlocks; //abstract blocks in the group
368 QList<ConnectionItem *> connections = params->getCurrentScene()->getConnectionItems();
370 /* What must be done:
371 1 - creating a new GroupBlock
372 2 - moving the selected blocks from the current GroupBlock to the new GroupBlock
373 3 - creating a BlockItem that references the new GroupBlock
374 4 - creating a new GroupWidget
375 5 - creating a new GroupItem added to the scene of the GroupWidget
379 /* step 1 : creating new GroupBlock that will have as a parent the GroupBlock
380 associated to the GroupItem of the current scene
382 GroupBlock* parentBlock = params->getCurrentScene()->getGroupItem()->getRefBlock();
383 GroupBlock* newGroupBlock = new GroupBlock(parentBlock);
384 /* step 2: moving selected blocks */
385 foreach(BlockItem* blockItem, listBlocks) {
386 parentBlock->removeBlock(blockItem->getRefBlock());
387 newGroupBlock->addBlock(blockItem->getRefBlock());
390 GroupItem *parent = currentGroup->getScene()->getGroupItem();
391 GroupBlock *groupBlock = new GroupBlock(((GroupBlock*)parent->getRefBlock()),params->currentWindow);
392 BlockItem *blockItem = new BlockItem(params->getCurrentScene()->getGroupItem(),groupBlock,this,params);
393 GroupItem *groupItem = new GroupItem(blockItem,groupBlock,this,params);
395 //create the new window
396 GroupWidget* win = new GroupWidget(this,params);
397 win->getScene()->setGroupItem(groupItem);
398 win->getScene()->addItem(groupItem);
399 ((GroupBlock*)groupItem->getRefBlock())->setWindow(win);
400 params->addWindow(win);
404 params->getCurrentScene()->addBlockItem(blockItem);
405 params->getCurrentScene()->addItem(blockItem);
406 ((GroupItem*)params->getCurrentScene()->getGroupItem())->addBlockItem(blockItem);
408 //replace selected blocks in the group
409 foreach(AbstractBoxItem *block, listBlocks){
410 ((GroupItem*)block->getParentItem())->removeBlockItem(block);
411 ((GroupBlock*)block->getParentItem()->getRefBlock())->removeBlock(block->getRefBlock());
412 params->getCurrentScene()->removeItem(block);
413 params->getCurrentScene()->removeBlockItem(block);
415 groupBlock->addBlock(block->getRefBlock());
416 listAbstractBlocks.append(block->getRefBlock());
418 block->setUpperItem(groupItem);
419 groupItem->addBlockItem(block);
420 win->getScene()->addItem(block);
421 win->getScene()->addBlockItem(block);
424 //replace connection between selected blocks in the group
425 foreach(ConnectionItem *conn, connections){
426 if(listBlocks.contains(conn->getFromInterfaceItem()->getOwner())){
427 if(listBlocks.contains(conn->getToInterfaceItem()->getOwner())){
428 parent->removeConnection(conn);
429 params->getCurrentScene()->removeItem(conn);
431 groupItem->addConnection(conn);
432 win->getScene()->addItem(conn);
437 //create new interfaces and connections for the new group
438 foreach(AbstractBoxItem *block, listBlocks){
439 foreach(InterfaceItem *inter, block->getInterfaces()){
440 cout << "inter : " << inter->getName().toStdString() << endl;
441 if(inter->refInter->getConnectedFrom() != NULL && inter->refInter->getDirection() == AbstractInterface::Input){
442 cout << "connected from non null" << endl;
443 if(!listAbstractBlocks.contains(inter->refInter->getConnectedFrom()->getOwner())){
445 AbstractInterface *iface = inter->refInter->clone(0);
446 iface->setName(iface->getName()+"_group");
447 groupBlock->addInterface(iface);
449 InterfaceItem *ifaceItem = new InterfaceItem(0,Parameters::East,iface,blockItem,params);
450 blockItem->addInterface(ifaceItem);
451 blockItem->resetInterfacesPosition();
453 InterfaceItem *ifaceGroupItem = new InterfaceItem(0,Parameters::West,iface,groupItem,params);
454 groupItem->addInterface(ifaceGroupItem);
455 groupItem->resetInterfacesPosition();
456 foreach(ConnectionItem* conn, currentGroup->getScene()->getInterfaceConnections(inter)){
457 if(conn->getToInterfaceItem() == inter){
458 conn->setToInterfaceItem(ifaceItem);
459 ifaceItem->refInter->setConnectedFrom(NULL);
460 conn->getFromInterfaceItem()->refInter->clearConnectedTo();
461 connect(ifaceItem,conn->getFromInterfaceItem());
464 params->setCurrentWindow(win);
466 inter->refInter->setConnectedFrom(NULL);
467 ifaceGroupItem->refInter->clearConnectedTo();
468 connect(inter,ifaceGroupItem);
469 params->setCurrentWindow(mainWindow);
473 if(!inter->refInter->getConnectedTo().isEmpty() && inter->refInter->getDirection() == AbstractInterface::Output){
474 cout << "connected to non null" << endl;
475 foreach(AbstractInterface *iface, inter->refInter->getConnectedTo()){
476 if(!listAbstractBlocks.contains(iface->getOwner())){
478 AbstractInterface *iface = inter->refInter->clone(0);
479 iface->setName(iface->getName()+"_group");
480 groupBlock->addInterface(iface);
482 InterfaceItem *ifaceItem = new InterfaceItem(0,Parameters::East,iface,blockItem,params);
483 blockItem->addInterface(ifaceItem);
484 blockItem->resetInterfacesPosition();
486 foreach(ConnectionItem* conn, currentGroup->getScene()->getInterfaceConnections(inter)){
487 if(conn->getFromInterfaceItem() == inter){
488 conn->setFromInterfaceItem(ifaceItem);
489 iface->addConnectedTo(conn->getToInterfaceItem()->refInter);
490 conn->getToInterfaceItem()->refInter->setConnectedFrom(iface);
494 InterfaceItem *ifaceGroupItem = new InterfaceItem(0,Parameters::East,iface,groupItem,params);
495 groupItem->addInterface(ifaceGroupItem);
496 groupItem->resetInterfacesPosition();
497 inter->refInter->clearConnectedTo();
498 ifaceGroupItem->refInter->setConnectedFrom(NULL);
499 connect(ifaceGroupItem,inter);
508 parent->updateShape();
509 currentGroup->getScene()->updateConnectionItemsShape();
511 groupItem->updateShape();
512 win->getScene()->updateConnectionItemsShape();
513 groupItem->update(groupItem->boundingRect());
518 void Dispatcher::removeBlock(AbstractBoxItem *item) {
522 GroupScene *scene = params->getCurrentScene();
523 AbstractBlock* block = item->getRefBlock();
524 if (block->isReferenceBlock()) return;
526 GroupBlock* group = (GroupBlock*)item->getParentItem()->getRefBlock();
528 removeConnections(item);
531 group->removeBlock(block);
533 //remove the associated window
534 if(block->isGroupBlock()){
535 foreach(QWidget *window, params->windows){
536 if(!window->inherits("MainWindow")){
537 if(((GroupWidget*)window)->getScene()->getGroupItem()->getRefBlock() == block){
538 params->removeWindow(window);
547 //supprimer l'item de la scène
548 cout << "dispatcher : remove item of scene " << params->currentWindow << endl;
549 ((GroupItem *)scene->getGroupItem())->removeBlockItem(item);
550 scene->removeItem(item);
551 scene->removeBlockItem(item);
554 ((GroupItem *)scene->getGroupItem())->updateShape();
556 params->updateToolbar();
557 params->unsaveModif = true;
562 void Dispatcher::removeAllBlockConnections(AbstractBoxItem *block) {
564 GroupScene* scene = block->getScene();
565 // supprimer les connections associées au bloc
566 foreach (ConnectionItem *conn, scene->getConnectionItems()) {
567 if(conn->getToInterfaceItem()->owner == block || conn->getFromInterfaceItem()->owner == block){
568 removeConnection(conn);
571 scene->getGroupItem()->updateInterfacesAndConnections();
574 void Dispatcher::removeConnection(ConnectionItem *conn) {
576 GroupScene *scene = params->getCurrentScene();
577 GroupItem* currentGroup = scene->getGroupItem();
579 conn->getFromInterfaceItem()->unconnectTo(conn->getToInterfaceItem());
581 scene->removeConnectionItem(conn);
584 currentGroup->updateInterfacesAndConnections();
585 params->unsaveModif = true;
588 void Dispatcher::removeUselessGroupInterfaces() {
590 GroupScene *scene = params->getCurrentScene();
591 GroupItem* currentGroup = scene->getGroupItem();
593 foreach(InterfaceItem *inter, currentGroup->getInterfaces()) {
594 if(inter->refInter->getConnectedTo().length() == 0) {
595 // NB : remove from view also remove from model
596 currentGroup->removeInterface(inter);
599 scene->updateConnectionItemsShape();
602 void Dispatcher::showBlocksLibrary(){
603 cout << "showing block library" << endl;
604 mainWindow->getLibrary()->show();
605 mainWindow->getLibrary()->raise();
608 void Dispatcher::showProperties(InterfaceItem *inter)
610 new InterfacePropertiesWindow(inter);
613 /* connectInterToGroup() :
614 The only way for a block (functional of group) within a GroupItem to be connected
615 to the latter is to right-click on one of its interfaces and to choose "connect to group".
616 That action will create a new InterfaceItem on the GroupItem and a connectionItem between the
619 void Dispatcher::connectInterToGroup(InterfaceItem *item){
621 // getting the GroupBlock and GroupItem that are parent of the block that owns item
622 ConnectedInterface *refInter = item->refInter;
623 cout << "owner of iface = " << qPrintable(refInter->getOwner()->getName()) << endl;
624 GroupBlock* parentBlock = AB_TO_GRP(refInter->getOwner()->getParent());
625 cout << "create iface for parent group = " << qPrintable(parentBlock->getName()) << endl;
626 GroupItem *parentItem = item->getOwner()->getScene()->getGroupItem();
628 // creating/adding the group interface in the graph model
629 GroupInterface *groupInter = new GroupInterface(parentBlock,refInter->getName()+"_group",refInter->getDirection(),refInter->getLevel());
630 groupInter->setType(refInter->getType());
631 groupInter->setWidth(refInter->getWidth());
632 groupInter->setPurpose(refInter->getPurpose());
633 parentItem->getRefBlock()->addInterface(groupInter);
635 // connect both interface
637 if (refInter->getDirection() == AbstractInterface::Output) {
638 ok = refInter->connectTo(groupInter);
639 ok = ok & groupInter->connectFrom(refInter);
641 else if (refInter->getDirection() == AbstractInterface::Input) {
642 ok = groupInter->connectTo(refInter);
643 ok = ok & refInter->connectFrom(groupInter);
645 else if (refInter->getDirection() == AbstractInterface::InOut) {
646 ok = refInter->connectTo(groupInter);
647 ok = ok & groupInter->connectFrom(refInter);
648 ok = ok & groupInter->connectTo(refInter);
649 ok = ok & refInter->connectFrom(groupInter);
652 cerr << "abnormal case while connecting a block iface to its parent group" << endl;
654 // creating/adding the group interface in the current scene model, and connection item
655 InterfaceItem *groupIfaceItem = new InterfaceItem(0,item->getOrientation(),groupInter,parentItem,params);
656 parentItem->addInterface(groupIfaceItem,true);
658 parentItem->getScene()->createConnectionItem(item, groupIfaceItem);
660 // if groupItem is not topGroup, must also add a new interface to the parent BlockItem
661 BoxItem* parent2Item = parentItem->getParentItem();
662 if(parent2Item != NULL){
663 InterfaceItem *blockIfaceItem = new InterfaceItem(0,item->getOrientation(),groupInter,parent2Item,params);
664 parent2Item->addInterface(blockIfaceItem,true);
668 parentItem->getScene()->updateConnectionItemsShape();
670 params->unsaveModif = true;
675 void Dispatcher::disconnectInterFromGroup(InterfaceItem *item) {
676 static QString fctName = "Dispatcher::disconnectInterFromGroup()";
678 cout << "call to " << qPrintable(fctName) << endl;
681 // getting the GroupBlock and GroupItem that are parent of the block that owns item
682 ConnectedInterface *refInter = item->refInter;
683 ConnectedInterface *groupInter = NULL;
684 GroupBlock* parentGroup = AB_TO_GRP(refInter->getOwner()->getParent());
685 GroupItem *parentItem = item->getOwner()->getScene()->getGroupItem();
687 // removing the connection from graph
689 cout << "removing connections from graph ..." ;
692 if (refInter->getDirection() == AbstractInterface::Output) {
693 groupInter = refInter->getConnectionToParentGroup(); // must be a single connection to
694 refInter->clearConnectedTo();
695 groupInter->clearConnectedFrom();
697 else if (refInter->getDirection() == AbstractInterface::Input) {
698 groupInter = refInter->getConnectedFrom();
699 refInter->clearConnectedFrom();
700 groupInter->clearConnectedTo();
702 else if (refInter->getDirection() == AbstractInterface::InOut) {
703 groupInter = refInter->getConnectionToParentGroup(); // must be a single connection to
704 refInter->clearConnectedTo();
705 refInter->clearConnectedFrom();
706 groupInter->clearConnectedTo();
707 groupInter->clearConnectedFrom();
710 cout << "done." << endl ;
713 if (groupInter == NULL) {
714 cerr << "abnormal case 1 while removing an interface item of a block, linked to a parent group" << endl;
718 cout << "getting group interface item, and connection item ..." ;
722 InterfaceItem* groupIfaceItem = parentItem->searchInterfaceByRef(groupInter);
723 if (groupIfaceItem == NULL) {
724 cerr << "abnormal case 2 while removing an interface item of a block, linked to a parent group" << endl;
726 ConnectionItem* conn = parentItem->getScene()->searchConnectionItem(item,groupIfaceItem);
728 cerr << "abnormal case 3 while removing an interface item of a block, linked to a parent group" << endl;
731 cout << "done." << endl ;
734 // removing the interface group item from the group item, and the connection item
736 cout << "removing group interface item, and connection item ..." ;
739 item->removeConnectionItem(conn);
740 groupIfaceItem->removeConnectionItem(conn);
741 parentItem->removeInterface(groupIfaceItem); // CAUTION : this deletes the interface item.
742 parentItem->getScene()->removeConnectionItem(conn);
744 cout << "done." << endl ;
747 // removing the interface box item in the parent scene
749 cout << "removing the inteeface item of box item in parent scene if needed ..." ;
752 BoxItem* parent2Item = parentItem->getParentItem();
753 if (parent2Item != NULL) {
754 InterfaceItem* group2IfaceItem = parent2Item->searchInterfaceByRef(groupInter);
755 parent2Item->removeInterface(group2IfaceItem);
758 cout << "done." << endl ;
761 // removing the interface group from the group
763 cout << "removing group interface ..." ;
765 parentGroup->removeInterface(groupInter);
767 cout << "done." << endl ;
772 void Dispatcher::removeGroupInterface(InterfaceItem *item) {
773 static QString fctName = "Dispatcher::removeGroupInterface()";
775 cout << "call to " << qPrintable(fctName) << endl;
778 /* NB: there is a single connection between item and another one that is owned
779 by a BoxItem. Thus, we just have to find it and to call disconnectInterFromGroup();
781 ConnectionItem* conn = item->connections.at(0);
782 if (conn->getFromInterfaceItem() == item) {
783 disconnectInterFromGroup(conn->getToInterfaceItem());
786 disconnectInterFromGroup(conn->getFromInterfaceItem());
790 QMap<int, QString> Dispatcher::getAllGroupNames() {
792 QMap<int, QString> list;
793 foreach(GroupWidget *group, groupList) {
794 list.insert(group->getScene()->getId(), group->getScene()->getGroupItem()->getRefBlock()->getName());
799 GroupScene* Dispatcher::searchSceneById(int id) {
800 foreach(GroupWidget *group, groupList){
801 if(group->getScene()->getId() == id)
802 return group->getScene();
804 cout << "search scene by id :" << id << " :: not found..." << endl;
808 GroupItem *Dispatcher::searchGroupItemById(int id) {
809 foreach(GroupWidget *group, groupList) {
810 GroupScene* scene = group->getScene();
811 if (scene->getGroupItem()->getId() == id) return scene->getGroupItem();
813 cout << "search GroupItem by id :" << id << " :: not found..." << endl;
817 BoxItem *Dispatcher::searchBlockItemById(int id) {
818 foreach(GroupWidget *group, groupList) {
820 GroupScene* scene = group->getScene();
821 foreach(BoxItem *item, scene->getBlockItems()){
822 if(item->getId() == id){
827 cout << "search BlockItem by id :" << id << " :: not found..." << endl;
831 InterfaceItem* Dispatcher::searchInterfaceItemById(int id) {
833 foreach(GroupWidget *group, groupList) {
835 GroupScene* scene = group->getScene();
837 foreach(InterfaceItem *item, scene->getGroupItem()->getInterfaces()){
838 if(item->getId() == id){
842 foreach(BoxItem *block, scene->getBlockItems()){
843 foreach(InterfaceItem *item, block->getInterfaces()){
844 if(item->getId() == id){
850 cout << "search interface by id :" << id << " :: not found..." << endl;