All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MainWindow.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 
45  class GAZEBO_VISIBLE MainWindow : public QMainWindow
46  {
47  Q_OBJECT
48 
49  public: MainWindow();
50  public: virtual ~MainWindow();
51 
52  public: void Load();
53  public: void Init();
54 
55  public: unsigned int GetEntityId(const std::string &_name);
56  public: bool HasEntityName(const std::string &_name);
57 
61  public: void AddToLeftColumn(const std::string &_name, QWidget *_widget);
62 
68  public: void ShowLeftColumnWidget(const std::string &_name = "default");
69 
72  public: RenderWidget *GetRenderWidget() const;
73 
75  public slots: void Play();
76 
78  public slots: void Pause();
79 
80  protected: void closeEvent(QCloseEvent *_event);
81 
82  private: void OnGUI(ConstGUIPtr &_msg);
83 
84  private slots: void ItemSelected(QTreeWidgetItem *, int);
85  private slots: void New();
86  private slots: void Open();
87  private slots: void Import();
88  private slots: void Save();
89  private slots: void SaveAs();
90 
92  private slots: void SaveINI();
93 
94  private slots: void About();
95  private slots: void Step();
96  private slots: void NewModel();
97  private slots: void Arrow();
98 
100  private slots: void Translate();
101 
103  private slots: void Rotate();
104 
106  private slots: void Scale();
107 
108  private slots: void CreateBox();
109  private slots: void CreateSphere();
110  private slots: void CreateCylinder();
111  private slots: void CreateMesh();
112  private slots: void CreatePointLight();
113  private slots: void CreateSpotLight();
114  private slots: void CreateDirectionalLight();
115 
117  private slots: void CaptureScreenshot();
118 
119  private slots: void InsertModel();
120  private slots: void ShowGrid();
121  private slots: void ShowCollisions();
122  private slots: void ShowJoints();
123  private slots: void ShowContacts();
124  private slots: void ShowCOM();
125  private slots: void Reset();
126  private slots: void FullScreen();
127  private slots: void FPS();
128  private slots: void Orbit();
129  private slots: void ViewOculus();
130  private slots: void OnResetModelOnly();
131  private slots: void OnResetWorld();
132  private slots: void SetTransparent();
133  private slots: void SetWireframe();
134 
136  private slots: void OnPlayActionChanged();
137 
139  private slots: void DataLogger();
140 
142  private slots: void SelectTopic();
143 
145  private slots: void Diagnostics();
146 
149  private: void OnFullScreen(bool _value);
150  private: void OnMoveMode(bool _mode);
151 
153  private: void CreateActions();
154 
156  private: void CreateMenus();
157 
159  private: void CreateToolbars();
160 
162  private: void CreateMenuBar();
163 
165  private: void CreateEditors();
166 
171  public: void ShowMenuBar(QMenuBar *_bar = NULL);
172 
173  private: void OnModel(ConstModelPtr &_msg);
174 
177  private: void OnLight(ConstLightPtr &_msg);
178 
179  private: void OnResponse(ConstResponsePtr &_msg);
180  private: void OnWorldModify(ConstWorldModifyPtr &_msg);
181  private: void OnManipMode(const std::string &_mode);
182  private: void OnSetSelectedEntity(const std::string &_name,
183  const std::string &_mode);
184  private: void OnStats(ConstWorldStatisticsPtr &_msg);
185 
188  private: void OnInputStepSizeChanged(int _value);
189 
192  private: void OnFollow(const std::string &_modelName);
193 
198  private: void CreateDisabledIcon(const std::string &_pixmap,
199  QAction *_act);
200 
201  private: QToolBar *playToolbar;
202 
203  private: RenderWidget *renderWidget;
204  private: ToolsWidget *toolsWidget;
205  private: ModelListWidget *modelListWidget;
206 
207  private: transport::NodePtr node;
208  private: transport::PublisherPtr worldControlPub;
209  private: transport::PublisherPtr serverControlPub;
210  private: transport::PublisherPtr selectionPub;
211  private: transport::PublisherPtr requestPub;
212  private: transport::PublisherPtr scenePub;
213  private: transport::SubscriberPtr responseSub;
214  private: transport::SubscriberPtr guiSub;
215  private: transport::SubscriberPtr newEntitySub, statsSub;
216  private: transport::SubscriberPtr worldModSub;
217 
219  private: transport::SubscriberPtr lightSub;
220 
221  private: QDockWidget *toolsDock;
222 
223  private: std::vector<event::ConnectionPtr> connections;
224 
225  // A map that associates physics_id's with entity names
226  private: std::map<std::string, unsigned int> entities;
227 
229  private: msgs::Request *requestMsg;
230 
232  private: QTabWidget *tabWidget;
233 
235  private: QMenuBar *menuBar;
236 
238  private: QMenu *editMenu;
239 
241  private: QHBoxLayout *menuLayout;
242 
244  private: QStackedWidget *leftColumn;
245 
247  private: std::map<std::string, int> leftColumnStack;
248 
251  private: std::string saveFilename;
252 
254  private: int inputStepSize;
255 
257  private: std::list<Editor*> editors;
258 
259 #ifdef HAVE_OCULUS
260  private: gui::OculusWindow *oculusWindow;
261 #endif
262  };
263  }
264 }
265 #endif
A widget that provides data logging functionality.
Definition: DataLogger.hh:34
A widget that renders a camera view suitable for the Oculus Rift.
Definition: OculusWindow.hh:39
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:48
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:52
Definition: MainWindow.hh:45
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:44
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48