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
00048
00049 namespace gui
00050 {
00051 using namespace mrpt::utils;
00052
00053 DEFINE_SERIALIZABLE_PRE(CDisplayWindow3D)
00054
00055
00112 class MRPTDLLIMPEXP CDisplayWindow3D : public mrpt::utils::CSerializable
00113 {
00114
00115 DEFINE_SERIALIZABLE( CDisplayWindow3D )
00116
00117
00118 public:
00121 synch::CSemaphore m_semThreadReady;
00122
00125 synch::CSemaphore m_semWindowDestroyed;
00126
00127
00130 void * getWxObject() { return m_hwnd.get(); }
00131
00134 void notifyChildWindowDestruction();
00135
00136 protected:
00137
00138 float m_minRange,m_maxRange,m_FOV;
00139
00140
00143 std::string m_caption;
00144
00147 void_ptr_noncopy m_hwnd;
00148
00151 opengl::COpenGLScenePtr m_3Dscene;
00152
00155 synch::CCriticalSection m_csAccess3DScene;
00156
00159 volatile bool m_keyPushed;
00160
00163 void createOpenGLContext();
00164
00165 void_ptr_noncopy m_DisplayDeviceContext;
00166 void_ptr_noncopy m_GLRenderingContext;
00167
00168 std::string m_grab_imgs_prefix;
00169 unsigned int m_grab_imgs_idx;
00170
00171 void doRender();
00172
00173 public:
00176 CDisplayWindow3D(
00177 const std::string &windowCaption = std::string(),
00178 unsigned int initialWindowWidth = 400,
00179 unsigned int initialWindowHeight = 300 );
00180
00183 ~CDisplayWindow3D();
00184
00188 opengl::COpenGLScenePtr & get3DSceneAndLock( );
00189
00193 void unlockAccess3DScene();
00194
00198 void forceRepaint();
00199
00203 void repaint() { forceRepaint(); }
00204
00208 void updateWindow() { forceRepaint(); }
00209
00212 float getMinRange() const { return m_minRange; };
00213
00216 float getMaxRange() const { return m_maxRange; };
00217
00220 float getFOV() const { return m_FOV; };
00221
00225 void setMinRange(float v) { m_minRange=v; };
00226
00230 void setMaxRange(float v) { m_maxRange=v; };
00231
00235 void setFOV(float v) { m_FOV=v; };
00236
00237
00241 bool keyHit()
00242 {
00243 return m_keyPushed;
00244 }
00245
00250 int getPushedKey()
00251 {
00252 if (m_keyPushed)
00253 {
00254 m_keyPushed = false;
00255 return 1;
00256 }
00257 else
00258 return 0;
00259 }
00260
00264 void clearKeyHitFlag()
00265 {
00266 m_keyPushed = false;
00267 }
00268
00271 void resize( unsigned int width, unsigned int height );
00272
00275 void setPos( int x, int y );
00276
00279 void setWindowTitle( const std::string &str );
00280
00284 void waitForKey( );
00285
00288 void setCameraElevationDeg( float deg );
00289
00292 void setCameraAzimuthDeg( float deg );
00293
00296 void setCameraPointingToPoint( float x,float y, float z );
00297
00300 void setCameraZoom( float zoom );
00301
00303 void setCameraProjective( bool isProjective );
00304
00305
00308 bool isOpen();
00309
00310
00321 void grabImagesStart( const std::string &grab_imgs_prefix = std::string("video_") );
00322
00326 void grabImagesStop();
00327
00331 std::string grabImageGetNextFile();
00332
00333 };
00334 }
00335 }
00336
00337 #endif