MRPT  2.0.4
CWxGLCanvasBase.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 
12 #include <mrpt/config.h>
13 #include <mrpt/gui/CGlCanvasBase.h>
16 
17 namespace mrpt
18 {
19 namespace gui
20 {
21 }
22 } // namespace mrpt
23 // have wxWidgets libs
24 
25 #if MRPT_HAS_WXWIDGETS
26 
27 #include <wx/artprov.h>
28 #include <wx/bitmap.h>
29 #include <wx/icon.h>
30 #include <wx/image.h>
31 #include <wx/intl.h>
32 #include <wx/string.h>
33 
34 #include <wx/busyinfo.h>
35 #include <wx/colordlg.h>
36 #include <wx/dcmemory.h>
37 #include <wx/dirdlg.h>
38 #include <wx/filedlg.h>
39 #include <wx/imaglist.h>
40 #include <wx/log.h>
41 #include <wx/msgdlg.h>
42 #include <wx/progdlg.h>
43 #include <wx/textdlg.h>
44 
45 #if wxUSE_GLCANVAS && MRPT_HAS_OPENGL_GLUT
46 
47 #include <wx/dcclient.h>
48 #include <wx/glcanvas.h>
49 
50 // To avoid conflicts between Eigen & X11 headers
51 #ifdef Success
52 #undef Success
53 #endif
54 
55 namespace mrpt
56 {
57 namespace gui
58 {
59 /** This class implements a OpenGL canvas, and it's used in
60  * gui::CDisplayWindow3D and a number of standalone applications in the MRPT
61  * project.
62  * There is a filter to control the user capability of moving the camera with
63  * the mouse. See OnUserManuallyMovesCamera
64  * \ingroup mrpt_gui_grp
65  */
66 class CWxGLCanvasBase : public CGlCanvasBase, public wxGLCanvas
67 {
68  public:
69  CWxGLCanvasBase(
70  wxWindow* parent, wxWindowID id = wxID_ANY,
71  const wxPoint& pos = wxDefaultPosition,
72  const wxSize& size = wxDefaultSize, long style = 0,
73  const wxString& name = _T("CWxGLCanvasBase"));
74 
75  ~CWxGLCanvasBase() override = default;
76 
77  void OnPaint(wxPaintEvent& event);
78  void OnSize(wxSizeEvent& event);
79  void OnEraseBackground(wxEraseEvent& event);
80  void OnEnterWindow(wxMouseEvent& event);
81 
82  void OnChar(wxKeyEvent& event);
83 
84  void OnMouseDown(wxMouseEvent& event);
85  void OnMouseMove(wxMouseEvent& event);
86  void OnMouseUp(wxMouseEvent&);
87  void OnMouseWheel(wxMouseEvent& event);
88 
89  void Render();
90  void InitGL();
91 
92  /** Set the camera from a CPose3D, which defines the +X,+Y axis as image
93  * place RIGHT and UP dirctions, and -Z as towards the pointing direction.
94  */
95  void setCameraPose(const mrpt::poses::CPose3D& camPose);
96 
97  /** Methods that can be implemented in custom derived classes */
98  virtual void OnCharCustom([[maybe_unused]] wxKeyEvent& event) {}
99  virtual void OnPreRender() {}
100  virtual void OnPostRender() {}
101  virtual void OnPostRenderSwapBuffers(
102  [[maybe_unused]] double At, [[maybe_unused]] wxPaintDC& dc)
103  {
104  }
105 
106  virtual void OnRenderError([[maybe_unused]] const wxString& str) {}
107 
108  protected:
109  std::unique_ptr<wxGLContext> m_gl_context;
110  bool m_init = false;
111 
112  long m_Key = 0;
113  unsigned long m_StartTime = 0;
114  unsigned long m_LastTime = 0;
115  unsigned long m_LastRedraw = 0;
116 
117  // Used to create the gl context at startup.
118  void OnWindowCreation(wxWindowCreateEvent& ev);
119  void swapBuffers() override;
120  void preRender() override;
121  void postRender() override;
122  void renderError(const std::string& err_msg) override;
123 
124 }; // end of class
125 
126 } // namespace gui
127 } // namespace mrpt
128 
129 #endif // wxUSE_GLCANVAS
130 #endif // MRPT_HAS_WXWIDGETS
size_t size(const MATRIXLIKE &m, const int dim)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85



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