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 "gepetto/gui/fwd.hh"
21 
22 #include <QList>
23 #include <QStandardItemModel>
24 #include <QMainWindow>
25 #include <QCheckBox>
26 #include <QLabel>
27 
29 
33 
34 #include <gepetto/gui/settings.hh>
35 
36 namespace Ui {
37  class MainWindow;
38 }
39 
40 namespace gepetto {
41  namespace gui {
43  class MainWindow : public QMainWindow
44  {
45  Q_OBJECT
46 
47  public:
48  enum RefreshType {
49  RefreshBodyTree = 1,
50  RefreshPlugins = 2,
51  RefreshAll = RefreshBodyTree + RefreshPlugins
52  };
53 
55 
56  explicit MainWindow(Settings* settings, QWidget *parent = 0);
57  ~MainWindow();
58 
60  static MainWindow* instance ();
61 
66  void insertDockWidget (QDockWidget* dock,
67  Qt::DockWidgetArea area = Qt::AllDockWidgetAreas,
68  Qt::Orientation orientation = Qt::Horizontal);
69 
72  void removeDockWidget (QDockWidget* dock);
73 
75  WindowsManagerPtr_t osg () const;
76 
78  {
79  return selectionHandler_;
80  }
81 
83  QList <OSGWidget*> osgWindows () const;
84 
86  PluginManager* pluginManager ();
87 
88  ActionSearchBar* actionSearchBar () const;
89 
90  QMenu* pluginMenu () const;
91 
92 #if GEPETTO_GUI_HAS_PYTHONQT
93  PythonWidget* pythonWidget()
95  {
96  return pythonWidget_;
97  }
98 #endif
99 
100 signals:
102  void viewCreated (OSGWidget* widget);
103  void refresh ();
104  void applyCurrentConfiguration();
105  void configurationValidation();
106  void selectJointFromBodyName(const QString bodyName);
107 
108  void logString(QString msg);
109  void logErrorString(QString msg);
110 
111  public slots:
114 
116  BodyTreeWidget* bodyTree () const;
117 
120  void log (const QString& text);
123  void logError (const QString& text);
124 
128  void logJobStarted (int id, const QString& text);
129 
133  void logJobDone (int id, const QString& text);
134 
138  void logJobFailed (int id, const QString& text);
139 
142  void requestRefresh ();
144  void requestApplyCurrentConfiguration ();
145 
147  void requestConfigurationValidation ();
148 
151  void configurationValidationStatusChanged (bool valid);
152 
155  void configurationValidationStatusChanged (QStringList bodiesInCollision);
156 
159  void requestSelectJointFromBodyName (const QString bodyName);
160 
162  void onOpenPluginManager ();
163 
167  void registerSignal(const char *signal, QObject* obj);
168 
172  QObject* getFromSignal(const char *signal);
173 
178  void connectSignal(const char *signal, const char *slot, QObject* obj);
179 
180 
184  void registerSlot(const char *slot, QObject* obj);
185 
189  QObject* getFromSlot(const char *slot);
190 
195  void connectSlot(const char *slot, const char *signal, QObject* obj);
196 
201  void registerShortcut(QString widgetName, QString actionName, QAction* action);
202 
203 
208  void registerShortcut(QString widgetName, QAction* action);
209 
211 
212  OSGWidget* createView (const std::string& name);
213 
214 
215  private slots:
216  void addOSGWidget(OSGWidget* osgWidget);
217  void createDefaultView();
218  void openLoadRobotDialog ();
219  void openLoadEnvironmentDialog ();
220  void activateCollision(bool activate);
221  void dockVisibilityChanged(bool visible);
222  void hsplitTabifiedDockWidget();
223  void vsplitTabifiedDockWidget();
224 
225  void handleWorkerDone (int id);
226 
227  void resetConnection ();
228  void closeConnection ();
229  void about ();
230 
231  private:
232  void splitTabifiedDockWidget(Qt::Orientation orientation);
233  void setupInterface ();
234  void createCentralWidget ();
235 
236  static MainWindow* instance_;
237 
238  ::Ui::MainWindow* ui_;
239  OSGWidget* centralWidget_;
240  QList <OSGWidget*> osgWindows_;
241 #if GEPETTO_GUI_HAS_PYTHONQT
242  PythonWidget* pythonWidget_;
243 #endif
244  ShortcutFactory* shortcutFactory_;
245  SelectionHandler* selectionHandler_;
246 
247  WindowsManagerPtr_t osgViewerManagers_;
248  QThread worker_;
249 
250  QCheckBox* collisionValidationActivated_;
251  LedIndicator* collisionIndicator_;
252  QLabel* collisionLabel_;
253 
254  QStandardItemModel *bodyTreeModel_;
255 
256  ActionSearchBar* actionSearchBar_;
257 
258  QStringList robotNames_;
259  QStringList lastBodiesInCollision_;
260 
261  std::map<std::string, QObject *> registeredSlots_;
262  std::map<std::string, QObject *> registeredSignals_;
263  };
264  } // namespace gui
265 } // namespace gepetto
266 
267 Q_DECLARE_METATYPE (std::string)
268 
269 #endif // GEPETTO_GUI_MAINWINDOW_HH
Definition: ledindicator.hh:24
Definition: action-search-bar.hh:29
Definition: dialogloadenvironment.hh:23
Class.
Definition: mainwindow.hh:43
Settings * settings_
Definition: mainwindow.hh:54
Contains the list of all the bodies in the scene.
Definition: bodytreewidget.hh:31
Definition: settings.hh:37
Definition: action-search-bar.hh:27
Definition: pythonwidget.hh:87
Definition: pluginmanagerdialog.hh:35
Definition: shortcut-factory.hh:30
RefreshType
Definition: mainwindow.hh:48
SelectionHandler * selectionHandler()
Definition: mainwindow.hh:77
Definition: config-osg.h:52
Definition: selection-handler.hh:90
Widget that displays scenes.
Definition: osgwidget.hh:44
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:55