MRPT
1.9.9
|
Keeps a list of text messages which can be rendered to OpenGL contexts by graphic classes.
Definition at line 22 of file CTextMessageCapable.h.
#include <mrpt/opengl/CTextMessageCapable.h>
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::T2DTextData > | m_2D_texts |
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().
x | The 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[. |
y | The 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[. |
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().
Definition at line 146 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.
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) |
||
) |
overload with more font parameters - refer to mrpt::opengl::gl_utils::glDrawText()
Definition at line 181 of file CTextMessageCapable.cpp.
References mrpt::opengl::TFontParams::color, mrpt::opengl::TFontParams::draw_shadow, mrpt::opengl::TFontParams::font, mrpt::opengl::MRPT_GLUT_BITMAP_NONE, mrpt::opengl::TFontParams::shadow_color, mrpt::opengl::T2DTextData::text, mrpt::opengl::TFontParams::vfont_kerning, mrpt::opengl::TFontParams::vfont_name, mrpt::opengl::TFontParams::vfont_scale, mrpt::opengl::TFontParams::vfont_spacing, mrpt::opengl::TFontParams::vfont_style, mrpt::opengl::T2DTextData::x, and mrpt::opengl::T2DTextData::y.
void CTextMessageCapable::clearTextMessages | ( | ) |
Definition at line 145 of file CTextMessageCapable.cpp.
|
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().
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.
Definition at line 165 of file CTextMessageCapable.cpp.
|
protected |
Definition at line 25 of file CTextMessageCapable.h.
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020 |