Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes
mrpt::gui::CGlCanvasBase Class Referenceabstract

Detailed Description

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

Definition at line 28 of file CGlCanvasBase.h.

#include <mrpt/gui/CGlCanvasBase.h>

Classes

struct  CamaraParams
 

Public Member Functions

 CGlCanvasBase ()
 
virtual ~CGlCanvasBase ()
 
void setMinimumZoom (float zoom)
 Sets the minimum of the zoom See also setMaximumZoom(float) More...
 
void setMaximumZoom (float zoom)
 Sets the maximum of the zoom See also setMinimumZoom(float) More...
 
void setMousePos (int x, int y)
 Saves the click position of the mouse See also setMouseClicked(bool) More...
 
void setMouseClicked (bool is)
 Sets the property mouseClicked By default, this property is false. More...
 
void updateLastPos (int x, int y)
 Sets the last mouse position. More...
 
void resizeViewport (int w, int h)
 Calls the glViewport function. More...
 
void clearColors ()
 Calls the glClearColor function See also setClearColors(float, float, float, float) More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
CamaraParams cameraParams () const
 Returns a copy of CamaraParams See also getRefCameraParams(), setCameraParams(const CamaraParams &) More...
 
const CamaraParamsgetRefCameraParams () const
 Returns a reference to CamaraParams See also cameraParams(), setCameraParams(const CamaraParams &) More...
 
virtual void setCameraParams (const CamaraParams &params)
 Sets the CamaraParams See also cameraParams(), getRefCameraParams() More...
 
mrpt::opengl::CCameraupdateCameraParams (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) More...
 
void setUseCameraFromScene (bool is)
 If set to true (default=false), the cameraPointingX,... More...
 
bool getUseCameraFromScene () const
 See also void setUseCameraFromScene(bool) More...
 
virtual void setCameraPointing (float pointX, float pointY, float pointZ)
 Saves the pointing of the camera See also getCameraPointingX(), getCameraPointingY(), getCameraPointingZ() More...
 
float getCameraPointingX () const
 Returns the x pointing of the camera See also setCameraPointing(float, float, float) More...
 
float getCameraPointingY () const
 Returns the y pointing of the camera See also setCameraPointing(float, float, float) More...
 
float getCameraPointingZ () const
 Returns the z pointing of the camera See also setCameraPointing(float, float, float) More...
 
virtual void setZoomDistance (float zoom)
 Saves camera zooming See also getZoomDistance() More...
 
float getZoomDistance () const
 Returns a zoom See also setZoomDistance(float) More...
 
virtual void setAzimuthDegrees (float ang)
 Saves the degrees of the azimuth camera See also getAzimuthDegrees() More...
 
float getAzimuthDegrees () const
 Returns a azimuth degrees See also setAzimuthDegrees(float) More...
 
virtual void setElevationDegrees (float ang)
 Saves the degrees of the elevation camera See also getElevationDegrees() More...
 
float getElevationDegrees () const
 Returns a elevation degrees See also setElevationDegrees(float) More...
 
virtual void setCameraProjective (bool is)
 
bool isCameraProjective () const
 
virtual void setCameraFOV (float FOV)
 
float cameraFOV () const
 
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() More...
 
float getClearColorR () const
 
float getClearColorG () const
 
float getClearColorB () const
 
float getClearColorA () const
 
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. More...
 
void getLastMousePosition (int &x, int &y) const
 
mrpt::opengl::COpenGLScene::PtrgetOpenGLSceneRef ()
 At constructor an empty scene is created. More...
 
void setOpenGLSceneRef (mrpt::opengl::COpenGLScene::Ptr scene)
 

Static Public Attributes

static float SENSIBILITY_DEG_PER_PIXEL = 0.1f
 

Protected Member Functions

virtual void swapBuffers ()=0
 
virtual void preRender ()=0
 
virtual void postRender ()=0
 
virtual void renderError (const std::string &err_msg)=0
 
virtual double renderCanvas (int width=-1, int height=-1)
 

Private Attributes

float clearColorR = .4f
 
float clearColorG = .4f
 
float clearColorB = .4f
 
float clearColorA = 1.f
 
bool useCameraFromScene = false
 
mrpt::opengl::COpenGLScene::Ptr m_openGLScene
 
int m_mouseLastX = 0
 
int m_mouseLastY = 0
 
int m_mouseClickX = 0
 
int m_mouseClickY = 0
 
bool mouseClicked = false
 
float m_minZoom = 1.f
 
float m_maxZoom = 3200.f
 
CamaraParams m_cameraParams
 

Constructor & Destructor Documentation

◆ CGlCanvasBase()

mrpt::gui::CGlCanvasBase::CGlCanvasBase ( )
inline

Definition at line 44 of file CGlCanvasBase.h.

◆ ~CGlCanvasBase()

virtual mrpt::gui::CGlCanvasBase::~CGlCanvasBase ( )
inlinevirtual

Definition at line 45 of file CGlCanvasBase.h.

Member Function Documentation

◆ cameraFOV()

float mrpt::gui::CGlCanvasBase::cameraFOV ( ) const

◆ cameraParams()

CamaraParams mrpt::gui::CGlCanvasBase::cameraParams ( ) const

◆ clearColors()

void mrpt::gui::CGlCanvasBase::clearColors ( )

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

◆ getAzimuthDegrees()

float mrpt::gui::CGlCanvasBase::getAzimuthDegrees ( ) const

Returns a azimuth degrees See also setAzimuthDegrees(float)

◆ getCameraPointingX()

float mrpt::gui::CGlCanvasBase::getCameraPointingX ( ) const

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

◆ getCameraPointingY()

float mrpt::gui::CGlCanvasBase::getCameraPointingY ( ) const

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

◆ getCameraPointingZ()

float mrpt::gui::CGlCanvasBase::getCameraPointingZ ( ) const

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

◆ getClearColorA()

float mrpt::gui::CGlCanvasBase::getClearColorA ( ) const

◆ getClearColorB()

float mrpt::gui::CGlCanvasBase::getClearColorB ( ) const

◆ getClearColorG()

float mrpt::gui::CGlCanvasBase::getClearColorG ( ) const

◆ getClearColorR()

float mrpt::gui::CGlCanvasBase::getClearColorR ( ) const

◆ getElevationDegrees()

float mrpt::gui::CGlCanvasBase::getElevationDegrees ( ) const

Returns a elevation degrees See also setElevationDegrees(float)

◆ getLastMousePosition()

void mrpt::gui::CGlCanvasBase::getLastMousePosition ( int &  x,
int &  y 
) const
inline

Definition at line 223 of file CGlCanvasBase.h.

References m_mouseLastX, and m_mouseLastY.

◆ getOpenGLSceneRef()

mrpt::opengl::COpenGLScene::Ptr& mrpt::gui::CGlCanvasBase::getOpenGLSceneRef ( )
inline

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

Definition at line 233 of file CGlCanvasBase.h.

References m_openGLScene.

◆ getRefCameraParams()

const CamaraParams& mrpt::gui::CGlCanvasBase::getRefCameraParams ( ) const

◆ getUseCameraFromScene()

bool mrpt::gui::CGlCanvasBase::getUseCameraFromScene ( ) const

◆ getZoomDistance()

float mrpt::gui::CGlCanvasBase::getZoomDistance ( ) const

Returns a zoom See also setZoomDistance(float)

◆ isCameraProjective()

bool mrpt::gui::CGlCanvasBase::isCameraProjective ( ) const

◆ OnUserManuallyMovesCamera()

virtual void mrpt::gui::CGlCanvasBase::OnUserManuallyMovesCamera ( float  new_cameraPointingX,
float  new_cameraPointingY,
float  new_cameraPointingZ,
float  new_cameraZoomDistance,
float  new_cameraElevationDeg,
float  new_cameraAzimuthDeg 
)
inlinevirtual

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.

Definition at line 210 of file CGlCanvasBase.h.

References mrpt::gui::CGlCanvasBase::CamaraParams::cameraAzimuthDeg, mrpt::gui::CGlCanvasBase::CamaraParams::cameraElevationDeg, mrpt::gui::CGlCanvasBase::CamaraParams::cameraPointingX, mrpt::gui::CGlCanvasBase::CamaraParams::cameraPointingY, mrpt::gui::CGlCanvasBase::CamaraParams::cameraPointingZ, mrpt::gui::CGlCanvasBase::CamaraParams::cameraZoomDistance, and m_cameraParams.

◆ postRender()

virtual void mrpt::gui::CGlCanvasBase::postRender ( )
protectedpure virtual

◆ preRender()

virtual void mrpt::gui::CGlCanvasBase::preRender ( )
protectedpure virtual

◆ renderCanvas()

virtual double mrpt::gui::CGlCanvasBase::renderCanvas ( int  width = -1,
int  height = -1 
)
protectedvirtual

◆ renderError()

virtual void mrpt::gui::CGlCanvasBase::renderError ( const std::string err_msg)
protectedpure virtual

◆ resizeViewport()

void mrpt::gui::CGlCanvasBase::resizeViewport ( int  w,
int  h 
)

Calls the glViewport function.

◆ setAzimuthDegrees()

virtual void mrpt::gui::CGlCanvasBase::setAzimuthDegrees ( float  ang)
virtual

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

◆ setCameraFOV()

virtual void mrpt::gui::CGlCanvasBase::setCameraFOV ( float  FOV)
virtual

◆ setCameraParams()

virtual void mrpt::gui::CGlCanvasBase::setCameraParams ( const CamaraParams params)
virtual

◆ setCameraPointing()

virtual void mrpt::gui::CGlCanvasBase::setCameraPointing ( float  pointX,
float  pointY,
float  pointZ 
)
virtual

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

◆ setCameraProjective()

virtual void mrpt::gui::CGlCanvasBase::setCameraProjective ( bool  is)
virtual

◆ setClearColors()

void mrpt::gui::CGlCanvasBase::setClearColors ( float  r,
float  g,
float  b,
float  a = 1.0f 
)

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

◆ setElevationDegrees()

virtual void mrpt::gui::CGlCanvasBase::setElevationDegrees ( float  ang)
virtual

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

◆ setMaximumZoom()

void mrpt::gui::CGlCanvasBase::setMaximumZoom ( float  zoom)

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

◆ setMinimumZoom()

void mrpt::gui::CGlCanvasBase::setMinimumZoom ( float  zoom)

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

◆ setMouseClicked()

void mrpt::gui::CGlCanvasBase::setMouseClicked ( bool  is)

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

See also setMousePos(int, int)

◆ setMousePos()

void mrpt::gui::CGlCanvasBase::setMousePos ( int  x,
int  y 
)

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

◆ setOpenGLSceneRef()

void mrpt::gui::CGlCanvasBase::setOpenGLSceneRef ( mrpt::opengl::COpenGLScene::Ptr  scene)

◆ setUseCameraFromScene()

void mrpt::gui::CGlCanvasBase::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()

◆ setZoomDistance()

virtual void mrpt::gui::CGlCanvasBase::setZoomDistance ( float  zoom)
virtual

Saves camera zooming See also getZoomDistance()

◆ swapBuffers()

virtual void mrpt::gui::CGlCanvasBase::swapBuffers ( )
protectedpure virtual

◆ updateCameraParams()

mrpt::opengl::CCamera& mrpt::gui::CGlCanvasBase::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)

◆ updateLastPos()

void mrpt::gui::CGlCanvasBase::updateLastPos ( int  x,
int  y 
)

Sets the last mouse position.

◆ updateOrbitCamera()

void mrpt::gui::CGlCanvasBase::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()

◆ updatePan()

void mrpt::gui::CGlCanvasBase::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()

◆ updateRotate()

void mrpt::gui::CGlCanvasBase::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()

◆ updateZoom() [1/2]

void mrpt::gui::CGlCanvasBase::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)

◆ updateZoom() [2/2]

void mrpt::gui::CGlCanvasBase::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)

Member Data Documentation

◆ clearColorA

float mrpt::gui::CGlCanvasBase::clearColorA = 1.f
private

Definition at line 249 of file CGlCanvasBase.h.

◆ clearColorB

float mrpt::gui::CGlCanvasBase::clearColorB = .4f
private

Definition at line 248 of file CGlCanvasBase.h.

◆ clearColorG

float mrpt::gui::CGlCanvasBase::clearColorG = .4f
private

Definition at line 248 of file CGlCanvasBase.h.

◆ clearColorR

float mrpt::gui::CGlCanvasBase::clearColorR = .4f
private

Definition at line 248 of file CGlCanvasBase.h.

◆ m_cameraParams

CamaraParams mrpt::gui::CGlCanvasBase::m_cameraParams
private

Definition at line 258 of file CGlCanvasBase.h.

Referenced by OnUserManuallyMovesCamera().

◆ m_maxZoom

float mrpt::gui::CGlCanvasBase::m_maxZoom = 3200.f
private

Definition at line 257 of file CGlCanvasBase.h.

◆ m_minZoom

float mrpt::gui::CGlCanvasBase::m_minZoom = 1.f
private

Definition at line 256 of file CGlCanvasBase.h.

◆ m_mouseClickX

int mrpt::gui::CGlCanvasBase::m_mouseClickX = 0
private

Definition at line 254 of file CGlCanvasBase.h.

◆ m_mouseClickY

int mrpt::gui::CGlCanvasBase::m_mouseClickY = 0
private

Definition at line 254 of file CGlCanvasBase.h.

◆ m_mouseLastX

int mrpt::gui::CGlCanvasBase::m_mouseLastX = 0
private

Definition at line 253 of file CGlCanvasBase.h.

Referenced by getLastMousePosition().

◆ m_mouseLastY

int mrpt::gui::CGlCanvasBase::m_mouseLastY = 0
private

Definition at line 253 of file CGlCanvasBase.h.

Referenced by getLastMousePosition().

◆ m_openGLScene

mrpt::opengl::COpenGLScene::Ptr mrpt::gui::CGlCanvasBase::m_openGLScene
private
Initial value:
=
mrpt::make_aligned_shared<mrpt::opengl::COpenGLScene>()

Definition at line 251 of file CGlCanvasBase.h.

Referenced by getOpenGLSceneRef().

◆ mouseClicked

bool mrpt::gui::CGlCanvasBase::mouseClicked = false
private

Definition at line 255 of file CGlCanvasBase.h.

◆ SENSIBILITY_DEG_PER_PIXEL

float CGlCanvasBase::SENSIBILITY_DEG_PER_PIXEL = 0.1f
static

Definition at line 191 of file CGlCanvasBase.h.

◆ useCameraFromScene

bool mrpt::gui::CGlCanvasBase::useCameraFromScene = false
private

Definition at line 250 of file CGlCanvasBase.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019