MainWindow.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _MAINWINDOW_HH_
18 #define _MAINWINDOW_HH_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 #include <list>
24 
25 #include <boost/thread/mutex.hpp>
26 
27 #include "gazebo/gazebo_config.h"
28 #include "gazebo/gui/qt.h"
29 #include "gazebo/gui/DataLogger.hh"
30 #include "gazebo/common/Event.hh"
31 #include "gazebo/msgs/MessageTypes.hh"
33 #include "gazebo/util/system.hh"
34 
35 #ifdef HAVE_OCULUS
37 #endif
38 
39 namespace gazebo
40 {
41  namespace gui
42  {
43  class RenderWidget;
44  class ToolsWidget;
45  class ModelListWidget;
46  class Editor;
47  class SpaceNav;
48 
49  class GAZEBO_VISIBLE MainWindow : public QMainWindow
50  {
51  Q_OBJECT
52 
53  public: MainWindow();
54  public: virtual ~MainWindow();
55 
56  public: void Load();
57  public: void Init();
58 
59  public: unsigned int GetEntityId(const std::string &_name);
60  public: bool HasEntityName(const std::string &_name);
61 
65  public: void AddToLeftColumn(const std::string &_name, QWidget *_widget);
66 
72  public: void ShowLeftColumnWidget(const std::string &_name = "default");
73 
76  public: RenderWidget *GetRenderWidget() const;
77 
80  public: bool IsPaused() const;
81 
83  public slots: void Play();
84 
86  public slots: void Pause();
87 
90  public: void SetLeftPaneVisibility(bool _on);
91 
94  public: void AddMenu(QMenu *_menu);
95 
100  public: void ShowMenuBar(QMenuBar *_bar = NULL);
101 
110  public: QAction *CloneAction(QAction *_action, QObject *_parent);
111 
115  public: Editor *GetEditor(const std::string &_name) const;
116 
118  signals: void AddPlugins();
119 
121  signals: void Close();
122 
123  protected: void closeEvent(QCloseEvent *_event);
124 
125  private: void OnGUI(ConstGUIPtr &_msg);
126 
127  private slots: void ItemSelected(QTreeWidgetItem *, int);
128  private slots: void New();
129  private slots: void Open();
130  private slots: void Import();
131  private slots: void Save();
132  private slots: void SaveAs();
133 
135  private slots: void SaveINI();
136 
138  private slots: void Clone();
139 
140  private slots: void About();
141  private slots: void Step();
142  private slots: void Arrow();
143 
145  private slots: void Translate();
146 
148  private slots: void Rotate();
149 
151  private slots: void Scale();
152 
155  private slots: void Align();
156 
158  private slots: void Snap();
159 
160  private slots: void CreateBox();
161  private slots: void CreateSphere();
162  private slots: void CreateCylinder();
163  private slots: void CreateMesh();
164  private slots: void CreatePointLight();
165  private slots: void CreateSpotLight();
166  private slots: void CreateDirectionalLight();
167 
169  private slots: void CaptureScreenshot();
170 
171  private slots: void InsertModel();
172 
174  private slots: void ShowGrid();
175 
177  private slots: void ShowOrigin();
178 
180  private slots: void ShowCollisions();
181 
183  private slots: void ShowJoints();
184 
186  private slots: void ShowContacts();
187 
189  private slots: void ShowCOM();
190 
192  private slots: void ShowInertia();
193 
195  private slots: void ShowLinkFrame();
196 
198  private slots: void FullScreen();
199 
201  private slots: void ShowToolbars();
202 
203  private slots: void FPS();
204  private slots: void Orbit();
205  private slots: void ViewOculus();
206  private slots: void OnResetModelOnly();
207  private slots: void OnResetWorld();
208  private slots: void SetTransparent();
209  private slots: void SetWireframe();
210 
212  private slots: void ShowGUIOverlays();
213 
215  private slots: void DataLogger();
216 
218  private slots: void OnDataLoggerClosed();
219 
221  private slots: void SelectTopic();
222 
224  private slots: void Diagnostics();
225 
227  private slots: void OnAddPlugins();
228 
231  private slots: void OnEditorGroup(QAction *_action);
232 
235  private: void OnFullScreen(bool _value);
236 
239  private: void OnShowToolbars(bool _value);
240 
241  private: void OnMoveMode(bool _mode);
242 
244  private: void CreateActions();
245 
247  private: void DeleteActions();
248 
250  private: void CreateMenus();
251 
253  private: void CreateMenuBar();
254 
256  private: void CreateEditors();
257 
258  private: void OnModel(ConstModelPtr &_msg);
259 
262  private: void OnLight(ConstLightPtr &_msg);
263 
264  private: void OnResponse(ConstResponsePtr &_msg);
265  private: void OnWorldModify(ConstWorldModifyPtr &_msg);
266  private: void OnManipMode(const std::string &_mode);
267  private: void OnSetSelectedEntity(const std::string &_name,
268  const std::string &_mode);
269 
272  private: void OnInputStepSizeChanged(int _value);
273 
276  private: void OnFollow(const std::string &_modelName);
277 
282  private: void CreateDisabledIcon(const std::string &_pixmap,
283  QAction *_act);
284 
285  private: QToolBar *playToolbar;
286 
287  private: RenderWidget *renderWidget;
288  private: ToolsWidget *toolsWidget;
289  private: ModelListWidget *modelListWidget;
290 
291  private: transport::NodePtr node;
292  private: transport::PublisherPtr worldControlPub;
293  private: transport::PublisherPtr serverControlPub;
294  private: transport::PublisherPtr requestPub;
295  private: transport::PublisherPtr scenePub;
296  private: transport::SubscriberPtr responseSub;
297  private: transport::SubscriberPtr guiSub;
298  private: transport::SubscriberPtr newEntitySub, statsSub;
299  private: transport::SubscriberPtr worldModSub;
300 
302  private: transport::SubscriberPtr lightSub;
303 
304  private: QDockWidget *toolsDock;
305 
306  private: std::vector<event::ConnectionPtr> connections;
307 
308  // A map that associates physics_id's with entity names
309  private: std::map<std::string, unsigned int> entities;
310 
312  private: msgs::Request *requestMsg;
313 
315  private: QTabWidget *tabWidget;
316 
318  private: QMenuBar *menuBar;
319 
321  private: QMenu *editMenu;
322 
324  private: QHBoxLayout *menuLayout;
325 
327  private: QStackedWidget *leftColumn;
328 
330  private: std::map<std::string, int> leftColumnStack;
331 
334  private: std::string saveFilename;
335 
337  private: int inputStepSize;
338 
340  private: std::map<std::string, Editor *> editors;
341 
343  private: std::vector<QActionGroup *> alignActionGroups;
344 
346  private: SpaceNav *spacenav;
347 
348 #ifdef HAVE_OCULUS
349  private: gui::OculusWindow *oculusWindow;
350 #endif
351 
353  private: std::vector<boost::shared_ptr<msgs::Plugin const> > pluginMsgs;
354 
356  private: boost::mutex pluginLoadMutex;
357 
359  private: QSplitter *splitter;
360 
362  private: gui::DataLogger *dataLogger;
363  };
364  }
365 }
366 #endif
A widget that provides data logging functionality.
Definition: DataLogger.hh:34
Interface to the space navigator joystick.
Definition: SpaceNav.hh:51
A widget that renders a camera view suitable for the Oculus Rift.
Definition: OculusWindow.hh:39
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
Forward declarations for transport.
A widget that manages all the tools on the right side of the render widget.
Definition: ToolsWidget.hh:39
Plot diagnostic information.
Definition: gui/Diagnostics.hh:39
Definition: RenderWidget.hh:40
#define NULL
Definition: CommonTypes.hh:30
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
Definition: MainWindow.hh:49
Definition: ModelListWidget.hh:54
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
Base class for editors, such as BuildingEditor and TerrainEditor.
Definition: Editor.hh:35
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:66