GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: include/gepetto/gui/mainwindow.hh Lines: 0 4 0.0 %
Date: 2020-05-14 11:23:33 Branches: 0 2 0.0 %

Line Branch Exec Source
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
28
#include <gepetto/gui/ledindicator.hh>
29
30
#include <gepetto/gui/dialog/dialogloadrobot.hh>
31
#include <gepetto/gui/dialog/dialogloadenvironment.hh>
32
#include <gepetto/gui/dialog/pluginmanagerdialog.hh>
33
34
#include <gepetto/gui/settings.hh>
35
36
namespace Ui {
37
  class MainWindow;
38
}
39
40
namespace gepetto {
41
  namespace gui {
42
    /// Class
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
54
        Settings* settings_;
55
56
        explicit MainWindow(Settings* settings, QWidget *parent = 0);
57
        ~MainWindow();
58
59
        /// Return the instance of MainWindow stored
60
        static MainWindow* instance ();
61
62
        /// Insert a dockwidget in the dock area of the window.
63
        /// \param dock widget to add
64
        /// \param area where the widget will be add
65
        /// \param orientation of the widget
66
        void insertDockWidget (QDockWidget* dock,
67
            Qt::DockWidgetArea area = Qt::AllDockWidgetAreas,
68
            Qt::Orientation orientation = Qt::Horizontal);
69
70
        /// Remove a dock widget.
71
        /// \param dock widget to remove
72
        void removeDockWidget (QDockWidget* dock);
73
74
        /// Get
75
        WindowsManagerPtr_t osg () const;
76
77
        SelectionHandler* selectionHandler()
78
        {
79
          return selectionHandler_;
80
        }
81
82
        /// Get the list of windows.
83
        QList <OSGWidget*> osgWindows () const;
84
85
        /// Get the plugin manager.
86
        PluginManager* pluginManager ();
87
88
        ActionSearchBar* actionSearchBar () const;
89
90
        QMenu* pluginMenu () const;
91
92
#if GEPETTO_GUI_HAS_PYTHONQT
93
        /// Get the python widget.
94
        PythonWidget* pythonWidget()
95
        {
96
          return pythonWidget_;
97
        }
98
#endif
99
100
signals:
101
        /// Triggered when an OSGWidget is created.
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:
112
          /// \ingroup plugin_python
113
          /// \{
114
115
        /// Get the body tree widget.
116
        BodyTreeWidget* bodyTree () const;
117
118
        /// Add the text to logs.
119
        /// \param text text to log
120
        void log (const QString& text);
121
        /// Add the text to logs and colors it in red.
122
        /// \param text text to log
123
        void logError (const QString& text);
124
125
        /// Log that a job has started.
126
        /// \param id id of the job
127
        /// \param text text to log
128
          void logJobStarted (int id, const QString& text);
129
130
          /// Log that a job has successfuly finished.
131
          /// \param id id of the job
132
          /// \param text text to log
133
          void logJobDone    (int id, const QString& text);
134
135
          /// Log that a job has failed.
136
          /// \param id id of the job
137
          /// \param text text to log
138
          void logJobFailed  (int id, const QString& text);
139
140
        /// Request a refresh of the interface.
141
        /// \param refreshType tells what to refresh. See RefreshType
142
        void requestRefresh ();
143
        /// Emit a signal to display the current configuration in the viewer.
144
        void requestApplyCurrentConfiguration ();
145
146
        /// Emit a signal to check if the the current configuration is valid.
147
        void requestConfigurationValidation ();
148
149
        /// Display if a configuration is valid or not.
150
        /// \param valid configuration is valid
151
        void configurationValidationStatusChanged (bool valid);
152
153
        /// Display if a configuration is valid or not.
154
        /// \param bodiesInCollision list of bodies in collision
155
        void configurationValidationStatusChanged (QStringList bodiesInCollision);
156
157
        /// Emit a signal to tell that a body has been selected.
158
        /// \param bodyName name of the body selected
159
        void requestSelectJointFromBodyName (const QString bodyName);
160
161
        /// Open the plugin manager dialog.
162
        void onOpenPluginManager ();
163
164
        /// Register an object signal that can be accessible without knowing the class definition.
165
        /// \param signal signal's name
166
        /// \param obj object's instance
167
        void registerSignal(const char *signal, QObject* obj);
168
169
        /// Get the instance of object which holds the signal.
170
        /// \param signal signal's name
171
        /// \return object's instance
172
        QObject* getFromSignal(const char *signal);
173
174
        /// Connect an object's slot to a registered signal.
175
        /// \param signal signal's name
176
        /// \param slot slot's name
177
        /// \param obj object's instance
178
        void connectSignal(const char *signal, const char *slot, QObject* obj);
179
180
181
        /// Register an object slot that can be accessible without knowing the class definition.
182
        /// \param slot slot's name
183
        /// \param obj object's instance
184
        void registerSlot(const char *slot, QObject* obj);
185
186
        /// Get the instance of object which holds the slot.
187
        /// \param slot slot's name
188
        /// \return object's instance
189
        QObject* getFromSlot(const char *slot);
190
191
        /// Connect an object's signal to a registered slot.
192
        /// \param slot slot's name
193
        /// \param signal signal's name
194
        /// \param obj object's instance
195
        void connectSlot(const char *slot, const char *signal, QObject* obj);
196
197
        /// Register an action on which users can change the shortcut to trigger it.
198
        /// \param widgetName widget's name that handle the action
199
        /// \param actionName action's name
200
        /// \param action action to modify
201
        void registerShortcut(QString widgetName, QString actionName, QAction* action);
202
203
204
        /// Register an action on which users can change the shortcut to trigger it.
205
        /// User action->text() as action name.
206
        /// \param widgetName widget's name that handle the action
207
        /// \param action action to modify
208
        void registerShortcut(QString widgetName, QAction* action);
209
210
        /// \}
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