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 #ifndef CDisplayWindow3D_H
00029 #define CDisplayWindow3D_H
00030
00031 #include <mrpt/utils/CSerializable.h>
00032 #include <mrpt/synch.h>
00033 #include <mrpt/opengl.h>
00034 #include <mrpt/utils/safe_pointers.h>
00035
00036
00037
00038
00039 namespace mrpt
00040 {
00041 namespace utils
00042 {
00043 class CMRPTImage;
00044 class CMRPTImageFloat;
00045 }
00046
00047 namespace gui
00048 {
00049 using namespace mrpt::utils;
00050
00051 class C3DWindowDialog;
00052
00053 DEFINE_SERIALIZABLE_PRE(CDisplayWindow3D)
00054
00055
00092 class MRPTDLLIMPEXP CDisplayWindow3D : public mrpt::utils::CSerializable
00093 {
00094
00095 DEFINE_SERIALIZABLE( CDisplayWindow3D )
00096
00097 friend class C3DWindowDialog;
00098
00099 public:
00102 synch::CSemaphore m_semThreadReady;
00103
00106 synch::CSemaphore m_semWindowDestroyed;
00107
00108
00111 void * getWxObject() { return m_hwnd.get(); }
00112
00115 void notifyChildWindowDestruction();
00116
00117 protected:
00118
00119 float m_minRange,m_maxRange,m_FOV;
00120
00121
00124 std::string m_caption;
00125
00128 void_ptr_noncopy m_hwnd;
00129
00132 opengl::COpenGLScenePtr m_3Dscene;
00133
00136 synch::CCriticalSection m_csAccess3DScene;
00137
00139 volatile bool m_keyPushed;
00140 volatile int m_keyPushedCode;
00141
00144 void createOpenGLContext();
00145
00146 void_ptr_noncopy m_DisplayDeviceContext;
00147 void_ptr_noncopy m_GLRenderingContext;
00148
00149 std::string m_grab_imgs_prefix;
00150 unsigned int m_grab_imgs_idx;
00151
00152 void doRender();
00153
00154 public:
00157 CDisplayWindow3D(
00158 const std::string &windowCaption = std::string(),
00159 unsigned int initialWindowWidth = 400,
00160 unsigned int initialWindowHeight = 300 );
00161
00164 ~CDisplayWindow3D();
00165
00169 opengl::COpenGLScenePtr & get3DSceneAndLock( );
00170
00174 void unlockAccess3DScene();
00175
00179 void forceRepaint();
00180
00184 void repaint() { forceRepaint(); }
00185
00189 void updateWindow() { forceRepaint(); }
00190
00193 float getMinRange() const { return m_minRange; };
00194
00197 float getMaxRange() const { return m_maxRange; };
00198
00201 float getFOV() const { return m_FOV; };
00202
00206 void setMinRange(float v) { m_minRange=v; };
00207
00211 void setMaxRange(float v) { m_maxRange=v; };
00212
00216 void setFOV(float v) { m_FOV=v; };
00217
00220 void resize( unsigned int width, unsigned int height );
00221
00224 void setPos( int x, int y );
00225
00228 void setWindowTitle( const std::string &str );
00229
00233 int waitForKey( );
00234
00238 bool keyHit() const
00239 {
00240 return m_keyPushed;
00241 }
00242
00246 void clearKeyHitFlag()
00247 {
00248 m_keyPushed = false;
00249 }
00250
00251
00254 void setCameraElevationDeg( float deg );
00255
00258 void setCameraAzimuthDeg( float deg );
00259
00262 void setCameraPointingToPoint( float x,float y, float z );
00263
00266 void setCameraZoom( float zoom );
00267
00269 void setCameraProjective( bool isProjective );
00270
00271
00274 bool isOpen();
00275
00276
00287 void grabImagesStart( const std::string &grab_imgs_prefix = std::string("video_") );
00288
00292 void grabImagesStop();
00293
00297 std::string grabImageGetNextFile();
00298
00299 };
00300 }
00301 }
00302
00303 #endif