#include <mrpt/gui/CDisplayWindow3D.h>
Public Member Functions | |
void * | getWxObject () |
Read-only access to the wxDialog object. | |
void | notifyChildWindowDestruction () |
Called by wx main thread to set m_hwnd to NULL. | |
CDisplayWindow3D (const std::string &windowCaption=std::string(), unsigned int initialWindowWidth=400, unsigned int initialWindowHeight=300) | |
Constructor. | |
~CDisplayWindow3D () | |
Destructor. | |
opengl::COpenGLScenePtr & | get3DSceneAndLock () |
Gets a reference to the smart shared pointer that holds the internal scene (carefuly read introduction in gui::CDisplayWindow3D before use!) This also locks the critical section for accesing the scene, thus the window will not be repainted until it is unlocked. | |
void | unlockAccess3DScene () |
Unlocks the access to the internal 3D scene. | |
void | forceRepaint () |
Repaints the window. | |
void | repaint () |
Repaints the window. | |
void | updateWindow () |
Repaints the window. | |
float | getMinRange () const |
Return the camera min range (z) (used for gluPerspective). | |
float | getMaxRange () const |
Return the camera max range (z) (used for gluPerspective). | |
float | getFOV () const |
Return the camera field of view (in degrees) (used for gluPerspective). | |
void | setMinRange (float v) |
Changes the camera min range (z) (used for gluPerspective). | |
void | setMaxRange (float v) |
Changes the camera max range (z) (used for gluPerspective). | |
void | setFOV (float v) |
Changes the camera field of view (in degrees) (used for gluPerspective). | |
bool | keyHit () |
Returns true if a key has been pushed, without blocking waiting for a new key being pushed. | |
int | getPushedKey () |
This function returns 0 if no key has been pushed on the window, or the GLUT key (or special key) code of the last pushed key. | |
void | clearKeyHitFlag () |
Assure that "keyHit" will return false until the next pushed key. | |
void | resize (unsigned int width, unsigned int height) |
Resizes the window, stretching the image to fit into the display area. | |
void | setPos (int x, int y) |
Changes the position of the window on the screen. | |
void | setWindowTitle (const std::string &str) |
Changes the window title. | |
void | waitForKey () |
Waits for any key to be pushed on the image. | |
void | setCameraElevationDeg (float deg) |
Changes the camera parameters programatically. | |
void | setCameraAzimuthDeg (float deg) |
Changes the camera parameters programatically. | |
void | setCameraPointingToPoint (float x, float y, float z) |
Changes the camera parameters programatically. | |
void | setCameraZoom (float zoom) |
Changes the camera parameters programatically. | |
void | setCameraProjective (bool isProjective) |
Sets the camera as projective, or orthogonal. | |
bool | isOpen () |
Returns false if the user has closed the window. | |
void | grabImagesStart (const std::string &grab_imgs_prefix=std::string("video_")) |
Start to save rendered images to disk. | |
void | grabImagesStop () |
Stops image grabbing started by grabImagesStart. | |
std::string | grabImageGetNextFile () |
Increments by one the image counter and return the next image file name (Users normally don't want to call this method). | |
Public Attributes | |
synch::CSemaphore | m_semThreadReady |
This semaphore will be signaled when the wx window is built and ready. | |
synch::CSemaphore | m_semWindowDestroyed |
This semaphore will be signaled when the wx window is destroyed. | |
Protected Member Functions | |
void | createOpenGLContext () |
Throws an exception on initialization error. | |
void | doRender () |
Protected Attributes | |
float | m_minRange |
float | m_maxRange |
float | m_FOV |
std::string | m_caption |
The caption of the window:. | |
void_ptr_noncopy | m_hwnd |
The window's handle. | |
opengl::COpenGLScenePtr | m_3Dscene |
Internal OpenGL object (see general discussion in about usage of this object). | |
synch::CCriticalSection | m_csAccess3DScene |
Critical section for accesing m_3Dscene. | |
volatile bool | m_keyPushed |
Auxiliars. | |
void_ptr_noncopy | m_DisplayDeviceContext |
void_ptr_noncopy | m_GLRenderingContext |
std::string | m_grab_imgs_prefix |
unsigned int | m_grab_imgs_idx |
This class always contains internally an instance of opengl::COpenGLScene, which the objects, viewports, etc. to be rendered.
Since MRPT 0.6.2, images can be grabbed automatically to disk for easy creation of videos. See CDisplayWindow3D::grabImagesStart
Since the 3D rendering is performed in a detached thread, especial care must be taken when updating the 3D scene to be rendered. The process involves an internal critical section and it must always consist of these steps:
CDisplayWindow3D win("My window"); // Adquire the scene: opengl::COpenGLScenePtr &ptrScene = win.get3DSceneAndLock(); // Modify the scene: ptrScene->... // or replace by another scene: ptrScene = otherScene; // Unlock it, so the window can use it for redraw: win.unlockAccess3DScene(); // Update window, if required win.forceRepaint();
An alternative way of updating the scene is by creating, before locking the 3D window, a new object of class COpenGLScene, then locking the window only for replacing the pointers, freeing next the old object. This may be advantageous is generating the 3D scene takes a long time, since while the window is locked it will not be responsive to the user input or window redraw. The alternative way is:
CDisplayWindow3D win("My window"); // Create my scene: COpenGLScene *myScene = new COpenGLScene(); ... // Adquire the scene: COpenGLScene **theScene = win.get3DSceneAndLock(); COpenGLScene *oldScene = *theScene; // Keep copy of old object *theScene = myScene; // Replace just the pointer (fast!) win.unlockAccess3DScene(); // Unlock it, so the window can use it for redraw: // Update window, if required win.forceRepaint(); // Free the old object: delete oldScene;
Definition at line 112 of file CDisplayWindow3D.h.
mrpt::gui::CDisplayWindow3D::CDisplayWindow3D | ( | const std::string & | windowCaption = std::string() , |
|
unsigned int | initialWindowWidth = 400 , |
|||
unsigned int | initialWindowHeight = 300 | |||
) |
Constructor.
mrpt::gui::CDisplayWindow3D::~CDisplayWindow3D | ( | ) |
Destructor.
void mrpt::gui::CDisplayWindow3D::clearKeyHitFlag | ( | ) | [inline] |
Assure that "keyHit" will return false until the next pushed key.
Definition at line 264 of file CDisplayWindow3D.h.
void mrpt::gui::CDisplayWindow3D::createOpenGLContext | ( | ) | [protected] |
Throws an exception on initialization error.
void mrpt::gui::CDisplayWindow3D::doRender | ( | ) | [protected] |
void mrpt::gui::CDisplayWindow3D::forceRepaint | ( | ) |
Repaints the window.
forceRepaint, repaint and updateWindow are all aliases of the same method.
opengl::COpenGLScenePtr& mrpt::gui::CDisplayWindow3D::get3DSceneAndLock | ( | ) |
Gets a reference to the smart shared pointer that holds the internal scene (carefuly read introduction in gui::CDisplayWindow3D before use!) This also locks the critical section for accesing the scene, thus the window will not be repainted until it is unlocked.
float mrpt::gui::CDisplayWindow3D::getFOV | ( | ) | const [inline] |
Return the camera field of view (in degrees) (used for gluPerspective).
Definition at line 220 of file CDisplayWindow3D.h.
float mrpt::gui::CDisplayWindow3D::getMaxRange | ( | ) | const [inline] |
Return the camera max range (z) (used for gluPerspective).
Definition at line 216 of file CDisplayWindow3D.h.
float mrpt::gui::CDisplayWindow3D::getMinRange | ( | ) | const [inline] |
Return the camera min range (z) (used for gluPerspective).
Definition at line 212 of file CDisplayWindow3D.h.
int mrpt::gui::CDisplayWindow3D::getPushedKey | ( | ) | [inline] |
This function returns 0 if no key has been pushed on the window, or the GLUT key (or special key) code of the last pushed key.
Calling this method also clears the "key pushed" flag.
Definition at line 250 of file CDisplayWindow3D.h.
void* mrpt::gui::CDisplayWindow3D::getWxObject | ( | ) | [inline] |
std::string mrpt::gui::CDisplayWindow3D::grabImageGetNextFile | ( | ) |
Increments by one the image counter and return the next image file name (Users normally don't want to call this method).
void mrpt::gui::CDisplayWindow3D::grabImagesStart | ( | const std::string & | grab_imgs_prefix = std::string("video_") |
) |
Start to save rendered images to disk.
Images will be saved independently as png files, depending on the template path passed to this method. For example:
path_prefix: "./video_"
Will generate "./video_000001.png", etc.
void mrpt::gui::CDisplayWindow3D::grabImagesStop | ( | ) |
bool mrpt::gui::CDisplayWindow3D::isOpen | ( | ) |
Returns false if the user has closed the window.
bool mrpt::gui::CDisplayWindow3D::keyHit | ( | ) | [inline] |
Returns true if a key has been pushed, without blocking waiting for a new key being pushed.
Definition at line 241 of file CDisplayWindow3D.h.
void mrpt::gui::CDisplayWindow3D::notifyChildWindowDestruction | ( | ) |
Called by wx main thread to set m_hwnd to NULL.
void mrpt::gui::CDisplayWindow3D::repaint | ( | ) | [inline] |
Repaints the window.
forceRepaint, repaint and updateWindow are all aliases of the same method.
Definition at line 203 of file CDisplayWindow3D.h.
void mrpt::gui::CDisplayWindow3D::resize | ( | unsigned int | width, | |
unsigned int | height | |||
) |
Resizes the window, stretching the image to fit into the display area.
void mrpt::gui::CDisplayWindow3D::setCameraAzimuthDeg | ( | float | deg | ) |
Changes the camera parameters programatically.
void mrpt::gui::CDisplayWindow3D::setCameraElevationDeg | ( | float | deg | ) |
Changes the camera parameters programatically.
void mrpt::gui::CDisplayWindow3D::setCameraPointingToPoint | ( | float | x, | |
float | y, | |||
float | z | |||
) |
Changes the camera parameters programatically.
void mrpt::gui::CDisplayWindow3D::setCameraProjective | ( | bool | isProjective | ) |
Sets the camera as projective, or orthogonal.
void mrpt::gui::CDisplayWindow3D::setCameraZoom | ( | float | zoom | ) |
Changes the camera parameters programatically.
void mrpt::gui::CDisplayWindow3D::setFOV | ( | float | v | ) | [inline] |
Changes the camera field of view (in degrees) (used for gluPerspective).
The window is not updated with this method, call "forceRepaint" to update the 3D view.
Definition at line 235 of file CDisplayWindow3D.h.
void mrpt::gui::CDisplayWindow3D::setMaxRange | ( | float | v | ) | [inline] |
Changes the camera max range (z) (used for gluPerspective).
The window is not updated with this method, call "forceRepaint" to update the 3D view.
Definition at line 230 of file CDisplayWindow3D.h.
void mrpt::gui::CDisplayWindow3D::setMinRange | ( | float | v | ) | [inline] |
Changes the camera min range (z) (used for gluPerspective).
The window is not updated with this method, call "forceRepaint" to update the 3D view.
Definition at line 225 of file CDisplayWindow3D.h.
void mrpt::gui::CDisplayWindow3D::setPos | ( | int | x, | |
int | y | |||
) |
Changes the position of the window on the screen.
void mrpt::gui::CDisplayWindow3D::setWindowTitle | ( | const std::string & | str | ) |
Changes the window title.
void mrpt::gui::CDisplayWindow3D::unlockAccess3DScene | ( | ) |
Unlocks the access to the internal 3D scene.
Typically user will want to call forceRepaint after updating the scene.
void mrpt::gui::CDisplayWindow3D::updateWindow | ( | ) | [inline] |
Repaints the window.
forceRepaint, repaint and updateWindow are all aliases of the same method.
Definition at line 208 of file CDisplayWindow3D.h.
void mrpt::gui::CDisplayWindow3D::waitForKey | ( | ) |
opengl::COpenGLScenePtr mrpt::gui::CDisplayWindow3D::m_3Dscene [protected] |
Internal OpenGL object (see general discussion in about usage of this object).
Definition at line 151 of file CDisplayWindow3D.h.
std::string mrpt::gui::CDisplayWindow3D::m_caption [protected] |
Definition at line 165 of file CDisplayWindow3D.h.
float mrpt::gui::CDisplayWindow3D::m_FOV [protected] |
Definition at line 138 of file CDisplayWindow3D.h.
Definition at line 166 of file CDisplayWindow3D.h.
unsigned int mrpt::gui::CDisplayWindow3D::m_grab_imgs_idx [protected] |
Definition at line 169 of file CDisplayWindow3D.h.
std::string mrpt::gui::CDisplayWindow3D::m_grab_imgs_prefix [protected] |
Definition at line 168 of file CDisplayWindow3D.h.
void_ptr_noncopy mrpt::gui::CDisplayWindow3D::m_hwnd [protected] |
volatile bool mrpt::gui::CDisplayWindow3D::m_keyPushed [protected] |
float mrpt::gui::CDisplayWindow3D::m_maxRange [protected] |
Definition at line 138 of file CDisplayWindow3D.h.
float mrpt::gui::CDisplayWindow3D::m_minRange [protected] |
Definition at line 138 of file CDisplayWindow3D.h.
This semaphore will be signaled when the wx window is built and ready.
Definition at line 121 of file CDisplayWindow3D.h.
This semaphore will be signaled when the wx window is destroyed.
Definition at line 125 of file CDisplayWindow3D.h.
Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN:exported at Mon Jan 12 13:00:16 UTC 2009 |