YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
builderwindow.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#include "builderwindow.h"
7//#include "ui_builderwindow.h"
8#include <QHBoxLayout>
9#include <QSplitter>
10
11
12BuilderWindow::BuilderWindow(Application *app, Manager *lazyManager, SafeManager *safeManager, bool editingMode, QWidget *parent) :
13 QWidget(parent)/*,
14 ui(new Ui::BuilderWindow)*/
15{
16
17 //ui->setupUi(this);
18 this->editingMode = editingMode;
19 this->lazyManager = lazyManager;
20 this->app = app;
21 this->safeManager = safeManager;
22
23
24 init();
25
26}
27
28void BuilderWindow::init()
29{
30 scene = new BuilderScene(this);
31 scene->setSceneRect(QRectF(0, 0, 2000, 2000));
32 scene->setBackgroundBrush(QPixmap(":/images/background2.png"));
33 connect(scene,SIGNAL(addedModule(void*,QPointF)),this,SLOT(onAddModule(void*,QPointF)));
34 connect(scene,SIGNAL(addedApplication(void*,QPointF)),this,SLOT(onAddedApplication(void*,QPointF)));
35 connect(scene,SIGNAL(addNewConnection(void*,void*)),this,SLOT(onAddNewConnection(void*,void*)));
36
37 view = new CustomView(this);
38 connect(view,SIGNAL(pressedNullItem()),this,SLOT(initApplicationTab()));
39 connect(view,SIGNAL(addSourcePort(QString,QPointF)),this,SLOT(onAddSourcePort(QString,QPointF)));
40 connect(view,SIGNAL(addDestinationPort(QString,QPointF)),this,SLOT(onAddDestinationPort(QString,QPointF)));
41 connect(view,SIGNAL(addModule(void*,QPointF)),this,SLOT(onAddModule(void*,QPointF)));
42 connect(view,SIGNAL(addNewConnection(void*,void*)),this,SLOT(onAddNewConnection(void*,void*)));
43 connect(view,SIGNAL(modified()),this,SLOT(onModified()));
44
45 view->setMouseTracking(true);
46 view->setScene(scene);
47 view->centerOn(scene->sceneRect().width()/2,scene->sceneRect().height()/2);
49
50 QAction *zoomIn = builderToolbar.addAction("Zoom In");
51 QAction *zoomOut = builderToolbar.addAction("Zoom Out");
52 QAction *restoreZoom = builderToolbar.addAction("Reset Zoom");
53 builderToolbar.addSeparator();
54 QAction *showGrid = builderToolbar.addAction("Show Grid");
55 QAction *snapToGrid = builderToolbar.addAction("Snap to Grid");
56 builderToolbar.addSeparator();
57
58 snapToGrid->setCheckable(true);
59 showGrid->setCheckable(true);
60 showGrid->setChecked(true);
61 connect(snapToGrid,SIGNAL(triggered(bool)),this,SLOT(onSnap(bool)));
62 connect(restoreZoom,SIGNAL(triggered()),this,SLOT(onRestoreZoom()));
63 connect(showGrid,SIGNAL(triggered(bool)),this,SLOT(onShowGrid(bool)));
64 connect(zoomIn,SIGNAL(triggered(bool)),this,SLOT(onZoomIn()));
65 connect(zoomOut,SIGNAL(triggered(bool)),this,SLOT(onZoomOut()));
66
67 if(editingMode){
68 prepareManagerFrom(lazyManager,app->getName());
69 }
70
71
72 auto* layout = new QVBoxLayout;
73 if(editingMode){
75 connect(propertiesTab,SIGNAL(modified()),this,SLOT(onModified()));
77 splitter = new QSplitter;
78 splitter->addWidget(view);
79 splitter->addWidget(propertiesTab);
80 layout->addWidget(splitter);
81 }else{
82 layout->addWidget(view);
83 }
84
85
86 layout->setMargin(0);
87 view->centerOn(0,0);
88 setLayout(layout);
89
90
91 m_modified = false;
92 emit modified(false);
93
94 //onRestoreZoom();
95
96}
97
99{
100 if(!editingMode){
101 return true;
102 }
104 if (!application) {
105 return true;
106 }
107
108 foreach (QGraphicsItem *it, scene->items()) {
109 if(it->type() == QGraphicsItem::UserType+SourcePortItemType){
110 if(((SourcePortItem*)it)->isErrorState()){
111 return false;
112 }
113 }
114 if(it->type() == QGraphicsItem::UserType+DestinationPortItemType){
115 if(((DestinationPortItem*)it)->isErrorState()){
116 return false;
117 }
118 }
119 }
120
121 m_modified = !manager.saveApplication(application->getName());
122 emit modified(m_modified);
123 return !m_modified;
124}
125
127{
129 if (!application) {
130 return {};
131 };
132 return QString(application->getXmlFile());
133}
134void BuilderWindow::setFileName(QString filename)
135{
137 if (application) {
138 application->setXmlFile(filename.toStdString().c_str());
139 }
140 return;
141}
143{
145 if (!application) {
146 return {};
147 };
148 return QString(application->getName());
149}
150void BuilderWindow::setAppName(QString appName)
151{
153 if (application) {
154 application->setName(appName.toStdString().c_str());
155 }
156 return;
157}
158
159void BuilderWindow::prepareManagerFrom(Manager* lazy,
160 const char* szAppName)
161{
162
163 // making manager from lazy manager
164 KnowledgeBase* lazy_kb = lazy->getKnowledgeBase();
165
166 ModulePContainer mods = lazy_kb->getModules();
167 for (auto& mod : mods) {
169 }
170
171 ResourcePContainer res = lazy_kb->getResources();
172 for (auto& re : res) {
174 }
175
176 ApplicaitonPContainer apps = lazy_kb->getApplications();
177 for (auto& app : apps) {
179 }
180
181 // loading application
182 manager.loadApplication(szAppName);
183
184
185}
186
187
189{
190 //delete ui;
191 for(int i=0;i<scene->items().count();i++){
192 QGraphicsItem *it = scene->items().at(i);
193 if(it->type() == QGraphicsItem::UserType + (int)ModuleItemType){
194 auto* bItem = (BuilderItem*)it;
195 disconnect(bItem->signalHandler(),SIGNAL(moduleSelected(QGraphicsItem*)),this,SLOT(onModuleSelected(QGraphicsItem*)));
196 disconnect(bItem->signalHandler(),SIGNAL(requestNewConnection(QPointF,QGraphicsItem*)),scene,SLOT(onNewConnectionRequested(QPointF,QGraphicsItem*)));
197 disconnect(bItem->signalHandler(),SIGNAL(addNewConnection(QPointF,QGraphicsItem*)),scene,SLOT(onNewConnectionAdded(QPointF,QGraphicsItem*)));
198 disconnect(bItem->signalHandler(),SIGNAL(modified()),this,SLOT(onModified()));
199 disconnect(bItem->signalHandler(),SIGNAL(moved()),this,SLOT(onMoved()));
200 }
201 if(it->type() == QGraphicsItem::UserType + (int)ApplicationItemType){
202 auto* bItem = (BuilderItem*)it;
203 disconnect(bItem->signalHandler(),SIGNAL(moduleSelected(QGraphicsItem*)),this,SLOT(onModuleSelected(QGraphicsItem*)));
204 disconnect(bItem->signalHandler(),SIGNAL(connectctionSelected(QGraphicsItem*)),this,SLOT(onConnectionSelected(QGraphicsItem*)));
205 disconnect(bItem->signalHandler(),SIGNAL(applicationSelected(QGraphicsItem*)),this,SLOT(onApplicationSelected(QGraphicsItem*)));
206 disconnect(bItem->signalHandler(),SIGNAL(modified()),this,SLOT(onModified()));
207 disconnect(bItem->signalHandler(),SIGNAL(moved()),this,SLOT(onMoved()));
208 }
209 }
210 view->close();
211 scene->clear();
212
213 //view->deleteAllItems();
214}
215
216
218{
219 return &builderToolbar;
220}
221
223{
224 layout()->removeWidget(&builderToolbar);
225 builderToolbar.hide();
226}
227
229{
230 layout()->removeWidget(&builderToolbar);
231 if(editingMode){
232 layout()->removeWidget(splitter);
233 }else{
234 layout()->removeWidget(view);
235 }
236
237 layout()->addWidget(&builderToolbar);
238 if(editingMode){
239 layout()->addWidget(splitter);
240 }else{
241 layout()->addWidget(view);
242 }
243
244 builderToolbar.show();
245}
246
247void BuilderWindow::addAction(QAction *act)
248{
249 builderActions.append(act);
250
251}
252
254{
255 modulesAction.append(act);
256}
257
259{
260 connectionsAction.append(act);
261}
262
263void BuilderWindow::setModuleRunning(bool running, int id)
264{
265 for(int i=0;i<scene->items().count();i++){
266 if(scene->items().at(i)->type() == (QGraphicsItem::UserType + ModuleItemType)){
267 ModuleItem *m = (ModuleItem *)scene->items().at(i);
268 if(m->getId() == id){
269 m->setRunning(running);
270 break;
271 }
272 }
273 if(scene->items().at(i)->type() == (QGraphicsItem::UserType + ApplicationItemType)){
274 ApplicationItem *a = (ApplicationItem *)scene->items().at(i);
275 a->setModuleRunning(running,id);
276 }
277 }
278}
279
280void BuilderWindow::setConnectionConnected(bool connected, QString from, QString to)
281{
282 for(int i=0;i<scene->items().count();i++){
283 if(scene->items().at(i)->type() == (QGraphicsItem::UserType + ConnectionItemType)){
284 Arrow *m = (Arrow *)scene->items().at(i);
285 if(m->getFrom() == from && m->getTo() == to){
286 m->setConnected(connected);
287 break;
288 }
289 }
290 if(scene->items().at(i)->type() == (QGraphicsItem::UserType + ApplicationItemType)){
291 ApplicationItem *a = (ApplicationItem *)scene->items().at(i);
292 a->setConnectionConnected(connected,from,to);
293 }
294 }
295}
296
297
298
299bool BuilderWindow::isApplicationPresent(Application *application)
300{
301 for(int i=0;i<scene->items().count();i++){
302 BuilderItem *it = (BuilderItem*)scene->items().at(i);
303 if(it->type() == QGraphicsItem::UserType + ApplicationItemType){
304 auto* appItem = (ApplicationItem*)it;
305 if(appItem->getInnerApplication() == application){
306 return true;
307 }
308 }
309 }
310 return false;
311}
312
313bool BuilderWindow::isModulePresent(Module *module)
314{
315 for(int i=0;i<scene->items().count();i++){
316 BuilderItem *it = (BuilderItem*)scene->items().at(i);
317 if(it->type() == QGraphicsItem::UserType + ModuleItemType){
318 auto* appItem = (ModuleItem*)it;
319 if(appItem->getInnerModule() == module){
320 return true;
321 }
322 }
323 }
324 return false;
325}
326
327
328
329
330void BuilderWindow::load(bool refresh)
331{
332 index = 0;
333
334
335 usedModulesId.clear();
336 connectionsId = 0;
337
338 bool ret = true;//safeManager->loadApplication(app->getName());
339 if(ret){
340 Application* mainApplication;
341 CnnContainer connections;
342 ApplicaitonPContainer applications;
343 ModulePContainer modules;
345
346
347 if(!editingMode){
348 mainApplication = safeManager->getKnowledgeBase()->getApplication();
349 connections = safeManager->getKnowledgeBase()->getConnections(mainApplication);
350 applications = safeManager->getKnowledgeBase()->getApplications(mainApplication);
351 exes = safeManager->getExecutables();
352 }else{
353 mainApplication = manager.getKnowledgeBase()->getApplication();
354 connections = manager.getKnowledgeBase()->getConnections(mainApplication);
355 applications = manager.getKnowledgeBase()->getApplications(mainApplication);
356 modules = manager.getKnowledgeBase()->getModules(mainApplication);
357 }
358
359 //ModulePContainer modules = safeManager->getKnowledgeBase()->getModules(mainApplication);
360
361 /*************************************/
362 ExecutablePIterator exeitr;
363 ModulePIterator moditr;
364 /*************************************/
365
366
367
369 for(appItr=applications.begin(); appItr!=applications.end(); appItr++)
370 {
371 Application* application = (*appItr);
372 addApplication(application,&connectionsId);
373 }
374
375
376 if(!editingMode){
377 for(exeitr=exes.begin(); exeitr<exes.end(); exeitr++){
378 Module* module = (*exeitr)->getModule();
379
380 QString id = QString("%1").arg((*exeitr)->getID());
381 bool idFound = false;
382 foreach (int usedId, usedModulesId) {
383 if(usedId == id.toInt()){
384 idFound = true;
385 break;
386 }
387 }
388 if(!idFound){
389 usedModulesId.append(id.toInt());
390 addModule(module,id.toInt());
391 }
392
393 }
394 }else{
395 for(moditr=modules.begin(); moditr<modules.end(); moditr++){
396 auto* module = (Module*)(*moditr);
397 addModule(module,-1);
398 }
399 }
400
401
402
403 index = (index/900)*100+50;
404 CnnIterator citr;
405 ModulePContainer allModules;
406 if(!editingMode){
407 allModules = safeManager->getKnowledgeBase()->getSelModules();
408 }else{
409 allModules = manager.getKnowledgeBase()->getSelModules();
410 }
411
412 for(citr=connections.begin(); citr<connections.end(); citr++){
413 Connection baseCon = *citr;
414// if(baseCon.owner()->getLabel() != mainApplication->getLabel()){
415// continue;
416// }
417 GraphicModel model = baseCon.getModelBase();
418 InputData* input = nullptr;
419 OutputData* output = nullptr;
420 BuilderItem *source = nullptr;
421 BuilderItem *dest = nullptr;
422 QString inModulePrefix,outModulePrefix;
423 findInputOutputData((*citr), allModules, input, output,&inModulePrefix,&outModulePrefix);
424 if(output){
425 source = findModelFromOutput(output,outModulePrefix);
426 }else{
427 bool bExist = false;
428 SourcePortItem *sourcePort = nullptr;
429 for(int i=0;i<scene->items().count() && !bExist;i++){
430 if(scene->items().at(i)->type() == (QGraphicsItem::UserType + SourcePortItemType)){
431 SourcePortItem *auxSourceport = (SourcePortItem*)scene->items().at(i);
432 if(auxSourceport->getItemName() == baseCon.from()){
433 source = auxSourceport;
434 bExist = true;
435 break;
436 }
437
438 }
439 if(scene->items().at(i)->type() == (QGraphicsItem::UserType + ApplicationItemType)){
440 // TODO
441 qDebug() << "APPLICATION CONN";
442 }
443 }
444 if(!bExist){
445 sourcePort = (SourcePortItem*)addSourcePort((*citr).from());
446 source = sourcePort;
447
448 if(model.points.size() > 1){
449 source->setPos(model.points[1].x /*+ source->boundingRect().width()/2*/,
450 model.points[1].y /*+ source->boundingRect().height()/2*/);
451 }else{
452 source->setPos(10 + source->boundingRect().width()/2, index);
453 }
454 }
455
456
457 index += 40;
458 }
459 if(input){
460 dest = findModelFromInput(input,inModulePrefix);
461 }else{
462 bool bExist = false;
463 for(int i=0;i<scene->items().count() && !bExist;i++){
464 if(scene->items().at(i)->type() == (QGraphicsItem::UserType + DestinationPortItemType)){
465 DestinationPortItem *auxDestPort = (DestinationPortItem*)scene->items().at(i);
466 if(auxDestPort->getItemName() == baseCon.to()){
467 dest = auxDestPort;
468 bExist = true;
469 break;
470 }
471 }
472 if(scene->items().at(i)->type() == (QGraphicsItem::UserType + ApplicationItemType)){
473 // TODO
474 qDebug() << "APPLICATION CONN";
475 }
476 }
477 if(!bExist){
478 dest = (DestinationPortItem*)addDestinantionPort((*citr).to());
479
480 size_t size = model.points.size();
481 if(size > 2){
482 dest->setPos(model.points[size-1].x /*+ dest->boundingRect().width()/2*/,
483 model.points[size-1].y/* + dest->boundingRect().height()/2*/);
484 }else{
485 dest->setPos(400 + dest->boundingRect().width()/2, index);
486 }
487 }
488
489
490 }
491
492 //Arrow *arrow;
493 // check for arbitrators
494 std::string strCarrier = baseCon.carrier();
495 if((strCarrier.find("recv.priority") != std::string::npos)){
496 // TODO
497 }else{
498 if(source && dest){
499// Arrow *arrow =(Arrow*)addConnection(source,dest,id);
500// arrow->setConnection(baseCon);
501 auto* arrow =(Arrow*)addConnection(source,dest,connectionsId);
502 arrow->setConnection(baseCon);
503
504// arrow = new Arrow(source, dest, baseCon,id,!editingMode ? safeManager : &manager,false,editingMode);
505// arrow->setActions(connectionsAction);
506// connect(arrow->signalHandler(),SIGNAL(connectctionSelected(QGraphicsItem*)),this,SLOT(onConnectionSelected(QGraphicsItem*)));
507// arrow->setColor(QColor(Qt::red));
508// source->addArrow(arrow);
509// dest->addArrow(arrow);
510// scene->addItem(arrow);
511// arrow->setZValue(1);
512// arrow->updatePosition();
513 //itemsList.append(arrow);
514 }
515 }
517 }
518 }
519
520 QRectF rr = itemsBoundingRect();
521 view->fitInView(rr,Qt::KeepAspectRatio);
522
523
524}
525
527{
528 QRectF rr;
529 foreach(QGraphicsItem *it, scene->items()){
530 if(it->parentItem() != nullptr && it->parentItem()->type() != QGraphicsItem::UserType + ConnectionItemType){
531 continue;
532 }
533 if(it->type() == QGraphicsItem::UserType + ModuleItemType ||
534 it->type() == QGraphicsItem::UserType + ApplicationItemType ||
535 it->type() == QGraphicsItem::UserType + SourcePortItemType ||
536 it->type() == QGraphicsItem::UserType + DestinationPortItemType){
537 QRectF bRect = it->mapToScene(it->boundingRect()).boundingRect();
538 rr = rr.united(bRect);
539 }
540
541 if(it->type() == QGraphicsItem::UserType + ConnectionItemType){
542 auto* bItem = (Arrow *)it;
543 foreach (LineHandle *i, bItem->handles()) {
544 rr = rr.united(bItem->mapToScene(bItem->mapFromItem(i,i->boundingRect()).boundingRect()).boundingRect());
545 }
546 }
547 }
548 return rr;
549}
550
551BuilderItem *BuilderWindow::onAddSourcePort(QString name,QPointF pos)
552{
553 BuilderItem *it = addSourcePort(name,true);
554 it->snapToGrid(scene->snap);
555 it->setSelected(true);
556 it->setPos(pos);
557 return it;
558}
559
560BuilderItem *BuilderWindow::onAddDestinationPort(QString name,QPointF pos)
561{
562 BuilderItem *it = addDestinantionPort(name,true);
563 it->snapToGrid(scene->snap);
564 it->setSelected(true);
565 it->setPos(pos);
566 return it;
567}
568
569BuilderItem *BuilderWindow::onAddNewConnection(void *startItem ,void *endItem, int connectionId)
570{
572
573 Application* mainApplication = nullptr;
574 mainApplication = manager->getKnowledgeBase()->getApplication();
575 Connection connection;
576 auto* myStartItem = (BuilderItem*)startItem;
577 auto* myEndItem = (BuilderItem*)endItem;
578 GyPoint p,p1,fakeLblPoint;
579 QString label;
580 setToolTip(QString("%1 --> %2").arg(myStartItem->getItemName()).arg(myEndItem->getItemName()));
581
582 bool bExternTo = false;
583 bool bExternFrom = false;
584
585 InputData* input = nullptr;
586 OutputData* output = nullptr;
587
588 std::string strFrom,strTo ;
589
590 // Source
591 if(myStartItem->type() == (QGraphicsItem::UserType + (int)ModulePortItemType)){
592 PortItem *port = ((PortItem*)myStartItem);
593 auto* module = (ModuleItem *)port->parentItem();
594 int portType = port->getPortType();
595 if(portType == OUTPUT_PORT){
596 output = port->getOutputData();
597 strFrom = std::string(module->getInnerModule()->getPrefix()) + std::string(port->getOutputData()->getPort());
598 label = QString("%1").arg(port->getOutputData()->getCarrier());
599
600 if(((ModuleItem*)port->parentItem())->getInnerModule()->owner() != mainApplication){
601 bExternFrom = true;
602 }
603 }
604
605 }else if(myStartItem->type() == (QGraphicsItem::UserType + (int)SourcePortItemType)){
606 strFrom = std::string(myStartItem->getItemName().toLatin1().data());
607 bExternFrom = true;
608 }
609
610 // Destination
611 if(myEndItem->type() == (QGraphicsItem::UserType + (int)ModulePortItemType)){
612 PortItem *port = ((PortItem*)myEndItem);
613 auto* module = (ModuleItem *)port->parentItem();
614 int portType = port->getPortType();
615 if(portType == INPUT_PORT){
616 input = port->getInputData();
617 strTo = std::string(module->getInnerModule()->getPrefix()) + std::string(port->getInputData()->getPort());
618 label = QString("%1").arg(port->getInputData()->getCarrier());
619
620 if(((ModuleItem*)port->parentItem())->getInnerModule()->owner() != mainApplication){
621 bExternTo = true;
622 }
623 }
624
625 }else if(myEndItem->type() == (QGraphicsItem::UserType + (int)DestinationPortItemType)){
626 strTo = std::string(myEndItem->getItemName().toLatin1().data());
627 bExternTo = true;
628
629 }
630
631
632
633 if(label.isEmpty()){
634 label = "udp";
635 }
636
637 auto* arrow = (Arrow*)addConnection((BuilderItem*)startItem, (BuilderItem*)endItem,connectionId);
638
639 connection.setFrom(strFrom.c_str());
640 connection.setTo(strTo.c_str());
641 connection.setCarrier(label.toLatin1().data());
642 connection.setFromExternal(bExternFrom);
643 connection.setToExternal(bExternTo);
644 connection.setCorOutputData(output);
645 connection.setCorInputData(input);
646
647
648 fakeLblPoint.x = -1;
649 fakeLblPoint.y = -1;
650 p.x = (myStartItem->pos()).x();
651 p.y = (myStartItem->pos()).y();
652 p1.x = (myEndItem->pos()).x();
653 p1.y = (myEndItem->pos()).y();
654 arrow->getModel()->points.clear();
655 arrow->getModel()->points.push_back(fakeLblPoint);
656 arrow->getModel()->points.push_back(p);
657 arrow->getModel()->points.push_back(p1);
658 connection.setModel(arrow->getModel());
659 connection.setModelBase(*arrow->getModel());
660 connection.setPersistent(false);
661 connection = manager->getKnowledgeBase()->addConnectionToApplication(mainApplication, connection);
662
663 arrow->setConnection(connection);
664 //arrow->updateModel(p,p1,fakeLblPoint);
665// Arrow *arrow = new Arrow((BuilderItem*)startItem, (BuilderItem*)endItem, &manager,false,editingMode);
666// arrow->setActions(connectionsAction);
667// connect(arrow->signalHandler(),SIGNAL(connectctionSelected(QGraphicsItem*)),this,SLOT(onConnectionSelected(QGraphicsItem*)));
668// arrow->setColor(QColor(Qt::red));
669// ((BuilderItem*)startItem)->addArrow(arrow);
670// ((BuilderItem*)endItem)->addArrow(arrow);
671// scene->addItem(arrow);
672// arrow->setZValue(-1000.0);
673// arrow->updatePosition();
674// scene->items().append(arrow);
675
676 m_modified = true;
677 emit modified(true);
678 return arrow;
679
680
681}
682
683
684
685BuilderItem * BuilderWindow::addConnection(void *startItem ,void *endItem, int connectionId)
686{
687 auto* arrow = new Arrow((BuilderItem*)startItem,(BuilderItem*)endItem,connectionId,!editingMode ? safeManager : &manager,false,editingMode);
689 connect(arrow->signalHandler(),SIGNAL(connectctionSelected(QGraphicsItem*)),this,SLOT(onConnectionSelected(QGraphicsItem*)));
690 connect(arrow->signalHandler(),SIGNAL(modified()),this,SLOT(onModified()));
691 connect(arrow->signalHandler(),SIGNAL(moved()),this,SLOT(onMoved()));
692 arrow->setColor(QColor(Qt::red));
693 ((BuilderItem*)startItem)->addArrow(arrow);
694 ((BuilderItem*)endItem)->addArrow(arrow);
695 scene->addItem(arrow);
696 //arrow->setZValue(1000.0);
697 arrow->updatePosition();
698 scene->items().append(arrow);
699
700
701
702 return arrow;
703}
704
705BuilderItem * BuilderWindow::addDestinantionPort(QString name, bool editOnStart)
706{
707 Application *mainApplication = nullptr;
708 if(!editingMode){
709 mainApplication = safeManager->getKnowledgeBase()->getApplication();
710 }else{
711 mainApplication = manager.getKnowledgeBase()->getApplication();
712 }
713 DestinationPortItem *destPort = new DestinationPortItem(name,false,editOnStart,mainApplication);
714 connect(destPort->signalHandler(),SIGNAL(addNewConnection(QPointF,QGraphicsItem*)),scene,SLOT(onNewConnectionAdded(QPointF,QGraphicsItem*)));
715 connect(destPort->signalHandler(),SIGNAL(modified()),this,SLOT(onModified()));
716 //itemsList.append(destPort);
717
718 scene->addItem(destPort);
719 return destPort;
720}
721
722void BuilderWindow::onMoved()
723{
724 foreach(QGraphicsItem *it, scene->selectedItems()){
725 if(it->parentItem() != nullptr && it->parentItem()->type() != QGraphicsItem::UserType + ConnectionItemType){
726 continue;
727 }
728 if(it->type() == QGraphicsItem::UserType + ModuleItemType){
729 auto* bItem = (ModuleItem *)it;
730 bItem->updateGraphicModel();
731 }
732 if(it->type() == QGraphicsItem::UserType + ApplicationItemType){
733 auto* bItem = (ApplicationItem *)it;
734 bItem->updateGraphicModel();
735 }
736 if(it->type() == QGraphicsItem::UserType + ConnectionItemType){
737 auto* bItem = (Arrow *)it;
738 bItem->updateGraphicModel();
739 }
740 if(it->type() == QGraphicsItem::UserType + HandleItemType){
741 auto* bItem = (Arrow *)it->parentItem();
742 bItem->updateGraphicModel();
743 }
744 if(it->type() == QGraphicsItem::UserType + ArrowLabelItemType){
745 auto* bItem = (Arrow *)it->parentItem();
746 bItem->updateGraphicModel();
747 }
748 }
749}
750
751void BuilderWindow::onModified()
752{
753 m_modified = true;
754 emit modified(true);
755}
756
757BuilderItem * BuilderWindow::addSourcePort(QString name, bool editOnStart)
758{
759 Application *mainApplication = nullptr;
760 if(!editingMode){
761 mainApplication = safeManager->getKnowledgeBase()->getApplication();
762 }else{
763 mainApplication = manager.getKnowledgeBase()->getApplication();
764 }
765 SourcePortItem *sourcePort = new SourcePortItem(name,false,editOnStart,mainApplication);
766 connect(sourcePort->signalHandler(),SIGNAL(requestNewConnection(QPointF,QGraphicsItem*)),scene,SLOT(onNewConnectionRequested(QPointF,QGraphicsItem*)));
767 connect(sourcePort->signalHandler(),SIGNAL(modified()),this,SLOT(onModified()));
768
769 //itemsList.append(sourcePort);
770 scene->addItem(sourcePort);
771 return sourcePort;
772}
773
775{
776 auto* it = new ModuleItem(module,moduleId,false,editingMode,!editingMode ? safeManager : &manager);
778 connect(it->signalHandler(),SIGNAL(moduleSelected(QGraphicsItem*)),this,SLOT(onModuleSelected(QGraphicsItem*)));
779 connect(it->signalHandler(),SIGNAL(requestNewConnection(QPointF,QGraphicsItem*)),scene,SLOT(onNewConnectionRequested(QPointF,QGraphicsItem*)));
780 connect(it->signalHandler(),SIGNAL(addNewConnection(QPointF,QGraphicsItem*)),scene,SLOT(onNewConnectionAdded(QPointF,QGraphicsItem*)));
781 connect(it->signalHandler(),SIGNAL(modified()),this,SLOT(onModified()));
782 connect(it->signalHandler(),SIGNAL(moved()),this,SLOT(onMoved()));
783 //itemsList.append(it);
784 scene->addItem(it);
785 it->setZValue(2);
786 if(module->getModelBase().points.size()>0){
787 it->setPos(module->getModelBase().points[0].x /*+ it->boundingRect().width()/2*/,
788 module->getModelBase().points[0].y /*+ it->boundingRect().height()/2*/);
789 }else{
790 it->setPos(index%900+10 + it->boundingRect().width()/2,
791 (index/900)*100+10 + it->boundingRect().height()/2);
792 index += 300;
793 }
794 return it;
795}
796
798{
799
800 auto* appItem = new ApplicationItem(application,!editingMode ? safeManager : &manager,&usedModulesId, false,editingMode,connectionsId);
801
802 if(!editingMode){
803 connect(appItem->signalHandler(),SIGNAL(moduleSelected(QGraphicsItem*)),this,SLOT(onModuleSelected(QGraphicsItem*)));
804 connect(appItem->signalHandler(),SIGNAL(connectctionSelected(QGraphicsItem*)),this,SLOT(onConnectionSelected(QGraphicsItem*)));
805 appItem->setModulesAction(modulesAction);
806 }else{
807 connect(appItem->signalHandler(),SIGNAL(modified()),this,SLOT(onModified()));
808 connect(appItem->signalHandler(),SIGNAL(moved()),this,SLOT(onMoved()));
809 }
810
811 connect(appItem->signalHandler(),SIGNAL(applicationSelected(QGraphicsItem*)),this,SLOT(onApplicationSelected(QGraphicsItem*)));
812
813
814 scene->addItem(appItem);
815 appItem->init();
816
817 if(application->getModelBase().points.size()>0){
818 appItem->setPos(application->getModelBase().points[0].x,
819 application->getModelBase().points[0].y);
820 } else {
821 appItem->setPos(index%900+10,
822 (index/900)*100+10);
823 index += 300;
824 }
825 //itemsList.append(appItem);
826 return appItem;
827
828}
829
830void BuilderWindow::onAddedApplication(void *app,QPointF pos)
831{
832 if(!editingMode){
833 return;
834 }
835
836 ApplicationInterface iapp((const char*)((Application*)app)->getName());
837 GraphicModel modBase;
838 GyPoint p;
839 p.x = pos.x();
840 p.y = pos.y();
841 modBase.points.push_back(p);
842 iapp.setModelBase(modBase);
843
844 Application* mainApplication = manager.getKnowledgeBase()->getApplication();
845 if (!mainApplication) {
846 return;
847 }
848
849 std::string strPrefix = "/";
850 std::string uniqeId = manager.getKnowledgeBase()->getUniqueAppID(mainApplication, iapp.getName());
851
852 strPrefix += (uniqeId);
853 iapp.setPrefix(strPrefix.c_str());
854 Application* application = manager.getKnowledgeBase()->addIApplicationToApplication(mainApplication, iapp);
855 if(application){
856 addApplication(application,&connectionsId);
857
858 }
859 m_modified = true;
860 emit modified(true);
861}
862
863BuilderItem *BuilderWindow::onAddModule(void *mod,QPointF pos)
864{
865
866 BuilderItem *modIt = nullptr;
867 if(!editingMode){
868 return modIt;
869 }
870
871
872 ModuleInterface imod((const char*)((Module*)mod)->getName());
873 GraphicModel modBase;
874 GyPoint p;
875 p.x = pos.x();
876 p.y = pos.y();
877 modBase.points.push_back(p);
878 imod.setModelBase(modBase);
879
880 Application* mainApplication = manager.getKnowledgeBase()->getApplication();
881 if(!mainApplication){
882 return modIt;
883 }
884
885 Module* module = manager.getKnowledgeBase()->addIModuleToApplication(mainApplication, imod, true);
886
887 if(module){
888 std::string strPrefix = std::string("/") + module->getLabel();
889 module->setBasePrefix(strPrefix.c_str());
890 //module->setBasePrefix(((Module*)mod)->getBasePrefix());
891 module->setBroker(((Module*)mod)->getBroker());
892 module->setHost(((Module*)mod)->getHost());
893 module->setParam(((Module*)mod)->getParam());
894 module->setWorkDir(((Module*)mod)->getWorkDir());
895 module->setStdio(((Module*)mod)->getStdio());
896
897
898 std::string strAppPrefix = mainApplication->getBasePrefix();
899 std::string prefix = strAppPrefix+module->getBasePrefix();
900 manager.getKnowledgeBase()->setModulePrefix(module, prefix.c_str(), false);
901
902 modIt = addModule(module,-1);
903 modIt->setSelected(true);
904 modIt->snapToGrid(scene->snap);
905
906
907 //load(true);
908 }
909 m_modified = true;
910 emit modified(true);
911 return modIt;
912
913}
914
915void BuilderWindow::setSelectedConnections(QList<int>selectedIds)
916{
917 if(editingMode){
918 return;
919 }
920 foreach (QGraphicsItem *it, scene->items()) {
921 if(it->parentItem() != nullptr){
922 continue;
923 }
924 if(it->type() == QGraphicsItem::UserType + ConnectionItemType){
925 auto* arrow = (Arrow*)it;
926 if(selectedIds.contains(arrow->getId())){
927 arrow->setConnectionSelected(true);
928 }else{
929 arrow->setConnectionSelected(false);
930 }
931 }else
932 if(it->type() == QGraphicsItem::UserType + ApplicationItemType){
933 auto* app = (ApplicationItem*)it;
934 app->setSelectedConnections(selectedIds);
935 }
936 }
937}
938
939void BuilderWindow::setSelectedModules(QList<int>selectedIds)
940{
941 if(editingMode){
942 return;
943 }
944 foreach (QGraphicsItem *it, scene->items()) {
945 if(it->parentItem() != nullptr){
946 continue;
947 }
948 if(it->type() == QGraphicsItem::UserType + ModuleItemType){
949 auto* mod = (ModuleItem*)it;
950 if(selectedIds.contains(mod->getId())){
951 mod->setModuleSelected(true);
952 }else{
953 mod->setModuleSelected(false);
954 }
955 }else
956 if(it->type() == QGraphicsItem::UserType + ApplicationItemType){
957 auto* app = (ApplicationItem*)it;
958 app->setSelectedModules(selectedIds);
959 }
960 }
961}
962
963void BuilderWindow::onConnectionSelected(QGraphicsItem *it)
964{
965 //initModuleTab((ModuleItem*)it);
966 Q_UNUSED(it);
967 if(editingMode){
968 return;
969 }
970
971 QList<int> selectedModules;
972 foreach (QGraphicsItem *item , scene->selectedItems()) {
973
974 if(item->type() == QGraphicsItem::UserType + (int)ConnectionItemType){
975 auto* arrow = (Arrow*)item;
976 selectedModules.append(arrow->getId());
977 }
978 }
979 emit setConnectionSelected(selectedModules);
980}
981
982void BuilderWindow::onModuleSelected(QGraphicsItem *it)
983{
984
985 Q_UNUSED(it);
986 if(editingMode){
987 if(scene->selectedItems().count() > 1){
989 return;
990 }
991
993 return;
994 }
995
996 QList<int> selectedModules;
997 foreach (QGraphicsItem *item , scene->selectedItems()) {
998
999 if(item->type() == QGraphicsItem::UserType + (int)ModuleItemType){
1000 auto* mod = (ModuleItem*)item;
1001 selectedModules.append(mod->getId());
1002 }
1003 }
1004 emit setModuleSelected(selectedModules);
1005}
1006
1007void BuilderWindow::onApplicationSelected(QGraphicsItem* it)
1008{
1009 if(!editingMode){
1010 return;
1011 }
1012 propertiesTab->showApplicationTab(((ApplicationItem*)it)->getInnerApplication());
1013}
1014
1015void BuilderWindow::initApplicationTab()
1016{
1017 if(!editingMode){
1018 return;
1019 }
1020
1022
1023
1024}
1025
1026void BuilderWindow::initModuleTab(ModuleItem *it)
1027{
1028// propertiesTab->clear();
1029// propertiesTab->addTab(moduleProperties,"Module Properties");
1030// propertiesTab->addTab(moduleDescription,"Description");
1031// moduleProperties->clear();
1032// moduleDescription->clear();
1033
1034// QTreeWidgetItem *modName = new QTreeWidgetItem(moduleProperties,QStringList() << "Name" << it->getInnerModule()->getName());
1035// QTreeWidgetItem *modNode = new QTreeWidgetItem(moduleProperties,QStringList() << "Node" << it->getInnerModule()->getHost());
1036// QTreeWidgetItem *modStdio = new QTreeWidgetItem(moduleProperties,QStringList() << "Stdio" << it->getInnerModule()->getStdio());
1037// QTreeWidgetItem *modWorkDir = new QTreeWidgetItem(moduleProperties,QStringList() << "Workdir" << it->getInnerModule()->getWorkDir());
1038// QTreeWidgetItem *modPrefix = new QTreeWidgetItem(moduleProperties,QStringList() << "Prefix" << it->getInnerModule()->getPrefix());
1039// QTreeWidgetItem *modDeployer = new QTreeWidgetItem(moduleProperties,QStringList() << "Deployer");
1040// QTreeWidgetItem *modParams = new QTreeWidgetItem(moduleProperties,QStringList() << "Parameters" << it->getInnerModule()->getParam());
1041
1042// modNode->setFlags(modNode->flags() | Qt::ItemIsEditable);
1043// modStdio->setFlags(modStdio->flags() | Qt::ItemIsEditable);
1044
1045// moduleProperties->addTopLevelItem(modName);
1046// moduleProperties->addTopLevelItem(modNode);
1047// moduleProperties->addTopLevelItem(modStdio);
1048// moduleProperties->addTopLevelItem(modWorkDir);
1049// moduleProperties->addTopLevelItem(modPrefix);
1050// moduleProperties->addTopLevelItem(modDeployer);
1051// moduleProperties->addTopLevelItem(modParams);
1052
1053
1054// QTreeWidgetItem *nameItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Name" << it->getInnerModule()->getName());
1055// QTreeWidgetItem *versionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Version" << it->getInnerModule()->getVersion());
1056// QTreeWidgetItem *descriptionItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Description" << it->getInnerModule()->getDescription());
1057// QTreeWidgetItem *parametersItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Parameters");
1058// for(int i=0;i<it->getInnerModule()->argumentCount();i++){
1059// Argument a = it->getInnerModule()->getArgumentAt(i);
1060// QTreeWidgetItem *it = new QTreeWidgetItem(parametersItem,QStringList() << a.getParam() << a.getDescription());
1061// Q_UNUSED(it);
1062// }
1063
1064// QTreeWidgetItem *authorsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Authors" << it->getInnerModule()->getName());
1065// for(int i=0;i<it->getInnerModule()->authorCount();i++){
1066// Author a = it->getInnerModule()->getAuthorAt(i);
1067// QTreeWidgetItem *it = new QTreeWidgetItem(authorsItem,QStringList() << a.getName() << a.getEmail());
1068// Q_UNUSED(it);
1069// }
1070
1071// QTreeWidgetItem *inputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Inputs" << it->getInnerModule()->getName());
1072// for(int i=0;i<it->getInnerModule()->inputCount();i++){
1073// InputData a = it->getInnerModule()->getInputAt(i);
1074
1075// QTreeWidgetItem *type = new QTreeWidgetItem(inputsItem,QStringList() << "Type" << a.getName());
1076// QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort());
1077// QTreeWidgetItem *desc = new QTreeWidgetItem(type,QStringList() << "Description" << a.getDescription());
1078// QTreeWidgetItem *req = new QTreeWidgetItem(type,QStringList() << "Required" << (a.isRequired() ? "yes" : "no"));
1079// Q_UNUSED(port);
1080// Q_UNUSED(desc);
1081// Q_UNUSED(req);
1082// }
1083
1084// QTreeWidgetItem *outputsItem = new QTreeWidgetItem(moduleDescription,QStringList() << "Outputs" << it->getInnerModule()->getName());
1085// for(int i=0;i<it->getInnerModule()->outputCount();i++){
1086// OutputData a = it->getInnerModule()->getOutputAt(i); //TODO controllare
1087
1088// QTreeWidgetItem *type = new QTreeWidgetItem(outputsItem,QStringList() << "Type" << a.getName());
1089// QTreeWidgetItem *port = new QTreeWidgetItem(type,QStringList() << "Port" << a.getPort());
1090// QTreeWidgetItem *desc = new QTreeWidgetItem(type,QStringList() << "Description" << a.getDescription());
1091// Q_UNUSED(port);
1092// Q_UNUSED(desc);
1093// }
1094
1095// moduleDescription->addTopLevelItem(nameItem);
1096// moduleDescription->addTopLevelItem(versionItem);
1097// moduleDescription->addTopLevelItem(descriptionItem);
1098// moduleDescription->addTopLevelItem(parametersItem);
1099// moduleDescription->addTopLevelItem(authorsItem);
1100// moduleDescription->addTopLevelItem(inputsItem);
1101// moduleDescription->addTopLevelItem(outputsItem);
1102}
1103
1104void BuilderWindow::onRestoreZoom()
1105{
1106 //view->resetMatrix();
1107 QRectF rr = itemsBoundingRect();
1108 view->fitInView(rr,Qt::KeepAspectRatio);
1109}
1110
1111void BuilderWindow::onZoomIn()
1112{
1113 view->scale(1.1,1.1);
1114}
1115
1116void BuilderWindow::onZoomOut()
1117{
1118 view->scale(0.9,0.9);
1119}
1120
1121void BuilderWindow::onSnap(bool checked)
1122{
1123 scene->snapToGrid(checked);
1124}
1125
1126void BuilderWindow::onShowGrid(bool checked)
1127{
1128 if(checked){
1129 scene->setBackgroundBrush(QPixmap(":/images/background2.png"));
1130 }else{
1131 scene->setBackgroundBrush(QBrush(QColor("#f8f8ff")));
1132 }
1133}
1134
1135void BuilderWindow::findInputOutputData(Connection& cnn, ModulePContainer &modules,
1136 InputData* &input_, OutputData* &output_, QString *inModulePrefix,QString *outModulePrefix)
1137{
1138 input_ = nullptr;
1139 output_ = nullptr;
1140 std::string strTo = cnn.to();
1141 std::string strFrom = cnn.from();
1142 qDebug() << "CONNECTION FROM " << strFrom.data() << " TO " << strTo.data();
1143
1144 ModulePIterator itr;
1145 for(itr=modules.begin(); itr!=modules.end(); itr++)
1146 {
1147 Module* module = (*itr);
1148 for(int i=0; i<module->inputCount(); i++)
1149 {
1150 InputData &input = module->getInputAt(i);
1151 std::string strInput = std::string(module->getPrefix()) + std::string(input.getPort());
1152 if(strTo == strInput)
1153 {
1154 input_ = &input;
1155 *inModulePrefix = QString("%1").arg(module->getPrefix());
1156 break;
1157 }
1158 }
1159
1160 for(int i=0; i<module->outputCount(); i++)
1161 {
1162 OutputData &output = module->getOutputAt(i);
1163 std::string strOutput = std::string(module->getPrefix()) + std::string(output.getPort());
1164 if(strFrom == strOutput)
1165 {
1166 output_ = &output;
1167 *outModulePrefix = QString("%1").arg(module->getPrefix());
1168 break;
1169 }
1170 }
1171 }
1172}
1173
1174PortItem* BuilderWindow::findModelFromOutput(OutputData* output,QString modulePrefix)
1175{
1176 for(int i=0; i<scene->items().count(); i++)
1177 {
1178 QGraphicsItem *it = scene->items().at(i);
1179 if(it->type() == (QGraphicsItem::UserType + (int)ApplicationItemType)){
1180 auto* application = (ApplicationItem*)it;
1181 for(int j=0; j<application->getModulesList().count(); j++){
1182 if(application->getModulesList().at(j)->type() == QGraphicsItem::UserType + ModuleItemType){
1183 ModuleItem *module = (ModuleItem*)application->getModulesList().at(j);
1184 for(int k=0;k<module->oPorts.count();k++){
1185 PortItem *port = module->oPorts.at(k);
1186 //QString prefix = QString("%1%2").arg(application->getInnerApplication()->getPrefix()).arg(module->getInnerModule()->getBasePrefix());
1187 //if(!strcmp(port->outData.getPort(), (*output).getPort()) && modulePrefix == prefix) {
1188 if(port->outData == output){
1189 return port;
1190 }
1191 }
1192 }
1193 }
1194
1195 }
1196
1197 if(it->type() == (QGraphicsItem::UserType + (int)ModuleItemType)){
1198 auto* module = (ModuleItem*)it;
1199 for(int k=0;k<module->oPorts.count();k++){
1200 PortItem *port = module->oPorts.at(k);
1201 //if(!strcmp(port->outData.getPort(), (*output).getPort()) && modulePrefix == QString("%1").arg(module->getInnerModule()->getPrefix())) {
1202 if(port->outData == output){
1203 return port;
1204 }
1205 }
1206
1207 }
1208 }
1209
1210
1211 return nullptr;
1212}
1213
1214PortItem* BuilderWindow::findModelFromInput(InputData* input,QString modulePrefix)
1215{
1216 for(int i=0; i<scene->items().count(); i++)
1217 {
1218 QGraphicsItem *it = scene->items().at(i);
1219
1220 if(it->type() == (QGraphicsItem::UserType + (int)ApplicationItemType)){
1221 auto* application = (ApplicationItem*)it;
1222 for(int j=0;j<application->getModulesList().count();j++){
1223 if(application->getModulesList().at(j)->type() == QGraphicsItem::UserType + ModuleItemType){
1224 ModuleItem *module = (ModuleItem*)application->getModulesList().at(j);
1225 for(int k=0;k<module->iPorts.count();k++){
1226 PortItem *port = module->iPorts.at(k);
1227 //QString prefix = QString("%1%2").arg(application->getInnerApplication()->getPrefix()).arg(module->getInnerModule()->getBasePrefix());
1228 //if(!strcmp(port->inData.getPort(),(*input).getPort()) && modulePrefix == prefix) {
1229 if(port->inData == input){
1230 return port;
1231 }
1232 }
1233 }
1234 }
1235
1236 }
1237
1238 if(it->type() == (QGraphicsItem::UserType + (int)ModuleItemType)){
1239 auto* module = (ModuleItem*)it;
1240 for(int k=0;k<module->iPorts.count();k++){
1241 PortItem *port = module->iPorts.at(k);
1242 //if(!strcmp(port->inData.getPort(),(*input).getPort()) && modulePrefix == QString("%1").arg(module->getInnerModule()->getPrefix())){
1243 if(port->inData == input){
1244 return port;
1245 }
1246 }
1247
1248 }
1249 }
1250
1251
1252 return nullptr;
1253}
1254
1255
1256
1257
1258void BuilderWindow::setOutputPortAvailable(QString oData, bool available)
1259{
1260 foreach (QGraphicsItem *it, scene->items()) {
1261
1262 if(it->type() == QGraphicsItem::UserType + ModuleItemType){
1263 auto* mod = (ModuleItem*)it;
1264
1265 foreach (PortItem *oPort, mod->oPorts) {
1266 QString strPort = QString("%1%2").arg(mod->getInnerModule()->getPrefix()).arg(oPort->outData->getPort());
1267
1268 if(strPort == oData ){
1270 }
1271 }
1272
1273
1274 }else
1275 if(it->type() == QGraphicsItem::UserType + ApplicationItemType){
1276 auto* app = (ApplicationItem*)it;
1277 app->setOutputPortAvailable(oData, available);
1278 }else
1279 if(it->type() == QGraphicsItem::UserType + SourcePortItemType){
1280 auto* source = (SourcePortItem*)it;
1281
1282 QString strPort = QString("%1").arg(source->getItemName());
1283 if(strPort == oData){
1284 source->setAvailable(available);
1285 }
1286
1287 }
1288 }
1289}
1290
1291void BuilderWindow::setInputPortAvailable(QString iData, bool available)
1292{
1293
1294
1295 foreach (QGraphicsItem *it, scene->items()) {
1296 if(it->type() == QGraphicsItem::UserType + ModuleItemType){
1297 auto* mod = (ModuleItem*)it;
1298
1299 foreach (PortItem *iPort, mod->iPorts) {
1300 QString strPort = QString("%1%2").arg(mod->getInnerModule()->getPrefix()).arg(iPort->inData->getPort());
1301 if(strPort == iData){
1303 }
1304 }
1305
1306
1307 }else
1308 if(it->type() == QGraphicsItem::UserType + ApplicationItemType){
1309 auto* app = (ApplicationItem*)it;
1310 app->setInputPortAvailable(iData,available);
1311 }
1312 else{
1313 if(it->type() == QGraphicsItem::UserType + DestinationPortItemType){
1314 auto* dest = (DestinationPortItem*)it;
1315
1316 QString strPort = QString("%1").arg(dest->getItemName());
1317 if(strPort == iData){
1318 dest->setAvailable(available);
1319 }
1320 }
1321 }
1322 }
1323}
1324
1325/**********************************************************************************/
1326/**********************************************************************************/
1327/**********************************************************************************/
1328/**********************************************************************************/
1329
1330CustomView::CustomView(BuilderWindow *builder,QGraphicsView *parent) :
1331 QGraphicsView(parent),
1332 builder(builder),
1333 editingMode(false),
1334 m_rubberBandActive(false),
1335 mousepressed(false),
1336 rubberBand(nullptr)
1337{
1338 setInteractive(true);
1339
1340// QGLWidget *viewport = new QGLWidget(QGLFormat(QGL::SampleBuffers));
1341// setViewport(viewport);
1342
1343 setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
1344 setDragMode(QGraphicsView::RubberBandDrag);
1345 setOptimizationFlags(QGraphicsView::DontSavePainterState |QGraphicsView::DontAdjustForAntialiasing);
1346 setViewportUpdateMode(/*QGraphicsView::FullViewportUpdate*/QGraphicsView::BoundingRectViewportUpdate);
1347 setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
1348
1349}
1350
1352{
1353 editingMode = editing;
1354 if(scene()){
1355 ((BuilderScene*)scene())->editingMode = editingMode;
1356 }
1357}
1358
1360{
1361 return editingMode;
1362}
1363
1364
1365void CustomView::wheelEvent(QWheelEvent *event){
1366 if(event->modifiers() == Qt::CTRL){
1367 if(event->angleDelta().y() > 0){
1368 scale(1.1,1.1);
1369 }else{
1370 scale(0.9,0.9);
1371 }
1372
1373 return;
1374 }
1375 QGraphicsView::wheelEvent(event);
1376}
1377
1378void CustomView::keyPressEvent(QKeyEvent *event){
1379 if(event->key() == Qt::Key_A && event->modifiers() == Qt::CTRL){
1380 foreach (QGraphicsItem *it, items()) {
1381 it->setSelected(true);
1382 }
1383 }
1384 if(editingMode && event->key() == Qt::Key_Delete){
1386 QGraphicsView::keyPressEvent(event);
1387 return;
1388 }
1389 if(editingMode && event->key() == Qt::Key_C && event->modifiers() == Qt::CTRL){
1390 QGraphicsView::keyPressEvent(event);
1392 return;
1393 }
1394 if(editingMode && event->key() == Qt::Key_V && event->modifiers() == Qt::CTRL){
1395 QGraphicsView::keyPressEvent(event);
1396 pasteSelectedItems(QPoint());
1397 return;
1398 }
1399 QGraphicsView::keyPressEvent(event);
1400}
1401
1402void CustomView::mouseReleaseEvent(QMouseEvent* event)
1403{
1404
1405 QGraphicsView::mouseReleaseEvent(event);
1406}
1407
1408void CustomView::mousePressEvent(QMouseEvent* event)
1409{
1410
1411 if(event->button()==Qt::LeftButton){
1412 if(event->modifiers()==Qt::ControlModifier){
1413 setDragMode(QGraphicsView::ScrollHandDrag);
1414
1415 QGraphicsView::mousePressEvent(event);
1416 return;
1417 }else{
1418 if(itemAt(event->pos()) == nullptr){
1419 setDragMode(QGraphicsView::RubberBandDrag);
1420 emit pressedNullItem();
1421 QGraphicsView::mousePressEvent(event);
1422 return;
1423 }else{
1424 setDragMode(QGraphicsView::NoDrag);
1425 QGraphicsView::mousePressEvent(event);
1426 return;
1427 }
1428 }
1429 }
1430
1431 setDragMode(QGraphicsView::NoDrag);
1432 QGraphicsView::mousePressEvent(event);
1433
1434}
1435
1436void CustomView::contextMenuEvent(QContextMenuEvent *event)
1437{
1438
1439 QMenu menu(this);
1440 QGraphicsItem *it = itemAt(event->pos());
1441 QAction *copyAction = nullptr;
1442 QAction *pasteAction = nullptr;
1443 QAction *deleteAction = nullptr;
1444
1445 if(editingMode){
1446 if(!it){
1447 QAction *addSourcePortAction = menu.addAction("Add Source Port");
1448 QAction *addDestinationPortAction = menu.addAction("Add Destination Port");
1449 menu.addSeparator();
1450 pasteAction = menu.addAction("Paste");
1451
1452 if(!copiedItems.isEmpty()){
1453 pasteAction->setEnabled(true);
1454 }else{
1455 pasteAction->setEnabled(false);
1456 }
1457
1458
1459 QAction *act = menu.exec(event->globalPos());
1460 if(act == addSourcePortAction){
1461 emit addSourcePort("Source",mapToScene(event->pos()));
1462 }
1463 if(act == addDestinationPortAction){
1464 emit addDestinationPort("Destination",mapToScene(event->pos()));
1465 }
1466 if(act == pasteAction){
1467 pasteSelectedItems(event->pos());
1468 }
1469 QGraphicsView::contextMenuEvent(event);
1470 return;
1471 }
1472
1473 if(!((BuilderItem*)it)->isNestedInApp() && it->type() != QGraphicsItem::UserType + ApplicationItemType){
1474 copyAction = menu.addAction("Copy");
1475 pasteAction = menu.addAction("Paste");
1476 deleteAction = menu.addAction("Delete");
1477
1478 menu.addSeparator();
1479
1480 if(!copiedItems.isEmpty()){
1481 pasteAction->setEnabled(true);
1482 }else{
1483 pasteAction->setEnabled(false);
1484 }
1485 if(it->type() == QGraphicsItem::UserType + ConnectionItemType){
1486 copyAction->setEnabled(false);
1487 pasteAction->setEnabled(false);
1488 }
1489 }
1490
1491
1492
1493 }else{
1494 if(it){
1495 if(it->type() == QGraphicsItem::UserType + ModuleItemType ||
1496 it->type() == QGraphicsItem::UserType + ConnectionItemType){
1497 auto* bItem = (BuilderItem*)it;
1498
1499 foreach(QAction *act, bItem->getActions()){
1500 menu.addAction(act);
1501 }
1502 }
1503 }else{
1504 foreach(QAction *act, builder->builderActions){
1505 menu.addAction(act);
1506 }
1507 }
1508
1509
1510 }
1511
1512
1513
1514
1515
1516 if(menu.isEmpty()){
1517 QGraphicsView::contextMenuEvent(event);
1518 return;
1519 }
1520
1521 QAction *act = menu.exec(event->globalPos());
1522 if(!act){
1523 QGraphicsView::contextMenuEvent(event);
1524 return;
1525 }
1526
1527 if(act == deleteAction){
1528 if(it && it->type() == QGraphicsItem::UserType + (int)HandleItemType){
1530 }else{
1532 }
1533 }
1534 if(act == copyAction){
1536 }
1537 if(act == pasteAction){
1538 pasteSelectedItems(event->pos());
1539 }
1540
1541 update();
1542 QGraphicsView::contextMenuEvent(event);
1543
1544}
1545
1546
1548 QList <QGraphicsItem*>selectedItems;
1549
1550
1551 qDebug() << "Left Items in scene " << items().count();
1552 foreach (QGraphicsItem* item, items()) {
1553 if(item->type() != QGraphicsItem::UserType + (int)ModulePortItemType &&
1554 item->type() != QGraphicsItem::UserType + (int)ArrowLabelItemType &&
1555 item->type() != QGraphicsItem::UserType + (int)HandleItemType &&
1556 item->parentItem() == nullptr){
1557 selectedItems.append(item);
1558 }
1559 }
1560 foreach (QGraphicsItem* item, selectedItems) {
1561
1562 if(item->type() == QGraphicsItem::UserType + (int)ConnectionItemType){
1563 if(selectedItems.removeOne(item)){
1564 //builder->itemsList.removeOne(item);
1565 delete item;
1566 }
1567 }
1568
1569 }
1570
1571 foreach (QGraphicsItem* item, selectedItems) {
1572 if(item->type() == QGraphicsItem::UserType + (int)ModuleItemType ||
1573 item->type() == QGraphicsItem::UserType + (int)SourcePortItemType ||
1574 item->type() == QGraphicsItem::UserType + (int)DestinationPortItemType ||
1575 item->type() == QGraphicsItem::UserType + (int)ApplicationItemType){
1576 if(selectedItems.removeOne(item)){
1577 //builder->itemsList.removeOne(item);
1578 delete item;
1579 }
1580 }
1581 }
1582 emit modified();
1583}
1584
1585
1586void CustomView::deleteSelectedItems(QGraphicsItem *it){
1587 copiedItems.clear();
1588 QList <QGraphicsItem*>selectedItems;
1589 //bool deleteOnlyHandle = false;
1590 if(it && it->type() == QGraphicsItem::UserType + (int)HandleItemType){
1591 //deleteOnlyHandle = true;
1592 auto* arrow = (Arrow*)it->parentItem();
1593 arrow->removeHandle((LineHandle*)it);
1594 delete it;
1595 return;
1596 }
1597
1598 foreach (QGraphicsItem* item, items()) {
1599 if(item->isSelected() &&
1600 item->type() != QGraphicsItem::UserType + (int)ModulePortItemType &&
1601 item->type() != QGraphicsItem::UserType + (int)ArrowLabelItemType &&
1602 item->type() != QGraphicsItem::UserType + (int)HandleItemType &&
1603 item->parentItem() == nullptr){
1604 selectedItems.append(item);
1605 }
1606 }
1607
1608// foreach (QGraphicsItem* item, selectedItems) {
1609// if(item->type() == QGraphicsItem::UserType + (int)HandleItemType){
1610// selectedItems.removeOne(item);
1611// //builder->itemsList.removeOne(item);
1612// delete item;
1613// }
1614
1615// }
1616
1617// if(deleteOnlyHandle){
1618// return;
1619// }
1620
1621 foreach (QGraphicsItem* item, selectedItems) {
1622
1623 if(item->type() == QGraphicsItem::UserType + (int)ConnectionItemType){
1624 if(selectedItems.removeOne(item)){
1625 //builder->itemsList.removeOne(item);
1626 // scene()->removeItem(item);
1627 delete item;
1628 }
1629 }
1630
1631 }
1632
1633 foreach (QGraphicsItem* item, selectedItems) {
1634 if(item->type() == QGraphicsItem::UserType + (int)ModuleItemType ||
1635 item->type() == QGraphicsItem::UserType + (int)SourcePortItemType ||
1636 item->type() == QGraphicsItem::UserType + (int)DestinationPortItemType ||
1637 item->type() == QGraphicsItem::UserType + (int)ApplicationItemType){
1638 if(selectedItems.removeOne(item)){
1639 //builder->itemsList.removeOne(item);
1640 //scene()->removeItem(item);
1641 delete item;
1642 }
1643
1644 }
1645
1646 }
1647 emit modified();
1648}
1649
1651 copiedItems.clear();
1652
1653 foreach (QGraphicsItem* item, items()) {
1654 if(item->isSelected()){
1655 if(item->type() == QGraphicsItem::UserType + (int)SourcePortItemType ||
1656 item->type() == QGraphicsItem::UserType + (int)DestinationPortItemType ||
1657 item->type() == QGraphicsItem::UserType + (int)ModuleItemType ||
1658 item->type() == QGraphicsItem::UserType + (int)ConnectionItemType){
1659
1660 copiedItems.append(item);
1661 }
1662 }
1663 }
1664}
1665
1667
1668 foreach (QGraphicsItem* item, items()) {
1669 item->setSelected(false);
1670 }
1671
1672 bool firstAdded = true;
1673 QSize offset;
1674
1675 QMap <QGraphicsItem*,QGraphicsItem*> pastedItems;
1676 QList <QGraphicsItem*> itemsToRemove;
1677 foreach (QGraphicsItem* item, copiedItems) {
1678 if(item->type() == QGraphicsItem::UserType + (int)ConnectionItemType){
1679 Arrow *arrow = ((Arrow*)item);
1680 BuilderItem *startItem = arrow->startItem();
1681 BuilderItem *endItem = arrow->endItem();
1682
1683 BuilderItem *copiedStartItem = nullptr;
1684 BuilderItem *copiedEndItem = nullptr;
1685
1686 PortItem *startPort = nullptr;
1687 PortItem *endPort = nullptr;
1688
1689 if(startItem->type() == QGraphicsItem::UserType + (int)ModulePortItemType){
1690 startPort = (PortItem*)startItem;
1691 startItem = (ModuleItem *)startPort->parentItem();
1692 }
1693
1694 if(endItem->type() == QGraphicsItem::UserType + (int)ModulePortItemType){
1695 endPort = (PortItem*)endItem;
1696 endItem = (ModuleItem *)endPort->parentItem();
1697 }
1698
1699 for(int i=0;i<itemsToRemove.count();i++){
1700 if(itemsToRemove.at(i) == startItem){
1701 copiedStartItem = (BuilderItem*)pastedItems.value(startItem);
1702 }
1703 if(itemsToRemove.at(i) == endItem){
1704 copiedEndItem = (BuilderItem*)pastedItems.value(endItem);
1705 }
1706 }
1707
1708 bool startContained = false;
1709 bool endContained = false;
1710 for(int i=0;i<copiedItems.count();i++){
1711 if(copiedItems.at(i) == startItem){
1712 startContained = true;
1713 }
1714 if(copiedItems.at(i) == endItem){
1715 endContained = true;
1716 }
1717 }
1718
1719
1720
1721 if(startContained && endContained){
1722
1723 BuilderItem *startConnection = nullptr;
1724 BuilderItem *endConnection = nullptr;
1725
1726 if(startItem->type() == QGraphicsItem::UserType + (int)ModuleItemType){
1727 // Start is a Port Module
1728 if(!copiedStartItem){
1729 copiedStartItem = pasteItem(startItem,&offset,&firstAdded,pos);
1730 itemsToRemove.append(startItem);
1731 pastedItems.insert(startItem,copiedStartItem);
1732 }
1733
1734 int portIndex = ((ModuleItem *)startItem)->oPorts.indexOf(startPort);
1735 PortItem *newPort = ((ModuleItem *)copiedStartItem)->oPorts.at(portIndex);
1736 startConnection = newPort;
1737
1738
1739
1740 }else{
1741 if(!copiedStartItem){
1742 copiedStartItem = pasteItem(startItem,&offset,&firstAdded,pos);
1743 itemsToRemove.append(startItem);
1744 pastedItems.insert(startItem,copiedStartItem);
1745 }
1746 startConnection = copiedStartItem;
1747
1748 }
1749
1750 if(endItem->type() == QGraphicsItem::UserType + (int)ModuleItemType){
1751 // Destination is a Port Module
1752 if(!copiedEndItem){
1753 copiedEndItem = pasteItem(endItem,&offset,&firstAdded,pos);
1754 itemsToRemove.append(endItem);
1755 pastedItems.insert(endItem,copiedEndItem);
1756 }
1757
1758
1759 int portIndex = ((ModuleItem *)endItem)->iPorts.indexOf(endPort);
1760 PortItem *newPort = ((ModuleItem *)copiedEndItem)->iPorts.at(portIndex);
1761 endConnection = newPort;
1762
1763
1764 }else{
1765 if(!copiedEndItem){
1766 copiedEndItem = pasteItem(endItem,&offset,&firstAdded,pos);
1767 itemsToRemove.append(endItem);
1768 pastedItems.insert(endItem,copiedEndItem);
1769 }
1770 endConnection = copiedEndItem;
1771
1772 }
1773
1774
1775 if(startConnection && endConnection){
1776 builder->onAddNewConnection(startConnection,endConnection);
1777 }
1778
1779 itemsToRemove.append(item);
1780
1781 }
1782 }
1783 }
1784
1785
1786
1787
1788 while(!itemsToRemove.isEmpty()) {
1789 //item->setSelected(false);
1790 copiedItems.removeOne(itemsToRemove.takeLast());
1791 }
1792
1793
1794 foreach (QGraphicsItem* item, copiedItems) {
1795 pasteItem(item,&offset,&firstAdded,pos);
1796 }
1797
1798
1799 hide();
1800 show();
1801
1802}
1803
1804
1805BuilderItem *CustomView::pasteItem(QGraphicsItem *item, QSize *offset, bool *firstAdded,QPoint pos)
1806{
1807 BuilderItem *ret = nullptr;
1808 ModuleItem *mod = nullptr;
1809 SourcePortItem *sPort = nullptr;
1810 DestinationPortItem *dPort = nullptr;
1811 switch (item->type()) {
1812 case QGraphicsItem::UserType + (int)SourcePortItemType:
1813 sPort = ((SourcePortItem*)item);
1814 if(pos.isNull()){
1815 ret = builder->onAddSourcePort(QString("%1_copy").arg(sPort->getItemName().toLatin1().data()),
1816 QPointF(sPort->pos().x() + 20, sPort->pos().y() + 20));
1817 }else{
1818 if(copiedItems.count() <= 1){
1819 ret = builder->onAddSourcePort(QString("%1_copy").arg(sPort->getItemName().toLatin1().data()),
1820 QPointF(mapToScene(pos).x(), mapToScene(pos).y()));
1821 }else{
1822 if(*firstAdded){
1823 ret = builder->onAddSourcePort(QString("%1_copy").arg(sPort->getItemName().toLatin1().data()),
1824 QPointF(mapToScene(pos).x(), mapToScene(pos).y()));
1825 *offset = QSize(mapToScene(pos).x() - sPort->pos().x(), mapToScene(pos).y() - sPort->pos().y());
1826 }else{
1827 ret = builder->onAddSourcePort(QString("%1_copy").arg(sPort->getItemName().toLatin1().data()),
1828 QPointF(offset->width() + sPort->pos().x(), offset->height() + sPort->pos().y()));
1829 }
1830
1831 }
1832 }
1833 break;
1834 case QGraphicsItem::UserType + (int)DestinationPortItemType:
1835 dPort = ((DestinationPortItem*)item);
1836 if(pos.isNull()){
1837 ret = builder->onAddDestinationPort(QString("%1_copy").arg(dPort->getItemName().toLatin1().data()),
1838 QPointF(dPort->pos().x() + 20, dPort->pos().y() + 20));
1839 }else{
1840 if(copiedItems.count() <= 1){
1841 ret = builder->onAddDestinationPort(QString("%1_copy").arg(dPort->getItemName().toLatin1().data()),
1842 QPointF(mapToScene(pos).x(), mapToScene(pos).y()));
1843 }else{
1844 if(*firstAdded){
1845 ret = builder->onAddDestinationPort(QString("%1_copy").arg(dPort->getItemName().toLatin1().data()),
1846 QPointF(mapToScene(pos).x(), mapToScene(pos).y()));
1847 *offset = QSize(mapToScene(pos).x() - dPort->pos().x(), mapToScene(pos).y() - dPort->pos().y());
1848 }else{
1849 ret = builder->onAddDestinationPort(QString("%1_copy").arg(dPort->getItemName().toLatin1().data()),
1850 QPointF(offset->width() + dPort->pos().x(), offset->height() + dPort->pos().y()));
1851 }
1852
1853 }
1854 }
1855 break;
1856 case QGraphicsItem::UserType + (int)ModuleItemType:
1857 mod = ((ModuleItem*)item);
1858 if(pos.isNull()){
1859 ret = builder->onAddModule(mod->getInnerModule(),QPointF(mod->pos().x() + 20, mod->pos().y() + 20));
1860 }else{
1861 if(copiedItems.count() <= 1){
1862 ret = builder->onAddModule(mod->getInnerModule(),QPointF(mapToScene(pos).x(), mapToScene(pos).y()));
1863 }else{
1864 if(*firstAdded){
1865 ret = builder->onAddModule(mod->getInnerModule(),QPointF(mapToScene(pos).x(), mapToScene(pos).y()));
1866 *offset = QSize(mapToScene(pos).x() - mod->pos().x(), mapToScene(pos).y() - mod->pos().y());
1867 }else{
1868 ret = builder->onAddModule(mod->getInnerModule(),QPointF(offset->width() + mod->pos().x(), offset->height() + mod->pos().y()));
1869 }
1870
1871 }
1872
1873 }
1874 break;
1875 default:
1876 break;
1877 }
1878
1879
1880 *firstAdded = false;
1881 return ret;
1882}
bool ret
int SIGNAL(int pid, int signum)
void setModuleRunning(bool, int)
void setConnectionConnected(bool connected, QString from, QString to)
Definition arrow.h:106
BuilderItem * startItem() const
Definition arrow.h:132
QString getFrom()
Definition arrow.cpp:278
QString getTo()
Definition arrow.cpp:283
BuilderItem * endItem() const
Definition arrow.h:133
void setConnected(bool)
Definition arrow.cpp:288
QRectF boundingRect() const override=0
QString getItemName()
void snapToGrid(bool snap)
ItemSignalHandler * signalHandler()
void setActions(QList< QAction * >)
int type() const override=0
void snapToGrid(bool snap)
void setSelectedConnections(QList< int >selectedIds)
QList< QAction * > modulesAction
void load(bool refresh=false)
void addModulesAction(QAction *)
QSplitter * splitter
Application * app
BuilderItem * addConnection(void *startItem, void *endItem, int connectionId)
BuilderScene * scene
BuilderWindow(Application *app, Manager *lazyManager, SafeManager *safeManager, bool editingMode=false, QWidget *parent=0)
SafeManager * safeManager
QList< QAction * > connectionsAction
QRectF itemsBoundingRect()
QList< int > usedModulesId
void setConnectionSelected(QList< int >)
friend class CustomView
CustomView * view
QString getAppName()
void setFileName(QString filename)
void setInputPortAvailable(QString, bool)
ApplicationItem * addApplication(Application *app, int *connectionsId=0)
Manager * lazyManager
QString getFileName()
void setConnectionConnected(bool, QString from, QString to)
void addAction(QAction *)
BuilderItem * addSourcePort(QString name, bool editOnStart=false)
QToolBar builderToolbar
void setAppName(QString appName)
void setModuleRunning(bool, int id)
BuilderItem * addModule(Module *module, int moduleId)
BuilderItem * addDestinantionPort(QString name, bool editOnStart=false)
void setOutputPortAvailable(QString, bool)
QToolBar * getToolBar()
QList< QAction * > builderActions
PropertiesTable * propertiesTab
void addConnectionsAction(QAction *)
void setModuleSelected(QList< int >)
void modified(bool)
void setSelectedModules(QList< int >selectedIds)
void wheelEvent(QWheelEvent *event) override
void modified()
void pressedNullItem()
void pasteSelectedItems(QPoint pos)
void keyPressEvent(QKeyEvent *event) override
void mouseReleaseEvent(QMouseEvent *event) override
CustomView(BuilderWindow *builder, QGraphicsView *parent=0)
bool getEditingMode()
void copySelectedItems()
void addDestinationPort(QString, QPointF pos)
void addSourcePort(QString, QPointF pos)
void setEditingMode(bool editing)
void deleteAllItems()
void contextMenuEvent(QContextMenuEvent *event) override
void mousePressEvent(QMouseEvent *event) override
void deleteSelectedItems(QGraphicsItem *it=NULL)
void setRunning(bool)
Module * getInnerModule()
OutputData * outData
Definition moduleitem.h:104
InputData * getInputData()
int getPortType()
InputData * inData
Definition moduleitem.h:105
void setAvailable(PortStatus)
@ unavailable
Definition moduleitem.h:92
OutputData * getOutputData()
void addModules(ModuleItem *)
void showApplicationTab(Application *application)
void showModuleTab(ModuleItem *it)
Class ApplicationInterface.
Class Application.
void setName(const char *szName)
const char * getBasePrefix()
void setXmlFile(const char *szFilename)
GraphicModel & getModelBase()
Class Connection.
Definition application.h:56
void setTo(const char *szTo)
Definition application.h:81
void setFromExternal(bool ext)
Definition application.h:83
void setCarrier(const char *szCr)
Definition application.h:82
GraphicModel & getModelBase()
void setToExternal(bool ext)
Definition application.h:84
void setPersistent(bool per)
Definition application.h:89
void setCorOutputData(OutputData *out)
void setModelBase(GraphicModel &mdl)
void setFrom(const char *szFrom)
Definition application.h:80
void setModel(GraphicModel *mdl)
void setCorInputData(InputData *in)
std::vector< GyPoint > points
Definition node.h:29
Class InputData.
Definition data.h:21
const char * getCarrier()
Definition data.h:38
const char * getPort()
Definition data.h:36
Class KnowledgeBase.
Definition kbase.h:32
Application * addIApplicationToApplication(Application *application, ApplicationInterface &app, bool isNew=false)
Definition kbase.cpp:661
const ModulePContainer & getModules(Application *parent=nullptr)
Definition kbase.cpp:217
const ModulePContainer & getSelModules()
Definition kbase.h:67
bool setModulePrefix(Module *module, const char *szPrefix, bool updateBasePrefix=true)
Definition kbase.cpp:467
bool addResource(GenericResource *resource)
Definition kbase.cpp:144
Connection & addConnectionToApplication(Application *application, Connection &cnn)
Definition kbase.cpp:562
Application * getApplication()
Definition kbase.h:84
bool addModule(Module *module)
Definition kbase.cpp:120
const ApplicaitonPContainer & getApplications(Application *parent=nullptr)
Definition kbase.cpp:188
const CnnContainer & getConnections(Application *parent=nullptr)
Definition kbase.cpp:246
const std::string getUniqueAppID(Application *parent, const char *szAppName)
Definition kbase.cpp:650
const ResourcePContainer & getResources(Application *parent=nullptr)
Definition kbase.cpp:261
bool addApplication(Application *application, char **szAppName_=nullptr, bool modifyName=false)
Definition kbase.cpp:76
Class Manager.
Definition manager.h:20
ExecutablePContainer & getExecutables()
Definition manager.h:82
bool loadApplication(const char *szAppName)
Definition manager.cpp:240
bool saveApplication(const char *szAppName, const char *fileName=nullptr)
Definition manager.cpp:266
KnowledgeBase * getKnowledgeBase()
Definition manager.h:103
Class ModuleInterface.
Class Module.
Definition module.h:99
GraphicModel & getModelBase()
Definition module.h:186
const char * getPrefix()
Definition module.h:140
const char * getCarrier()
Definition data.h:85
const char * getPort()
Definition data.h:83
#define INPUT_PORT
Definition commons.h:14
@ ApplicationItemType
Definition commons.h:17
@ ConnectionItemType
Definition commons.h:17
@ SourcePortItemType
Definition commons.h:17
@ ModulePortItemType
Definition commons.h:17
@ ModuleItemType
Definition commons.h:17
@ DestinationPortItemType
Definition commons.h:17
@ HandleItemType
Definition commons.h:17
@ ArrowLabelItemType
Definition commons.h:17
#define OUTPUT_PORT
Definition commons.h:15
std::vector< Application * >::iterator ApplicationPIterator
std::vector< Executable * >::iterator ExecutablePIterator
Definition executable.h:167
std::vector< Connection >::iterator CnnIterator
std::vector< Executable * > ExecutablePContainer
Definition executable.h:166
std::vector< Module * > ModulePContainer
Definition module.h:230
std::vector< GenericResource * > ResourcePContainer
Definition resource.h:58
std::vector< Application * > ApplicaitonPContainer
std::vector< Connection > CnnContainer
std::vector< Module * >::iterator ModulePIterator
Definition module.h:231