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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019