9 #ifndef opengl_COpenGLViewport_H
10 #define opengl_COpenGLViewport_H
25 namespace utils {
class CImage; }
73 void setCloneView( const
std::
string &clonedViewport );
81 void setImageView(const
mrpt::utils::
CImage &img);
86 void setImageView_fast(
mrpt::utils::
CImage &img);
91 inline
void resetCloneView() { setNormalMode(); }
130 inline std::string
getName() {
return m_name; }
146 void setViewportPosition(
150 const double height );
159 void getViewportPosition(
168 void setViewportClipDistances(
const double clip_min,
const double clip_max);
173 void getViewportClipDistances(
double &clip_min,
double &clip_max)
const;
177 inline void setBorderSize(
unsigned int lineWidth ) { m_borderWidth = lineWidth; }
213 inline const_iterator
begin()
const {
return m_objects.begin(); }
214 inline const_iterator
end()
const {
return m_objects.end(); }
215 inline iterator
begin() {
return m_objects.begin(); }
216 inline iterator
end() {
return m_objects.end(); }
225 void insert(
const CRenderizablePtr &newObject );
234 CRenderizablePtr getByName(
const std::string &str );
243 template <
typename T>
244 typename T::SmartPtr
getByClass(
const size_t &ith = 0 )
const
247 size_t foundCount = 0;
250 if ( (*it).present() && (*it)->GetRuntimeClass()->derivedFrom( class_ID ) )
251 if (foundCount++ == ith)
252 return typename T::SmartPtr(*it);
259 typename T::SmartPtr o = CSetOfObjectsPtr(*it)->getByClass<T>(ith);
260 if (o.present())
return o;
263 return typename T::SmartPtr();
269 void removeObject(
const CRenderizablePtr & obj );
272 inline size_t size()
const {
return m_objects.size(); }
274 inline bool empty()
const {
return m_objects.empty(); }
297 void initializeAllTextures();
304 void render(
const int render_width,
const int render_height )
const;
315 double m_view_x,
m_view_y,m_view_width,m_view_height;
325 TLastProjectiveMatrixInfo() : is_projective(true),
eye(0,0,0),pointing(0,0,0),up(0,0,0), FOV(30), viewport_width(640), viewport_height(480), azimuth(0), elev(0), zoom(1)
355 inline COpenGLViewportPtr &operator<<(COpenGLViewportPtr &s,const CRenderizablePtr &r) {
363 inline COpenGLViewportPtr &operator<<(COpenGLViewportPtr &s,const std::vector<CRenderizablePtr> &v) {
opengl::CListOpenGLObjects m_objects
The list of objects that comprise the 3D scene.
void setBorderSize(unsigned int lineWidth)
Set the border size ("frame") of the viewport (default=0).
const COpenGLViewport *const source_viewport
const opengl::CCamera & getCamera() const
Get a reference to the camera associated with this viewport.
mrpt::utils::CImagePtr m_imageview_img
The image to display, after calling setImageView()
bool m_isTransparent
Whether to clear color buffer.
opengl::CCamera & getCamera()
Get a reference to the camera associated with this viewport.
A set of object, which are referenced to the coordinates framework established in this object...
uint32_t m_borderWidth
Default=0, the border around the viewport.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
mrptEventGLPostRender(const COpenGLViewport *obj)
A class for storing images as grayscale or RGB bitmaps.
The basic event type for the observer-observable pattern in MRPT.
std::vector< CLight > m_lights
#define ASSERT_BELOW_(__A, __B)
bool m_custom_backgb_color
std::deque< CRenderizablePtr > CListOpenGLObjects
A list of objects pointers, automatically managing memory free at destructor, and managing copies cor...
CLight & getLight(const size_t i)
const Scalar * const_iterator
mrpt::utils::TColorf m_background_color
used only if m_custom_backgb_color
CListOpenGLObjects::iterator iterator
mrpt::utils::TColorf getCustomBackgroundColor() const
A viewport within a COpenGLScene, containing a set of OpenGL objects to render.
void setCloneCamera(bool enable)
If set to true, and setCloneView() has been called, this viewport will be rendered using the camera o...
Each of the possible lights of a 3D scene.
const COpenGLViewport *const source_viewport
bool m_isClonedCamera
Set by setCloneCamera.
A class for storing a list of text lines.
This base provides a set of functions for maths stuff.
bool m_isImageView
Set by setImageView.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
TPoint3D up
Up vector of the camera.
virtual void do_nothing()
Just to allow this class to be polymorphic.
TLastProjectiveMatrixInfo m_lastProjMat
Info updated with each "render()" and used in "get3DRayForPixelCoord".
bool m_OpenGL_enablePolygonNicest
const_iterator begin() const
mrptEventGLPreRender(const COpenGLViewport *obj)
#define CLASS_ID_NAMESPACE(class_name, namespaceName)
Access to runtime class ID for a defined class name.
const CLight & getLight(const size_t i) const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
TLastProjectiveMatrixInfo()
An event sent by an mrpt::opengl::COpenGLViewport just after clearing the viewport and setting the GL...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
float elev
Camera elev & azimuth, in radians.
An event sent by an mrpt::opengl::COpenGLViewport after calling the scene OpenGL drawing primitives a...
TPoint3D pointing
The camera points to here.
void enablePolygonNicest(bool enable=true)
Sets glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST) is enabled, or GL_FASTEST otherwise.
size_t size() const
Number of objects contained.
CListOpenGLObjects::const_iterator const_iterator
The namespace for 3D scene representation and rendering.
This class allows the user to create, load, save, and render 3D scenes using OpenGL primitives...
void setTransparent(bool trans)
Set the transparency, that is, whether the viewport will be rendered transparent over previous viewpo...
A RGB color - floats in the range [0,1].
std::string m_clonedViewport
Only if m_isCloned=true.
void lightsClearAll()
Removes all lights (and disables the global "GL_LIGHTING")
std::string getName()
Returns the name of the viewport.
void addLight(const CLight &l)
Append a new light to the scene.
bool isPolygonNicestEnabled() const
void setCustomBackgroundColor(const mrpt::utils::TColorf &color)
Set a background color different from that of the parent GUI window.
A structure that holds runtime class type information.
const_iterator end() const
EIGEN_STRONG_INLINE void eye()
Make the matrix an identity matrix.
A camera: if added to a scene, the viewpoint defined by this camera will be used instead of the camer...
virtual void do_nothing()
Just to allow this class to be polymorphic.
Inherit from this class for those objects capable of being observed by a CObserver class...
bool isTransparent()
Return whether the viewport will be rendered transparent over previous viewports. ...
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
TPoint3D eye
The camera is here.
utils::safe_ptr< COpenGLScene > m_parent
The scene that contains this viewport.
opengl::CCamera m_camera
The camera associated to the viewport.
A wrapper class for pointers that can be safely copied with "=" operator without problems.
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)...
std::string m_name
The viewport's name.
bool m_isCloned
Set by setCloneView.
3D line, represented by a base point and a director vector.
void setNumberOfLights(const size_t N)
Allocates a number of lights, which must be correctly defined via getLight(i), etc.