A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
This class has protected constuctor, thus it cannot be created by users. Use COpenGLScene::createViewport instead. A viewport has these "operation modes":
In any case, the viewport can be resized to only fit a part of the entire parent viewport. There will be always at least one viewport in a COpenGLScene named "main".
Refer to mrpt::opengl::COpenGLScene for further details.
Definition at line 63 of file COpenGLViewport.h.
#include <mrpt/opengl/COpenGLViewport.h>
Classes | |
struct | TLastProjectiveMatrixInfo |
Public Member Functions | |
virtual | ~COpenGLViewport () |
Destructor: clears all objects. | |
Set the viewport "modes" | |
void | setCloneView (const std::string &clonedViewport) |
Set this viewport as a clone of some other viewport, given its name - as a side effect, current list of internal OpenGL objects is cleared. | |
void | setImageView (const mrpt::utils::CImage &img) |
Set this viewport into "image view"-mode, where an image is efficiently drawn (fitting the viewport area) using an OpenGL textured quad. | |
void | setImageView_fast (mrpt::utils::CImage &img) |
Just like setImageView but moves the internal image memory instead of making a copy, so it's faster but empties the input image. | |
void | resetCloneView () |
Reset the viewport to normal mode: rendering its own objects. | |
void | setCloneCamera (bool enable) |
If set to true, and setCloneView() has been called, this viewport will be rendered using the camera of the cloned viewport. | |
void | setNormalMode () |
Resets the viewport to a normal 3D viewport. | |
Change or read viewport properties (except "viewport modes") | |
std::string | getName () |
Returns the name of the viewport. | |
void | setViewportPosition (const double x, const double y, const double width, const double height) |
Change the viewport position and dimension on the rendering window. | |
void | getViewportPosition (double &x, double &y, double &width, double &height) |
Get the current viewport position and dimension on the rendering window. | |
void | setViewportClipDistances (const double clip_min, const double clip_max) |
Set the min/max clip depth distances of the rendering frustum (default: 0.1 - 10000). | |
void | getViewportClipDistances (double &clip_min, double &clip_max) const |
Get the current min/max clip depth distances of the rendering frustum (default: 0.1 - 10000). | |
void | setBorderSize (unsigned int lineWidth) |
Set the border size ("frame") of the viewport (default=0). | |
bool | isTransparent () |
Return whether the viewport will be rendered transparent over previous viewports. | |
void | setTransparent (bool trans) |
Set the transparency, that is, whether the viewport will be rendered transparent over previous viewports (default=false). | |
void | setCustomBackgroundColor (const TColorf &color) |
Set a background color different from that of the parent GUI window. | |
bool | hasCustomBackgroundColor () const |
TColorf | getCustomBackgroundColor () const |
void | get3DRayForPixelCoord (const double x_coord, const double y_coord, mrpt::math::TLine3D &out_ray, mrpt::poses::CPose3D *out_cameraPose=NULL) const |
Compute the 3D ray corresponding to a given pixel; this can be used to allow the user to pick and select 3D objects by clicking onto the 2D image. | |
Protected Member Functions | |
COpenGLViewport (COpenGLScene *parent=NULL, const std::string &name=std::string("")) | |
Constructor, invoked from COpenGLScene only. | |
void | initializeAllTextures () |
Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL). | |
void | dumpListOfObjects (utils::CStringList &lst) |
Retrieves a list of all objects in text form. | |
void | render (const int render_width, const int render_height) const |
Render the objects in this viewport (called from COpenGLScene only). | |
void | internal_setImageView_fast (const mrpt::utils::CImage &img, bool is_fast) |
Protected Attributes | |
opengl::CCamera | m_camera |
The camera associated to the viewport. | |
utils::safe_ptr< COpenGLScene > | m_parent |
The scene that contains this viewport. | |
bool | m_isCloned |
Set by setCloneView. | |
bool | m_isClonedCamera |
Set by setCloneCamera. | |
std::string | m_clonedViewport |
Only if m_isCloned=true. | |
std::string | m_name |
The viewport's name. | |
bool | m_isTransparent |
Whether to clear color buffer. | |
uint32_t | m_borderWidth |
Default=0, the border around the viewport. | |
double | m_view_x |
double | m_view_y |
double | m_view_width |
double | m_view_height |
The viewport position [0,1]. | |
double | m_clip_min |
double | m_clip_max |
The min/max clip depth distances (default: 0.1 - 10000). | |
bool | m_custom_backgb_color |
TColorf | m_background_color |
used only if m_custom_backgb_color | |
bool | m_isImageView |
Set by setImageView. | |
CRenderizablePtr | m_imageview_quad |
A mrpt::opengl::CTexturedPlane used after setImageView() is called. | |
TLastProjectiveMatrixInfo | m_lastProjMat |
Info updated with each "render()" and used in "get3DRayForPixelCoord". | |
opengl::CListOpenGLObjects | m_objects |
The list of objects that comprise the 3D scene. | |
Friends | |
class | COpenGLScene |
RTTI stuff | |
| |
typedef COpenGLViewportPtr | SmartPtr |
static mrpt::utils::CLASSINIT | _init_COpenGLViewport |
static mrpt::utils::TRuntimeClassId | classCOpenGLViewport |
static const mrpt::utils::TRuntimeClassId * | classinfo |
static const mrpt::utils::TRuntimeClassId * | _GetBaseClass () |
virtual const mrpt::utils::TRuntimeClassId * | GetRuntimeClass () const |
Returns information about the class of an object in runtime. | |
virtual mrpt::utils::CObject * | duplicate () const |
Returns a copy of the object, indepently of its class. | |
static mrpt::utils::CObject * | CreateObject () |
static COpenGLViewportPtr | Create () |
Contained objects set/get/search | |
| |
typedef CListOpenGLObjects::const_iterator | const_iterator |
typedef CListOpenGLObjects::iterator | iterator |
const_iterator | begin () const |
const_iterator | end () const |
iterator | begin () |
iterator | end () |
void | clear () |
Delete all internal obejcts. | |
void | insert (const CRenderizablePtr &newObject) |
Insert a new object into the list. | |
void | getCurrentCameraPose (mrpt::poses::CPose3D &out_cameraPose) const |
Compute the current 3D camera pose. | |
CRenderizablePtr | getByName (const std::string &str) |
Returns the first object with a given name, or NULL if not found. | |
template<typename T > | |
T::SmartPtr | getByClass (const size_t &ith=0) const |
Returns the i'th object of a given class (or of a descendant class), or NULL (an empty smart pointer) if not found. | |
void | removeObject (const CRenderizablePtr &obj) |
Removes the given object from the scene (it also deletes the object to free its memory). | |
size_t | size () const |
Number of objects contained. | |
bool | empty () const |
opengl::CCamera & | getCamera () |
Get a reference to the camera associated with this viewport. | |
const opengl::CCamera & | getCamera () const |
Get a reference to the camera associated with this viewport. |
Definition at line 194 of file COpenGLViewport.h.
Definition at line 195 of file COpenGLViewport.h.
A typedef for the associated smart pointer
Definition at line 65 of file COpenGLViewport.h.
virtual mrpt::opengl::COpenGLViewport::~COpenGLViewport | ( | ) | [virtual] |
Destructor: clears all objects.
mrpt::opengl::COpenGLViewport::COpenGLViewport | ( | COpenGLScene * | parent = NULL , |
|
const std::string & | name = std::string("") | |||
) | [protected] |
Constructor, invoked from COpenGLScene only.
static const mrpt::utils::TRuntimeClassId* mrpt::opengl::COpenGLViewport::_GetBaseClass | ( | ) | [static, protected] |
Reimplemented from mrpt::utils::CSerializable.
const_iterator mrpt::opengl::COpenGLViewport::begin | ( | ) | const [inline] |
Definition at line 197 of file COpenGLViewport.h.
iterator mrpt::opengl::COpenGLViewport::begin | ( | ) | [inline] |
Definition at line 199 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::clear | ( | ) |
Delete all internal obejcts.
static COpenGLViewportPtr mrpt::opengl::COpenGLViewport::Create | ( | ) | [static] |
static mrpt::utils::CObject* mrpt::opengl::COpenGLViewport::CreateObject | ( | ) | [static] |
void mrpt::opengl::COpenGLViewport::dumpListOfObjects | ( | utils::CStringList & | lst | ) | [protected] |
Retrieves a list of all objects in text form.
virtual mrpt::utils::CObject* mrpt::opengl::COpenGLViewport::duplicate | ( | ) | const [virtual] |
Returns a copy of the object, indepently of its class.
Implements mrpt::utils::CObject.
bool mrpt::opengl::COpenGLViewport::empty | ( | ) | const [inline] |
Definition at line 258 of file COpenGLViewport.h.
const_iterator mrpt::opengl::COpenGLViewport::end | ( | ) | const [inline] |
Definition at line 198 of file COpenGLViewport.h.
iterator mrpt::opengl::COpenGLViewport::end | ( | ) | [inline] |
Definition at line 200 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::get3DRayForPixelCoord | ( | const double | x_coord, | |
const double | y_coord, | |||
mrpt::math::TLine3D & | out_ray, | |||
mrpt::poses::CPose3D * | out_cameraPose = NULL | |||
) | const |
Compute the 3D ray corresponding to a given pixel; this can be used to allow the user to pick and select 3D objects by clicking onto the 2D image.
x_coord | Horizontal coordinate with the usual meaning (0:left of the viewport, W-1: right border). | |
y_coord | Horizontal coordinate with the usual meaning (0:top of the viewport, H-1: right border). | |
out_cameraPose | If not NULL, will have the camera 3D pose as a mrpt::poses::CPose3D. See also |
T::SmartPtr mrpt::opengl::COpenGLViewport::getByClass | ( | const size_t & | ith = 0 |
) | const [inline] |
Returns the i'th object of a given class (or of a descendant class), or NULL (an empty smart pointer) if not found.
Example:
CSpherePtr obs = view.getByClass<CSphere>();
By default (ith=0), the first observation is returned.
Definition at line 228 of file COpenGLViewport.h.
References CLASS_ID_NAMESPACE.
CRenderizablePtr mrpt::opengl::COpenGLViewport::getByName | ( | const std::string & | str | ) |
Returns the first object with a given name, or NULL if not found.
const opengl::CCamera& mrpt::opengl::COpenGLViewport::getCamera | ( | ) | const [inline] |
Get a reference to the camera associated with this viewport.
Definition at line 263 of file COpenGLViewport.h.
opengl::CCamera& mrpt::opengl::COpenGLViewport::getCamera | ( | ) | [inline] |
Get a reference to the camera associated with this viewport.
Definition at line 261 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::getCurrentCameraPose | ( | mrpt::poses::CPose3D & | out_cameraPose | ) | const |
Compute the current 3D camera pose.
TColorf mrpt::opengl::COpenGLViewport::getCustomBackgroundColor | ( | ) | const [inline] |
Definition at line 174 of file COpenGLViewport.h.
std::string mrpt::opengl::COpenGLViewport::getName | ( | ) | [inline] |
Returns the name of the viewport.
Definition at line 112 of file COpenGLViewport.h.
virtual const mrpt::utils::TRuntimeClassId* mrpt::opengl::COpenGLViewport::GetRuntimeClass | ( | ) | const [virtual] |
Returns information about the class of an object in runtime.
Reimplemented from mrpt::utils::CSerializable.
void mrpt::opengl::COpenGLViewport::getViewportClipDistances | ( | double & | clip_min, | |
double & | clip_max | |||
) | const |
Get the current min/max clip depth distances of the rendering frustum (default: 0.1 - 10000).
void mrpt::opengl::COpenGLViewport::getViewportPosition | ( | double & | x, | |
double & | y, | |||
double & | width, | |||
double & | height | |||
) |
Get the current viewport position and dimension on the rendering window.
X & Y coordinates here can have two interpretations:
bool mrpt::opengl::COpenGLViewport::hasCustomBackgroundColor | ( | ) | const [inline] |
Definition at line 172 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::initializeAllTextures | ( | ) | [protected] |
Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL).
void mrpt::opengl::COpenGLViewport::insert | ( | const CRenderizablePtr & | newObject | ) |
Insert a new object into the list.
The object MUST NOT be deleted, it will be deleted automatically by this object when not required anymore.
void mrpt::opengl::COpenGLViewport::internal_setImageView_fast | ( | const mrpt::utils::CImage & | img, | |
bool | is_fast | |||
) | [protected] |
bool mrpt::opengl::COpenGLViewport::isTransparent | ( | ) | [inline] |
Return whether the viewport will be rendered transparent over previous viewports.
Definition at line 163 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::removeObject | ( | const CRenderizablePtr & | obj | ) |
Removes the given object from the scene (it also deletes the object to free its memory).
void mrpt::opengl::COpenGLViewport::render | ( | const int | render_width, | |
const int | render_height | |||
) | const [protected] |
Render the objects in this viewport (called from COpenGLScene only).
void mrpt::opengl::COpenGLViewport::resetCloneView | ( | ) | [inline] |
Reset the viewport to normal mode: rendering its own objects.
Definition at line 94 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::setBorderSize | ( | unsigned int | lineWidth | ) | [inline] |
Set the border size ("frame") of the viewport (default=0).
Definition at line 159 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::setCloneCamera | ( | bool | enable | ) | [inline] |
If set to true, and setCloneView() has been called, this viewport will be rendered using the camera of the cloned viewport.
Definition at line 98 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::setCloneView | ( | const std::string & | clonedViewport | ) |
Set this viewport as a clone of some other viewport, given its name - as a side effect, current list of internal OpenGL objects is cleared.
By default, only the objects are cloned, not the camera. See
void mrpt::opengl::COpenGLViewport::setCustomBackgroundColor | ( | const TColorf & | color | ) | [inline] |
Set a background color different from that of the parent GUI window.
Definition at line 170 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::setImageView | ( | const mrpt::utils::CImage & | img | ) |
Set this viewport into "image view"-mode, where an image is efficiently drawn (fitting the viewport area) using an OpenGL textured quad.
Call this method with the new image to update the displayed image (but recall to first lock the parent openglscene's critical section, then do the update, then release the lock, and then issue a window repaint). Internally, the texture is drawn using a mrpt::opengl::CTexturedPlane The viewport can be reverted to behave like a normal viewport by calling setNormalMode()
void mrpt::opengl::COpenGLViewport::setImageView_fast | ( | mrpt::utils::CImage & | img | ) |
Just like setImageView but moves the internal image memory instead of making a copy, so it's faster but empties the input image.
void mrpt::opengl::COpenGLViewport::setNormalMode | ( | ) |
Resets the viewport to a normal 3D viewport.
void mrpt::opengl::COpenGLViewport::setTransparent | ( | bool | trans | ) | [inline] |
Set the transparency, that is, whether the viewport will be rendered transparent over previous viewports (default=false).
Definition at line 167 of file COpenGLViewport.h.
void mrpt::opengl::COpenGLViewport::setViewportClipDistances | ( | const double | clip_min, | |
const double | clip_max | |||
) |
Set the min/max clip depth distances of the rendering frustum (default: 0.1 - 10000).
void mrpt::opengl::COpenGLViewport::setViewportPosition | ( | const double | x, | |
const double | y, | |||
const double | width, | |||
const double | height | |||
) |
Change the viewport position and dimension on the rendering window.
X & Y coordinates here can have two interpretations:
width & height can be interpreted as:
size_t mrpt::opengl::COpenGLViewport::size | ( | ) | const [inline] |
Number of objects contained.
Definition at line 256 of file COpenGLViewport.h.
friend class COpenGLScene [friend] |
Definition at line 66 of file COpenGLViewport.h.
mrpt::utils::CLASSINIT mrpt::opengl::COpenGLViewport::_init_COpenGLViewport [static, protected] |
Definition at line 65 of file COpenGLViewport.h.
Definition at line 65 of file COpenGLViewport.h.
const mrpt::utils::TRuntimeClassId* mrpt::opengl::COpenGLViewport::classinfo [static] |
Definition at line 65 of file COpenGLViewport.h.
used only if m_custom_backgb_color
Definition at line 300 of file COpenGLViewport.h.
uint32_t mrpt::opengl::COpenGLViewport::m_borderWidth [protected] |
Default=0, the border around the viewport.
Definition at line 296 of file COpenGLViewport.h.
The camera associated to the viewport.
Definition at line 289 of file COpenGLViewport.h.
double mrpt::opengl::COpenGLViewport::m_clip_max [protected] |
The min/max clip depth distances (default: 0.1 - 10000).
Definition at line 298 of file COpenGLViewport.h.
double mrpt::opengl::COpenGLViewport::m_clip_min [protected] |
Definition at line 298 of file COpenGLViewport.h.
std::string mrpt::opengl::COpenGLViewport::m_clonedViewport [protected] |
Only if m_isCloned=true.
Definition at line 293 of file COpenGLViewport.h.
bool mrpt::opengl::COpenGLViewport::m_custom_backgb_color [protected] |
Definition at line 299 of file COpenGLViewport.h.
A mrpt::opengl::CTexturedPlane used after setImageView() is called.
Definition at line 302 of file COpenGLViewport.h.
bool mrpt::opengl::COpenGLViewport::m_isCloned [protected] |
Set by setCloneView.
Definition at line 291 of file COpenGLViewport.h.
bool mrpt::opengl::COpenGLViewport::m_isClonedCamera [protected] |
Set by setCloneCamera.
Definition at line 292 of file COpenGLViewport.h.
bool mrpt::opengl::COpenGLViewport::m_isImageView [protected] |
Set by setImageView.
Definition at line 301 of file COpenGLViewport.h.
bool mrpt::opengl::COpenGLViewport::m_isTransparent [protected] |
Whether to clear color buffer.
Definition at line 295 of file COpenGLViewport.h.
TLastProjectiveMatrixInfo mrpt::opengl::COpenGLViewport::m_lastProjMat [mutable, protected] |
Info updated with each "render()" and used in "get3DRayForPixelCoord".
Definition at line 317 of file COpenGLViewport.h.
std::string mrpt::opengl::COpenGLViewport::m_name [protected] |
The viewport's name.
Definition at line 294 of file COpenGLViewport.h.
The list of objects that comprise the 3D scene.
Objects are automatically deleted when calling "clear" or in the destructor.
Definition at line 322 of file COpenGLViewport.h.
The scene that contains this viewport.
Definition at line 290 of file COpenGLViewport.h.
double mrpt::opengl::COpenGLViewport::m_view_height [protected] |
The viewport position [0,1].
Definition at line 297 of file COpenGLViewport.h.
double mrpt::opengl::COpenGLViewport::m_view_width [protected] |
Definition at line 297 of file COpenGLViewport.h.
double mrpt::opengl::COpenGLViewport::m_view_x [protected] |
Definition at line 297 of file COpenGLViewport.h.
double mrpt::opengl::COpenGLViewport::m_view_y [protected] |
Definition at line 297 of file COpenGLViewport.h.
Page generated by Doxygen 1.7.1 for MRPT 0.9.4 SVN: at Mon Jan 10 23:33:19 UTC 2011 |