class mrpt::opengl::CTextMessageCapable

Overview

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

#include <mrpt/opengl/CTextMessageCapable.h>

class CTextMessageCapable
{
public:
    // structs

    struct DataPerText;
    struct TListTextMessages;

    // methods

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

    bool updateTextMessage(size_t unique_index, const std::string& text);
};

// direct descendants

class Viewport;

Methods

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

Add 2D text messages overlapped to the 3D rendered scene.

overload with more font parameters - refer to mrpt::opengl::gl_utils::glDrawText()

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

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.

See also:

clearTextMessages, updateTextMessage

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.