Class CTextMessageCapable

Nested Relationships

Nested Types

Inheritance Relationships

Derived Type

Class Documentation

class CTextMessageCapable

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

Subclassed by mrpt::viz::Viewport

Public Functions

void clearTextMessages()
void addTextMessage(double x_frac, double y_frac, const std::string &text, size_t unique_index = 0, const TFontParams &fontParams = TFontParams())

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().

You’ll need to refresh the display manually with forceRepaint().

See also

clearTextMessages, updateTextMessage

Parameters:
  • 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.

bool updateTextMessage(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.

inline const TListTextMessages &getTextMessages() const

Protected Attributes

TListTextMessages m_2D_texts
struct DataPerText : public mrpt::viz::T2DTextData

Public Members

mutable mrpt::viz::CText::Ptr gl_text
mrpt::viz::CText::Ptr gl_text_shadow
mutable bool gl_text_outdated = true
struct TListTextMessages

Public Functions

void regenerateGLobjects() const

(re)generate all CText objects in the gl_text fields

Public Members

mutable mrpt::containers::NonCopiableData<std::shared_mutex> mtx
std::map<uint32_t, DataPerText> messages