MRPT  1.9.9
CWxGLCanvasBase.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 #ifndef CMyGLCanvas_H
11 #define CMyGLCanvas_H
12 
13 #include <mrpt/gui/CGlCanvasBase.h>
14 
18 
19 namespace mrpt
20 {
21 namespace gui
22 {
23 }
24 } // At least declare the existence of the namespace mrpt::gui even if we don't
25 // have wxWidgets libs
26 
27 #if MRPT_HAS_WXWIDGETS
28 
29 #include <wx/string.h>
30 #include <wx/intl.h>
31 #include <wx/bitmap.h>
32 #include <wx/icon.h>
33 #include <wx/image.h>
34 #include <wx/artprov.h>
35 
36 #include <wx/msgdlg.h>
37 #include <wx/filedlg.h>
38 #include <wx/progdlg.h>
39 #include <wx/imaglist.h>
40 #include <wx/busyinfo.h>
41 #include <wx/log.h>
42 #include <wx/textdlg.h>
43 #include <wx/dirdlg.h>
44 #include <wx/colordlg.h>
45 #include <wx/dcmemory.h>
46 
47 #if wxUSE_GLCANVAS && MRPT_HAS_OPENGL_GLUT
48 
49 #include <wx/glcanvas.h>
50 #include <wx/dcclient.h>
51 
52 // To avoid conflicts between Eigen & X11 headers
53 #ifdef Success
54 #undef Success
55 #endif
56 
57 namespace mrpt
58 {
59 namespace gui
60 {
61 /** This class implements a OpenGL canvas, and it's used in
62  * gui::CDisplayWindow3D and a number of standalone applications in the MRPT
63  * project.
64  * There is a filter to control the user capability of moving the camera with
65  * the mouse. See OnUserManuallyMovesCamera
66  * \ingroup mrpt_gui_grp
67  */
68 class CWxGLCanvasBase : public CGlCanvasBase,
69  public wxGLCanvas,
71 {
72  public:
73  CWxGLCanvasBase(
74  wxWindow* parent, wxWindowID id = wxID_ANY,
75  const wxPoint& pos = wxDefaultPosition,
76  const wxSize& size = wxDefaultSize, long style = 0,
77  const wxString& name = _T("CWxGLCanvasBase"));
78 
79  virtual ~CWxGLCanvasBase();
80 
81  void OnPaint(wxPaintEvent& event);
82  void OnSize(wxSizeEvent& event);
83  void OnEraseBackground(wxEraseEvent& event);
84  void OnEnterWindow(wxMouseEvent& event);
85 
86  void OnChar(wxKeyEvent& event);
87 
88  void OnMouseDown(wxMouseEvent& event);
89  void OnMouseMove(wxMouseEvent& event);
90  void OnMouseUp(wxMouseEvent&);
91  void OnMouseWheel(wxMouseEvent& event);
92 
93  void Render();
94  void InitGL();
95 
96  /** Set the camera from a CPose3D, which defines the +X,+Y axis as image
97  * place RIGHT and UP dirctions, and -Z as towards the pointing direction.
98  */
99  void setCameraPose(const mrpt::poses::CPose3D& camPose);
100 
101  /** Methods that can be implemented in custom derived classes */
102  virtual void OnCharCustom(wxKeyEvent& event) { MRPT_UNUSED_PARAM(event); }
103  virtual void OnPreRender() {}
104  virtual void OnPostRender() {}
105  virtual void OnPostRenderSwapBuffers(double At, wxPaintDC& dc)
106  {
107  MRPT_UNUSED_PARAM(At);
108  MRPT_UNUSED_PARAM(dc);
109  }
110 
111  virtual void OnRenderError(const wxString& str) { MRPT_UNUSED_PARAM(str); }
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  virtual void swapBuffers() override;
124  virtual void preRender() override;
125  virtual void postRender() override;
126  virtual void renderError(const std::string& err_msg) override;
127 
128 }; // end of class
129 
130 } // end namespace
131 } // end namespace
132 
133 #endif // wxUSE_GLCANVAS
134 #endif // MRPT_HAS_WXWIDGETS
135 #endif // CMyGLCanvas_H
Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes...
GLsizei const GLchar ** string
Definition: glext.h:4101
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:86
GLuint const GLchar * name
Definition: glext.h:4054
GLsizeiptr size
Definition: glext.h:3923
#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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020