MRPT  2.0.1
CQtGlCanvasBase.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://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  ~CQtGlCanvasBase() override = default;
31 
32  void initializeGL() override;
33  void paintGL() override;
34  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  void mousePressEvent(QMouseEvent* event) override;
44  void mouseMoveEvent(QMouseEvent* event) override;
45  void mouseReleaseEvent(QMouseEvent* event) override;
46  void wheelEvent(QWheelEvent* event) override;
47 
48  void swapBuffers() override {}
49  void preRender() override {}
50  void postRender() override {}
51  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{false};
66  bool m_isPressRMouseButton{false};
67 
69 
70 }; // end of class
71 
72 } // namespace mrpt::gui
73 #endif // MRPT_HAS_Qt5
std::shared_ptr< CRenderizable > Ptr
Definition: CRenderizable.h:50
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:24



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020