Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef CMyGLCanvas_H
00030 #define CMyGLCanvas_H
00031
00032 #include <mrpt/opengl.h>
00033
00034 #if MRPT_HAS_WXWIDGETS
00035
00036 #include <wx/string.h>
00037 #include <wx/intl.h>
00038 #include <wx/bitmap.h>
00039 #include <wx/icon.h>
00040 #include <wx/image.h>
00041 #include <wx/artprov.h>
00042
00043 #include <wx/msgdlg.h>
00044 #include <wx/filedlg.h>
00045 #include <wx/progdlg.h>
00046 #include <wx/imaglist.h>
00047 #include <wx/busyinfo.h>
00048 #include <wx/log.h>
00049 #include <wx/textdlg.h>
00050 #include <wx/dirdlg.h>
00051 #include <wx/colordlg.h>
00052 #include <wx/dcmemory.h>
00053
00054 #if wxUSE_GLCANVAS && MRPT_HAS_OPENGL_GLUT
00055
00056 #include <wx/glcanvas.h>
00057 #include <wx/dcclient.h>
00058
00059 namespace mrpt
00060 {
00061 namespace gui
00062 {
00063
00064
00065
00066 class MRPTDLLIMPEXP CMyGLCanvasBase: public wxGLCanvas
00067 {
00068 public:
00069 CMyGLCanvasBase( wxWindow *parent, wxWindowID id = wxID_ANY,
00070 const wxPoint& pos = wxDefaultPosition,
00071 const wxSize& size = wxDefaultSize,
00072 long style = 0, const wxString& name = _T("CMyGLCanvasBase") );
00073
00074 virtual ~CMyGLCanvasBase();
00075
00076 void OnPaint(wxPaintEvent& event);
00077 void OnSize(wxSizeEvent& event);
00078 void OnEraseBackground(wxEraseEvent& event);
00079 void OnEnterWindow(wxMouseEvent& event);
00080
00081 void OnChar(wxKeyEvent& event);
00082
00083 void OnLeftDown(wxMouseEvent& event);
00084 void OnMouseMove(wxMouseEvent& event);
00085 void OnRightDown(wxMouseEvent& event);
00086 void OnRightUp(wxMouseEvent& event);
00087 void OnLeftUp(wxMouseEvent& event);
00088 void OnMouseWheel(wxMouseEvent& event);
00089
00090 void Render();
00091 void InitGL();
00092
00093
00094 float cameraPointingX,cameraPointingY,cameraPointingZ;
00095 float cameraZoomDistance;
00096 float cameraElevationDeg,cameraAzimuthDeg;
00097 bool cameraIsProjective;
00098
00099
00100
00101 void setCameraPose(const mrpt::poses::CPose3D &camPose);
00102
00103
00104 float clearColorR,clearColorG,clearColorB;
00105
00106 static float SENSIBILITY_DEG_PER_PIXEL;
00107
00108
00109 virtual void OnCharCustom( wxKeyEvent& event ) { }
00110
00111 virtual void OnPreRender() { }
00112 virtual void OnPostRender() { }
00113 virtual void OnPostRenderSwapBuffers(double At, wxPaintDC &dc) { }
00114 virtual void OnRenderError( const wxString &str ) { }
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 virtual void OnUserManuallyMovesCamera(
00130 float new_cameraPointingX,
00131 float new_cameraPointingY,
00132 float new_cameraPointingZ,
00133 float new_cameraZoomDistance,
00134 float new_cameraElevationDeg,
00135 float new_cameraAzimuthDeg )
00136 {
00137 cameraPointingX = new_cameraPointingX;
00138 cameraPointingY = new_cameraPointingY;
00139 cameraPointingZ = new_cameraPointingZ;
00140 cameraZoomDistance = new_cameraZoomDistance;
00141 cameraElevationDeg = new_cameraElevationDeg ;
00142 cameraAzimuthDeg = new_cameraAzimuthDeg;
00143 }
00144
00145 inline void getLastMousePosition(int &x,int& y) const {
00146 x =m_mouseLastX;
00147 y =m_mouseLastY;
00148 }
00149
00150
00151
00152 opengl::COpenGLScenePtr m_openGLScene;
00153
00154 protected:
00155 wxGLContext *m_gl_context;
00156 bool m_init;
00157
00158 int m_mouseLastX,m_mouseLastY;
00159
00160 int mouseClickX,mouseClickY;
00161 bool mouseClicked;
00162
00163 long m_Key;
00164 unsigned long m_StartTime;
00165 unsigned long m_LastTime;
00166 unsigned long m_LastRedraw;
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 void renderTextBitmap(
00179 int screen_x,
00180 int screen_y,
00181 const std::string &str,
00182 float color_r=1,
00183 float color_g=1,
00184 float color_b=1,
00185 int font = 1
00186 );
00187
00188
00189 void OnWindowCreation(wxWindowCreateEvent &ev);
00190
00191 DECLARE_EVENT_TABLE()
00192
00193 };
00194
00195 }
00196 }
00197
00198 #endif // wxUSE_GLCANVAS
00199 #endif // MRPT_HAS_WXWIDGETS
00200 #endif // CMyGLCanvas_H
00201