MRPT  1.9.9
CQtGlCanvasBase.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #pragma once
11 #include <mrpt/gui/CGlCanvasBase.h>
12 
13 #include <mrpt/config.h>
14 #if MRPT_HAS_Qt5
15 
16 #include <QtGlobal>
17 #if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
18 #include <QGLWidget>
19 #define QOpenGLWidget QGLWidget
20 #else
21 #include <QOpenGLWidget>
22 #endif
23 
24 namespace mrpt::gui
25 {
26 class CQtGlCanvasBase : public QOpenGLWidget, public mrpt::gui::CGlCanvasBase
27 {
28  public:
29  CQtGlCanvasBase(QWidget* parent = nullptr);
30  virtual ~CQtGlCanvasBase() = default;
31 
32  virtual void initializeGL() override;
33  virtual void paintGL() override;
34  virtual void resizeGL(int width, int height) override;
35 
36  mrpt::opengl::COpenGLViewport::Ptr mainViewport() const;
37 
38  /** Returns the zoom distance of the camera
39  * See also setZoomDistance(float), getZoomDistance()*/
40  float getCameraZoomDistance() const;
41 
42  protected:
43  virtual void mousePressEvent(QMouseEvent* event) override;
44  virtual void mouseMoveEvent(QMouseEvent* event) override;
45  virtual void mouseReleaseEvent(QMouseEvent* event) override;
46  virtual void wheelEvent(QWheelEvent* event) override;
47 
48  virtual void swapBuffers() override {}
49  virtual void preRender() override {}
50  virtual void postRender() override {}
51  virtual void renderError(const std::string& err_msg) override;
52 
53  virtual void updateCamerasParams();
54  virtual void insertToMap(const opengl::CRenderizable::Ptr& newObject);
55  virtual void removeFromMap(const opengl::CRenderizable::Ptr& newObject);
56 
57  bool isPressLMouseButton() const;
58  bool isPressRMouseButton() const;
59  /** m_isPressLMouseButton and m_isPressRMouseButton are saved in
60  * mousePressEvent for mouseMoveEvent as true
61  * This function sets it as false */
62  void unpressMouseButtons();
63 
64  private:
65  bool m_isPressLMouseButton;
66  bool m_isPressRMouseButton;
67 
69 
70 }; // end of class
71 
72 }
73 #endif // MRPT_HAS_Qt5
74 
75 
std::shared_ptr< CRenderizable > Ptr
Definition: CRenderizable.h:43
GLenum GLsizei width
Definition: glext.h:3531
GLsizei const GLchar ** string
Definition: glext.h:4101
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:14
This base class implements a working with opengl::Camera and a OpenGL canvas, and it&#39;s used in gui::C...
Definition: CGlCanvasBase.h:28
GLenum GLsizei GLsizei height
Definition: glext.h:3554



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020