A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time. More...
#include <mrpt/gui/CDisplayWindow3D.h>


Public Member Functions | |
| CDisplayWindow3D (const std::string &windowCaption=std::string(), unsigned int initialWindowWidth=400, unsigned int initialWindowHeight=300) | |
| Constructor. | |
| virtual | ~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). | |
| 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 | 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. | |
| float | getCameraElevationDeg () const |
| Get camera parameters programatically. | |
| float | getCameraAzimuthDeg () const |
| Get camera parameters programatically. | |
| void | getCameraPointingToPoint (float &x, float &y, float &z) const |
| Get camera parameters programatically. | |
| float | getCameraZoom () const |
| Get camera parameters programatically. | |
| bool | isCameraProjective () const |
| Sets the camera as projective, or orthogonal. | |
| void | useCameraFromScene (bool useIt=true) |
| If set to true (default = false), the mouse-based scene navigation will be disabled and the camera position will be determined by the opengl viewports in the 3D scene. | |
| bool | getLastMousePosition (int &x, int &y) const |
| Gets the last x,y pixel coordinates of the mouse. | |
| void | setCursorCross (bool cursorIsCross) |
| Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true). | |
| 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. | |
| void | captureImagesStart () |
| Enables the grabbing of CImage objects from screenshots of the window. | |
| void | captureImagesStop () |
| Stop image grabbing. | |
| void | getLastWindowImage (mrpt::utils::CImage &out_img) const |
| Retrieve the last captured image from the window. | |
| mrpt::utils::CImagePtr | getLastWindowImagePtr () const |
| Retrieve the last captured image from the window, as a smart pointer. | |
| 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). | |
| bool | isCapturingImgs () const |
| void | addTextMessage (const double x_frac, const double y_frac, const std::string &text, const mrpt::utils::TColorf &color=mrpt::utils::TColorf(1.0, 1.0, 1.0), const size_t unique_index=0, const TOpenGLFont font=MRPT_GLUT_BITMAP_TIMES_ROMAN_24) |
| Add 2D text messages overlapped to the 3D rendered scene. | |
| void | clearTextMessages () |
| Clear all text messages created with addTextMessage(). | |
Static Public Member Functions | |
| static CDisplayWindow3DPtr | Create (const std::string &windowCaption=std::string(), unsigned int initialWindowWidth=400, unsigned int initialWindowHeight=300) |
| Class factory returning a smart pointer. | |
Private Member Functions | |
| void | createOpenGLContext () |
| Throws an exception on initialization error. | |
| void | doRender () |
Private Attributes | |
| float | m_minRange |
| float | m_maxRange |
| float | m_FOV |
| 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. | |
| void_ptr_noncopy | m_DisplayDeviceContext |
| void_ptr_noncopy | m_GLRenderingContext |
| std::string | m_grab_imgs_prefix |
| unsigned int | m_grab_imgs_idx |
| bool | m_is_capturing_imgs |
| CImagePtr | m_last_captured_img |
| synch::CCriticalSection | m_last_captured_img_cs |
Friends | |
| class | C3DWindowDialog |
| class | CMyGLCanvas_DisplayWindow3D |
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.
This class always contains internally an instance of opengl::COpenGLScene, which the objects, viewports, etc. to be rendered.
Images can be grabbed automatically to disk for easy creation of videos. See CDisplayWindow3D::grabImagesStart (and for creating videos, mrpt::utils::CVideoFileWriter).
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 smart pointer. 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 window can also display a set of 2D text messages overlapped to the 3D scene. See CDisplayWindow3D::add2DTextMessage
For a list of supported events with the observer/observable pattern, see the discussion in mrpt::gui::CBaseGUIWindow.
Definition at line 99 of file CDisplayWindow3D.h.
| mrpt::gui::CDisplayWindow3D::CDisplayWindow3D | ( | const std::string & | windowCaption = std::string(), |
|
| unsigned int | initialWindowWidth = 400, |
|||
| unsigned int | initialWindowHeight = 300 | |||
| ) |
Constructor.
| virtual mrpt::gui::CDisplayWindow3D::~CDisplayWindow3D | ( | ) | [virtual] |
Destructor.
| void mrpt::gui::CDisplayWindow3D::addTextMessage | ( | const double | x_frac, | |
| const double | y_frac, | |||
| const std::string & | text, | |||
| const mrpt::utils::TColorf & | color = mrpt::utils::TColorf(1.0, 1.0, 1.0), |
|||
| const size_t | unique_index = 0, |
|||
| const TOpenGLFont | font = MRPT_GLUT_BITMAP_TIMES_ROMAN_24 | |||
| ) |
Add 2D text messages overlapped to the 3D rendered scene.
The string will remain displayed in the 3D window until it's changed with subsequent calls to this same method, or all the texts are cleared with clearTextMessages().
| x_frac | The X position, in the range [0,1] (left,right, of the 3D viewport). | |
| y_frac | The Y position, in the range [0,1] (bottom,top, of the 3D viewport). | |
| text | The text string to display. | |
| color | The text color. For example: TColorf(1.0,1.0,1.0) | |
| unique_index | An "index" for this text message, so that subsequent calls with the same index will overwrite this text message instead of creating new ones. |
You'll need to refresh the display manually with forceRepaint().
| void mrpt::gui::CDisplayWindow3D::captureImagesStart | ( | ) |
Enables the grabbing of CImage objects from screenshots of the window.
| void mrpt::gui::CDisplayWindow3D::captureImagesStop | ( | ) |
Stop image grabbing.
| void mrpt::gui::CDisplayWindow3D::clearTextMessages | ( | ) |
Clear all text messages created with addTextMessage().
You'll need to refresh the display manually with forceRepaint().
| static CDisplayWindow3DPtr mrpt::gui::CDisplayWindow3D::Create | ( | const std::string & | windowCaption = std::string(), |
|
| unsigned int | initialWindowWidth = 400, |
|||
| unsigned int | initialWindowHeight = 300 | |||
| ) | [inline, static] |
Class factory returning a smart pointer.
Definition at line 144 of file CDisplayWindow3D.h.
| void mrpt::gui::CDisplayWindow3D::createOpenGLContext | ( | ) | [private] |
Throws an exception on initialization error.
| void mrpt::gui::CDisplayWindow3D::doRender | ( | ) | [private] |
| 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::getCameraAzimuthDeg | ( | ) | const |
Get camera parameters programatically.
| float mrpt::gui::CDisplayWindow3D::getCameraElevationDeg | ( | ) | const |
Get camera parameters programatically.
| void mrpt::gui::CDisplayWindow3D::getCameraPointingToPoint | ( | float & | x, | |
| float & | y, | |||
| float & | z | |||
| ) | const |
Get camera parameters programatically.
| float mrpt::gui::CDisplayWindow3D::getCameraZoom | ( | ) | const |
Get camera parameters programatically.
| float mrpt::gui::CDisplayWindow3D::getFOV | ( | ) | const [inline] |
Return the camera field of view (in degrees) (used for gluPerspective).
Definition at line 191 of file CDisplayWindow3D.h.
| bool mrpt::gui::CDisplayWindow3D::getLastMousePosition | ( | int & | x, | |
| int & | y | |||
| ) | const |
Gets the last x,y pixel coordinates of the mouse.
| void mrpt::gui::CDisplayWindow3D::getLastWindowImage | ( | mrpt::utils::CImage & | out_img | ) | const |
Retrieve the last captured image from the window.
You MUST CALL FIRST captureImagesStart to enable image grabbing.
| mrpt::utils::CImagePtr mrpt::gui::CDisplayWindow3D::getLastWindowImagePtr | ( | ) | const |
Retrieve the last captured image from the window, as a smart pointer.
This method is more efficient than getLastWindowImage since only a copy of the pointer is performed, while getLastWindowImage would copy the entire image.
You MUST CALL FIRST captureImagesStart to enable image grabbing.
| float mrpt::gui::CDisplayWindow3D::getMaxRange | ( | ) | const [inline] |
Return the camera max range (z) (used for gluPerspective).
Definition at line 187 of file CDisplayWindow3D.h.
| float mrpt::gui::CDisplayWindow3D::getMinRange | ( | ) | const [inline] |
Return the camera min range (z) (used for gluPerspective).
Definition at line 183 of file CDisplayWindow3D.h.
| 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 | ( | ) |
Stops image grabbing started by grabImagesStart.
| bool mrpt::gui::CDisplayWindow3D::isCameraProjective | ( | ) | const |
Sets the camera as projective, or orthogonal.
| bool mrpt::gui::CDisplayWindow3D::isCapturingImgs | ( | ) | const [inline] |
Definition at line 312 of file CDisplayWindow3D.h.
| void mrpt::gui::CDisplayWindow3D::repaint | ( | ) | [inline] |
Repaints the window.
forceRepaint, repaint and updateWindow are all aliases of the same method.
Definition at line 174 of file CDisplayWindow3D.h.
| void mrpt::gui::CDisplayWindow3D::resize | ( | unsigned int | width, | |
| unsigned int | height | |||
| ) | [virtual] |
Resizes the window, stretching the image to fit into the display area.
Implements mrpt::gui::CBaseGUIWindow.
| 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::setCursorCross | ( | bool | cursorIsCross | ) |
Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true).
| 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 206 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 201 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 196 of file CDisplayWindow3D.h.
| void mrpt::gui::CDisplayWindow3D::setPos | ( | int | x, | |
| int | y | |||
| ) | [virtual] |
Changes the position of the window on the screen.
Implements mrpt::gui::CBaseGUIWindow.
| void mrpt::gui::CDisplayWindow3D::setWindowTitle | ( | const std::string & | str | ) | [virtual] |
Changes the window title.
Implements mrpt::gui::CBaseGUIWindow.
| 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 179 of file CDisplayWindow3D.h.
| void mrpt::gui::CDisplayWindow3D::useCameraFromScene | ( | bool | useIt = true |
) |
If set to true (default = false), the mouse-based scene navigation will be disabled and the camera position will be determined by the opengl viewports in the 3D scene.
friend class C3DWindowDialog [friend] |
Reimplemented from mrpt::gui::CBaseGUIWindow.
Definition at line 104 of file CDisplayWindow3D.h.
friend class CMyGLCanvas_DisplayWindow3D [friend] |
Definition at line 105 of file CDisplayWindow3D.h.
opengl::COpenGLScenePtr mrpt::gui::CDisplayWindow3D::m_3Dscene [private] |
Internal OpenGL object (see general discussion in about usage of this object).
Definition at line 113 of file CDisplayWindow3D.h.
Critical section for accesing m_3Dscene.
Definition at line 117 of file CDisplayWindow3D.h.
Definition at line 123 of file CDisplayWindow3D.h.
float mrpt::gui::CDisplayWindow3D::m_FOV [private] |
Definition at line 108 of file CDisplayWindow3D.h.
Definition at line 124 of file CDisplayWindow3D.h.
unsigned int mrpt::gui::CDisplayWindow3D::m_grab_imgs_idx [private] |
Definition at line 127 of file CDisplayWindow3D.h.
std::string mrpt::gui::CDisplayWindow3D::m_grab_imgs_prefix [private] |
Definition at line 126 of file CDisplayWindow3D.h.
bool mrpt::gui::CDisplayWindow3D::m_is_capturing_imgs [private] |
Definition at line 129 of file CDisplayWindow3D.h.
CImagePtr mrpt::gui::CDisplayWindow3D::m_last_captured_img [private] |
Definition at line 130 of file CDisplayWindow3D.h.
Definition at line 131 of file CDisplayWindow3D.h.
float mrpt::gui::CDisplayWindow3D::m_maxRange [private] |
Definition at line 108 of file CDisplayWindow3D.h.
float mrpt::gui::CDisplayWindow3D::m_minRange [private] |
Definition at line 108 of file CDisplayWindow3D.h.
| Page generated by Doxygen 1.6.1 for MRPT 0.9.0 SVN: at Mon Jun 7 06:47:58 UTC 2010 |