class mrpt::gui::CGlCanvasBase

This base class implements a working with opengl::Camera and a OpenGL canvas, and it’s used in gui::CWxGLCanvasBase and gui::CQtGlCanvasBase.

#include <mrpt/gui/CGlCanvasBase.h>

class CGlCanvasBase
{
public:
    // structs

    struct CamaraParams;

    // construction

    CGlCanvasBase();

    //
methods

    void setMinimumZoom(float zoom);
    void setMaximumZoom(float zoom);
    void setMousePos(int x, int y);
    void setMouseClicked(bool is);
    void updateLastPos(int x, int y);
    void resizeViewport(int w, int h);
    void clearColors();
    void updateZoom(CamaraParams& params, int x, int y) const;
    void updateZoom(CamaraParams& params, float delta) const;
    void updateRotate(CamaraParams& params, int x, int y) const;
    void updateOrbitCamera(CamaraParams& params, int x, int y) const;
    void updatePan(CamaraParams& params, int x, int y) const;
    CamaraParams cameraParams() const;
    const CamaraParams& getRefCameraParams() const;
    virtual void setCameraParams(const CamaraParams& params);
    mrpt::opengl::CCamera& updateCameraParams(mrpt::opengl::CCamera& cam) const;
    void setUseCameraFromScene(bool is);
    bool getUseCameraFromScene() const;
    virtual void setCameraPointing(float pointX, float pointY, float pointZ);
    float getCameraPointingX() const;
    float getCameraPointingY() const;
    float getCameraPointingZ() const;
    virtual void setZoomDistance(float zoom);
    float getZoomDistance() const;
    virtual void setAzimuthDegrees(float ang);
    float getAzimuthDegrees() const;
    virtual void setElevationDegrees(float ang);
    float getElevationDegrees() const;
    void setClearColors(float r, float g, float b, float a = 1.0f);

    virtual void OnUserManuallyMovesCamera(
        float new_cameraPointingX,
        float new_cameraPointingY,
        float new_cameraPointingZ,
        float new_cameraZoomDistance,
        float new_cameraElevationDeg,
        float new_cameraAzimuthDeg
        );

    mrpt::opengl::COpenGLScene::Ptr& getOpenGLSceneRef();
};

// direct descendants

class CGlCanvasBaseHeadless;

Methods

void setMinimumZoom(float zoom)

Sets the minimum of the zoom See also setMaximumZoom(float)

void setMaximumZoom(float zoom)

Sets the maximum of the zoom See also setMinimumZoom(float)

void setMousePos(int x, int y)

Saves the click position of the mouse See also setMouseClicked(bool)

void setMouseClicked(bool is)

Sets the property mouseClicked By default, this property is false.

See also setMousePos(int, int)

void updateLastPos(int x, int y)

Sets the last mouse position.

void resizeViewport(int w, int h)

Calls the glViewport function.

void clearColors()

Calls the glClearColor function See also setClearColors(float, float, float, float)

void updateZoom(CamaraParams& params, int x, int y) const

This function for the mouse event It gets a reference to CamaraParams, x, y and updates the zoom of the CameraParams.

See also updateZoom(CamaraParams &, float)

void updateZoom(CamaraParams& params, float delta) const

This function for the wheel event It gets a reference to CamaraParams, delta and updates the zoom of the CameraParams.

See also updateZoom(CamaraParams &, int, int)

void updateRotate(CamaraParams& params, int x, int y) const

This function for the mouse event It gets a reference to CamaraParams, x, y and updates the elevation and azimuth.

See also getElevationDegrees(), getAzimuthDegrees()

void updateOrbitCamera(CamaraParams& params, int x, int y) const

This function for the mouse event It gets a reference to CamaraParams, x, y and updates the elevation and azimuth.

See also getElevationDegrees(), getAzimuthDegrees()

void updatePan(CamaraParams& params, int x, int y) const

This function for the mouse event It gets a reference to CamaraParams, x, y and updates the pointing of the camera.

See also getCameraPointingX(), getCameraPointingY(), getCameraPointingZ()

CamaraParams cameraParams() const

Returns a copy of CamaraParams See also getRefCameraParams(), setCameraParams(const CamaraParams &)

const CamaraParams& getRefCameraParams() const

Returns a reference to CamaraParams See also cameraParams(), setCameraParams(const CamaraParams &)

virtual void setCameraParams(const CamaraParams& params)

Sets the CamaraParams See also cameraParams(), getRefCameraParams()

mrpt::opengl::CCamera& updateCameraParams(mrpt::opengl::CCamera& cam) const

This function gets a reference to mrpt::opengl::CCamera and updates the camera parameters(pointing, zoom, azimuth, elevation, IsProjective, FOV)

void setUseCameraFromScene(bool is)

If set to true (default=false), the cameraPointingX,…

parameters are ignored and the camera stored in the 3D scene is used instead. See also void bool getUseCameraFromScene()

bool getUseCameraFromScene() const

See also void setUseCameraFromScene(bool)

virtual void setCameraPointing(float pointX, float pointY, float pointZ)

Saves the pointing of the camera See also getCameraPointingX(), getCameraPointingY(), getCameraPointingZ()

float getCameraPointingX() const

Returns the x pointing of the camera See also setCameraPointing(float, float, float)

float getCameraPointingY() const

Returns the y pointing of the camera See also setCameraPointing(float, float, float)

float getCameraPointingZ() const

Returns the z pointing of the camera See also setCameraPointing(float, float, float)

virtual void setZoomDistance(float zoom)

Saves camera zooming See also getZoomDistance()

float getZoomDistance() const

Returns a zoom See also setZoomDistance(float)

virtual void setAzimuthDegrees(float ang)

Saves the degrees of the azimuth camera See also getAzimuthDegrees()

float getAzimuthDegrees() const

Returns a azimuth degrees See also setAzimuthDegrees(float)

virtual void setElevationDegrees(float ang)

Saves the degrees of the elevation camera See also getElevationDegrees()

float getElevationDegrees() const

Returns a elevation degrees See also setElevationDegrees(float)

void setClearColors(float r, float g, float b, float a = 1.0f)

Sets the RGBA colors for glClearColor See also clearColors(), getClearColorR(), getClearColorG(), getClearColorB(), getClearColorA()

virtual void OnUserManuallyMovesCamera(
    float new_cameraPointingX,
    float new_cameraPointingY,
    float new_cameraPointingZ,
    float new_cameraZoomDistance,
    float new_cameraElevationDeg,
    float new_cameraAzimuthDeg
    )

Overload this method to limit the capabilities of the user to move the camera using the mouse.

For all these variables:

  • cameraPointingX

  • cameraPointingY

  • cameraPointingZ

  • cameraZoomDistance

  • cameraElevationDeg

  • cameraAzimuthDeg

A “new_NAME” variable will be passed with the temptative new value after the user action. The default behavior should be to copy all the new variables to the variables listed above but in the middle any find of user-defined filter can be implemented.

mrpt::opengl::COpenGLScene::Ptr& getOpenGLSceneRef()

At constructor an empty scene is created.

The object is freed at GL canvas destructor. This function returns a smart pointer to the opengl scene getOpenGLSceneRef