GLWidget.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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: explicit GLWidget(QWidget *_parent = 0);
54  public: virtual ~GLWidget();
55 
61  public: void ViewScene(rendering::ScenePtr _scene);
62 
65  public: rendering::UserCameraPtr Camera() const;
66 
69  public: rendering::ScenePtr Scene() const;
70 
71  public: void Clear();
72 
75  public: std::vector<rendering::VisualPtr> SelectedVisuals() const;
76 
77  signals: void clicked();
78 
81  signals: void selectionMsgReceived(const QString &_name);
82 
83  protected: virtual void moveEvent(QMoveEvent *_e);
84  protected: virtual void paintEvent(QPaintEvent *_e);
85  protected: virtual void resizeEvent(QResizeEvent *_e);
86 
91  protected: virtual void showEvent(QShowEvent *_e);
92 
93  protected: virtual void enterEvent(QEvent *_event);
94 
95 
96  protected: void keyPressEvent(QKeyEvent *_event);
97  protected: void keyReleaseEvent(QKeyEvent *_event);
98  protected: void wheelEvent(QWheelEvent *_event);
99  protected: void mousePressEvent(QMouseEvent *_event);
100  protected: void mouseDoubleClickEvent(QMouseEvent *_event);
101  protected: void mouseMoveEvent(QMouseEvent *_event);
102  protected: void mouseReleaseEvent(QMouseEvent *_event);
103 
107  protected: virtual QPaintEngine *paintEngine() const;
108 
109  private: std::string OgreHandle() const;
110 
114  private: bool OnMouseMove(const common::MouseEvent &_event);
115 
117  private: void OnMouseMoveNormal();
118 
120  private: void OnMouseMoveMakeEntity();
121 
125  private: bool OnMouseRelease(const common::MouseEvent &_event);
126 
128  private: void OnMouseReleaseNormal();
129 
131  private: void OnMouseReleaseMakeEntity();
132 
136  private: bool OnMousePress(const common::MouseEvent &_event);
137 
139  private: void OnMousePressNormal();
140 
142  private: void OnMousePressMakeEntity();
143 
147  private: bool OnMouseDoubleClick(const common::MouseEvent &_event);
148 
149  private: void OnRequest(ConstRequestPtr &_msg);
150  private: void OnCreateScene(const std::string &_name);
151  private: void OnRemoveScene(const std::string &_name);
152  private: void OnMoveMode(bool _mode);
153  private: void OnCreateEntity(const std::string &_type,
154  const std::string &_data);
155 
156  private: void OnFPS();
157  private: void OnOrbit();
158  private: void OnManipMode(const std::string &_mode);
159 
160  private: void OnSetSelectedEntity(const std::string &_name,
161  const std::string &_mode);
162 
163  private: bool eventFilter(QObject *_obj, QEvent *_event);
164 
165  private: void ClearSelection();
166 
169  private: void SetSelectedVisual(rendering::VisualPtr _vis);
170 
172  private: void DeselectAllVisuals();
173 
181  private: void OnAlignMode(const std::string &_axis,
182  const std::string &_config, const std::string &_target,
183  const bool _preview, const bool _inverted = false);
184 
187  private: void Copy(const std::string &_name);
188 
191  private: void Paste(const std::string &_name);
192 
194  private slots: void OnCopy();
195 
197  private slots: void OnPaste();
198 
201  private slots: void OnModelEditor(bool _checked);
202 
204  private slots: void OnOrtho();
205 
207  private slots: void OnPerspective();
208 
214  private: void SetMouseEventButton(const Qt::MouseButton &_button);
215 
221  private: void SetMouseEventButtons(const Qt::MouseButtons &_buttons);
222 
225  private: std::unique_ptr<GLWidgetPrivate> dataPtr;
226  };
227  }
228 }
229 
230 #endif
Generic description of a mouse event.
Definition: MouseEvent.hh:35
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:94
Definition: GLWidget.hh:40
Forward declarations for the common classes.
Definition: Animation.hh:26
Model level.
Definition: GLWidget.hh:48
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
SelectionLevels
Unique identifiers for all selection levels supported.
Definition: GLWidget.hh:46
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114