YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
applicationviewwidget.h
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#ifndef APPLICATIONVIEWWIDGET_H
7#define APPLICATIONVIEWWIDGET_H
8
9#include <QWidget>
11#include <yarp/manager/module.h>
12#include <QTreeWidgetItem>
13#include "safe_manager.h"
14#include "genericviewwidget.h"
15#include "stdoutwindow.h"
16#include <QList>
17#include <QDockWidget>
18#include "yarpbuilderlib.h"
19#include <customtreewidget.h>
20
21namespace Ui {
23}
24
29{
30 Q_OBJECT
31
32public:
34 yarp::manager::Manager *lazyManager,
35 yarp::os::Property* config,
36 bool editingMode = false,
37 QWidget *parent = nullptr);
38 ~ApplicationViewWidget() override;
39
40 void runApplicationSet(bool onlySelected);
41 void stopApplicationSet(bool onlySelected);
42 void killApplicationSet(bool onlySelected);
43 void connectConnectionSet(bool onlySelected);
44 void disconnectConnectionSet(bool onlySelected);
45 void refresh();
46 void selectAll();
47 void exportGraph();
48
49 bool isRunning();
50
51 void onModStart(int which) override;
52 void onModStop(int which) override;
53 void onModStdout(int which, const char* msg) override;
54 void onConConnect(int which) override;
55 void onConDisconnect(int which) override;
56 void onResAvailable(int which) override;
57 void onResUnAvailable(int which) override;
58 void onConAvailable(int from, int to) override;
59 void onConUnAvailable(int from, int to) override;
60 void onError() override;
61 void onLoadBalance() override;
62 void closeManager();
63 QToolBar* getBuilderToolBar();
65 void showBuilder(bool);
66
67 bool anyModuleSelected();
69
72
73 bool save();
74 QString getFileName();
75 void setFileName(QString filename);
76 QString getAppName();
77 void setAppName(QString appName);
78
79 bool isEditingMode();
80
81private:
82 bool getConRowByID(int id, int *row);
83 bool getResRowByID(int id, int *row);
84 QTreeWidgetItem *getModRowByID(int id, QTreeWidgetItem *parent = NULL);
85 void reportErrors();
86 void prepareManagerFrom(yarp::manager::Manager* lazy);
87 void updateApplicationWindow();
88 bool isEditable(QTreeWidgetItem *it,int col);
89 void selectAllModule(bool check);
90 void selectAllConnections(bool check);
91 void selectAllResources(bool check);
92 void createModulesViewContextMenu();
93 void createConnectionsViewContextMenu();
94 void createResourcesViewContextMenu();
95 bool timeout(double base, double timeout);
96 bool areAllShutdown();
97 void runNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs);
98 void stopNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs);
99 void killNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs);
100 void refreshNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs);
101 bool areAllNestedApplicationShutdown(QTreeWidgetItem *it);
102 void closeNestedApplicationStdOut(QTreeWidgetItem *it,int id);
103 void assignHostNestedApplication(QTreeWidgetItem *it);
104 void attachStdOutNestedApplication(QTreeWidgetItem *it,std::vector<int> *MIDs);
105 void modStdOutNestedApplication(QTreeWidgetItem *it, int id,QString s);
106 void selectAllNestedApplicationModule(QTreeWidgetItem *it, bool check);
107 bool scanAvailableCarriers(QString carrier, bool isConnection = true);
108 void updateConnection(int index, std::vector<int> &CIDs);
109 void updateConnectionItem(QTreeWidgetItem *it);
110
117 bool costlyRefresh(bool &costly);
118
125 void selectModule(QTreeWidgetItem *it, bool check);
126
127
128
129private:
130 QMainWindow *builderWindowContainer;
131 QDockWidget *builderWidget;
132 BuilderWindow *builder;
133 QToolBar *builderToolBar;
134 QStringList stringLst;
135
136 Ui::ApplicationViewWidget *ui;
137 SafeManager safeManager;
140 yarp::os::Property* m_pConfig;
142
143 QAction *modRunAction;
144 QAction *modStopAction;
145 QAction *modkillAction;
146 QAction *modSeparator;
147 QAction *modRefreshAction;
148 QAction *modSelectAllAction;
149 QAction *modAttachAction;
150 QAction *modAssignAction;
151
152 QMenu *connContex;
153 QMenu *connSubMenu;
154 QAction *connConnectAction;
155 QAction *connDisconnectAction;
156 QAction *connSeparatorAction;
157 QAction *connRefreshAction;
158 QAction *connSelectAllAction;
159 QAction *conn1SeparatorAction;
160 QAction *connInspectAction;
161 QAction *connYARPViewAction;
162 QAction *connYARPReadAction;
163 QAction *connYARPHearAction;
164 QAction *connYARPScopeAction;
165
166 QAction *resRefreshAction;
167 QAction *resSelectAllAction;
168
169 QList <StdoutWindow*> stdoutWinList;
170
171 bool editingMode;
172 bool m_firstRefresh{true}; // flag to perform host enumeration only at the first refresh
173 int m_resourcesNumber{0}; // number of hosts
174
175 std::vector<std::string> listOfResourceNames;
176 std::map<std::string,int> itemsSelectedForResource; // map resource name to number of
177 //items selected for that resource,
178 // used to keep track of how many items are selected for each resource
179
180
181private slots:
182 void onAssignHost();
183 void onCloseStdOut(int);
184 void onAttachStdout();
185 void onDetachStdout();
186 void onYARPView();
187 void onYARPHear();
188 void onYARPRead();
189 void onYARPScope();
190 void onResourceItemSelectionChanged();
191 void onConnectionItemSelectionChanged();
192 void onModuleItemSelectionChanged();
193 void selectAllModule();
194 void selectAllConnections();
195 void selectAllResources();
196 void onItemDoubleClicked(QTreeWidgetItem*,int);
197 void onItemChanged(QTreeWidgetItem*,int);
198 bool onRun();
199 bool onStop();
200 bool onKill();
201 bool onConnect();
202 bool onDisconnect();
203 bool onRefresh();
204
205 void onSelfSafeLoadBalance();
206 void onSelfConnect(int which);
207 void onSelfDisconnect(int which);
208 void onSelfResAvailable(int which);
209 void onSelfResUnavailable(int which);
210 void onSelfStart(int which);
211 void onSelfStop(int which);
212
213 void onRefreshApplication();
214 void onModuleSelected(QList<int> ids);
215 void onConnectionSelected(QList<int> id);
216
217 void onModuleItemChanged(QTreeWidgetItem*,int);
218
219signals:
220 void logWarning(QString);
221 void logError(QString);
222
224 void selfConnect(int);
225 void selfDisconnect(int);
228 void selfStart(int);
229 void selfStop(int);
230
231
232};
233
234#endif // APPLICATIONVIEWWIDGET_H
The Application View Widget.
void onError() override
Called when an error occurred.
void selfResAvailable(int)
void connectConnectionSet(bool onlySelected)
Connect all modules in the application to their ports using connections list.
void selfResUnavailable(int)
void selectAll()
Select all element in the widget (modules, connections, resources)
void setFileName(QString filename)
void runApplicationSet(bool onlySelected)
Run all modules in the application.
void onConConnect(int which) override
Called when a connection has been performed.
void exportGraph()
Export the current Graph.
void logWarning(QString)
void onConAvailable(int from, int to) override
Called when a connection become available.
bool isRunning()
Tells if a modules is in running state.
void onModStart(int which) override
Called when a modlue has been started.
void onLoadBalance() override
Refresh all and reports errors.
void onModStop(int which) override
Called when a modlue has been stopped.
void killApplicationSet(bool onlySelected)
Kill all running modules in the application.
void onConUnAvailable(int from, int to) override
Called when a connection become unavailable.
CustomTreeWidget * getConnectionList()
void setAppName(QString appName)
void onResUnAvailable(int which) override
Called when a resource become unavailable.
void logError(QString)
void disconnectConnectionSet(bool onlySelected)
Disconnect all modules in the application to their ports using connections list.
void onConDisconnect(int which) override
Called when a disconnection has been performed.
CustomTreeWidget * getModuleList()
void onModStdout(int which, const char *msg) override
Called when a modlue has writes on stdout.
void onResAvailable(int which) override
Called when a resource became available.
void stopApplicationSet(bool onlySelected)
Stop all modules in the application.
A custom QTreeWidget.
Generic View Widget.
Class Application.
Class Manager.
Definition manager.h:21
A class for storing options and configuration information.
Definition Property.h:33
std::string ids(size_t indent)
Definition aboutdlg.h:11