YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
mainwindow.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 "mainwindow.h"
7#include "ui_mainwindow.h"
8
9#include <yarp/conf/version.h>
11#include <yarp/os/Log.h>
13#include <dirent.h>
18
19#include "moduleviewwidget.h"
21#include "resourceviewwidget.h"
22#include "yarpbuilderlib.h"
23
24#include "template_res.h"
25#include "aboutdlg.h"
26
27#include <QGridLayout>
28#include <QMessageBox>
29#include <QFileDialog>
30#include <QDesktopServices>
31#include <QInputDialog>
32
33#include <QWizardPage>
34#include <QLabel>
35#include <QLineEdit>
36
37
38
39#if defined(_WIN32)
40# pragma warning (disable : 4250)
41# pragma warning (disable : 4520)
42#else
43# include <unistd.h>
44# include <cerrno>
45# include <csignal>
46# if defined(YARP_HAS_SYS_TYPES_H)
47# include <sys/types.h>
48# endif
49# if defined(YARP_HAS_SYS_WAIT_H)
50# include <sys/wait.h>
51# endif
52#endif
53
54#ifndef APP_NAME
55 #define APP_NAME "yarpmanager"
56#endif
57
58
59
60bool isAbsolute(const char *path) { //copied from yarp_OS ResourceFinder.cpp
61 if (path[0]=='/'||path[0]=='\\') {
62 return true;
63 }
64 std::string str(path);
65 if (str.length()>1) {
66 if (str[1]==':') {
67 return true;
68 }
69 }
70 return false;
71}
72
73MainWindow::MainWindow(QWidget *parent) :
74 QMainWindow(parent),
75 ui(new Ui::MainWindow)
76{
77 ui->setupUi(this);
78
79 qRegisterMetaType< QVector<int> >("QVector<int>");
80 ui->mainToolBar->setContextMenuPolicy(Qt::PreventContextMenu);
81 ui->menuBar->setContextMenuPolicy(Qt::PreventContextMenu);
82 auto label = new QLabel("", ui->statusBar);
83 auto yarpino = new QLabel("", ui->statusBar);
84 QPixmap pixmap(QPixmap(":/yarp-robot-22.png").scaledToHeight(ui->statusBar->height()));
85 yarpino->setPixmap(pixmap);
86 label->setText("Powered by");
87 ui->statusBar->insertPermanentWidget(0,label);
88 ui->statusBar->insertPermanentWidget(1,yarpino);
89 prevWidget = nullptr;
90
91 watcher = new QFileSystemWatcher(this);
92
93
94
95 connect(ui->entitiesTree,SIGNAL(viewResource(yarp::manager::Computer*)),this,SLOT(viewResource(yarp::manager::Computer*)));
96 connect(ui->entitiesTree,SIGNAL(viewModule(yarp::manager::Module*)),this,SLOT(viewModule(yarp::manager::Module*)));
97 connect(ui->entitiesTree,SIGNAL(viewApplication(yarp::manager::Application*,bool)),this,SLOT(viewApplication(yarp::manager::Application*,bool)));
98 connect(ui->entitiesTree,SIGNAL(openFiles()),this,SLOT(onOpen()));
99 connect(ui->entitiesTree,SIGNAL(importFiles()),this,SLOT(onImportFiles()));
100 connect(ui->entitiesTree,SIGNAL(removeApplication(QString, QString)),this,SLOT(onRemoveApplication(QString, QString)));
101 connect(ui->entitiesTree,SIGNAL(removeModule(QString)),this,SLOT(onRemoveModule(QString)));
102 connect(ui->entitiesTree,SIGNAL(removeResource(QString)),this,SLOT(onRemoveResource(QString)));
103 connect(ui->entitiesTree,SIGNAL(reopenApplication(QString,QString)),this,SLOT(onReopenApplication(QString,QString)),Qt::DirectConnection);
104 connect(ui->entitiesTree,SIGNAL(reopenModule(QString,QString)),this,SLOT(onReopenModule(QString,QString)),Qt::DirectConnection);
105 connect(ui->entitiesTree,SIGNAL(reopenResource(QString,QString)),this,SLOT(onReopenResource(QString,QString)),Qt::DirectConnection);
106
107 connect(ui->actionRun_all,SIGNAL(triggered()),this,SLOT(onRun()));
108 connect(ui->actionStop_all,SIGNAL(triggered()),this,SLOT(onStop()));
109 connect(ui->actionKill_all,SIGNAL(triggered()),this,SLOT(onKill()));
110 connect(ui->actionConnect_all,SIGNAL(triggered()),this,SLOT(onConnect()));
111 connect(ui->actionDisconnect_all,SIGNAL(triggered()),this,SLOT(onDisconnect()));
112
113 connect(ui->actionRun,SIGNAL(triggered()),this,SLOT(onRunSelected()));
114 connect(ui->actionStop,SIGNAL(triggered()),this,SLOT(onStopSelected()));
115 connect(ui->actionKill,SIGNAL(triggered()),this,SLOT(onKillSelected()));
116 connect(ui->actionConnect,SIGNAL(triggered()),this,SLOT(onConnectSelected()));
117 connect(ui->actionDisconnect,SIGNAL(triggered()),this,SLOT(onDisconnectSelected()));
118
119 connect(ui->actionRefresh_Status,SIGNAL(triggered()),this,SLOT(onRefresh()));
120 connect(ui->actionSelect_All,SIGNAL(triggered()),this,SLOT(onSelectAll()));
121 connect(ui->actionExport_Graph,SIGNAL(triggered()),this,SLOT(onExportGraph()));
122 connect(ui->actionNew_Application,SIGNAL(triggered()),this,SLOT(onNewApplication()));
123 connect(ui->actionImport_Files,SIGNAL(triggered()),this,SLOT(onImportFiles()));
124 connect(ui->mainTabs,SIGNAL(tabCloseRequested(int)),this,SLOT(onTabClose(int)));
125 connect(ui->mainTabs,SIGNAL(currentChanged(int)),this,SLOT(onTabChangeItem(int)));
126 connect(ui->actionNew_Module,SIGNAL(triggered()),this,SLOT(onNewModule()));
127 connect(ui->actionNew_Resource,SIGNAL(triggered()),this,SLOT(onNewResource()));
128 connect(ui->actionClose,SIGNAL(triggered()),this,SLOT(onClose()));
129 connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(close()));
130 connect(ui->actionOpen_File,SIGNAL(triggered()),this,SLOT(onOpen()));
131 connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(onSave()));
132 connect(ui->actionSave_As,SIGNAL(triggered()),this,SLOT(onSaveAs()));
133 connect(ui->actionHelp,SIGNAL(triggered()),this,SLOT(onHelp()));
134 connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(onAbout()));
135 connect(ui->actionYarpClean, SIGNAL(triggered()),this, SLOT(onYarpClean()));
136 connect(ui->actionYarpNameList, SIGNAL(triggered()),this, SLOT(onYarpNameList()));
137
138 connect(this,SIGNAL(selectItem(QString, bool)),ui->entitiesTree,SLOT(onSelectItem(QString, bool)));
139
140 connect(watcher, SIGNAL(fileChanged(const QString &)), this, SLOT(onFileChanged(const QString &)));
141
142 //Adding actions for making the window listen key events(shortcuts)
143 this->addAction(ui->actionQuit);
144 this->addAction(ui->actionSave);
145 this->addAction(ui->actionSave_As);
146 this->addAction(ui->actionClose);
147 this->addAction(ui->actionRefresh_Status);
148 onTabChangeItem(-1);
149
150 ui->actionConnect->setEnabled(false);
151 ui->actionDisconnect->setEnabled(false);
152 ui->actionRun->setEnabled(false);
153 ui->actionStop->setEnabled(false);
154 ui->actionKill->setEnabled(false);
155
156 ui->actionAuto_reload->setChecked(true);
157
158 ui->action_Manager_Window->setChecked(true);
159#ifdef WIN32
160 ui->tabWidgetLeft->tabBar()->hide();
161#else
163
164 std::string confFile = rf.findFileByName("cluster-config.xml");
165 if (!confFile.empty())
166 {
167 ui->clusterWidget->setConfigFile(confFile);
168 ui->clusterWidget->init();
169 connect(ui->clusterWidget, SIGNAL(logError(QString)), this, SLOT(onLogError(QString)));
170 connect(ui->clusterWidget, SIGNAL(logMessage(QString)), this, SLOT(onLogMessage(QString)));
171 }
172 else
173 {
174 ui->tabWidgetLeft->tabBar()->hide();
175 }
176#endif
177
178}
179
181{
182
183 delete ui;
184}
185void MainWindow::closeEvent(QCloseEvent *event)
186{
187 for(int i=0;i<ui->mainTabs->count();i++){
188 if(!onTabClose(i)){
189 event->ignore();
190 break;
191 }
192 }
193
194}
195
196void MainWindow::onWizardError(QString err)
197{
199 logger->addError(err.toLatin1().data());
200 reportErrors();
201}
202
208{
209 this->config = config;
210 const std::string directorySeparator{yarp::conf::filesystem::preferred_separator};
211
212 std::string basepath=config.check("ymanagerini_dir", yarp::os::Value("")).asString();
213
214 if(config.check("modpath")){
215 std::string strPath;
216 std::string modPaths(config.find("modpath").asString());
217 while (modPaths!=""){
218 std::string::size_type pos=modPaths.find(';');
219 strPath=modPaths.substr(0, pos);
221 if (!isAbsolute(strPath.c_str())) {
222 strPath.insert(0, basepath);
223 }
224 if ((strPath.rfind(directorySeparator) == std::string::npos) || (strPath.rfind(directorySeparator) != strPath.size() - 1)) {
225 strPath.append(directorySeparator);
226 }
227 lazyManager.addModules(strPath.c_str());
228 if (pos == std::string::npos || pos == 0) {
229 break;
230 }
231 modPaths=modPaths.substr(pos+1);
232 }
233 }
234
235 if(config.check("respath")){
236 std::string strPath;
237 std::string resPaths(config.find("respath").asString());
238 while (resPaths!=""){
239 std::string::size_type pos=resPaths.find(';');
240 strPath=resPaths.substr(0, pos);
242 if (!isAbsolute(strPath.c_str())) {
243 strPath.insert(0, basepath);
244 }
245
246 if ((strPath.rfind(directorySeparator) == std::string::npos) || (strPath.rfind(directorySeparator) != strPath.size() - 1)) {
247 strPath.append(directorySeparator);
248 }
249
250 lazyManager.addResources(strPath.c_str());
251 if (pos == std::string::npos) {
252 break;
253 }
254 resPaths=resPaths.substr(pos+1);
255 }
256 }
257
259
260
261 if(config.check("apppath")){
262 std::string strPath;
263 std::string appPaths(config.find("apppath").asString());
264 while (appPaths!=""){
265 std::string::size_type pos=appPaths.find(';');
266 strPath=appPaths.substr(0, pos);
268 if (!isAbsolute(strPath.c_str())){
269 strPath.insert(0, basepath);
270 }
271
272 if((strPath.rfind(directorySeparator)==std::string::npos) ||
273 (strPath.rfind(directorySeparator)!=strPath.size()-1)){
274 strPath.append(directorySeparator);
275 }
276
277 if(config.find("load_subfolders").asString() == "yes"){
278 if(!loadRecursiveApplications(strPath.c_str())){
279 logger->addError("Cannot load the applications from " + strPath);
280 }
281 loadRecursiveTemplates(strPath.c_str());
282 ui->entitiesTree->header()->setSortIndicator(0,Qt::SortOrder::AscendingOrder);
283 }
284 else{
285 lazyManager.addApplications(strPath.c_str());
286 }
287 if (pos==std::string::npos){
288 break;
289 }
290 appPaths=appPaths.substr(pos+1);
291 }
292 }
293
294 if (config.check("templpath")){
295 std::string strPath;
296 std::string templPaths(config.find("templpath").asString());
297 while (templPaths!=""){
298 std::string::size_type pos=templPaths.find(';');
299 strPath=templPaths.substr(0, pos);
301 if (!isAbsolute(strPath.c_str())){
302 strPath.insert(0, basepath);
303 }
304
305 if(!loadRecursiveTemplates(strPath.c_str())){
306 logger->addError("Cannot load the templates from " + strPath);
307 }
308
309 if (pos==std::string::npos){
310 break;
311 }
312 templPaths=templPaths.substr(pos+1);
313 }
314 }
315
316 if(config.check("external_editor")){
317 ext_editor = config.find("external_editor").asString();
318 ((EntitiesTreeWidget*)ui->entitiesTree)->setExtEditor(ext_editor);
319 }else{
320#if defined(_WIN32)
321 ext_editor = "notepad.exe";
322#else
323 ext_editor = "xdg-open";
324#endif
325 }
326
327 reportErrors();
328
329 syncApplicationList();
330
331 if(config.check("application")){
332 yarp::manager::XmlAppLoader appload(config.find("application").asString().c_str());
333 if(!appload.init()){
334 return;
335 }
336 yarp::manager::Application* application = appload.getNextApplication();
337 if(!application){
338 return; // TODO far ritornare valore per chiudere in caso di errore
339 }
340 // add this application to the manager if does not exist
341 if(!lazyManager.getKnowledgeBase()->getApplication(application->getName())){
342 lazyManager.getKnowledgeBase()->addApplication(application);
343 syncApplicationList();
344 }
345 //manageApplication(application->getName());
346 }
347
348 if (config.check("load_application")){
349 std::string applicationName = config.find("load_application").asString();
350 yarp::manager::XmlAppLoader appload(applicationName.c_str());
351 if(!appload.init()){
352 logger->addError("Cannot load the application with XmlAppLoader from " + applicationName);
353 return;
354 }
355 yarp::manager::Application* application = appload.getNextApplication();
356 if(!application){
357 logger->addError("Cannot load the application from " + applicationName);
358 return;
359 }
360 // add this application to the manager if does not exist
361 if(!lazyManager.getKnowledgeBase()->getApplication(application->getName())){
362 lazyManager.getKnowledgeBase()->addApplication(application);
363 syncApplicationList();
364 }
365 // load the application in the main window
366 viewApplication(application, false);
367
368 }
369
370 onYarpNameList();
371}
372
376{
378 if(logger->errorCount() || logger->warningCount()){
379 const char* err;
380 while((err=logger->getLastError())){
381 onLogError(err);
382 }
383 while((err=logger->getLastWarning())){
384 onLogWarning(err);
385 }
386 }
387}
388
391void MainWindow::syncApplicationList(QString selectNodeForEditing, bool open)
392{
393 if (!listOfAppFiles.isEmpty())
394 {
395 watcher->removePaths(listOfAppFiles);
396 }
397 listOfAppFiles.clear();
398 ui->entitiesTree->clearApplications();
399 ui->entitiesTree->clearModules();
400 ui->entitiesTree->clearResources();
401 //ui->entitiesTree->clearTemplates();
404 unsigned int cnt = 0;
405 for(auto& itr : apps){
406 cnt++;
407 auto* app = dynamic_cast<yarp::manager::Application*>(itr);
408 if(app){
409 ui->entitiesTree->addApplication(app);
410 if(strcmp(selectNodeForEditing.toLatin1().data(),app->getName())==0){
411 emit selectItem(selectNodeForEditing, open);
412 }
413 listOfAppFiles.push_back(app->getXmlFile());
414 }
415 }
416
417 watcher->addPaths(listOfAppFiles);
418
420 for(auto& resource : resources) {
421 auto* comp = dynamic_cast<yarp::manager::Computer*>(resource);
422 if(comp){
423 ui->entitiesTree->addComputer(comp);
424 }
425 }
426
428 for(auto& module : modules) {
429 auto* mod = dynamic_cast<yarp::manager::Module*>(module);
430 if(mod){
431 ui->entitiesTree->addModule(mod);
432 }
433 }
434
435
436 if(cnt){
437 QString msg = QString("%1 applications are loaded successfully.").arg(cnt);
438 onLogMessage(msg);
439 }
440 else{
441 QString msg = QString("No application is loaded!");
442 onLogMessage(msg);
443 }
444}
445
449bool MainWindow::loadRecursiveTemplates(const char* szPath)
450{
451 const std::string directorySeparator{yarp::conf::filesystem::preferred_separator};
452 std::string strPath = szPath;
453 if((strPath.rfind(directorySeparator)==std::string::npos) ||
454 (strPath.rfind(directorySeparator)!=strPath.size()-1)) {
455 strPath.append(directorySeparator);
456 }
457
458 DIR *dir;
459 struct dirent *entry;
460 if ((dir = opendir(strPath.c_str())) == nullptr) {
461 return false;
462 }
463
464 // loading from current folder
466 yarp::manager::XmlTempLoader tempload(strPath.c_str(), nullptr);
467 if(tempload.init())
468 {
469 while((tmp = tempload.getNextAppTemplate())){
470 ui->entitiesTree->addAppTemplate(tmp);
471 }
472 }
473
474 while((entry = readdir(dir)))
475 {
476 if((std::string(entry->d_name) != std::string("."))
477 && (std::string(entry->d_name) != std::string("..")))
478 {
479
480 std::string name = strPath + std::string(entry->d_name);
481 loadRecursiveTemplates(name.c_str());
482 }
483 }
484 closedir(dir);
485
486 return true;
487}
488
492bool MainWindow::loadRecursiveApplications(const char* szPath)
493{
494 const std::string directorySeparator{yarp::conf::filesystem::preferred_separator};
495 std::string strPath = szPath;
496 if ((strPath.rfind(directorySeparator) == std::string::npos) || (strPath.rfind(directorySeparator) != strPath.size() - 1)) {
497 strPath = strPath + directorySeparator;
498 }
499
500 DIR *dir;
501 struct dirent *entry;
502 if ((dir = opendir(strPath.c_str())) == nullptr) {
503 return false;
504 }
505
506 lazyManager.addApplications(strPath.c_str());
507
508 while((entry = readdir(dir)))
509 {
510 if((std::string(entry->d_name) != std::string("."))
511 && (std::string(entry->d_name) != std::string("..")))
512 {
513 std::string name = strPath + std::string(entry->d_name);
514 loadRecursiveApplications(name.c_str());
515 }
516 }
517 closedir(dir);
518 return true;
519}
520
521bool MainWindow::initializeFile(std::string _class)
522{
523 QFile f(fileName);
524 bool b = f.open(QIODevice::ReadWrite);
525 QString appTemplate = "<application>\n"
526 " <name>" + currentAppName + "</name>\n"
527 " <description>" + currentAppDescription + "</description>\n"
528 " <version>" + currentAppVersion + "</version>\n"
529 " <authors>\n"
530 " </authors>\n"
531 "</application>\n";
532 if(b){
533 if (_class == "Resource") {
534 f.write(str_res_template.c_str());
535 } else if (_class == "Module") {
536 f.write(str_mod_template.c_str());
537 } else if (_class == "Application") {
538 f.write(appTemplate.toStdString().c_str());
539 } else {
540 return false;
541 }
542 f.flush();
543 f.close();
544 return true;
545 }else{
547 QString err = QString("Cannot create %1").arg(fileName);
548 logger->addError(err.toLatin1().data());
549 reportErrors();
550 return false;
551 }
552}
553
554int MainWindow::getAppTabIndex(QString appName)
555{
556 for (int i=0; i<ui->mainTabs->count(); i++){
557 if (ui->mainTabs->tabText(i) == appName){
558 return i;
559 }
560 }
561 return -1;
562}
563
564QString MainWindow::getAppNameFromXml(QString fileName)
565{
566 QString appName("");
569 for(auto& itr : apps)
570 {
571 auto* app = dynamic_cast<yarp::manager::Application*>(itr);
572 if(app)
573 {
574 if(app->getXmlFile() == fileName.toStdString())
575 {
576 return app->getName();
577 }
578 }
579 }
580 return appName;
581}
582
587{
588 for(int i=0;i<ui->mainTabs->count();i++){
589 if(ui->mainTabs->tabText(i) == res->getName()){
590 ui->mainTabs->setCurrentIndex(i);
591 return;
592 }
593 }
594
595 auto* w = new ResourceViewWidget(res,ui->mainTabs);
596 int index = ui->mainTabs->addTab(w,res->getName());
597 ui->mainTabs->setTabIcon(index,QIcon(":/computer22.svg"));
598 ui->mainTabs->setCurrentIndex(index);
599}
605{
606 for(int i=0;i<ui->mainTabs->count();i++){
607 if(ui->mainTabs->tabText(i) == module->getName()){
608 ui->mainTabs->setCurrentIndex(i);
609 return;
610 }
611 }
612
613 auto* w = new ModuleViewWidget(module,ui->mainTabs);
614 int index = ui->mainTabs->addTab(w,module->getName());
615 ui->mainTabs->setTabIcon(index,QIcon(":/module22.svg"));
616 ui->mainTabs->setCurrentIndex(index);
617}
618
623{
624
625 for (int i=0; i<ui->mainTabs->count(); i++){
626 if (ui->mainTabs->tabText(i) == app->getName()){
627 ui->mainTabs->setCurrentIndex(i);
628 return;
629 }
630 }
631
632 auto* w = new ApplicationViewWidget(app,&lazyManager,&config,editingMode,ui->mainTabs);
633 connect(w,SIGNAL(logError(QString)),this,SLOT(onLogError(QString)));
634 connect(w,SIGNAL(logWarning(QString)),this,SLOT(onLogWarning(QString)));
635 connect(w,SIGNAL(modified(bool)),this,SLOT(onModified(bool)));
636 int index = ui->mainTabs->addTab(w,app->getName());
637 ui->mainTabs->setTabIcon(index,QIcon(":/run22.svg"));
638 ui->mainTabs->setCurrentIndex(index);
639 if(!editingMode)
640 {
641 connect(w->getConnectionList(),SIGNAL(itemSelectionChanged()),this,SLOT(onApplicationSelectionChanged()));
642 connect(w->getModuleList(),SIGNAL(itemSelectionChanged()),this,SLOT(onApplicationSelectionChanged()));
643 }
644 if(editingMode){
645 ui->actionSelect_All->setEnabled(false);
646 ui->actionRefresh_Status->setEnabled(false);
647 ui->actionExport_Graph->setEnabled(false);
648 ui->actionConnect_all->setEnabled(false);
649 ui->actionDisconnect_all->setEnabled(false);
650 ui->actionRun_all->setEnabled(false);
651 ui->actionStop_all->setEnabled(false);
652 ui->actionKill_all->setEnabled(false);
653 ui->actionConnect->setEnabled(false);
654 ui->actionDisconnect->setEnabled(false);
655 ui->actionRun->setEnabled(false);
656 ui->actionStop->setEnabled(false);
657 ui->actionKill->setEnabled(false);
658 }else{
659 ui->actionSelect_All->setEnabled(true);
660 ui->actionRefresh_Status->setEnabled(true);
661 ui->actionExport_Graph->setEnabled(true);
662 ui->actionConnect_all->setEnabled(true);
663 ui->actionDisconnect_all->setEnabled(true);
664 ui->actionRun_all->setEnabled(true);
665 ui->actionStop_all->setEnabled(true);
666 ui->actionKill_all->setEnabled(true);
667 onRefresh();
668 }
669}
670
673void MainWindow::onExportGraph()
674{
675 QWidget *w = ui->mainTabs->currentWidget();
676 if(!w){
677 return;
678 }
679 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
680 if(type == yarp::manager::APPLICATION){
681 auto* ww = (ApplicationViewWidget*)w;
682 ww->exportGraph();
683 }
684}
685
688void MainWindow::onRun(bool onlySelected)
689{
690 QWidget *w = ui->mainTabs->currentWidget();
691 if(!w){
692 return;
693 }
694 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
695 if(type == yarp::manager::APPLICATION){
696 auto* ww = (ApplicationViewWidget*)w;
697 ww->runApplicationSet(onlySelected);
698 }
699}
700
703void MainWindow::onStop(bool onlySelected)
704{
705 QWidget *w = ui->mainTabs->currentWidget();
706 if(!w){
707 return;
708 }
709 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
710 if(type == yarp::manager::APPLICATION){
711 auto* ww = (ApplicationViewWidget*)w;
712 ww->stopApplicationSet(onlySelected);
713 }
714}
715
718void MainWindow::onKill(bool onlySelected)
719{
720 QWidget *w = ui->mainTabs->currentWidget();
721 if(!w){
722 return;
723 }
724 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
725 if(type == yarp::manager::APPLICATION){
726 auto* ww = (ApplicationViewWidget*)w;
727 ww->killApplicationSet(onlySelected);
728 }
729}
730
733void MainWindow::onConnect(bool onlySelected)
734{
735 QWidget *w = ui->mainTabs->currentWidget();
736 if(!w){
737 return;
738 }
739 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
740 if(type == yarp::manager::APPLICATION){
741 auto* ww = (ApplicationViewWidget*)w;
742 ww->connectConnectionSet(onlySelected);
743 }
744}
747void MainWindow::onDisconnect(bool onlySelected)
748{
749 QWidget *w = ui->mainTabs->currentWidget();
750 if(!w){
751 return;
752 }
753 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
754 if(type == yarp::manager::APPLICATION){
755 auto* ww = (ApplicationViewWidget*)w;
756 ww->disconnectConnectionSet(onlySelected);
757 }
758}
759
760void MainWindow::onRunSelected()
761{
762 onRun(true);
763}
764void MainWindow::onStopSelected()
765{
766 onStop(true);
767}
768void MainWindow::onKillSelected()
769{
770 onKill(true);
771}
772void MainWindow::onConnectSelected()
773{
774 onConnect(true);
775}
776void MainWindow::onDisconnectSelected()
777{
778 onDisconnect(true);
779}
782void MainWindow::onRefresh()
783{
784 QWidget *w = ui->mainTabs->currentWidget();
785 if(!w){
786 return;
787 }
788 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
789 if(type == yarp::manager::APPLICATION){
790 auto* ww = (ApplicationViewWidget*)w;
791 ww->refresh();
792 }
793
794 if(type == yarp::manager::RESOURCE){
795 auto* ww = (ResourceViewWidget*)w;
796 ww->refresh();
797 }
798}
799
802void MainWindow::onSelectAll()
803{
804 QWidget *w = ui->mainTabs->currentWidget();
805 if(!w){
806 return;
807 }
808 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
809 if(type == yarp::manager::APPLICATION){
810 auto* ww = (ApplicationViewWidget*)w;
811 ww->selectAll();
812 }
813}
814
818bool MainWindow::onTabClose(int index)
819{
820 auto* w = (GenericViewWidget*)ui->mainTabs->widget(index);
821 if(!w){
822 return false;
823 }
824 if(w->getType() == yarp::manager::APPLICATION){
826
827 if(aw && aw->isRunning()){
828 QMessageBox msgBox;
829 msgBox.setIcon(QMessageBox::Icon::Warning);
830 msgBox.setWindowTitle(QString("Closing %1").arg(ui->mainTabs->tabText(index)));
831 msgBox.setText(tr("You have some running module. After closing the application window you might not be able to recover them. Are you sure?"));
832 QPushButton* noButton = msgBox.addButton(tr("No"), QMessageBox::NoRole);
833 QPushButton* pstopAndClose = msgBox.addButton(tr("Yes and Stop"), QMessageBox::YesRole);
834 msgBox.addButton(tr("Yes"), QMessageBox::YesRole);
835 msgBox.setDefaultButton(noButton);
836 msgBox.exec();
837
838 if (msgBox.clickedButton() == noButton)
839 {
840 return false;
841 }
842 else if(msgBox.clickedButton() == pstopAndClose)
843 {
844 onStop();
845 }
846 }
847
848 QString fileOfCurrentApp = aw->getFileName();
849
850 if(aw->isModified() && aw->isEditingMode()){
851 QMessageBox::StandardButton btn = QMessageBox::question(this,"Save",QString("%1 has been modified\nDo you want to save it before closing?").arg(aw->getAppName().toLatin1().data()),
852 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
853 if(btn == QMessageBox::Yes){
854 bool ret = aw->save();
855 if(ret){
856 onReopenApplication(aw->getAppName(),fileOfCurrentApp);
857 ui->mainTabs->removeTab(index);
858 delete w;
859 return true;
860
861 }else{
862 QMessageBox::critical(this,"Error",QString("Error Saving the file"));
863 return false;
864 }
865 }
866 if(btn == QMessageBox::Cancel){
867 return false;
868 }
869 if (btn == QMessageBox::No){
870 QFile file(fileOfCurrentApp);
871 if(!file.exists()){
872 ui->entitiesTree->setCurrentItem(ui->entitiesTree->getWidgetItemByFilename(fileOfCurrentApp));
873 ui->entitiesTree->onRemove();
874 aw->closeManager();
875 ui->mainTabs->removeTab(index);
876 delete w;
877 return true;
878 }
879 }
880
881 }
882 aw->closeManager();
883 }
884 ui->mainTabs->removeTab(index);
885 delete w;
886 return true;
887}
888
892void MainWindow::onLogError(QString msg)
893{
894 QString text = QString ("[ERR] %1").arg(msg);
895 ui->logWidget->addItem(text);
896 ui->logWidget->item(ui->logWidget->count() - 1)->setBackground(QColor("#F9CCCA"));
897 ui->logWidget->setCurrentRow(ui->logWidget->count() - 1);
898}
899
903void MainWindow::onLogWarning(QString msg)
904{
905 QString text = QString ("[WAR] %1").arg(msg);
906 ui->logWidget->addItem(text);
907 ui->logWidget->item(ui->logWidget->count() - 1)->setBackground(QColor("#FFF6C8"));
908 ui->logWidget->setCurrentRow(ui->logWidget->count() - 1);
909}
910
914void MainWindow::onLogMessage(QString msg)
915{
917 msg = QString("[time: %1] ").arg(getElapsedTimeString(clock.getStartTime()).c_str()) + msg;
918 QString text = QString ("[MSG] %1").arg(msg);
919 ui->logWidget->addItem(text);
920 ui->logWidget->setCurrentRow(ui->logWidget->count() - 1);
921}
922
923
928{
929
930 auto* w = (GenericViewWidget*)ui->mainTabs->widget(index);
931 if(w && w->getType() == yarp::manager::APPLICATION){
932 auto* aw = (ApplicationViewWidget*)w;
933 if(aw->isEditingMode()){
934 ui->actionSelect_All->setEnabled(false);
935 ui->actionRefresh_Status->setEnabled(false);
936 ui->actionExport_Graph->setEnabled(false);
937 ui->actionConnect_all->setEnabled(false);
938 ui->actionDisconnect_all->setEnabled(false);
939 ui->actionRun_all->setEnabled(false);
940 ui->actionStop_all->setEnabled(false);
941 ui->actionKill_all->setEnabled(false);
942 ui->actionConnect->setEnabled(false);
943 ui->actionDisconnect->setEnabled(false);
944 ui->actionRun->setEnabled(false);
945 ui->actionStop->setEnabled(false);
946 ui->actionKill->setEnabled(false);
947 }else{
948 ui->actionSelect_All->setEnabled(true);
949 ui->actionRefresh_Status->setEnabled(true);
950 ui->actionExport_Graph->setEnabled(true);
951 ui->actionConnect_all->setEnabled(true);
952 ui->actionDisconnect_all->setEnabled(true);
953 ui->actionRun_all->setEnabled(true);
954 ui->actionStop_all->setEnabled(true);
955 ui->actionKill_all->setEnabled(true);
957 }
958
959
960 if(w->isModified()){
961 ui->actionSave->setEnabled(true);
962 ui->actionSave_As->setEnabled(true);
963 }else{
964 ui->actionSave->setEnabled(false);
965 ui->actionSave_As->setEnabled(false);
966 }
967 }
968 else {
969
970 if(w && w->getType() == yarp::manager::RESOURCE){
971 ui->actionRefresh_Status->setEnabled(true);
972 prevWidget = w;
973 }else{
974 ui->actionRefresh_Status->setEnabled(false);
975 prevWidget = nullptr;
976 }
977
978 ui->actionSelect_All->setEnabled(false);
979 ui->actionExport_Graph->setEnabled(false);
980 ui->actionConnect_all->setEnabled(false);
981 ui->actionDisconnect_all->setEnabled(false);
982 ui->actionRun_all->setEnabled(false);
983 ui->actionStop_all->setEnabled(false);
984 ui->actionKill_all->setEnabled(false);
985 ui->actionConnect->setEnabled(false);
986 ui->actionDisconnect->setEnabled(false);
987 ui->actionRun->setEnabled(false);
988 ui->actionStop->setEnabled(false);
989 ui->actionKill->setEnabled(false);
990 }
991}
992
994void MainWindow::onNewApplication()
995{
996 auto* newApplicationWizard = new NewApplicationWizard(&config);
997 newApplicationWizard->setWindowTitle("Create New Application");
998 if (newApplicationWizard->exec() == QDialog::Accepted){
999
1000 currentAppName = newApplicationWizard->name;
1001 currentAppDescription = newApplicationWizard->description;
1002 currentAppVersion = newApplicationWizard->version;
1003 fileName = newApplicationWizard->fileName;
1004 size_t len = newApplicationWizard->name.toLatin1().size();
1005 char* appName;
1006 appName = new char [len+1];
1007 strncpy(appName, newApplicationWizard->name.toLatin1().data(), len);
1008 appName[len] = '\0';
1009 if (newApplicationWizard->alreadyExists)
1010 {
1011 if (!lazyManager.removeApplication(newApplicationWizard->fileName.toLatin1().data(),
1012 appName))
1013 {
1014 reportErrors();
1015 if(appName)
1016 {
1017 delete [] appName;
1018 appName = nullptr;
1019 }
1020 return;
1021 }
1022 }
1023 initializeFile("Application");
1024
1025 if (lazyManager.addApplication(newApplicationWizard->fileName.toLatin1().data(),
1026 &appName,true))
1027 {
1028 QString newApp(appName);
1029 syncApplicationList(newApp);
1030
1031 }
1032 else
1033 {
1034 reportErrors();
1035 }
1036
1037 if(appName)
1038 {
1039 delete [] appName;
1040 appName = nullptr;
1041 }
1042 delete newApplicationWizard;
1043 QFile f(fileName);
1044 f.remove();
1045 onModified(true);
1046 return;
1047 }
1048 delete newApplicationWizard;
1049 qDebug() << "Rejected";
1050}
1051
1053void MainWindow::onNewResource()
1054{
1056
1057 fileName = QFileDialog::getSaveFileName(this,"Create new Resource description file",QApplication::applicationDirPath(),
1058 "Resource description files (*.xml)");
1059
1060 if(!initializeFile("Resource"))
1061 {
1062 QString msg = QString("Error while initializing %1.").arg(fileName.toStdString().c_str());
1063 logger->addError(msg.toLatin1().data());
1064 reportErrors();
1065 return;
1066 }
1067
1069 if(launcher.init(ext_editor.c_str(), fileName.toLatin1().data(), nullptr, nullptr, nullptr, nullptr)){
1070 if(!launcher.start() && !launcher.error().empty()){
1071 QString msg = QString("Error while launching %1. %2").arg(ext_editor.c_str()).arg(launcher.error().c_str());
1072 logger->addError(msg.toLatin1().data());
1073 reportErrors();
1074 }
1075 }
1076
1077}
1078
1080void MainWindow::onNewModule()
1081{
1083
1084 fileName = QFileDialog::getSaveFileName(this,"Create new Module description file",QApplication::applicationDirPath(),
1085 "Module description files (*.xml)");
1086
1087 if(!initializeFile("Module"))
1088 {
1089 QString msg = QString("Error while initializing %1.").arg(fileName.toStdString().c_str());
1090 logger->addError(msg.toLatin1().data());
1091 reportErrors();
1092 return;
1093 }
1094
1096 if(launcher.init(ext_editor.c_str(), fileName.toLatin1().data(), nullptr, nullptr, nullptr, nullptr)){
1097 if(!launcher.start() && !launcher.error().empty()){
1098 QString msg = QString("Error while launching %1. %2").arg(ext_editor.c_str()).arg(launcher.error().c_str());
1099 logger->addError(msg.toLatin1().data());
1100 reportErrors();
1101 }
1102 }
1103
1104}
1105
1107void MainWindow::onImportFiles()
1108{
1109 QString dir = QFileDialog::getExistingDirectory(this, tr("Please choose a folder"),
1110 QApplication::applicationDirPath(),
1111 QFileDialog::ShowDirsOnly
1112 | QFileDialog::DontResolveSymlinks);
1113 if(!dir.isEmpty()){
1114 if(config.find("load_subfolders").asString() == "yes"){
1115 if (loadRecursiveApplications(dir.toLatin1().data())) {
1116 syncApplicationList();
1117 }
1118 }
1119 else{
1120 if (lazyManager.addApplications(dir.toLatin1().data())) {
1121 syncApplicationList();
1122 }
1123 }
1124
1125 if(lazyManager.addResources(dir.toLatin1().data())){
1126 syncApplicationList();
1127 }
1128
1129 if(lazyManager.addModules(dir.toLatin1().data())){
1130 syncApplicationList();
1131 }
1132
1133 reportErrors();
1134 }
1135}
1136
1138void MainWindow::onClose()
1139{
1140 int index = ui->mainTabs->currentIndex();
1141 if(index < 0){
1142 return;
1143 }
1144 onTabClose(index);
1145}
1146
1147void MainWindow::onModified(bool mod)
1148{
1149 ui->actionSave->setEnabled(mod);
1150 ui->actionSave_As->setEnabled(mod);
1151 int index = ui->mainTabs->currentIndex();
1152 auto* gw = (GenericViewWidget*)ui->mainTabs->currentWidget();
1153 if(gw->getType() == yarp::manager::APPLICATION){
1154 auto* w = (ApplicationViewWidget*)gw;
1155 if(mod){
1156 ui->mainTabs->setTabText(index,w->getAppName() + "*");
1157 gw->setModified(mod);
1158 }else{
1159 ui->mainTabs->setTabText(index,w->getAppName());
1160 }
1161 }
1162}
1163
1164void MainWindow::onFileChanged(const QString &path)
1165{
1166
1167 watcher->addPaths(listOfAppFiles);
1168 if (!ui->actionAuto_reload->isChecked())
1169 {
1170 return;
1171 }
1172
1173 // get the app name from the file name
1174 QString appName = getAppNameFromXml(path);
1175
1176 QMessageBox::StandardButton reply;
1177 reply = QMessageBox::question(this, "File changed", "Xml file '" + path +
1178 "' changed.\nDo you want to reload the application? If open, the respective tab will be closed",
1179 QMessageBox::Yes|QMessageBox::No);
1180 if (reply == QMessageBox::No) {
1181 return;
1182 }
1183
1184 Application* app = (Application*) lazyManager.getNode(appName.toStdString());
1185 if (app)
1186 {
1187 int index = getAppTabIndex(appName);
1188 if (index >= 0)
1189 {
1190 if (!onTabClose(index))
1191 {
1192 return;
1193 }
1194 else
1195 {
1196 // refresh it in the application list
1197 onReopenApplication(appName, path);
1198 // the reference has been changed reopening the application
1199 app = (Application*) lazyManager.getNode(appName.toStdString());
1200 // is it already open in the tab? if so close it and reopen it after the refresh
1201 if (app)
1202 {
1203 viewApplication(app, false);
1204 }
1205 return; }
1206 }
1207 else
1208 {
1209 // refresh it in the application list
1210 onReopenApplication(appName, path);
1211 return;
1212 }
1213 }
1214 return;
1215}
1216
1217void MainWindow::onYarpClean()
1218{
1220 {
1221 onLogWarning(QString::fromLatin1("yarpserver is not running"));
1222 return;
1223 }
1224 QInputDialog* inputDialog = new QInputDialog(this);
1225 inputDialog->setOptions(QInputDialog::NoButtons);
1226
1227 bool ok=false;
1228
1229 float timeout = inputDialog->getDouble(nullptr ,"Running yarp clean",
1230 "Be aware that yarp clean with a little timetout could\n"
1231 "unregister ports that are actually open.\n\n"
1232 "Timeout(seconds):", 0.3, 0, 2147483647, 1, &ok);
1233 if (ok)
1234 {
1235 onLogMessage(QString("YARP clean: cleaning death ports..."));
1237 onYarpNameList();
1238 }
1239
1240}
1241
1242void MainWindow::onYarpNameList()
1243{
1245 {
1246 onLogWarning(QString::fromLatin1("yarpserver is not running"));
1247 return;
1248 }
1249 ui->entitiesTree->clearPorts();
1252 for(auto& port : ports)
1253 {
1254 std::string portName = port.name;
1255 std::string portIp = port.ip + " port " + port.port_number;
1256 ui->entitiesTree->addPort(QStringList() << QString(portName.c_str())
1257 << QString(portIp.c_str()));
1258 }
1259 onLogMessage(QString::fromLatin1("Running yarp name list...found %1 ports").arg(ports.size()));
1260}
1261
1262void MainWindow::onSave()
1263{
1264 auto* w = (GenericViewWidget *)ui->mainTabs->currentWidget();
1265 if(!w){
1266 return;
1267 }
1268 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
1269 if(type == yarp::manager::APPLICATION){
1270 auto* ww = (ApplicationViewWidget*)w;
1271 bool ret = ww->save();
1272 if(ret){
1273 onReopenApplication(ww->getAppName(),ww->getFileName());
1274 }else{
1275 QMessageBox::critical(this,"Error",QString("Error Saving the file"));
1276 }
1277 }
1278}
1279
1280void MainWindow::onSaveAs()
1281{
1282 auto* newApplicationWizard = new NewApplicationWizard(&config,true);
1283 newApplicationWizard->setWindowTitle("Save Application as");
1284 if(newApplicationWizard->exec() == QDialog::Accepted){
1285 fileName = newApplicationWizard->fileName;
1286 delete newApplicationWizard;
1287 }
1288 else
1289 {
1290 delete newApplicationWizard;
1291 return;
1292 }
1293 if(fileName.trimmed().size() == 0 || fileName.contains(" ")){
1294 QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr(std::string("Invalid file name " + fileName.toStdString()).c_str()));
1295 return;
1296 }
1297
1298 auto* w = (GenericViewWidget *)ui->mainTabs->currentWidget();
1299 if(!w){
1300 return;
1301 }
1302 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
1303 if(type == yarp::manager::APPLICATION){
1304 auto* ww = (ApplicationViewWidget*)w;
1305 QString oldAppName = ww->getAppName();
1306 QString oldFileName = ww->getFileName();
1307 ww->setFileName(fileName);
1308 size_t it1 = fileName.toStdString().find(".xml");
1309 if(it1 == std::string::npos)
1310 {
1311 yError("yarpmanager: '.xml' not present in filename");
1312 return;
1313 }
1314 QString appName = fileName.toStdString().substr(0,it1).c_str();
1315 size_t it2 =appName.toStdString().find_last_of('/');
1316 if(it2 != std::string::npos)
1317 {
1318 currentAppName = appName.toStdString().substr(it2+1).c_str();
1319 }
1320 else
1321 {
1322 currentAppName = appName;
1323 }
1324 ww->setAppName(currentAppName);
1325 if(fileName.isEmpty()){
1326 return;
1327 }
1328 reportErrors();
1329 onSave();
1330 ww->setAppName(oldAppName);
1331 ww->setFileName(oldFileName);
1332 onTabClose(ui->mainTabs->currentIndex());
1333 syncApplicationList();
1334 Application* newApp = (Application*) lazyManager.getNode(currentAppName.toStdString());
1335 if (newApp)
1336 {
1337 viewApplication(newApp,true);
1338 }
1339 }
1340}
1341
1343void MainWindow::onOpen()
1344{
1345 QString fileName = QFileDialog::getOpenFileName(this,"Please choose a File",QCoreApplication::applicationDirPath(),
1346 "Application description files (*.xml);;Modules description files (*.xml);;Resource description files (*.xml);;Any files (*.xml)");
1347
1348 if(fileName.isEmpty()){
1349 return;
1350 }
1351
1352 char* name = nullptr;
1353
1354 if(lazyManager.addApplication(fileName.toLatin1().data(), &name, true)){
1355 QString appName(name);
1356 syncApplicationList(appName,true);
1357 }
1358 if(name)
1359 {
1360 delete [] name;
1361 name = nullptr;
1362 }
1363
1364 if(lazyManager.addResource(fileName.toLatin1().data())){
1365 syncApplicationList();
1366 }
1367 if(lazyManager.addModule(fileName.toLatin1().data())){
1368 syncApplicationList();
1369 }
1370 reportErrors();
1371
1372}
1374void MainWindow::onAbout()
1375{
1376 QString copyright = "Copyright (C) 2006-2021 Istituto Italiano di Tecnologia (IIT)";
1377 QString name = APP_NAME;
1378 QString version = YARP_VERSION;
1379 AboutDlg dlg(name,version,copyright,"https://www.iit.it/");
1380 dlg.exec();
1381}
1382
1385void MainWindow::onHelp()
1386{
1387 QDesktopServices::openUrl(QUrl("http://www.yarp.it/yarpmanager.html"));
1388}
1389
1390void MainWindow::onRemoveApplication(QString xmlFile, QString appName)
1391{
1392 lazyManager.removeApplication(xmlFile.toLatin1().data(),appName.toLatin1().data());
1393 syncApplicationList();
1394}
1395
1396
1397void MainWindow::onReopenApplication(QString appName,QString fileName)
1398{
1399 lazyManager.removeApplication(fileName.toLatin1().data(), appName.toLatin1().data());
1400 char * appNamePtr = appName.toLatin1().data();
1401 lazyManager.addApplication(fileName.toLatin1().data(), &appNamePtr);
1402 syncApplicationList();
1403}
1404
1405void MainWindow::onRemoveModule(QString modName)
1406{
1407 lazyManager.removeModule(modName.toLatin1().data());
1408 syncApplicationList();
1409}
1410
1411void MainWindow::onReopenModule(QString modName,QString fileName)
1412{
1413 lazyManager.removeModule(modName.toLatin1().data());
1414 lazyManager.addModule(fileName.toLatin1().data());
1415 syncApplicationList();
1416}
1417
1418void MainWindow::onRemoveResource(QString resName)
1419{
1420 lazyManager.removeResource(resName.toLatin1().data());
1421 syncApplicationList();
1422}
1423
1424void MainWindow::onReopenResource(QString resName,QString fileName)
1425{
1426 lazyManager.removeResource(resName.toLatin1().data());
1427 lazyManager.addResource(fileName.toLatin1().data());
1428 syncApplicationList();
1429}
1430
1432{
1433 QWidget *w = ui->mainTabs->currentWidget();
1434 if(!w){
1435 return;
1436 }
1437 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
1438 if(type == yarp::manager::APPLICATION){
1439 auto* ww = (ApplicationViewWidget*)w;
1440 ui->actionRun->setEnabled(ww->anyModuleSelected());
1441 ui->actionStop->setEnabled(ww->anyModuleSelected());
1442 ui->actionKill->setEnabled(ww->anyModuleSelected());
1443 ui->actionConnect->setEnabled(ww->anyConnectionSelected());
1444 ui->actionDisconnect->setEnabled(ww->anyConnectionSelected());
1445 }
1446}
bool ret
#define yError(...)
Definition Log.h:361
int SIGNAL(int pid, int signum)
The Application View Widget.
bool isRunning()
Tells if a modules is in running state.
The Entities QtreeWidget.
Generic View Widget.
MainWindow class.
Definition display.h:22
void closeEvent(QCloseEvent *event) override
void onReopenApplication(QString, QString)
void init(yarp::os::Property config)
Init the application with the current configuration.
MainWindow(const yarp::os::ResourceFinder &rf, yarp::dev::IBattery *ibat, QWidget *parent=0, double refresh_period=10.0)
Definition display.cpp:186
void onReopenModule(QString, QString)
void viewApplication(yarp::manager::Application *app, bool editingMode)
Load the Application on the MainWindow.
void onTabChangeItem(int)
Called when a tab has been pressed.
void viewModule(yarp::manager::Module *)
Load the Module on the MainWindow.
void selectItem(QString, bool)
void onApplicationSelectionChanged()
void onRemoveResource(QString)
void onRemoveApplication(QString, QString)
void onReopenResource(QString, QString)
void onRemoveModule(QString)
void reportErrors()
Reports tge error on the log window.
void viewResource(yarp::manager::Computer *res)
Load the Resource on the MainWindow.
friend class NewApplicationWizard
Definition mainwindow.h:32
The Module View Widget.
The Resource View Widget.
Class Application.
Singleton class For storing execution start time.
Definition utility.h:86
static ClockStart & getInstance()
Definition utility.h:88
std::string getStartTime() const
Get the starting time as a string in HH:MM:SS format.
Definition utility.h:100
Singleton class ErrorLogger.
Definition utility.h:58
const char * getLastError()
Definition utility.cpp:148
void addError(const char *szError)
Definition utility.cpp:126
static ErrorLogger * Instance()
Singleton class ErrorLogger.
Definition utility.cpp:98
const char * getLastWarning()
Definition utility.cpp:167
Class KnowledgeBase.
Definition kbase.h:32
const ModulePContainer & getModules(Application *parent=nullptr)
Definition kbase.cpp:217
Application * getApplication()
Definition kbase.h:84
const ApplicaitonPContainer & getApplications(Application *parent=nullptr)
Definition kbase.cpp:188
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 LocalBroker.
Definition localbroker.h:33
std::string error() override
bool removeApplication(const char *szFileName, const char *szAppName)
Definition manager.cpp:184
bool addModule(const char *szFileName)
Definition manager.cpp:127
bool removeModule(const char *szModName)
Definition manager.cpp:202
bool addModules(const char *szPath)
Definition manager.cpp:141
bool addResources(const char *szPath)
Definition manager.cpp:170
Node * getNode(std::string appName)
Definition manager.cpp:483
bool addApplication(const char *szFileName, char **szAppName_=nullptr, bool modifyName=false)
Definition manager.cpp:90
bool addResource(const char *szFileName)
Definition manager.cpp:155
bool removeResource(const char *szResName)
Definition manager.cpp:220
bool addApplications(const char *szPath)
Definition manager.cpp:110
KnowledgeBase * getKnowledgeBase()
Definition manager.h:103
Class Module.
Definition module.h:99
const char * getName()
Definition module.h:128
Class XmlAppLoader.
Application * getNextApplication() override
Class XmlTempLoader.
static bool checkNetwork()
Check if the YARP Network is up and running.
Definition Network.cpp:1370
A class for storing options and configuration information.
Definition Property.h:33
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Helper class for finding config files and other external resources.
static ResourceFinder & getResourceFinderSingleton()
Access a ResourceFinder singleton whose lifetime will match that of the YARP library.
std::string findFileByName(const std::string &name)
Find the full path to a file.
A single value (typically within a Bottle).
Definition Value.h:43
virtual std::string asString() const
Get string value.
Definition Value.cpp:234
static bool getPortsList(ports_name_set &ports, bool complete=false)
static bool yarpClean(float timeout=0.1)
Definition aboutdlg.h:11
static constexpr value_type preferred_separator
Definition filesystem.h:21
void trimString(std::string &str)
Definition utility.cpp:403
enum yarp::manager::__NodeType NodeType
std::vector< Module * > ModulePContainer
Definition module.h:230
std::vector< GenericResource * > ResourcePContainer
Definition resource.h:58
std::string getElapsedTimeString(const std::string &startTimeStr)
Definition utility.cpp:362
std::vector< Application * > ApplicaitonPContainer
Abstract Class TempLoader.
static const std::string str_res_template
static const std::string str_mod_template
#define YARP_VERSION
Definition version.h:14
#define APP_NAME
bool isAbsolute(const char *path)