Main MRPT website > C++ reference
MRPT logo
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends

mrpt::gui::CDisplayWindowPlots Class Reference


Detailed Description

Create a GUI window and display plots with MATLAB-like interfaces and commands.

For a list of supported events with the observer/observable pattern, see the discussion in mrpt::gui::CBaseGUIWindow.

See CDisplayWindowPlots::plot

Definition at line 56 of file CDisplayWindowPlots.h.

#include <mrpt/gui/CDisplayWindowPlots.h>

Inheritance diagram for mrpt::gui::CDisplayWindowPlots:
Inheritance graph
[legend]

List of all members.

Public Types

typedef void(* TCallbackMenu )(int menuID, float cursor_x, float cursor_y, void *userParam)
 Type for the callback function used in setMenuCallback.

Public Member Functions

 CDisplayWindowPlots (const std::string &windowCaption=std::string(), unsigned int initialWidth=350, unsigned int initialHeight=300)
 Constructor.
virtual ~CDisplayWindowPlots ()
 Destructor.
virtual bool getLastMousePosition (int &x, int &y) const
 Gets the last x,y pixel coordinates of the mouse.
virtual void setCursorCross (bool cursorIsCross)
 Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true)
void resize (unsigned int width, unsigned int height)
 Resizes the window, stretching the image to fit into the display area.
void setPos (int x, int y)
 Changes the position of the window on the screen.
void setWindowTitle (const std::string &str)
 Changes the window title text.
void enableMousePanZoom (bool enabled)
 Enable/disable the feature of pan/zoom with the mouse (default=enabled)
template<typename T1 , typename T2 >
void plot (const std::vector< T1 > &x, const std::vector< T2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY"))
 Adds a new layer with a 2D plot based on two vectors of X and Y points, using a MATLAB-like syntax.
template<typename T1 , typename Derived2 >
void plot (const std::vector< T1 > &x, const Eigen::MatrixBase< Derived2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY"))
template<typename Derived1 , typename T2 >
void plot (const Eigen::MatrixBase< Derived1 > &x, const std::vector< T2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY"))
template<typename Derived1 , typename Derived2 >
void plot (const Eigen::MatrixBase< Derived1 > &x, const Eigen::MatrixBase< Derived2 > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY"))
template<typename T >
void plot (const std::vector< T > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY"))
template<typename Derived >
void plot (const Eigen::MatrixBase< Derived > &y, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotXY"))
void axis (float x_min, float x_max, float y_min, float y_max, bool aspectRatioFix=false)
 Set the view area according to the passed coordinated.
void axis_equal (bool enable=true)
 Enable/disable the fixed X/Y aspect ratio fix feature (default=disabled).
void axis_fit (bool aspectRatioFix=false)
 Fix automatically the view area according to existing graphs.
template<typename T >
void GUI_IMPEXP plotEllipse (const T mean_x, const T mean_y, const CMatrixTemplateNumeric< T > &cov22, const float quantiles, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotEllipse"), bool showName=false)
 Plots a 2D ellipse given its mean, covariance matrix, and Each call to this function creates a new plot, unless the plot name coincides with an already existing plot: in this case the new values are used to update this existing layer (this also applies to using the default plot name).
template<typename T >
void GUI_IMPEXP plotEllipse (const T mean_x, const T mean_y, const CMatrixFixedNumeric< T, 2, 2 > &cov22, const float quantiles, const std::string &lineFormat=std::string("b-"), const std::string &plotName=std::string("plotEllipse"), bool showName=false)
void image (const utils::CImage &img, const float &x_left, const float &y_bottom, const float &x_width, const float &y_height, const std::string &plotName=std::string("image"))
 Adds a bitmap image layer.
void clear ()
 Remove all plot objects in the display.
void clf ()
 Remove all plot objects in the display (clear and clf do exactly the same).
void hold_on ()
 Enables keeping all the graphs, instead of overwritting them.
void hold_off ()
 Disables keeping all the graphs (this is the default behavior).
void addPopupMenuEntry (const std::string &label, int menuID)
 Disables keeping all the graphs (this is the default behavior).
void setMenuCallback (TCallbackMenu userFunction, void *userParam=NULL)
 Must be called to have a callback when the user selects one of the user-defined entries in the popup menu.

Static Public Member Functions

static CDisplayWindowPlotsPtr Create (const std::string &windowCaption=std::string(), unsigned int initialWindowWidth=400, unsigned int initialWindowHeight=300)
 Class factory returning a smart pointer.

Protected Member Functions

void internal_plot (vector_float &x, vector_float &y, const std::string &lineFormat, const std::string &plotName)
template<typename VECTOR1 , typename VECTOR2 >
void internal_plot_interface (const VECTOR1 &x, const VECTOR2 &y, const std::string &lineFormat, const std::string &plotName)
template<typename VECTOR1 >
void internal_plot_interface (const VECTOR1 &y, const std::string &lineFormat, const std::string &plotName)

Protected Attributes

bool m_holdon
 Whether hold_on is enabled.
bool m_holdon_just_disabled
uint32_t m_holdon_cnt
 Counter for hold_on.
TCallbackMenu m_callback
void * m_callback_param

Friends

class CWindowDialogPlots

RTTI stuff

typedef CDisplayWindowPlotsPtr SmartPtr
static mrpt::utils::CLASSINIT _init_CDisplayWindowPlots
static mrpt::utils::TRuntimeClassId classCDisplayWindowPlots
static const
mrpt::utils::TRuntimeClassId
classinfo
static const
mrpt::utils::TRuntimeClassId
_GetBaseClass ()
virtual const
mrpt::utils::TRuntimeClassId
GetRuntimeClass () const
 Returns information about the class of an object in runtime.
virtual mrpt::utils::CObjectduplicate () const
 Returns a copy of the object, indepently of its class.
static mrpt::utils::CObjectCreateObject ()
static CDisplayWindowPlotsPtr Create ()

Member Typedef Documentation

A typedef for the associated smart pointer

Definition at line 59 of file CDisplayWindowPlots.h.

typedef void(* mrpt::gui::CDisplayWindowPlots::TCallbackMenu)(int menuID, float cursor_x, float cursor_y, void *userParam)

Type for the callback function used in setMenuCallback.

Definition at line 62 of file CDisplayWindowPlots.h.


Constructor & Destructor Documentation

mrpt::gui::CDisplayWindowPlots::CDisplayWindowPlots ( const std::string &  windowCaption = std::string(),
unsigned int  initialWidth = 350,
unsigned int  initialHeight = 300 
)

Constructor.

virtual mrpt::gui::CDisplayWindowPlots::~CDisplayWindowPlots ( ) [virtual]

Destructor.


Member Function Documentation

static const mrpt::utils::TRuntimeClassId* mrpt::gui::CDisplayWindowPlots::_GetBaseClass ( ) [static, protected]

Reimplemented from mrpt::gui::CBaseGUIWindow.

void mrpt::gui::CDisplayWindowPlots::addPopupMenuEntry ( const std::string &  label,
int  menuID 
)

Disables keeping all the graphs (this is the default behavior).

Parameters:
labelThe text that appears in the new popup menu item.
menuIDAny positive number (0,1,..). Used to tell which menu was selected in the user callback.
See also:
setMenuCallback
void mrpt::gui::CDisplayWindowPlots::axis ( float  x_min,
float  x_max,
float  y_min,
float  y_max,
bool  aspectRatioFix = false 
)

Set the view area according to the passed coordinated.

void mrpt::gui::CDisplayWindowPlots::axis_equal ( bool  enable = true)

Enable/disable the fixed X/Y aspect ratio fix feature (default=disabled).

void mrpt::gui::CDisplayWindowPlots::axis_fit ( bool  aspectRatioFix = false)

Fix automatically the view area according to existing graphs.

void mrpt::gui::CDisplayWindowPlots::clear ( )

Remove all plot objects in the display.

See also:
plot
void mrpt::gui::CDisplayWindowPlots::clf ( ) [inline]

Remove all plot objects in the display (clear and clf do exactly the same).

See also:
plot, hold_on, hold_off

Definition at line 241 of file CDisplayWindowPlots.h.

static CDisplayWindowPlotsPtr mrpt::gui::CDisplayWindowPlots::Create ( const std::string &  windowCaption = std::string(),
unsigned int  initialWindowWidth = 400,
unsigned int  initialWindowHeight = 300 
) [inline, static]

Class factory returning a smart pointer.

Definition at line 103 of file CDisplayWindowPlots.h.

References mrpt::gui::CDisplayWindowPlots.

static CDisplayWindowPlotsPtr mrpt::gui::CDisplayWindowPlots::Create ( ) [static]
static mrpt::utils::CObject* mrpt::gui::CDisplayWindowPlots::CreateObject ( ) [static]
virtual mrpt::utils::CObject* mrpt::gui::CDisplayWindowPlots::duplicate ( ) const [virtual]

Returns a copy of the object, indepently of its class.

Implements mrpt::utils::CObject.

void mrpt::gui::CDisplayWindowPlots::enableMousePanZoom ( bool  enabled)

Enable/disable the feature of pan/zoom with the mouse (default=enabled)

virtual bool mrpt::gui::CDisplayWindowPlots::getLastMousePosition ( int &  x,
int &  y 
) const [virtual]

Gets the last x,y pixel coordinates of the mouse.

Returns:
False if the window is closed.

Implements mrpt::gui::CBaseGUIWindow.

virtual const mrpt::utils::TRuntimeClassId* mrpt::gui::CDisplayWindowPlots::GetRuntimeClass ( ) const [virtual]

Returns information about the class of an object in runtime.

Reimplemented from mrpt::gui::CBaseGUIWindow.

void mrpt::gui::CDisplayWindowPlots::hold_off ( )

Disables keeping all the graphs (this is the default behavior).

See also:
hold_on, plot
void mrpt::gui::CDisplayWindowPlots::hold_on ( )

Enables keeping all the graphs, instead of overwritting them.

See also:
hold_off, plot
void mrpt::gui::CDisplayWindowPlots::image ( const utils::CImage img,
const float &  x_left,
const float &  y_bottom,
const float &  x_width,
const float &  y_height,
const std::string &  plotName = std::string("image") 
)

Adds a bitmap image layer.

Each call to this function creates a new layer, unless the plot name coincides with an already existing plot: in this case the new values are used to update this existing layer (this also applies to using the default plot name).

See also:
axis, axis_equal, axis_fit, hold_on, hold_off
void mrpt::gui::CDisplayWindowPlots::internal_plot ( vector_float x,
vector_float y,
const std::string &  lineFormat,
const std::string &  plotName 
) [protected]
template<typename VECTOR1 >
void mrpt::gui::CDisplayWindowPlots::internal_plot_interface ( const VECTOR1 &  y,
const std::string &  lineFormat,
const std::string &  plotName 
) [inline, protected]

Definition at line 85 of file CDisplayWindowPlots.h.

template<typename VECTOR1 , typename VECTOR2 >
void mrpt::gui::CDisplayWindowPlots::internal_plot_interface ( const VECTOR1 &  x,
const VECTOR2 &  y,
const std::string &  lineFormat,
const std::string &  plotName 
) [inline, protected]

Definition at line 75 of file CDisplayWindowPlots.h.

template<typename Derived1 , typename Derived2 >
void mrpt::gui::CDisplayWindowPlots::plot ( const Eigen::MatrixBase< Derived1 > &  x,
const Eigen::MatrixBase< Derived2 > &  y,
const std::string &  lineFormat = std::string("b-"),
const std::string &  plotName = std::string("plotXY") 
) [inline]

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

Definition at line 169 of file CDisplayWindowPlots.h.

template<typename T1 , typename T2 >
void mrpt::gui::CDisplayWindowPlots::plot ( const std::vector< T1 > &  x,
const std::vector< T2 > &  y,
const std::string &  lineFormat = std::string("b-"),
const std::string &  plotName = std::string("plotXY") 
) [inline]

Adds a new layer with a 2D plot based on two vectors of X and Y points, using a MATLAB-like syntax.

Each call to this function creates a new plot, unless the plot name coincides with an already existing plot: in this case the X & Y points are used to update this existing layer (this also applies to using the default plot name). If "hold_on" is enabled, then every call will always create a new plot, even if no "plotName" is provided.

The lineFormat string is a combination of the following characters:

  • Line styles:
    • '.': One point for each data point
    • '-': A continuous line
    • ':': A dashed line
  • Colors:
    • k: black
    • r: red
    • g: green
    • b: blue
    • m: magenta
    • c: cyan
  • Line width:
    • '1' to '9': The line width (default=1)

Examples:

  • 'r.' -> red points.
  • 'k3' or 'k-3' -> A black line with a line width of 3 pixels.
    Note:
    The vectors x & y can be of types: float or double.
    See also:
    axis, axis_equal, axis_fit, clear, hold_on, hold_off
    Template Parameters:
    VECTORCan be std::vector<float/double> or mrpt::dynamicsize_vector<float/double> or a column/row Eigen::Matrix<>

Definition at line 163 of file CDisplayWindowPlots.h.

template<typename Derived1 , typename T2 >
void mrpt::gui::CDisplayWindowPlots::plot ( const Eigen::MatrixBase< Derived1 > &  x,
const std::vector< T2 > &  y,
const std::string &  lineFormat = std::string("b-"),
const std::string &  plotName = std::string("plotXY") 
) [inline]

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

Definition at line 167 of file CDisplayWindowPlots.h.

template<typename T >
void mrpt::gui::CDisplayWindowPlots::plot ( const std::vector< T > &  y,
const std::string &  lineFormat = std::string("b-"),
const std::string &  plotName = std::string("plotXY") 
) [inline]

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

Definition at line 172 of file CDisplayWindowPlots.h.

template<typename Derived >
void mrpt::gui::CDisplayWindowPlots::plot ( const Eigen::MatrixBase< Derived > &  y,
const std::string &  lineFormat = std::string("b-"),
const std::string &  plotName = std::string("plotXY") 
) [inline]

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

Definition at line 174 of file CDisplayWindowPlots.h.

template<typename T1 , typename Derived2 >
void mrpt::gui::CDisplayWindowPlots::plot ( const std::vector< T1 > &  x,
const Eigen::MatrixBase< Derived2 > &  y,
const std::string &  lineFormat = std::string("b-"),
const std::string &  plotName = std::string("plotXY") 
) [inline]

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

Definition at line 165 of file CDisplayWindowPlots.h.

template<typename T >
void GUI_IMPEXP mrpt::gui::CDisplayWindowPlots::plotEllipse ( const T  mean_x,
const T  mean_y,
const CMatrixFixedNumeric< T, 2, 2 > &  cov22,
const float  quantiles,
const std::string &  lineFormat = std::string("b-"),
const std::string &  plotName = std::string("plotEllipse"),
bool  showName = false 
)

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

template<typename T >
void GUI_IMPEXP mrpt::gui::CDisplayWindowPlots::plotEllipse ( const T  mean_x,
const T  mean_y,
const CMatrixTemplateNumeric< T > &  cov22,
const float  quantiles,
const std::string &  lineFormat = std::string("b-"),
const std::string &  plotName = std::string("plotEllipse"),
bool  showName = false 
)

Plots a 2D ellipse given its mean, covariance matrix, and Each call to this function creates a new plot, unless the plot name coincides with an already existing plot: in this case the new values are used to update this existing layer (this also applies to using the default plot name).

If "hold_on" is enabled, then every call will always create a new plot, even if no "plotName" is provided.

For a description of lineFormat see CDisplayWindowPlots::plot. The "quantiles" value determines the confidence interval for the ellipse:

  • 1 : 68.27% confidence interval
  • 2 : 95.45%
  • 3 : 99.73%
  • 4 : 99.994%
    Note:
    This method can be called with 2x2 fixed-sized or dynamic-size matrices of types: float or double.
    See also:
    axis, axis_equal, axis_fit, hold_on, hold_off
void mrpt::gui::CDisplayWindowPlots::resize ( unsigned int  width,
unsigned int  height 
) [virtual]

Resizes the window, stretching the image to fit into the display area.

Implements mrpt::gui::CBaseGUIWindow.

virtual void mrpt::gui::CDisplayWindowPlots::setCursorCross ( bool  cursorIsCross) [virtual]

Set cursor style to default (cursorIsCross=false) or to a cross (cursorIsCross=true)

Implements mrpt::gui::CBaseGUIWindow.

void mrpt::gui::CDisplayWindowPlots::setMenuCallback ( TCallbackMenu  userFunction,
void *  userParam = NULL 
)

Must be called to have a callback when the user selects one of the user-defined entries in the popup menu.

See also:
addPopupMenuEntry
void mrpt::gui::CDisplayWindowPlots::setPos ( int  x,
int  y 
) [virtual]

Changes the position of the window on the screen.

Implements mrpt::gui::CBaseGUIWindow.

void mrpt::gui::CDisplayWindowPlots::setWindowTitle ( const std::string &  str) [virtual]

Changes the window title text.

Implements mrpt::gui::CBaseGUIWindow.


Friends And Related Function Documentation

friend class CWindowDialogPlots [friend]

Reimplemented from mrpt::gui::CBaseGUIWindow.

Definition at line 65 of file CDisplayWindowPlots.h.


Member Data Documentation

Definition at line 59 of file CDisplayWindowPlots.h.

Definition at line 59 of file CDisplayWindowPlots.h.

Definition at line 59 of file CDisplayWindowPlots.h.

Definition at line 70 of file CDisplayWindowPlots.h.

Definition at line 71 of file CDisplayWindowPlots.h.

Whether hold_on is enabled.

Definition at line 67 of file CDisplayWindowPlots.h.

Counter for hold_on.

Definition at line 69 of file CDisplayWindowPlots.h.

Definition at line 68 of file CDisplayWindowPlots.h.




Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011