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 "gazebo/gazebo_config.h"
26 #include "gazebo/gui/qt.h"
27 #include "gazebo/common/Event.hh"
28 #include "gazebo/msgs/MessageTypes.hh"
30 #include "gazebo/util/system.hh"
31 
32 #ifdef HAVE_OCULUS
34 #endif
35 
36 namespace gazebo
37 {
38  namespace gui
39  {
40  class RenderWidget;
41  class ToolsWidget;
42  class ModelListWidget;
43  class Editor;
44  class SpaceNav;
45 
46  class GAZEBO_VISIBLE MainWindow : public QMainWindow
47  {
48  Q_OBJECT
49 
50  public: MainWindow();
51  public: virtual ~MainWindow();
52 
53  public: void Load();
54  public: void Init();
55 
56  public: unsigned int GetEntityId(const std::string &_name);
57  public: bool HasEntityName(const std::string &_name);
58 
62  public: void AddToLeftColumn(const std::string &_name, QWidget *_widget);
63 
69  public: void ShowLeftColumnWidget(const std::string &_name = "default");
70 
73  public: RenderWidget *GetRenderWidget() const;
74 
76  public slots: void Play();
77 
79  public slots: void Pause();
80 
83  public: void SetLeftPaneVisibility(bool _on);
84 
86  signals: void AddPlugins();
87 
88  protected: void closeEvent(QCloseEvent *_event);
89 
90  private: void OnGUI(ConstGUIPtr &_msg);
91 
92  private slots: void ItemSelected(QTreeWidgetItem *, int);
93  private slots: void New();
94  private slots: void Open();
95  private slots: void Import();
96  private slots: void Save();
97  private slots: void SaveAs();
98 
100  private slots: void SaveINI();
101 
103  private slots: void Clone();
104 
105  private slots: void About();
106  private slots: void Step();
107  private slots: void Arrow();
108 
110  private slots: void Translate();
111 
113  private slots: void Rotate();
114 
116  private slots: void Scale();
117 
120  private slots: void Align();
121 
123  private slots: void Snap();
124 
125  private slots: void CreateBox();
126  private slots: void CreateSphere();
127  private slots: void CreateCylinder();
128  private slots: void CreateMesh();
129  private slots: void CreatePointLight();
130  private slots: void CreateSpotLight();
131  private slots: void CreateDirectionalLight();
132 
134  private slots: void CaptureScreenshot();
135 
136  private slots: void InsertModel();
137  private slots: void ShowGrid();
138  private slots: void ShowCollisions();
139  private slots: void ShowJoints();
140  private slots: void ShowContacts();
141  private slots: void ShowCOM();
142  private slots: void Reset();
143  private slots: void FullScreen();
144  private slots: void FPS();
145  private slots: void Orbit();
146  private slots: void ViewOculus();
147  private slots: void OnResetModelOnly();
148  private slots: void OnResetWorld();
149  private slots: void SetTransparent();
150  private slots: void SetWireframe();
151 
153  private slots: void OnPlayActionChanged();
154 
156  private slots: void DataLogger();
157 
159  private slots: void SelectTopic();
160 
162  private slots: void Diagnostics();
163 
165  private slots: void OnAddPlugins();
166 
169  private slots: void OnEditorGroup(QAction *_action);
170 
173  private: void OnFullScreen(bool _value);
174  private: void OnMoveMode(bool _mode);
175 
177  private: void CreateActions();
178 
180  private: void CreateMenus();
181 
183  private: void CreateToolbars();
184 
186  private: void CreateMenuBar();
187 
189  private: void CreateEditors();
190 
195  public: void ShowMenuBar(QMenuBar *_bar = NULL);
196 
197  private: void OnModel(ConstModelPtr &_msg);
198 
201  private: void OnLight(ConstLightPtr &_msg);
202 
203  private: void OnResponse(ConstResponsePtr &_msg);
204  private: void OnWorldModify(ConstWorldModifyPtr &_msg);
205  private: void OnManipMode(const std::string &_mode);
206  private: void OnSetSelectedEntity(const std::string &_name,
207  const std::string &_mode);
208  private: void OnStats(ConstWorldStatisticsPtr &_msg);
209 
212  private: void OnInputStepSizeChanged(int _value);
213 
216  private: void OnFollow(const std::string &_modelName);
217 
222  private: void CreateDisabledIcon(const std::string &_pixmap,
223  QAction *_act);
224 
225  private: QToolBar *playToolbar;
226 
227  private: RenderWidget *renderWidget;
228  private: ToolsWidget *toolsWidget;
229  private: ModelListWidget *modelListWidget;
230 
231  private: transport::NodePtr node;
232  private: transport::PublisherPtr worldControlPub;
233  private: transport::PublisherPtr serverControlPub;
234  private: transport::PublisherPtr requestPub;
235  private: transport::PublisherPtr scenePub;
236  private: transport::SubscriberPtr responseSub;
237  private: transport::SubscriberPtr guiSub;
238  private: transport::SubscriberPtr newEntitySub, statsSub;
239  private: transport::SubscriberPtr worldModSub;
240 
242  private: transport::SubscriberPtr lightSub;
243 
244  private: QDockWidget *toolsDock;
245 
246  private: std::vector<event::ConnectionPtr> connections;
247 
248  // A map that associates physics_id's with entity names
249  private: std::map<std::string, unsigned int> entities;
250 
252  private: msgs::Request *requestMsg;
253 
255  private: QTabWidget *tabWidget;
256 
258  private: QMenuBar *menuBar;
259 
261  private: QMenu *editMenu;
262 
264  private: QHBoxLayout *menuLayout;
265 
267  private: QStackedWidget *leftColumn;
268 
270  private: std::map<std::string, int> leftColumnStack;
271 
274  private: std::string saveFilename;
275 
277  private: int inputStepSize;
278 
280  private: std::list<Editor*> editors;
281 
283  private: std::vector<QActionGroup *> alignActionGroups;
284 
286  private: SpaceNav *spacenav;
287 
288 #ifdef HAVE_OCULUS
289  private: gui::OculusWindow *oculusWindow;
290 #endif
291 
293  private: std::vector<boost::shared_ptr<msgs::Plugin const> > pluginMsgs;
294 
296  private: boost::mutex pluginLoadMutex;
297 
299  private: QSplitter *splitter;
300  };
301  }
302 }
303 #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:41
#define NULL
Definition: CommonTypes.hh:30
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
Definition: MainWindow.hh:46
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
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48