ArmarXMainWindow.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#pragma once
25
26#include <QAction>
27#include <QDir>
28#include <QDockWidget>
29#include <QMainWindow>
30#include <QPluginLoader>
31#include <QSplashScreen>
32
36
42
43#include <Inventor/nodes/SoNode.h>
44#include <Inventor/nodes/SoSeparator.h>
45
46class QToolButton;
47class QLabel;
48class QScrollArea;
49class QSignalMapper;
50class QListWidgetItem;
51class QActionGroup;
52class QLineEdit;
53
54namespace Ui
55{
56 class ArmarXMainWindow;
57}
58
59// project
60namespace armarx
61{
62 class GuiUseCaseSelector;
63 class AddArmarXWidgetAction;
64
65 class ArmarXDockWidget;
66
68 {
69 SoNode* node;
70 QPointer<QDialog> sceneConfigDialog;
71 };
72
73 /**
74 * \brief The ArmarXMainWindow class
75 */
76 class ArmarXMainWindow : public QMainWindow, virtual public armarx::Logging
77 {
78 Q_OBJECT
79
80 public:
82 const std::vector<std::string>& packages,
83 const QString& configToLoad,
84 bool disablePreloading);
85 ~ArmarXMainWindow() override;
86
87 /**
88 * loads a plugin with the given file path
89 */
90 void loadPlugin(QString filePath);
91
92 /**
93 * emits the closeRequest signal
94 */
95 void closeEvent(QCloseEvent* event) override;
96
98 void addToRecentlyOpenedFileList(QString configFilepath);
99
100 /**
101 * @brief getDefaultPackageNames returns the names of all packages which are searched for plugins when the ArmarXGuiApp is started.
102 * @return vector of strings containing the names of the default packages
103 */
104 std::vector<std::string> getDefaultPackageNames();
105
106 /**
107 * Provides access to a viewer widget, if existent
108 */
110
111 /*!
112 * \brief Provides access to the coin3d mutex. Use this mutex to protect access to the 3d scene.
113 * \return
114 */
115 std::shared_ptr<std::recursive_mutex> getMutex3D();
116
117 bool existsWidget(const QString& widgetName);
118 QString getLibraryPathFromPackage(const QString& packageName);
119
120 QStringList getFavoriteWidgets();
121
122 public slots:
123 void loadPluginsFromPackage(const QString& packageName);
124 void loadGuiConfig(QString configFilepath = "", bool showAsOpenGuiConfig = true);
125 void appendFileToWindowTitle(const QString& filepath = "");
126
127 signals:
128 /**
129 * emitted, when the main window should be closed
130 */
132
133
134 void updateSceneList(QMap<QString, Viewer3DInfo>);
135 private slots:
136 void closeAllWidgets();
137 void closeAllWidgetsWithDialog();
138 void saveGuiConfig();
139 void saveGuiConfigAs();
140 void updateStatusOfOpenWidgets();
141 void enterFullscreenMode();
142 void leaveFullscreenMode();
143 void toggleWidgetLock();
144
145
146 /**
147 * shows a file dialog for loading a gui plugin
148 */
149 void pluginDialog();
150
151
152 // void listIndexes(const QModelIndexList & indexes);
153 ArmarXWidgetControllerPtr createArmarXWidget(QString widgetName,
154 QString customInstanceName,
155 QSettings* settings = NULL);
156 ArmarXWidgetControllerPtr addArmarXWidget(ArmarXWidgetControllerPtr newWidgetController,
157 bool createViewerWidget = true);
158 void addArmarXWidgetCanceled(ArmarXWidgetControllerPtr newWidgetController);
159 void removeArmarXWidget(QObject* widget);
160 void removeViewerWidget(QObject* widget);
161
162 void on_actionClear_tip_blacklist_triggered();
163
164 void on_actionAbout_triggered();
165
166 void on_actionLoadLastConfig_toggled(bool toggled);
167
168 void on_actionArmarX_Documentation_triggered();
169
170 void on_actionOpen_Use_Case_triggered();
171
172 void on_actionClear_plugin_cache_triggered();
173
174 void updateOpenWidgetButtonStatus(QString widgetName);
175
176 void openWidgetButtonClicked();
177
178 void onContextMenuFavoritesRequested(const QPoint& pos);
179 void onNumberOfMaxFavoritesChanged(int i);
180
181 void updatefavoriteActions();
182
183 private:
184 /**
185 * @brief updates the menu entry with the available widgets.
186 */
187 void updateAvailableWidgetList();
188 void updateOpenWidgetList();
189
190 /**
191 * Add the (optional) icon button to start ArViz Godot to the main widgets if ArViz Godot is available.
192 */
193 void addArVizGodotIcon();
194
195 /**
196 * sets a SoQtExamine rViewer up. This ExaminerViewer is contained by the class member QWidget* view
197 */
198 Viewer3DWidgetPtr setupViewerWidget();
199
200 /**
201 * loads all gui plugins in home/armarx recursively
202 */
203 void loadPlugins(const QString& pluginDir, bool searchRecursive = true);
204
205
206 void loadPlugins(const QSet<QString>& pluginDirs, bool searchRecursive = true);
207 void loadPlugins(const QStringList& fileNames);
208
209 QAction* addActionToToolBar(QAction* action, bool allowText);
210
211 PluginCache pluginCache;
212 QDir pluginsDir;
213 QStringList loadedPackages;
214 std::vector<QPluginLoader*> pluginsToLoad;
215 QList<QDir> directoriesToCheck;
216
217 ::Ui::ArmarXMainWindow* ui;
218
220
221 std::vector<ArmarXGuiInterface*> plugins;
222 QStringList loadedPluginFilepaths;
223
224 QList<QWidget*> widgetsList;
225 // WidgetCreatorMap availableWidgets;
226
227 QMap<QString, Viewer3DInfo> viewer3DMap;
228
229 QSignalMapper* signalMapper;
230 QActionGroup* layoutActions;
231 using OpenWidgetMap = QMap<QString, QPair<QDockWidget*, ArmarXWidgetControllerPtr>>;
232 OpenWidgetMap listOpenWidgets;
233 std::vector<ArmarXWidgetControllerPtr> pendingWidgets;
234 QListWidgetItem* viewerItem;
235
236 QPointer<TipDialog> tipDialog;
237 const int widgetUsageHistoryLength = 100;
238
239
240 std::vector<std::string> defaultPackageNames;
241
242
243 // Emergency Stop
244 EmergencyStopWidgetPtr emergencyStopWidget;
245 BatteryWidgetPtr batteryWidget;
246
247 QAction* leaveFullScreenActionF11;
248 QAction* leaveFullScreenActionEsc;
249
250 bool widgetsLocked;
251
252 private:
253 bool enteredOnce = false;
254 QPointer<QDockWidget> getBiggestOpenWidget();
255 QMenu* getCategoryMenu(const std::string& categoryString, QMenu* menu, QIcon widgetIcon);
256 const std::string settingsFile;
257 QSettings mainSettings;
258 QString configFilepath;
259 QString guiWindowBaseName;
260 QTimer* connectionStatusTimer;
261 QSplashScreen* splashSceen;
262 QString splashscreenPrefix;
263 GuiUseCaseSelector* guiUseCaseSelector;
264 QStringList mainWidgetNames;
265 QToolButton* openWidgetButton;
266 QLineEdit* searchField;
267 AddArmarXWidgetAction* addWidgetAction;
268 std::shared_ptr<std::recursive_mutex> mutex3d;
269 QMap<QString, QAction*> actionList;
270
271 QLabel* favoritesLabel;
272 std::vector<QAction*> favoriteActions;
273 QStringList favoriteActionWidgetNames;
274
275 friend class WidgetNameDialog;
276 friend class Viewer3DWidget;
277 };
278
279 /////////////////////////////////////////////////////////////////////////
280 //// Additional Helper Classes
281 /////////////////////////////////////////////////////////////////////////
282
283 class WidgetNameDialog;
284
285 /**
286 * \brief The ArmarXDockWidget class
287 */
288 class ArmarXDockWidget : public QDockWidget
289 {
290 public:
292 ~ArmarXDockWidget() override;
293 void setArmarXWidget(QWidget* widget);
294 void closeEvent(QCloseEvent* event) override;
295
296 void lockWidget();
297 void unlockWidget();
298
299 private:
301 QScrollArea* scrollArea;
302
303 QWidget* savedTitleBar;
304 };
305
306 class AddArmarXWidgetAction : public QAction
307 {
308 Q_OBJECT
309 public:
310 AddArmarXWidgetAction(QString widgetName,
311 QObject* parent = 0,
312 ArmarXMainWindow* mainGui = 0);
313 ~AddArmarXWidgetAction() override;
314
315 public slots:
316 void triggered(QString widgetName = QString());
317 void addArmarXWidget();
318 void dialogAccepted();
319 signals:
320 void clicked(QString widgetName, QString customInstanceName);
321 void accepted();
322
323 private:
324 ArmarXMainWindow* mainGui;
325 WidgetNameDialog* dialog;
326 };
327
328 class OpenRecentlyOpenedFileAction : public QAction
329 {
330 Q_OBJECT
331 public:
332 OpenRecentlyOpenedFileAction(QString text,
333 QObject* parent = 0,
334 ArmarXMainWindow* mainGui = 0);
335 public slots:
336 void openFile();
337
338 private:
339 ArmarXMainWindow* mainGui;
340 };
341
342
343} // namespace armarx
AddArmarXWidgetAction(QString widgetName, QObject *parent=0, ArmarXMainWindow *mainGui=0)
void triggered(QString widgetName=QString())
void clicked(QString widgetName, QString customInstanceName)
void closeEvent(QCloseEvent *event) override
void setArmarXWidget(QWidget *widget)
ArmarXDockWidget(QString name, ArmarXWidgetControllerPtr controller)
The ArmarXMainWindow class.
void loadPlugin(QString filePath)
loads a plugin with the given file path
ArmarXMainWindow(const armarx::ManagedIceObjectRegistryInterfacePtr &registry, const std::vector< std::string > &packages, const QString &configToLoad, bool disablePreloading)
QString getLibraryPathFromPackage(const QString &packageName)
void appendFileToWindowTitle(const QString &filepath="")
void loadPluginsFromPackage(const QString &packageName)
void addToRecentlyOpenedFileList(QString configFilepath)
std::vector< std::string > getDefaultPackageNames()
getDefaultPackageNames returns the names of all packages which are searched for plugins when the Arma...
void closeRequest()
emitted, when the main window should be closed
void closeEvent(QCloseEvent *event) override
emits the closeRequest signal
std::shared_ptr< std::recursive_mutex > getMutex3D()
Provides access to the coin3d mutex. Use this mutex to protect access to the 3d scene.
void loadGuiConfig(QString configFilepath="", bool showAsOpenGuiConfig=true)
bool existsWidget(const QString &widgetName)
Viewer3DWidgetPtr getViewerWidget()
Provides access to a viewer widget, if existent.
void updateSceneList(QMap< QString, Viewer3DInfo >)
Base Class for all Logging classes.
Definition Logging.h:240
OpenRecentlyOpenedFileAction(QString text, QObject *parent=0, ArmarXMainWindow *mainGui=0)
The WidgetNameDialog class.
ArmarX Headers.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< ManagedIceObjectRegistryInterface > ManagedIceObjectRegistryInterfacePtr
Definition Application.h:83
IceInternal::Handle< EmergencyStopWidget > EmergencyStopWidgetPtr
IceUtil::Handle< Viewer3DWidget > Viewer3DWidgetPtr
IceUtil::Handle< ArmarXWidgetController > ArmarXWidgetControllerPtr
IceInternal::Handle< BatteryWidget > BatteryWidgetPtr
QPointer< QDialog > sceneConfigDialog