GLWidget.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 _GAZEBO_GUI_GLWIDGET_HH_
18 #define _GAZEBO_GUI_GLWIDGET_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "gazebo/gui/qt.h"
25 #include "gazebo/msgs/msgs.hh"
27 #include "gazebo/util/system.hh"
28 
29 namespace gazebo
30 {
31  namespace common
32  {
33  class MouseEvent;
34  }
35 
36  namespace gui
37  {
38  class GLWidgetPrivate;
39 
40  class GZ_GUI_VISIBLE GLWidget : public QWidget
41  {
42  Q_OBJECT
43 
46  public: enum SelectionLevels {
50  LINK
51  };
52 
53  public: GLWidget(QWidget *_parent = 0);
54  public: virtual ~GLWidget();
55 
61  public: void ViewScene(rendering::ScenePtr _scene);
62 
66  public: rendering::UserCameraPtr GetCamera() const GAZEBO_DEPRECATED(7.0);
67 
70  public: rendering::UserCameraPtr Camera() const;
71 
75  public: rendering::ScenePtr GetScene() const GAZEBO_DEPRECATED(7.0);
76 
79  public: rendering::ScenePtr Scene() const;
80 
81  public: void Clear();
82 
85  public: std::vector<rendering::VisualPtr> SelectedVisuals() const;
86 
87  signals: void clicked();
88 
91  signals: void selectionMsgReceived(const QString &_name);
92 
93  protected: virtual void moveEvent(QMoveEvent *_e);
94  protected: virtual void paintEvent(QPaintEvent *_e);
95  protected: virtual void resizeEvent(QResizeEvent *_e);
96 
101  protected: virtual void showEvent(QShowEvent *_e);
102 
103  protected: virtual void enterEvent(QEvent *_event);
104 
105 
106  protected: void keyPressEvent(QKeyEvent *_event);
107  protected: void keyReleaseEvent(QKeyEvent *_event);
108  protected: void wheelEvent(QWheelEvent *_event);
109  protected: void mousePressEvent(QMouseEvent *_event);
110  protected: void mouseDoubleClickEvent(QMouseEvent *_event);
111  protected: void mouseMoveEvent(QMouseEvent *_event);
112  protected: void mouseReleaseEvent(QMouseEvent *_event);
113 
117  protected: virtual QPaintEngine *paintEngine() const;
118 
119  private: std::string OgreHandle() const;
120 
124  private: bool OnMouseMove(const common::MouseEvent &_event);
125 
127  private: void OnMouseMoveNormal();
128 
130  private: void OnMouseMoveMakeEntity();
131 
135  private: bool OnMouseRelease(const common::MouseEvent &_event);
136 
138  private: void OnMouseReleaseNormal();
139 
141  private: void OnMouseReleaseMakeEntity();
142 
146  private: bool OnMousePress(const common::MouseEvent &_event);
147 
149  private: void OnMousePressNormal();
150 
152  private: void OnMousePressMakeEntity();
153 
157  private: bool OnMouseDoubleClick(const common::MouseEvent &_event);
158 
159  private: void OnRequest(ConstRequestPtr &_msg);
160  private: void OnCreateScene(const std::string &_name);
161  private: void OnRemoveScene(const std::string &_name);
162  private: void OnMoveMode(bool _mode);
163  private: void OnCreateEntity(const std::string &_type,
164  const std::string &_data);
165 
166  private: void OnFPS();
167  private: void OnOrbit();
168  private: void OnManipMode(const std::string &_mode);
169 
170  private: void OnSetSelectedEntity(const std::string &_name,
171  const std::string &_mode);
172 
173  private: bool eventFilter(QObject *_obj, QEvent *_event);
174 
175  private: void ClearSelection();
176 
179  private: void SetSelectedVisual(rendering::VisualPtr _vis);
180 
182  private: void DeselectAllVisuals();
183 
191  private: void OnAlignMode(const std::string &_axis,
192  const std::string &_config, const std::string &_target,
193  const bool _preview, const bool _inverted = false);
194 
197  private: void Copy(const std::string &_name);
198 
201  private: void Paste(const std::string &_name);
202 
204  private slots: void OnCopy();
205 
207  private slots: void OnPaste();
208 
211  private slots: void OnModelEditor(bool _checked);
212 
214  private slots: void OnOrtho();
215 
217  private slots: void OnPerspective();
218 
224  private: void SetMouseEventButton(const Qt::MouseButton &_button);
225 
231  private: void SetMouseEventButtons(const Qt::MouseButtons &_buttons);
232 
235  private: std::unique_ptr<GLWidgetPrivate> dataPtr;
236  };
237  }
238 }
239 
240 #endif
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:92
Definition: GLWidget.hh:40
Forward declarations for the common classes.
Definition: Animation.hh:33
STL namespace.
Model level.
Definition: GLWidget.hh:48
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:80
SelectionLevels
Unique identifiers for all selection levels supported.
Definition: GLWidget.hh:46
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:112