gepetto-viewer  6.0.0
An user-friendly Graphical Interface
mainwindow.hh
Go to the documentation of this file.
1 // Copyright (c) 2015-2018, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef GEPETTO_GUI_MAINWINDOW_HH
18 #define GEPETTO_GUI_MAINWINDOW_HH
19 
20 #include <QCheckBox>
21 #include <QLabel>
22 #include <QList>
23 #include <QMainWindow>
24 #include <QStandardItemModel>
29 #include <gepetto/gui/settings.hh>
30 
31 #include "gepetto/gui/fwd.hh"
32 
33 namespace Ui {
34 class MainWindow;
35 }
36 
37 namespace gepetto {
38 namespace gui {
40 class MainWindow : public QMainWindow {
41  Q_OBJECT
42 
43  public:
44  enum RefreshType {
48  };
49 
51 
52  explicit MainWindow(Settings* settings, QWidget* parent = 0);
54 
56  static MainWindow* instance();
57 
62  void insertDockWidget(QDockWidget* dock,
63  Qt::DockWidgetArea area = Qt::AllDockWidgetAreas,
64  Qt::Orientation orientation = Qt::Horizontal);
65 
68  void removeDockWidget(QDockWidget* dock);
69 
72 
73  SelectionHandler* selectionHandler() { return selectionHandler_; }
74 
76  QList<OSGWidget*> osgWindows() const;
77 
80 
82 
83  QMenu* pluginMenu() const;
84 
85 #if GEPETTO_GUI_HAS_PYTHONQT
87  PythonWidget* pythonWidget() { return pythonWidget_; }
88 #endif
89 
90  signals:
92  void viewCreated(OSGWidget* widget);
93  void refresh();
96  void selectJointFromBodyName(const QString bodyName);
97 
98  void logString(QString msg);
99  void logErrorString(QString msg);
100 
101  public slots:
104 
107 
110  void log(const QString& text);
113  void logError(const QString& text);
114 
118  void logJobStarted(int id, const QString& text);
119 
123  void logJobDone(int id, const QString& text);
124 
128  void logJobFailed(int id, const QString& text);
129 
135 
138 
142 
145  void configurationValidationStatusChanged(QStringList bodiesInCollision);
146 
149  void requestSelectJointFromBodyName(const QString bodyName);
150 
153 
156  void registerSignal(const char* signal, QObject* obj);
157 
161  QObject* getFromSignal(const char* signal);
162 
167  void connectSignal(const char* signal, const char* slot, QObject* obj);
168 
171  void registerSlot(const char* slot, QObject* obj);
172 
176  QObject* getFromSlot(const char* slot);
177 
182  void connectSlot(const char* slot, const char* signal, QObject* obj);
183 
188  void registerShortcut(QString widgetName, QString actionName,
189  QAction* action);
190 
195  void registerShortcut(QString widgetName, QAction* action);
196 
198 
199  OSGWidget* createView(const std::string& name);
200 
201  private slots:
202  void addOSGWidget(OSGWidget* osgWidget);
203  void createDefaultView();
204  void openLoadRobotDialog();
205  void openLoadEnvironmentDialog();
206  void activateCollision(bool activate);
207  void dockVisibilityChanged(bool visible);
208  void hsplitTabifiedDockWidget();
209  void vsplitTabifiedDockWidget();
210 
211  void handleWorkerDone(int id);
212 
213  void resetConnection();
214  void closeConnection();
215  void about();
216 
217  private:
218  void splitTabifiedDockWidget(Qt::Orientation orientation);
219  void setupInterface();
220  void createCentralWidget();
221 
222  static MainWindow* instance_;
223 
224  ::Ui::MainWindow* ui_;
225  OSGWidget* centralWidget_;
226  QList<OSGWidget*> osgWindows_;
227 #if GEPETTO_GUI_HAS_PYTHONQT
228  PythonWidget* pythonWidget_;
229 #endif
230  ShortcutFactory* shortcutFactory_;
231  SelectionHandler* selectionHandler_;
232 
233  WindowsManagerPtr_t osgViewerManagers_;
234  QThread worker_;
235 
236  QCheckBox* collisionValidationActivated_;
237  LedIndicator* collisionIndicator_;
238  QLabel* collisionLabel_;
239 
240  QStandardItemModel* bodyTreeModel_;
241 
242  ActionSearchBar* actionSearchBar_;
243 
244  QStringList robotNames_;
245  QStringList lastBodiesInCollision_;
246 
247  std::map<std::string, QObject*> registeredSlots_;
248  std::map<std::string, QObject*> registeredSignals_;
249 };
250 } // namespace gui
251 } // namespace gepetto
252 
253 Q_DECLARE_METATYPE(std::string)
254 
255 #endif // GEPETTO_GUI_MAINWINDOW_HH
Definition: action-search-bar.hh:29
Contains the list of all the bodies in the scene.
Definition: bodytreewidget.hh:31
Definition: ledindicator.hh:24
Class.
Definition: mainwindow.hh:40
void viewCreated(OSGWidget *widget)
Triggered when an OSGWidget is created.
static MainWindow * instance()
Return the instance of MainWindow stored.
void logString(QString msg)
void selectJointFromBodyName(const QString bodyName)
WindowsManagerPtr_t osg() const
Get.
SelectionHandler * selectionHandler()
Definition: mainwindow.hh:73
MainWindow(Settings *settings, QWidget *parent=0)
void removeDockWidget(QDockWidget *dock)
void logErrorString(QString msg)
void insertDockWidget(QDockWidget *dock, Qt::DockWidgetArea area=Qt::AllDockWidgetAreas, Qt::Orientation orientation=Qt::Horizontal)
Settings * settings_
Definition: mainwindow.hh:50
OSGWidget * createView(const std::string &name)
ActionSearchBar * actionSearchBar() const
QList< OSGWidget * > osgWindows() const
Get the list of windows.
PythonWidget * pythonWidget()
Get the python widget.
Definition: mainwindow.hh:87
QMenu * pluginMenu() const
PluginManager * pluginManager()
Get the plugin manager.
RefreshType
Definition: mainwindow.hh:44
@ RefreshPlugins
Definition: mainwindow.hh:46
@ RefreshAll
Definition: mainwindow.hh:47
@ RefreshBodyTree
Definition: mainwindow.hh:45
Widget that displays scenes.
Definition: osgwidget.hh:44
Definition: pluginmanagerdialog.hh:34
Definition: pythonwidget.hh:90
Definition: selection-handler.hh:85
Definition: shortcut-factory.hh:29
void configurationValidationStatusChanged(bool valid)
void logJobFailed(int id, const QString &text)
void logError(const QString &text)
void connectSignal(const char *signal, const char *slot, QObject *obj)
QObject * getFromSignal(const char *signal)
BodyTreeWidget * bodyTree() const
Get the body tree widget.
void log(const QString &text)
void registerSlot(const char *slot, QObject *obj)
void registerSignal(const char *signal, QObject *obj)
void logJobDone(int id, const QString &text)
void requestApplyCurrentConfiguration()
Emit a signal to display the current configuration in the viewer.
void registerShortcut(QString widgetName, QString actionName, QAction *action)
void requestSelectJointFromBodyName(const QString bodyName)
void onOpenPluginManager()
Open the plugin manager dialog.
QObject * getFromSlot(const char *slot)
void configurationValidationStatusChanged(QStringList bodiesInCollision)
void logJobStarted(int id, const QString &text)
void registerShortcut(QString widgetName, QAction *action)
void requestConfigurationValidation()
Emit a signal to check if the the current configuration is valid.
void connectSlot(const char *slot, const char *signal, QObject *obj)
Definition: dialogloadenvironment.hh:23
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:58
Definition: action-search-bar.hh:27
Definition: settings.hh:36