Main MRPT website
>
C++ reference for MRPT 1.9.9
mrpt
gui
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
15
#include <
mrpt/opengl/opengl_fonts.h
>
16
#include <
mrpt/opengl/CTextMessageCapable.h
>
17
#include <
mrpt/opengl/COpenGLScene.h
>
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,
70
public
mrpt::opengl::CTextMessageCapable
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
CTextMessageCapable.h
MRPT_UNUSED_PARAM
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition:
common.h:186
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition:
CKalmanFilterCapable.h:30
CGlCanvasBase.h
name
GLuint const GLchar * name
Definition:
glext.h:4054
mrpt::opengl::CTextMessageCapable
Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes.
Definition:
CTextMessageCapable.h:24
opengl_fonts.h
COpenGLScene.h
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition:
CPose3D.h:88
string
GLsizei const GLchar ** string
Definition:
glext.h:4101
size
GLsizeiptr size
Definition:
glext.h:3923
Page generated by
Doxygen 1.8.17
for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST