class mrpt::opengl::CVectorField2D

Overview

A 2D vector field representation, consisting of points and arrows drawn on a plane (invisible grid).

mrpt::opengl::CVectorField2D mrpt::opengl::CVectorField2D mrpt::opengl::CVectorField2D mrpt::opengl::CVectorField2D

See also:

opengl::Scene

#include <mrpt/opengl/CVectorField2D.h>

class CVectorField2D:
    public mrpt::opengl::CRenderizableShaderPoints,
    public mrpt::opengl::CRenderizableShaderTriangles,
    public mrpt::opengl::CRenderizableShaderWireFrame
{
public:
    // construction

    CVectorField2D();

    CVectorField2D(
        mrpt::math::CMatrixFloat Matrix_x,
        mrpt::math::CMatrixFloat Matrix_y,
        float xmin = -1,
        float xmax = 1,
        float ymin = -1,
        float ymax = 1
        );

    // methods

    virtual void render(const RenderContext& rc) const;
    virtual void renderUpdateBuffers() const;
    virtual void freeOpenGLResources();
    virtual shader_list_t requiredShaders() const;
    virtual void onUpdateBuffers_Wireframe();
    virtual void onUpdateBuffers_Triangles();
    virtual void onUpdateBuffers_Points();
    const auto& shaderTrianglesBuffer() const;
    auto& shaderTrianglesBufferMutex() const;
    void clear();
    void setPointColor(const float R, const float G, const float B, const float A = 1);
    mrpt::img::TColorf getPointColor() const;
    void setVectorFieldColor(const float R, const float G, const float B, const float A = 1);
    mrpt::img::TColorf getVectorFieldColor() const;

    void setGridCenterAndCellSize(
        const float center_x,
        const float center_y,
        const float cellsize_x,
        const float cellsize_y
        );

    void setGridLimits(const float xmin, const float xmax, const float ymin, const float ymax);
    void getGridLimits(float& xmin, float& xmax, float& ymin, float& ymax) const;
    void getVectorField(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y) const;
    const mrpt::math::CMatrixFloat& getVectorField_x() const;
    mrpt::math::CMatrixFloat& getVectorField_x();
    const mrpt::math::CMatrixFloat& getVectorField_y() const;
    mrpt::math::CMatrixFloat& getVectorField_y();
    void setVectorField(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y);
    void adjustVectorFieldToGrid();
    void resize(size_t rows, size_t cols);
    size_t cols() const;
    size_t rows() const;
    virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const;
    void enableAntiAliasing(bool enable = true);
    bool isAntiAliasingEnabled() const;
    bool isLightEnabled() const;
    void enableLight(bool enable = true);
    TCullFace cullFaces() const;
};

Inherited Members

public:
    // structs

    struct OutdatedState;
    struct RenderContext;
    struct State;

    // methods

    virtual void render(const RenderContext& rc) const = 0;
    virtual void renderUpdateBuffers() const = 0;
    virtual shader_list_t requiredShaders() const;
    virtual void freeOpenGLResources() = 0;
    virtual void onUpdateBuffers_Points() = 0;
    virtual void onUpdateBuffers_Triangles() = 0;
    virtual void onUpdateBuffers_Wireframe() = 0;

Construction

CVectorField2D()

Constructor.

CVectorField2D(
    mrpt::math::CMatrixFloat Matrix_x,
    mrpt::math::CMatrixFloat Matrix_y,
    float xmin = -1,
    float xmax = 1,
    float ymin = -1,
    float ymax = 1
    )

Constructor with a initial set of lines.

Methods

virtual void render(const RenderContext& rc) const

Implements the rendering of 3D objects in each class derived from CRenderizable.

This can be called more than once (one per required shader program) if the object registered several shaders.

See also:

renderUpdateBuffers

virtual void renderUpdateBuffers() const

Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.

before they are sent for rendering in render()

virtual void freeOpenGLResources()

Free opengl buffers.

virtual shader_list_t requiredShaders() const

Returns the ID of the OpenGL shader program required to render this class.

See also:

DefaultShaderID

virtual void onUpdateBuffers_Wireframe()

Must be implemented in derived classes to update the geometric entities to be drawn in “m_*_buffer” fields.

virtual void onUpdateBuffers_Triangles()

Must be implemented in derived classes to update the geometric entities to be drawn in “m_*_buffer” fields.

virtual void onUpdateBuffers_Points()

Must be implemented in derived classes to update the geometric entities to be drawn in “m_*_buffer” fields.

void clear()

Clear the matrices.

void setPointColor(
    const float R,
    const float G,
    const float B,
    const float A = 1
    )

Set the point color in the range [0,1].

mrpt::img::TColorf getPointColor() const

Get the point color in the range [0,1].

void setVectorFieldColor(
    const float R,
    const float G,
    const float B,
    const float A = 1
    )

Set the arrow color in the range [0,1].

mrpt::img::TColorf getVectorFieldColor() const

Get the arrow color in the range [0,1].

void setGridCenterAndCellSize(
    const float center_x,
    const float center_y,
    const float cellsize_x,
    const float cellsize_y
    )

Set the coordinates of the grid on where the vector field will be drawn by setting its center and the cell size.

The number of cells is marked by the content of xcomp and ycomp.

See also:

xcomp, ycomp

void setGridLimits(
    const float xmin,
    const float xmax,
    const float ymin,
    const float ymax
    )

Set the coordinates of the grid on where the vector field will be drawn using x-y max and min values.

void getGridLimits(float& xmin, float& xmax, float& ymin, float& ymax) const

Get the coordinates of the grid on where the vector field is drawn using the max and min values.

void getVectorField(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y) const

Get the vector field.

Matrix_x stores the “x” component and Matrix_y stores the “y” component.

const mrpt::math::CMatrixFloat& getVectorField_x() const

Get the “x” component of the vector field, as a matrix where each entry represents a point in the 2D grid.

mrpt::math::CMatrixFloat& getVectorField_x()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

const mrpt::math::CMatrixFloat& getVectorField_y() const

Get the “y” component of the vector field, as a matrix where each entry represents a point in the 2D grid.

mrpt::math::CMatrixFloat& getVectorField_y()

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void setVectorField(mrpt::math::CMatrixFloat& Matrix_x, mrpt::math::CMatrixFloat& Matrix_y)

Set the vector field.

Matrix_x contains the “x” component and Matrix_y contains the “y” component.

void adjustVectorFieldToGrid()

Adjust the vector field in the scene (vectors magnitude) according to the grid size.

void resize(size_t rows, size_t cols)

Resizes the set.

size_t cols() const

Returns the total count of rows used to represent the vector field.

size_t rows() const

Returns the total count of columns used to represent the vector field.

virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const

Must be implemented by derived classes to provide the updated bounding box in the object local frame of coordinates.

This will be called only once after each time the derived class reports to notifyChange() that the object geometry changed.

See also:

getBoundingBox(), getBoundingBoxLocal(), getBoundingBoxLocalf()