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 OnKeyDown(wxKeyEvent& event);
00080 void OnKeyUp(wxKeyEvent& event);
00081 void OnEnterWindow(wxMouseEvent& 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 float clearColorR,clearColorG,clearColorB;
00100
00101 static float SENSIBILITY_DEG_PER_PIXEL;
00102
00103
00104 virtual void OnKeyDownCustom( wxKeyEvent& event ) { }
00105 virtual void OnKeyUpCustom( wxKeyEvent& event ) { }
00106
00107 virtual void OnPreRender() { }
00108 virtual void OnPostRender() { }
00109 virtual void OnPostRenderSwapBuffers(double At, wxPaintDC &dc) { }
00110 virtual void OnRenderError( const wxString &str ) { }
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 virtual void OnUserManuallyMovesCamera(
00126 float new_cameraPointingX,
00127 float new_cameraPointingY,
00128 float new_cameraPointingZ,
00129 float new_cameraZoomDistance,
00130 float new_cameraElevationDeg,
00131 float new_cameraAzimuthDeg )
00132 {
00133 cameraPointingX = new_cameraPointingX;
00134 cameraPointingY = new_cameraPointingY;
00135 cameraPointingZ = new_cameraPointingZ;
00136 cameraZoomDistance = new_cameraZoomDistance;
00137 cameraElevationDeg = new_cameraElevationDeg ;
00138 cameraAzimuthDeg = new_cameraAzimuthDeg;
00139 }
00140
00141
00142
00143 opengl::COpenGLScenePtr m_openGLScene;
00144
00145 protected:
00146 bool m_init;
00147
00148 int mouseClickX,mouseClickY;
00149 bool mouseClicked;
00150
00151 long m_Key;
00152 unsigned long m_StartTime;
00153 unsigned long m_LastTime;
00154 unsigned long m_LastRedraw;
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 void renderTextBitmap(
00167 int screen_x,
00168 int screen_y,
00169 const char *str,
00170 float color_r=1,
00171 float color_g=1,
00172 float color_b=1,
00173 int font = 1
00174 );
00175
00176 DECLARE_EVENT_TABLE()
00177
00178 };
00179
00180 }
00181 }
00182
00183 #endif // wxUSE_GLCANVAS
00184 #endif // MRPT_HAS_WXWIDGETS
00185 #endif // CMyGLCanvas_H
00186