MRPT  1.9.9
mrpt::opengl::CTextMessageCapable Class Reference

Detailed Description

Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes.

Definition at line 21 of file CTextMessageCapable.h.

#include <mrpt/opengl/CTextMessageCapable.h>

Inheritance diagram for mrpt::opengl::CTextMessageCapable:

Public Member Functions

void clearTextMessages ()
 
void addTextMessage (const double x_frac, const double y_frac, const std::string &text, const mrpt::img::TColorf &color=mrpt::img::TColorf(1.0, 1.0, 1.0), const size_t unique_index=0, const mrpt::opengl::TOpenGLFont font=mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_24)
 Add 2D text messages overlapped to the 3D rendered scene. More...
 
void addTextMessage (const double x_frac, const double y_frac, const std::string &text, const mrpt::img::TColorf &color, const std::string &font_name, const double font_size, const mrpt::opengl::TOpenGLFontStyle font_style=mrpt::opengl::NICE, const size_t unique_index=0, const double font_spacing=1.5, const double font_kerning=0.1, const bool has_shadow=false, const mrpt::img::TColorf &shadow_color=mrpt::img::TColorf(0, 0, 0))
 overload with more font parameters - refer to mrpt::opengl::gl_utils::glDrawText() More...
 
bool updateTextMessage (const size_t unique_index, const std::string &text)
 Just updates the text of a given text message, without touching the other parameters. More...
 

Protected Member Functions

void render_text_messages (const int w, const int h) const
 Renders the messages to the current opengl rendering context (to be called OUT of MRPT mrpt::opengl render() methods ). More...
 

Protected Attributes

std::map< size_t, mrpt::opengl::T2DTextDatam_2D_texts
 

Member Function Documentation

◆ addTextMessage() [1/2]

void CTextMessageCapable::addTextMessage ( const double  x_frac,
const double  y_frac,
const std::string text,
const mrpt::img::TColorf color = mrpt::img::TColorf(1.0, 1.0, 1.0),
const size_t  unique_index = 0,
const mrpt::opengl::TOpenGLFont  font = mrpt::opengl::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().

Parameters
xThe X position, interpreted as absolute pixels from the left if X>=1, absolute pixels from the left if X<0 or as a width factor if in the range [0,1[.
yThe Y position, interpreted as absolute pixels from the bottom if Y>=1, absolute pixels from the top if Y<0 or as a height factor if in the range [0,1[.
textThe text string to display.
colorThe text color. For example: TColorf(1.0,1.0,1.0)
unique_indexAn "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().

See also
clearTextMessages

Definition at line 150 of file CTextMessageCapable.cpp.

References mrpt::opengl::TFontParams::color, mrpt::opengl::TFontParams::font, mrpt::opengl::T2DTextData::text, mrpt::opengl::T2DTextData::x, and mrpt::opengl::T2DTextData::y.

◆ addTextMessage() [2/2]

void CTextMessageCapable::addTextMessage ( const double  x_frac,
const double  y_frac,
const std::string text,
const mrpt::img::TColorf color,
const std::string font_name,
const double  font_size,
const mrpt::opengl::TOpenGLFontStyle  font_style = mrpt::opengl::NICE,
const size_t  unique_index = 0,
const double  font_spacing = 1.5,
const double  font_kerning = 0.1,
const bool  has_shadow = false,
const mrpt::img::TColorf shadow_color = mrpt::img::TColorf(0, 0, 0) 
)

◆ clearTextMessages()

void CTextMessageCapable::clearTextMessages ( )

Definition at line 149 of file CTextMessageCapable.cpp.

◆ render_text_messages()

void CTextMessageCapable::render_text_messages ( const int  w,
const int  h 
) const
protected

Renders the messages to the current opengl rendering context (to be called OUT of MRPT mrpt::opengl render() methods ).

(w,h) are the dimensions of the rendering area in pixels.

Definition at line 25 of file CTextMessageCapable.cpp.

References mrpt::opengl::FILL, GL_DEPTH_TEST, GL_MATRIX_MODE, GL_MODELVIEW, GL_PROJECTION, glColor3f(), glDisable(), mrpt::opengl::gl_utils::glDrawText(), glEnable(), glGetIntegerv(), glLoadIdentity(), glMatrixMode(), glOrtho(), glPopMatrix(), glPushMatrix(), mrpt::opengl::gl_utils::glSetFont(), glTranslatef(), mrpt::opengl::MRPT_GLUT_BITMAP_HELVETICA_10, mrpt::opengl::MRPT_GLUT_BITMAP_HELVETICA_12, mrpt::opengl::MRPT_GLUT_BITMAP_HELVETICA_18, mrpt::opengl::MRPT_GLUT_BITMAP_NONE, mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_10, mrpt::opengl::MRPT_GLUT_BITMAP_TIMES_ROMAN_24, and MRPT_UNUSED_PARAM.

Referenced by mrpt::opengl::CFBORender::getFrame2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateTextMessage()

bool CTextMessageCapable::updateTextMessage ( const size_t  unique_index,
const std::string text 
)

Just updates the text of a given text message, without touching the other parameters.

Returns
false if given ID doesn't exist.

Definition at line 169 of file CTextMessageCapable.cpp.

References mrpt::opengl::T2DTextData::text.

Member Data Documentation

◆ m_2D_texts

std::map<size_t, mrpt::opengl::T2DTextData> mrpt::opengl::CTextMessageCapable::m_2D_texts
protected

Definition at line 24 of file CTextMessageCapable.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: a429c6f2f Mon Aug 19 15:45:44 2019 +0200 at lun ago 19 15:50:16 CEST 2019