MRPT  2.0.4
MRPT2NanoguiGLCanvas.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 #pragma once
10 
11 #include <mrpt/gui/CGlCanvasBase.h>
13 
14 #include <mutex>
15 
16 // Expose nanogui API to mrpt users, for direct use of nanogui classes.
17 #include <mrpt/config.h>
18 #if MRPT_HAS_NANOGUI
19 
20 #include <nanogui/nanogui.h>
21 
22 namespace mrpt::gui
23 {
24 /** An extension of nanogui::GLCanvas to render MRPT OpenGL scenes.
25  *
26  * Directly access `scene` (locking its mutex `scene_mtx` first) to update the
27  * scene to be rendered.
28  *
29  * \sa CDisplayWindowGUI
30  * \ingroup mrpt_gui_grp
31  */
32 class MRPT2NanoguiGLCanvas : public nanogui::GLCanvas
33 {
34  public:
35  MRPT2NanoguiGLCanvas(nanogui::Widget* parent);
37 
38  virtual void drawGL() override;
39 
40  /** The scene to render in this control.
41  * \note Users must lock the mutex scene_mtx while modifying this variable.
42  */
44  std::mutex scene_mtx;
45 
47  const CGlCanvasBase& camera() const { return m_headless_canvas; }
48 
49  protected:
50  /** @name Internal virtual functions to handle GUI events
51  * @{ */
52  virtual bool mouseMotionEvent(
53  const nanogui::Vector2i& p, const nanogui::Vector2i& rel, int button,
54  int modifiers) override;
55  virtual bool mouseButtonEvent(
56  const nanogui::Vector2i& p, int button, bool down,
57  int modifiers) override;
58  virtual bool scrollEvent(
59  const nanogui::Vector2i& p, const nanogui::Vector2f& rel) override;
60  /** @} */
61 
62  /** Used to keep track of mouse events on the camera */
64 };
65 
66 } // namespace mrpt::gui
67 
68 #endif // MRPT_HAS_NANOGUI
virtual bool scrollEvent(const nanogui::Vector2i &p, const nanogui::Vector2f &rel) override
virtual bool mouseMotionEvent(const nanogui::Vector2i &p, const nanogui::Vector2i &rel, int button, int modifiers) override
const CGlCanvasBase & camera() const
An extension of nanogui::GLCanvas to render MRPT OpenGL scenes.
MRPT2NanoguiGLCanvas(nanogui::Widget *parent)
virtual bool mouseButtonEvent(const nanogui::Vector2i &p, int button, bool down, int modifiers) override
internal::NanoGUICanvasHeadless m_headless_canvas
Used to keep track of mouse events on the camera.
mrpt::opengl::COpenGLScene::Ptr scene
The scene to render in this control.
Classes for creating GUI windows for 2D and 3D visualization.
Definition: about_box.h:14
Specialization of CGlCanvasBaseHeadless for nanogui events.
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.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020