Main MRPT website > C++ reference for MRPT 1.5.7
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
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 24 of file CTextMessageCapable.h.

#include <mrpt/opengl/CTextMessageCapable.h>

Inheritance diagram for mrpt::opengl::CTextMessageCapable:
Inheritance graph

Public Member Functions

void clearTextMessages ()
 
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 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::utils::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::utils::TColorf &shadow_color=mrpt::utils::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::utils::TColorf color = mrpt::utils::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 120 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::utils::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::utils::TColorf shadow_color = mrpt::utils::TColorf(0,0,0) 
)

◆ clearTextMessages()

void CTextMessageCapable::clearTextMessages ( )

Definition at line 114 of file CTextMessageCapable.cpp.

◆ render_text_messages()

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

◆ 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 142 of file CTextMessageCapable.cpp.

Member Data Documentation

◆ m_2D_texts

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

Definition at line 27 of file CTextMessageCapable.h.




Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019