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 if(config.check("disable_autoreload")){
371 ui->actionAuto_reload->setChecked(false);
372 }
373
374 onYarpNameList();
375}
376
380{
382 if(logger->errorCount() || logger->warningCount()){
383 const char* err;
384 while((err=logger->getLastError())){
385 onLogError(err);
386 }
387 while((err=logger->getLastWarning())){
388 onLogWarning(err);
389 }
390 }
391}
392
395void MainWindow::syncApplicationList(QString selectNodeForEditing, bool open)
396{
397 if (!listOfAppFiles.isEmpty())
398 {
399 watcher->removePaths(listOfAppFiles);
400 }
401 listOfAppFiles.clear();
402 ui->entitiesTree->clearApplications();
403 ui->entitiesTree->clearModules();
404 ui->entitiesTree->clearResources();
405 //ui->entitiesTree->clearTemplates();
408 unsigned int cnt = 0;
409 for(auto& itr : apps){
410 cnt++;
411 auto* app = dynamic_cast<yarp::manager::Application*>(itr);
412 if(app){
413 ui->entitiesTree->addApplication(app);
414 if(strcmp(selectNodeForEditing.toLatin1().data(),app->getName())==0){
415 emit selectItem(selectNodeForEditing, open);
416 }
417 listOfAppFiles.push_back(app->getXmlFile());
418 }
419 }
420
421 watcher->addPaths(listOfAppFiles);
422
424 for(auto& resource : resources) {
425 auto* comp = dynamic_cast<yarp::manager::Computer*>(resource);
426 if(comp){
427 ui->entitiesTree->addComputer(comp);
428 }
429 }
430
432 for(auto& module : modules) {
433 auto* mod = dynamic_cast<yarp::manager::Module*>(module);
434 if(mod){
435 ui->entitiesTree->addModule(mod);
436 }
437 }
438
439
440 if(cnt){
441 QString msg = QString("%1 applications are loaded successfully.").arg(cnt);
442 onLogMessage(msg);
443 }
444 else{
445 QString msg = QString("No application is loaded!");
446 onLogMessage(msg);
447 }
448}
449
453bool MainWindow::loadRecursiveTemplates(const char* szPath)
454{
455 const std::string directorySeparator{yarp::conf::filesystem::preferred_separator};
456 std::string strPath = szPath;
457 if((strPath.rfind(directorySeparator)==std::string::npos) ||
458 (strPath.rfind(directorySeparator)!=strPath.size()-1)) {
459 strPath.append(directorySeparator);
460 }
461
462 DIR *dir;
463 struct dirent *entry;
464 if ((dir = opendir(strPath.c_str())) == nullptr) {
465 return false;
466 }
467
468 // loading from current folder
470 yarp::manager::XmlTempLoader tempload(strPath.c_str(), nullptr);
471 if(tempload.init())
472 {
473 while((tmp = tempload.getNextAppTemplate())){
474 ui->entitiesTree->addAppTemplate(tmp);
475 }
476 }
477
478 while((entry = readdir(dir)))
479 {
480 if((std::string(entry->d_name) != std::string("."))
481 && (std::string(entry->d_name) != std::string("..")))
482 {
483
484 std::string name = strPath + std::string(entry->d_name);
485 loadRecursiveTemplates(name.c_str());
486 }
487 }
488 closedir(dir);
489
490 return true;
491}
492
496bool MainWindow::loadRecursiveApplications(const char* szPath)
497{
498 const std::string directorySeparator{yarp::conf::filesystem::preferred_separator};
499 std::string strPath = szPath;
500 if ((strPath.rfind(directorySeparator) == std::string::npos) || (strPath.rfind(directorySeparator) != strPath.size() - 1)) {
501 strPath = strPath + directorySeparator;
502 }
503
504 DIR *dir;
505 struct dirent *entry;
506 if ((dir = opendir(strPath.c_str())) == nullptr) {
507 return false;
508 }
509
510 lazyManager.addApplications(strPath.c_str());
511
512 while((entry = readdir(dir)))
513 {
514 if((std::string(entry->d_name) != std::string("."))
515 && (std::string(entry->d_name) != std::string("..")))
516 {
517 std::string name = strPath + std::string(entry->d_name);
518 loadRecursiveApplications(name.c_str());
519 }
520 }
521 closedir(dir);
522 return true;
523}
524
525bool MainWindow::initializeFile(std::string _class)
526{
527 QFile f(fileName);
528 bool b = f.open(QIODevice::ReadWrite);
529 QString appTemplate = "<application>\n"
530 " <name>" + currentAppName + "</name>\n"
531 " <description>" + currentAppDescription + "</description>\n"
532 " <version>" + currentAppVersion + "</version>\n"
533 " <authors>\n"
534 " </authors>\n"
535 "</application>\n";
536 if(b){
537 if (_class == "Resource") {
538 f.write(str_res_template.c_str());
539 } else if (_class == "Module") {
540 f.write(str_mod_template.c_str());
541 } else if (_class == "Application") {
542 f.write(appTemplate.toStdString().c_str());
543 } else {
544 return false;
545 }
546 f.flush();
547 f.close();
548 return true;
549 }else{
551 QString err = QString("Cannot create %1").arg(fileName);
552 logger->addError(err.toLatin1().data());
553 reportErrors();
554 return false;
555 }
556}
557
558int MainWindow::getAppTabIndex(QString appName)
559{
560 for (int i=0; i<ui->mainTabs->count(); i++){
561 if (ui->mainTabs->tabText(i) == appName){
562 return i;
563 }
564 }
565 return -1;
566}
567
568QString MainWindow::getAppNameFromXml(QString fileName)
569{
570 QString appName("");
573 for(auto& itr : apps)
574 {
575 auto* app = dynamic_cast<yarp::manager::Application*>(itr);
576 if(app)
577 {
578 if(app->getXmlFile() == fileName.toStdString())
579 {
580 return app->getName();
581 }
582 }
583 }
584 return appName;
585}
586
591{
592 for(int i=0;i<ui->mainTabs->count();i++){
593 if(ui->mainTabs->tabText(i) == res->getName()){
594 ui->mainTabs->setCurrentIndex(i);
595 return;
596 }
597 }
598
599 auto* w = new ResourceViewWidget(res,ui->mainTabs);
600 int index = ui->mainTabs->addTab(w,res->getName());
601 ui->mainTabs->setTabIcon(index,QIcon(":/computer22.svg"));
602 ui->mainTabs->setCurrentIndex(index);
603}
609{
610 for(int i=0;i<ui->mainTabs->count();i++){
611 if(ui->mainTabs->tabText(i) == module->getName()){
612 ui->mainTabs->setCurrentIndex(i);
613 return;
614 }
615 }
616
617 auto* w = new ModuleViewWidget(module,ui->mainTabs);
618 int index = ui->mainTabs->addTab(w,module->getName());
619 ui->mainTabs->setTabIcon(index,QIcon(":/module22.svg"));
620 ui->mainTabs->setCurrentIndex(index);
621}
622
627{
628
629 for (int i=0; i<ui->mainTabs->count(); i++){
630 if (ui->mainTabs->tabText(i) == app->getName()){
631 ui->mainTabs->setCurrentIndex(i);
632 return;
633 }
634 }
635
636 auto* w = new ApplicationViewWidget(app,&lazyManager,&config,editingMode,ui->mainTabs);
637 connect(w,SIGNAL(logError(QString)),this,SLOT(onLogError(QString)));
638 connect(w,SIGNAL(logWarning(QString)),this,SLOT(onLogWarning(QString)));
639 connect(w,SIGNAL(modified(bool)),this,SLOT(onModified(bool)));
640 int index = ui->mainTabs->addTab(w,app->getName());
641 ui->mainTabs->setTabIcon(index,QIcon(":/run22.svg"));
642 ui->mainTabs->setCurrentIndex(index);
643 if(!editingMode)
644 {
645 connect(w->getConnectionList(),SIGNAL(itemSelectionChanged()),this,SLOT(onApplicationSelectionChanged()));
646 connect(w->getModuleList(),SIGNAL(itemSelectionChanged()),this,SLOT(onApplicationSelectionChanged()));
647 }
648 if(editingMode){
649 ui->actionSelect_All->setEnabled(false);
650 ui->actionRefresh_Status->setEnabled(false);
651 ui->actionExport_Graph->setEnabled(false);
652 ui->actionConnect_all->setEnabled(false);
653 ui->actionDisconnect_all->setEnabled(false);
654 ui->actionRun_all->setEnabled(false);
655 ui->actionStop_all->setEnabled(false);
656 ui->actionKill_all->setEnabled(false);
657 ui->actionConnect->setEnabled(false);
658 ui->actionDisconnect->setEnabled(false);
659 ui->actionRun->setEnabled(false);
660 ui->actionStop->setEnabled(false);
661 ui->actionKill->setEnabled(false);
662 }else{
663 ui->actionSelect_All->setEnabled(true);
664 ui->actionRefresh_Status->setEnabled(true);
665 ui->actionExport_Graph->setEnabled(true);
666 ui->actionConnect_all->setEnabled(true);
667 ui->actionDisconnect_all->setEnabled(true);
668 ui->actionRun_all->setEnabled(true);
669 ui->actionStop_all->setEnabled(true);
670 ui->actionKill_all->setEnabled(true);
671 onRefresh();
672 }
673}
674
677void MainWindow::onExportGraph()
678{
679 QWidget *w = ui->mainTabs->currentWidget();
680 if(!w){
681 return;
682 }
683 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
684 if(type == yarp::manager::APPLICATION){
685 auto* ww = (ApplicationViewWidget*)w;
686 ww->exportGraph();
687 }
688}
689
692void MainWindow::onRun(bool onlySelected)
693{
694 QWidget *w = ui->mainTabs->currentWidget();
695 if(!w){
696 return;
697 }
698 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
699 if(type == yarp::manager::APPLICATION){
700 auto* ww = (ApplicationViewWidget*)w;
701 ww->runApplicationSet(onlySelected);
702 }
703}
704
707void MainWindow::onStop(bool onlySelected)
708{
709 QWidget *w = ui->mainTabs->currentWidget();
710 if(!w){
711 return;
712 }
713 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
714 if(type == yarp::manager::APPLICATION){
715 auto* ww = (ApplicationViewWidget*)w;
716 ww->stopApplicationSet(onlySelected);
717 }
718}
719
722void MainWindow::onKill(bool onlySelected)
723{
724 QWidget *w = ui->mainTabs->currentWidget();
725 if(!w){
726 return;
727 }
728 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
729 if(type == yarp::manager::APPLICATION){
730 auto* ww = (ApplicationViewWidget*)w;
731 ww->killApplicationSet(onlySelected);
732 }
733}
734
737void MainWindow::onConnect(bool onlySelected)
738{
739 QWidget *w = ui->mainTabs->currentWidget();
740 if(!w){
741 return;
742 }
743 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
744 if(type == yarp::manager::APPLICATION){
745 auto* ww = (ApplicationViewWidget*)w;
746 ww->connectConnectionSet(onlySelected);
747 }
748}
751void MainWindow::onDisconnect(bool onlySelected)
752{
753 QWidget *w = ui->mainTabs->currentWidget();
754 if(!w){
755 return;
756 }
757 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
758 if(type == yarp::manager::APPLICATION){
759 auto* ww = (ApplicationViewWidget*)w;
760 ww->disconnectConnectionSet(onlySelected);
761 }
762}
763
764void MainWindow::onRunSelected()
765{
766 onRun(true);
767}
768void MainWindow::onStopSelected()
769{
770 onStop(true);
771}
772void MainWindow::onKillSelected()
773{
774 onKill(true);
775}
776void MainWindow::onConnectSelected()
777{
778 onConnect(true);
779}
780void MainWindow::onDisconnectSelected()
781{
782 onDisconnect(true);
783}
786void MainWindow::onRefresh()
787{
788 QWidget *w = ui->mainTabs->currentWidget();
789 if(!w){
790 return;
791 }
792 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
793 if(type == yarp::manager::APPLICATION){
794 auto* ww = (ApplicationViewWidget*)w;
795 ww->refresh();
796 }
797
798 if(type == yarp::manager::RESOURCE){
799 auto* ww = (ResourceViewWidget*)w;
800 ww->refresh();
801 }
802}
803
806void MainWindow::onSelectAll()
807{
808 QWidget *w = ui->mainTabs->currentWidget();
809 if(!w){
810 return;
811 }
812 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
813 if(type == yarp::manager::APPLICATION){
814 auto* ww = (ApplicationViewWidget*)w;
815 ww->selectAll();
816 }
817}
818
822bool MainWindow::onTabClose(int index)
823{
824 auto* w = (GenericViewWidget*)ui->mainTabs->widget(index);
825 if(!w){
826 return false;
827 }
828 if(w->getType() == yarp::manager::APPLICATION){
830
831 if(aw && aw->isRunning()){
832 QMessageBox msgBox;
833 msgBox.setIcon(QMessageBox::Icon::Warning);
834 msgBox.setWindowTitle(QString("Closing %1").arg(ui->mainTabs->tabText(index)));
835 msgBox.setText(tr("You have some running module. After closing the application window you might not be able to recover them. Are you sure?"));
836 QPushButton* noButton = msgBox.addButton(tr("No"), QMessageBox::NoRole);
837 QPushButton* pstopAndClose = msgBox.addButton(tr("Yes and Stop"), QMessageBox::YesRole);
838 msgBox.addButton(tr("Yes"), QMessageBox::YesRole);
839 msgBox.setDefaultButton(noButton);
840 msgBox.exec();
841
842 if (msgBox.clickedButton() == noButton)
843 {
844 return false;
845 }
846 else if(msgBox.clickedButton() == pstopAndClose)
847 {
848 onStop();
849 }
850 }
851
852 QString fileOfCurrentApp = aw->getFileName();
853
854 if(aw->isModified() && aw->isEditingMode()){
855 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()),
856 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
857 if(btn == QMessageBox::Yes){
858 bool ret = aw->save();
859 if(ret){
860 onReopenApplication(aw->getAppName(),fileOfCurrentApp);
861 ui->mainTabs->removeTab(index);
862 delete w;
863 return true;
864
865 }else{
866 QMessageBox::critical(this,"Error",QString("Error Saving the file"));
867 return false;
868 }
869 }
870 if(btn == QMessageBox::Cancel){
871 return false;
872 }
873 if (btn == QMessageBox::No){
874 QFile file(fileOfCurrentApp);
875 if(!file.exists()){
876 ui->entitiesTree->setCurrentItem(ui->entitiesTree->getWidgetItemByFilename(fileOfCurrentApp));
877 ui->entitiesTree->onRemove();
878 aw->closeManager();
879 ui->mainTabs->removeTab(index);
880 delete w;
881 return true;
882 }
883 }
884
885 }
886 aw->closeManager();
887 }
888 ui->mainTabs->removeTab(index);
889 delete w;
890 return true;
891}
892
896void MainWindow::onLogError(QString msg)
897{
898 QString text = QString ("[ERR] %1").arg(msg);
899 ui->logWidget->addItem(text);
900 ui->logWidget->item(ui->logWidget->count() - 1)->setBackground(QColor("#F9CCCA"));
901 ui->logWidget->setCurrentRow(ui->logWidget->count() - 1);
902}
903
907void MainWindow::onLogWarning(QString msg)
908{
909 QString text = QString ("[WAR] %1").arg(msg);
910 ui->logWidget->addItem(text);
911 ui->logWidget->item(ui->logWidget->count() - 1)->setBackground(QColor("#FFF6C8"));
912 ui->logWidget->setCurrentRow(ui->logWidget->count() - 1);
913}
914
918void MainWindow::onLogMessage(QString msg)
919{
921 msg = QString("[time: %1] ").arg(getElapsedTimeString(clock.getStartTime()).c_str()) + msg;
922 QString text = QString ("[MSG] %1").arg(msg);
923 ui->logWidget->addItem(text);
924 ui->logWidget->setCurrentRow(ui->logWidget->count() - 1);
925}
926
927
932{
933
934 auto* w = (GenericViewWidget*)ui->mainTabs->widget(index);
935 if(w && w->getType() == yarp::manager::APPLICATION){
936 auto* aw = (ApplicationViewWidget*)w;
937 if(aw->isEditingMode()){
938 ui->actionSelect_All->setEnabled(false);
939 ui->actionRefresh_Status->setEnabled(false);
940 ui->actionExport_Graph->setEnabled(false);
941 ui->actionConnect_all->setEnabled(false);
942 ui->actionDisconnect_all->setEnabled(false);
943 ui->actionRun_all->setEnabled(false);
944 ui->actionStop_all->setEnabled(false);
945 ui->actionKill_all->setEnabled(false);
946 ui->actionConnect->setEnabled(false);
947 ui->actionDisconnect->setEnabled(false);
948 ui->actionRun->setEnabled(false);
949 ui->actionStop->setEnabled(false);
950 ui->actionKill->setEnabled(false);
951 }else{
952 ui->actionSelect_All->setEnabled(true);
953 ui->actionRefresh_Status->setEnabled(true);
954 ui->actionExport_Graph->setEnabled(true);
955 ui->actionConnect_all->setEnabled(true);
956 ui->actionDisconnect_all->setEnabled(true);
957 ui->actionRun_all->setEnabled(true);
958 ui->actionStop_all->setEnabled(true);
959 ui->actionKill_all->setEnabled(true);
961 }
962
963
964 if(w->isModified()){
965 ui->actionSave->setEnabled(true);
966 ui->actionSave_As->setEnabled(true);
967 }else{
968 ui->actionSave->setEnabled(false);
969 ui->actionSave_As->setEnabled(false);
970 }
971 }
972 else {
973
974 if(w && w->getType() == yarp::manager::RESOURCE){
975 ui->actionRefresh_Status->setEnabled(true);
976 prevWidget = w;
977 }else{
978 ui->actionRefresh_Status->setEnabled(false);
979 prevWidget = nullptr;
980 }
981
982 ui->actionSelect_All->setEnabled(false);
983 ui->actionExport_Graph->setEnabled(false);
984 ui->actionConnect_all->setEnabled(false);
985 ui->actionDisconnect_all->setEnabled(false);
986 ui->actionRun_all->setEnabled(false);
987 ui->actionStop_all->setEnabled(false);
988 ui->actionKill_all->setEnabled(false);
989 ui->actionConnect->setEnabled(false);
990 ui->actionDisconnect->setEnabled(false);
991 ui->actionRun->setEnabled(false);
992 ui->actionStop->setEnabled(false);
993 ui->actionKill->setEnabled(false);
994 }
995}
996
998void MainWindow::onNewApplication()
999{
1000 auto* newApplicationWizard = new NewApplicationWizard(&config);
1001 newApplicationWizard->setWindowTitle("Create New Application");
1002 if (newApplicationWizard->exec() == QDialog::Accepted){
1003
1004 currentAppName = newApplicationWizard->name;
1005 currentAppDescription = newApplicationWizard->description;
1006 currentAppVersion = newApplicationWizard->version;
1007 fileName = newApplicationWizard->fileName;
1008 size_t len = newApplicationWizard->name.toLatin1().size();
1009 char* appName;
1010 appName = new char [len+1];
1011 strncpy(appName, newApplicationWizard->name.toLatin1().data(), len);
1012 appName[len] = '\0';
1013 if (newApplicationWizard->alreadyExists)
1014 {
1015 if (!lazyManager.removeApplication(newApplicationWizard->fileName.toLatin1().data(),
1016 appName))
1017 {
1018 reportErrors();
1019 if(appName)
1020 {
1021 delete [] appName;
1022 appName = nullptr;
1023 }
1024 return;
1025 }
1026 }
1027 initializeFile("Application");
1028
1029 if (lazyManager.addApplication(newApplicationWizard->fileName.toLatin1().data(),
1030 &appName,true))
1031 {
1032 QString newApp(appName);
1033 syncApplicationList(newApp);
1034
1035 }
1036 else
1037 {
1038 reportErrors();
1039 }
1040
1041 if(appName)
1042 {
1043 delete [] appName;
1044 appName = nullptr;
1045 }
1046 delete newApplicationWizard;
1047 QFile f(fileName);
1048 f.remove();
1049 onModified(true);
1050 return;
1051 }
1052 delete newApplicationWizard;
1053 qDebug() << "Rejected";
1054}
1055
1057void MainWindow::onNewResource()
1058{
1060
1061 fileName = QFileDialog::getSaveFileName(this,"Create new Resource description file",QApplication::applicationDirPath(),
1062 "Resource description files (*.xml)");
1063
1064 if(!initializeFile("Resource"))
1065 {
1066 QString msg = QString("Error while initializing %1.").arg(fileName.toStdString().c_str());
1067 logger->addError(msg.toLatin1().data());
1068 reportErrors();
1069 return;
1070 }
1071
1073 if(launcher.init(ext_editor.c_str(), fileName.toLatin1().data(), nullptr, nullptr, nullptr, nullptr)){
1074 if(!launcher.start() && !launcher.error().empty()){
1075 QString msg = QString("Error while launching %1. %2").arg(ext_editor.c_str()).arg(launcher.error().c_str());
1076 logger->addError(msg.toLatin1().data());
1077 reportErrors();
1078 }
1079 }
1080
1081}
1082
1084void MainWindow::onNewModule()
1085{
1087
1088 fileName = QFileDialog::getSaveFileName(this,"Create new Module description file",QApplication::applicationDirPath(),
1089 "Module description files (*.xml)");
1090
1091 if(!initializeFile("Module"))
1092 {
1093 QString msg = QString("Error while initializing %1.").arg(fileName.toStdString().c_str());
1094 logger->addError(msg.toLatin1().data());
1095 reportErrors();
1096 return;
1097 }
1098
1100 if(launcher.init(ext_editor.c_str(), fileName.toLatin1().data(), nullptr, nullptr, nullptr, nullptr)){
1101 if(!launcher.start() && !launcher.error().empty()){
1102 QString msg = QString("Error while launching %1. %2").arg(ext_editor.c_str()).arg(launcher.error().c_str());
1103 logger->addError(msg.toLatin1().data());
1104 reportErrors();
1105 }
1106 }
1107
1108}
1109
1111void MainWindow::onImportFiles()
1112{
1113 QString dir = QFileDialog::getExistingDirectory(this, tr("Please choose a folder"),
1114 QApplication::applicationDirPath(),
1115 QFileDialog::ShowDirsOnly
1116 | QFileDialog::DontResolveSymlinks);
1117 if(!dir.isEmpty()){
1118 if(config.find("load_subfolders").asString() == "yes"){
1119 if (loadRecursiveApplications(dir.toLatin1().data())) {
1120 syncApplicationList();
1121 }
1122 }
1123 else{
1124 if (lazyManager.addApplications(dir.toLatin1().data())) {
1125 syncApplicationList();
1126 }
1127 }
1128
1129 if(lazyManager.addResources(dir.toLatin1().data())){
1130 syncApplicationList();
1131 }
1132
1133 if(lazyManager.addModules(dir.toLatin1().data())){
1134 syncApplicationList();
1135 }
1136
1137 reportErrors();
1138 }
1139}
1140
1142void MainWindow::onClose()
1143{
1144 int index = ui->mainTabs->currentIndex();
1145 if(index < 0){
1146 return;
1147 }
1148 onTabClose(index);
1149}
1150
1151void MainWindow::onModified(bool mod)
1152{
1153 ui->actionSave->setEnabled(mod);
1154 ui->actionSave_As->setEnabled(mod);
1155 int index = ui->mainTabs->currentIndex();
1156 auto* gw = (GenericViewWidget*)ui->mainTabs->currentWidget();
1157 if(gw->getType() == yarp::manager::APPLICATION){
1158 auto* w = (ApplicationViewWidget*)gw;
1159 if(mod){
1160 ui->mainTabs->setTabText(index,w->getAppName() + "*");
1161 gw->setModified(mod);
1162 }else{
1163 ui->mainTabs->setTabText(index,w->getAppName());
1164 }
1165 }
1166}
1167
1168void MainWindow::onFileChanged(const QString &path)
1169{
1170
1171 watcher->addPaths(listOfAppFiles);
1172 if (!ui->actionAuto_reload->isChecked())
1173 {
1174 return;
1175 }
1176
1177 // get the app name from the file name
1178 QString appName = getAppNameFromXml(path);
1179
1180 QMessageBox::StandardButton reply;
1181 reply = QMessageBox::question(this, "File changed", "Xml file '" + path +
1182 "' changed.\nDo you want to reload the application? If open, the respective tab will be closed",
1183 QMessageBox::Yes|QMessageBox::No);
1184 if (reply == QMessageBox::No) {
1185 return;
1186 }
1187
1188 Application* app = (Application*) lazyManager.getNode(appName.toStdString());
1189 if (app)
1190 {
1191 int index = getAppTabIndex(appName);
1192 if (index >= 0)
1193 {
1194 if (!onTabClose(index))
1195 {
1196 return;
1197 }
1198 else
1199 {
1200 // refresh it in the application list
1201 onReopenApplication(appName, path);
1202 // the reference has been changed reopening the application
1203 app = (Application*) lazyManager.getNode(appName.toStdString());
1204 // is it already open in the tab? if so close it and reopen it after the refresh
1205 if (app)
1206 {
1207 viewApplication(app, false);
1208 }
1209 return; }
1210 }
1211 else
1212 {
1213 // refresh it in the application list
1214 onReopenApplication(appName, path);
1215 return;
1216 }
1217 }
1218 return;
1219}
1220
1221void MainWindow::onYarpClean()
1222{
1224 {
1225 onLogWarning(QString::fromLatin1("yarpserver is not running"));
1226 return;
1227 }
1228 QInputDialog* inputDialog = new QInputDialog(this);
1229 inputDialog->setOptions(QInputDialog::NoButtons);
1230
1231 bool ok=false;
1232
1233 float timeout = inputDialog->getDouble(nullptr ,"Running yarp clean",
1234 "Be aware that yarp clean with a little timetout could\n"
1235 "unregister ports that are actually open.\n\n"
1236 "Timeout(seconds):", 0.3, 0, 2147483647, 1, &ok);
1237 if (ok)
1238 {
1239 onLogMessage(QString("YARP clean: cleaning death ports..."));
1241 onYarpNameList();
1242 }
1243
1244}
1245
1246void MainWindow::onYarpNameList()
1247{
1249 {
1250 onLogWarning(QString::fromLatin1("yarpserver is not running"));
1251 return;
1252 }
1253 ui->entitiesTree->clearPorts();
1256 for(auto& port : ports)
1257 {
1258 std::string portName = port.name;
1259 std::string portIp = port.ip + " port " + port.port_number;
1260 ui->entitiesTree->addPort(QStringList() << QString(portName.c_str())
1261 << QString(portIp.c_str()));
1262 }
1263 onLogMessage(QString::fromLatin1("Running yarp name list...found %1 ports").arg(ports.size()));
1264}
1265
1266void MainWindow::onSave()
1267{
1268 auto* w = (GenericViewWidget *)ui->mainTabs->currentWidget();
1269 if(!w){
1270 return;
1271 }
1272 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
1273 if(type == yarp::manager::APPLICATION){
1274 auto* ww = (ApplicationViewWidget*)w;
1275 bool ret = ww->save();
1276 if(ret){
1277 onReopenApplication(ww->getAppName(),ww->getFileName());
1278 }else{
1279 QMessageBox::critical(this,"Error",QString("Error Saving the file"));
1280 }
1281 }
1282}
1283
1284void MainWindow::onSaveAs()
1285{
1286 auto* newApplicationWizard = new NewApplicationWizard(&config,true);
1287 newApplicationWizard->setWindowTitle("Save Application as");
1288 if(newApplicationWizard->exec() == QDialog::Accepted){
1289 fileName = newApplicationWizard->fileName;
1290 delete newApplicationWizard;
1291 }
1292 else
1293 {
1294 delete newApplicationWizard;
1295 return;
1296 }
1297 if(fileName.trimmed().size() == 0 || fileName.contains(" ")){
1298 QMessageBox::critical(nullptr, QObject::tr("Error"), QObject::tr(std::string("Invalid file name " + fileName.toStdString()).c_str()));
1299 return;
1300 }
1301
1302 auto* w = (GenericViewWidget *)ui->mainTabs->currentWidget();
1303 if(!w){
1304 return;
1305 }
1306 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
1307 if(type == yarp::manager::APPLICATION){
1308 auto* ww = (ApplicationViewWidget*)w;
1309 QString oldAppName = ww->getAppName();
1310 QString oldFileName = ww->getFileName();
1311 ww->setFileName(fileName);
1312 size_t it1 = fileName.toStdString().find(".xml");
1313 if(it1 == std::string::npos)
1314 {
1315 yError("yarpmanager: '.xml' not present in filename");
1316 return;
1317 }
1318 QString appName = fileName.toStdString().substr(0,it1).c_str();
1319 size_t it2 =appName.toStdString().find_last_of('/');
1320 if(it2 != std::string::npos)
1321 {
1322 currentAppName = appName.toStdString().substr(it2+1).c_str();
1323 }
1324 else
1325 {
1326 currentAppName = appName;
1327 }
1328 ww->setAppName(currentAppName);
1329 if(fileName.isEmpty()){
1330 return;
1331 }
1332 reportErrors();
1333 onSave();
1334 ww->setAppName(oldAppName);
1335 ww->setFileName(oldFileName);
1336 onTabClose(ui->mainTabs->currentIndex());
1337 syncApplicationList();
1338 Application* newApp = (Application*) lazyManager.getNode(currentAppName.toStdString());
1339 if (newApp)
1340 {
1341 viewApplication(newApp,true);
1342 }
1343 }
1344}
1345
1347void MainWindow::onOpen()
1348{
1349 QString fileName = QFileDialog::getOpenFileName(this,"Please choose a File",QCoreApplication::applicationDirPath(),
1350 "Application description files (*.xml);;Modules description files (*.xml);;Resource description files (*.xml);;Any files (*.xml)");
1351
1352 if(fileName.isEmpty()){
1353 return;
1354 }
1355
1356 char* name = nullptr;
1357
1358 if(lazyManager.addApplication(fileName.toLatin1().data(), &name, true)){
1359 QString appName(name);
1360 syncApplicationList(appName,true);
1361 }
1362 if(name)
1363 {
1364 delete [] name;
1365 name = nullptr;
1366 }
1367
1368 if(lazyManager.addResource(fileName.toLatin1().data())){
1369 syncApplicationList();
1370 }
1371 if(lazyManager.addModule(fileName.toLatin1().data())){
1372 syncApplicationList();
1373 }
1374 reportErrors();
1375
1376}
1378void MainWindow::onAbout()
1379{
1380 QString copyright = "Copyright (C) 2006-2021 Istituto Italiano di Tecnologia (IIT)";
1381 QString name = APP_NAME;
1382 QString version = YARP_VERSION;
1383 AboutDlg dlg(name,version,copyright,"https://www.iit.it/");
1384 dlg.exec();
1385}
1386
1389void MainWindow::onHelp()
1390{
1391 QDesktopServices::openUrl(QUrl("http://www.yarp.it/yarpmanager.html"));
1392}
1393
1394void MainWindow::onRemoveApplication(QString xmlFile, QString appName)
1395{
1396 lazyManager.removeApplication(xmlFile.toLatin1().data(),appName.toLatin1().data());
1397 syncApplicationList();
1398}
1399
1400
1401void MainWindow::onReopenApplication(QString appName,QString fileName)
1402{
1403 lazyManager.removeApplication(fileName.toLatin1().data(), appName.toLatin1().data());
1404 char * appNamePtr = appName.toLatin1().data();
1405 lazyManager.addApplication(fileName.toLatin1().data(), &appNamePtr);
1406 syncApplicationList();
1407}
1408
1409void MainWindow::onRemoveModule(QString modName)
1410{
1411 lazyManager.removeModule(modName.toLatin1().data());
1412 syncApplicationList();
1413}
1414
1415void MainWindow::onReopenModule(QString modName,QString fileName)
1416{
1417 lazyManager.removeModule(modName.toLatin1().data());
1418 lazyManager.addModule(fileName.toLatin1().data());
1419 syncApplicationList();
1420}
1421
1422void MainWindow::onRemoveResource(QString resName)
1423{
1424 lazyManager.removeResource(resName.toLatin1().data());
1425 syncApplicationList();
1426}
1427
1428void MainWindow::onReopenResource(QString resName,QString fileName)
1429{
1430 lazyManager.removeResource(resName.toLatin1().data());
1431 lazyManager.addResource(fileName.toLatin1().data());
1432 syncApplicationList();
1433}
1434
1436{
1437 QWidget *w = ui->mainTabs->currentWidget();
1438 if(!w){
1439 return;
1440 }
1441 yarp::manager::NodeType type = ((GenericViewWidget*)w)->getType();
1442 if(type == yarp::manager::APPLICATION){
1443 auto* ww = (ApplicationViewWidget*)w;
1444 ui->actionRun->setEnabled(ww->anyModuleSelected());
1445 ui->actionStop->setEnabled(ww->anyModuleSelected());
1446 ui->actionKill->setEnabled(ww->anyModuleSelected());
1447 ui->actionConnect->setEnabled(ww->anyConnectionSelected());
1448 ui->actionDisconnect->setEnabled(ww->anyConnectionSelected());
1449 }
1450}
#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:185
bool addModule(const char *szFileName)
Definition manager.cpp:128
bool removeModule(const char *szModName)
Definition manager.cpp:203
bool addModules(const char *szPath)
Definition manager.cpp:142
bool addResources(const char *szPath)
Definition manager.cpp:171
Node * getNode(std::string appName)
Definition manager.cpp:484
bool addApplication(const char *szFileName, char **szAppName_=nullptr, bool modifyName=false)
Definition manager.cpp:91
bool addResource(const char *szFileName)
Definition manager.cpp:156
bool removeResource(const char *szResName)
Definition manager.cpp:221
bool addApplications(const char *szPath)
Definition manager.cpp:111
KnowledgeBase * getKnowledgeBase()
Definition manager.h:106
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:1495
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:44
virtual std::string asString() const
Get string value.
Definition Value.cpp:246
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)