pcl::visualization::PCLPlotter Class Reference
[Module visualization]

PCL Plotter main class. More...

#include <pcl/visualization/pcl_plotter.h>

List of all members.

Classes

struct  ExitCallback
struct  ExitMainLoopTimerCallback

Public Types

typedef std::vector< double > PolynomialFunction
 A representation of polynomial function.
typedef std::pair
< PolynomialFunction,
PolynomialFunction
RationalFunction
 A representation of rational function, defined as the ratio of two polynomial functions.

Public Member Functions

 PCLPlotter (char const *name="PCL Plotter")
 PCL Plotter constructor.
 ~PCLPlotter ()
 Destructor.
void addPlotData (double const *array_X, double const *array_Y, unsigned long size, char const *name="Y Axis", int type=vtkChart::LINE, char const *color=NULL)
 Adds a plot with correspondences in the arrays arrayX and arrayY.
void addPlotData (std::vector< double > const &array_X, std::vector< double >const &array_Y, char const *name="Y Axis", int type=vtkChart::LINE, std::vector< char > const &color=std::vector< char >())
 Adds a plot with correspondences in vectors arrayX and arrayY.
void addPlotData (std::vector< std::pair< double, double > > const &plot_data, char const *name="Y Axis", int type=vtkChart::LINE, std::vector< char > const &color=std::vector< char >())
 Adds a plot with correspondences in vector of pairs.
void addPlotData (PolynomialFunction const &p_function, double x_min, double x_max, char const *name="Y Axis", int num_points=100, int type=vtkChart::LINE, std::vector< char > const &color=std::vector< char >())
 Adds a plot based on the given polynomial function and the range in X axis.
void addPlotData (RationalFunction const &r_function, double x_min, double x_max, char const *name="Y Axis", int num_points=100, int type=vtkChart::LINE, std::vector< char > const &color=std::vector< char >())
 Adds a plot based on the given rational function and the range in X axis.
void addPlotData (double(*function)(double), double x_min, double x_max, char const *name="Y Axis", int num_points=100, int type=vtkChart::LINE, std::vector< char > const &color=std::vector< char >())
 Adds a plot based on a user defined callback function representing the function to plot.
void addPlotData (char const *filename, int type=vtkChart::LINE)
 Adds a plot based on a space/tab delimited table provided in a file.
void addHistogramData (std::vector< double > const &data, int const nbins=10, char const *name="Histogram", std::vector< char > const &color=std::vector< char >())
 Bins the elements in vector data into nbins equally spaced containers and plots the resulted histogram.
template<typename PointT >
bool addFeatureHistogram (const pcl::PointCloud< PointT > &cloud, int hsize, const std::string &id="cloud", int win_width=640, int win_height=200)
 Add a histogram feature to screen as a separate window, from a cloud containing a single histogram.
bool addFeatureHistogram (const pcl::PCLPointCloud2 &cloud, const std::string &field_name, const std::string &id="cloud", int win_width=640, int win_height=200)
 Add a histogram feature to screen as a separate window from a cloud containing a single histogram.
template<typename PointT >
bool addFeatureHistogram (const pcl::PointCloud< PointT > &cloud, const std::string &field_name, const int index, const std::string &id="cloud", int win_width=640, int win_height=200)
 Add a histogram feature to screen as a separate window.
bool addFeatureHistogram (const pcl::PCLPointCloud2 &cloud, const std::string &field_name, const int index, const std::string &id="cloud", int win_width=640, int win_height=200)
 Add a histogram feature to screen as a separate window.
void plot ()
 Draws all the plots added by addPlotData() or addHistogramData() till now.
void spinOnce (const int spin_time=1)
 Spins (runs the event loop) the interactor for spin_time amount of time.
void spin ()
 Spins (runs the event loop) the interactor indefinitely.
void clearPlots ()
 Remove all plots from the window.
void setColorScheme (int scheme)
 Set method for the color scheme of the plot.
int getColorScheme ()
 get the currently used color scheme
void setBackgroundColor (const double r, const double g, const double b)
 set/get method for the viewport's background color.
void setBackgroundColor (const double color[3])
 set/get method for the viewport's background color.
double * getBackgroundColor ()
 set/get method for the viewport's background color.
void setXRange (double min, double max)
 Set logical range of the X-Axis in plot coordinates.
void setYRange (double min, double max)
 Set logical range of the Y-Axis in plot coordinates.
void setTitle (const char *title)
 Set the main title of the plot.
void setXTitle (const char *title)
 Set the title of the X-Axis.
void setYTitle (const char *title)
 Set the title of the Y-Axis.
void setShowLegend (bool flag)
 Shows the legend of the graph.
void setWindowSize (int w, int h)
 set/get method for the window size.
int * getWindowSize ()
 set/get method for the window size.
vtkSmartPointer< vtkRenderWindow > getRenderWindow ()
 Return a pointer to the underlying VTK RenderWindow used.
void setViewInteractor (vtkSmartPointer< vtkRenderWindowInteractor > interactor)
 Set the view's interactor.
void startInteractor ()
 Initialize and Start the view's interactor.
void renderOnce ()
 Render the vtkWindow once.
bool wasStopped () const
 Returns true when the user tried to close the window.
void close ()
 Stop the interaction and close the visualizaton window.

Detailed Description

PCL Plotter main class.

Given point correspondences this class can be used to plot the data one against the other and display it on the screen. It also has methods for providing plot for important functions like histogram etc. Important functions of PCLHistogramVisualizer are redefined here so that this single class can take responsibility of all plotting related functionalities.

Author:
Kripasindhu Sarkar

Definition at line 77 of file pcl_plotter.h.


Member Typedef Documentation

A representation of polynomial function.

i'th element of the vector denotes the coefficient of x^i of the polynomial in variable x.

Definition at line 83 of file pcl_plotter.h.

A representation of rational function, defined as the ratio of two polynomial functions.

pair::first denotes the numerator and pair::second denotes the denominator of the Rational function.

Definition at line 87 of file pcl_plotter.h.


Constructor & Destructor Documentation

pcl::visualization::PCLPlotter::PCLPlotter ( char const *  name = "PCL Plotter"  ) 

PCL Plotter constructor.

Parameters:
[in] name Name of the window
pcl::visualization::PCLPlotter::~PCLPlotter (  ) 

Destructor.


Member Function Documentation

bool pcl::visualization::PCLPlotter::addFeatureHistogram ( const pcl::PCLPointCloud2 cloud,
const std::string &  field_name,
const int  index,
const std::string &  id = "cloud",
int  win_width = 640,
int  win_height = 200 
)

Add a histogram feature to screen as a separate window.

Parameters:
[in] cloud the PointCloud dataset containing the histogram
[in] field_name the field name containing the histogram
[in] index the point index to extract the histogram from
[in] id the point cloud object id (default: cloud)
[in] win_width the width of the window
[in] win_height the height of the window
template<typename PointT >
bool pcl::visualization::PCLPlotter::addFeatureHistogram ( const pcl::PointCloud< PointT > &  cloud,
const std::string &  field_name,
const int  index,
const std::string &  id = "cloud",
int  win_width = 640,
int  win_height = 200 
) [inline]

Add a histogram feature to screen as a separate window.

Parameters:
[in] cloud the PointCloud dataset containing the histogram
[in] field_name the field name containing the histogram
[in] index the point index to extract the histogram from
[in] id the point cloud object id (default: cloud)
[in] win_width the width of the window
[in] win_height the height of the window

Definition at line 62 of file pcl_plotter.hpp.

References addPlotData(), pcl::PointCloud< PointT >::points, and setWindowSize().

bool pcl::visualization::PCLPlotter::addFeatureHistogram ( const pcl::PCLPointCloud2 cloud,
const std::string &  field_name,
const std::string &  id = "cloud",
int  win_width = 640,
int  win_height = 200 
)

Add a histogram feature to screen as a separate window from a cloud containing a single histogram.

Parameters:
[in] cloud the PointCloud dataset containing the histogram
[in] field_name the field name containing the histogram
[in] id the point cloud object id (default: cloud)
[in] win_width the width of the window
[in] win_height the height of the window
template<typename PointT >
bool pcl::visualization::PCLPlotter::addFeatureHistogram ( const pcl::PointCloud< PointT > &  cloud,
int  hsize,
const std::string &  id = "cloud",
int  win_width = 640,
int  win_height = 200 
) [inline]

Add a histogram feature to screen as a separate window, from a cloud containing a single histogram.

Parameters:
[in] cloud the PointCloud dataset containing the histogram
[in] hsize the length of the histogram
[in] id the point cloud object id (default: cloud)
[in] win_width the width of the window
[in] win_height the height of the window

Definition at line 42 of file pcl_plotter.hpp.

References addPlotData(), pcl::PointCloud< PointT >::points, and setWindowSize().

void pcl::visualization::PCLPlotter::addHistogramData ( std::vector< double > const &  data,
int const   nbins = 10,
char const *  name = "Histogram",
std::vector< char > const &  color = std::vector< char >() 
)

Bins the elements in vector data into nbins equally spaced containers and plots the resulted histogram.

Parameters:
[in] data the raw data
[in] nbins the number of bins for the histogram
[in] name name of this histogram which will appear on legends if toggled on
[in] color a character array of 4 fields denoting the R,G,B and A component of the color of the plot ranging from 0 to 255. If this argument is not passed (or an empty vector is passed) the histogram is colored based on the current color scheme
void pcl::visualization::PCLPlotter::addPlotData ( char const *  filename,
int  type = vtkChart::LINE 
)

Adds a plot based on a space/tab delimited table provided in a file.

Parameters:
[in] filename name of the file containing the table. 1st column represents the values of X-Axis. Rest of the columns represent the corresponding values in Y-Axes. First row of the file is concidered for naming/labling of the plot. The plot-names should not contain any space in between.
[in] type type of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
void pcl::visualization::PCLPlotter::addPlotData ( double(*)(double)  function,
double  x_min,
double  x_max,
char const *  name = "Y Axis",
int  num_points = 100,
int  type = vtkChart::LINE,
std::vector< char > const &  color = std::vector< char >() 
)

Adds a plot based on a user defined callback function representing the function to plot.

Parameters:
[in] function a user defined callback function representing the relation y = function(x)
[in] x_min the left boundary of the range for displaying the plot
[in] x_max the right boundary of the range for displaying the plot
[in] name name of the plot which appears in the legend when toggled on
[in] num_points Number of points plotted to show the graph. More this number, more is the resolution.
[in] type type of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in] color a character array of 4 fields denoting the R,G,B and A component of the color of the plot ranging from 0 to 255. If this argument is not passed (or NULL is passed) the plot is colored based on a color scheme
void pcl::visualization::PCLPlotter::addPlotData ( RationalFunction const &  r_function,
double  x_min,
double  x_max,
char const *  name = "Y Axis",
int  num_points = 100,
int  type = vtkChart::LINE,
std::vector< char > const &  color = std::vector< char >() 
)

Adds a plot based on the given rational function and the range in X axis.

Parameters:
[in] r_function A rational function which is represented by the ratio of two polynomial functions. See description on the typedef for more details.
[in] x_min the left boundary of the range for displaying the plot
[in] x_max the right boundary of the range for displaying the plot
[in] name name of the plot which appears in the legend when toggled on
[in] num_points Number of points plotted to show the graph. More this number, more is the resolution.
[in] type type of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in] color a character array of 4 fields denoting the R,G,B and A component of the color of the plot ranging from 0 to 255. If this argument is not passed (or NULL is passed) the plot is colored based on a color scheme
void pcl::visualization::PCLPlotter::addPlotData ( PolynomialFunction const &  p_function,
double  x_min,
double  x_max,
char const *  name = "Y Axis",
int  num_points = 100,
int  type = vtkChart::LINE,
std::vector< char > const &  color = std::vector< char >() 
)

Adds a plot based on the given polynomial function and the range in X axis.

Parameters:
[in] p_function A polynomial function which is represented by a vector which stores the coefficients. See description on the typedef.
[in] x_min the left boundary of the range for displaying the plot
[in] x_max the right boundary of the range for displaying the plot
[in] name name of the plot which appears in the legend when toggled on
[in] num_points Number of points plotted to show the graph. More this number, more is the resolution.
[in] type type of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in] color a character array of 4 fields denoting the R,G,B and A component of the color of the plot ranging from 0 to 255. If this argument is not passed (or NULL is passed) the plot is colored based on a color scheme
void pcl::visualization::PCLPlotter::addPlotData ( std::vector< std::pair< double, double > > const &  plot_data,
char const *  name = "Y Axis",
int  type = vtkChart::LINE,
std::vector< char > const &  color = std::vector< char >() 
)

Adds a plot with correspondences in vector of pairs.

The the first and second field of the pairs of the vector forms the correspondence.

Parameters:
[in] name name of the plot which appears in the legend when toggled on
[in] type type of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in] color a character array of 4 fields denoting the R,G,B and A component of the color of the plot ranging from 0 to 255. If this argument is not passed (or NULL is passed) the plot is colored based on a color scheme
void pcl::visualization::PCLPlotter::addPlotData ( std::vector< double > const &  array_X,
std::vector< double >const &  array_Y,
char const *  name = "Y Axis",
int  type = vtkChart::LINE,
std::vector< char > const &  color = std::vector< char >() 
)

Adds a plot with correspondences in vectors arrayX and arrayY.

This is the vector version of the addPlotData function.

Parameters:
[in] array_X X coordinates of point correspondence array
[in] array_Y Y coordinates of point correspondence array
[in] size length of the array arrayX and arrayY
[in] name name of the plot which appears in the legend when toggled on
[in] type type of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in] color a character array of 4 fields denoting the R,G,B and A component of the color of the plot ranging from 0 to 255. If this argument is not passed (or NULL is passed) the plot is colored based on a color scheme
void pcl::visualization::PCLPlotter::addPlotData ( double const *  array_X,
double const *  array_Y,
unsigned long  size,
char const *  name = "Y Axis",
int  type = vtkChart::LINE,
char const *  color = NULL 
)

Adds a plot with correspondences in the arrays arrayX and arrayY.

Parameters:
[in] array_X X coordinates of point correspondence array
[in] array_Y Y coordinates of point correspondence array
[in] size length of the array arrayX and arrayY
[in] name name of the plot which appears in the legend when toggled on
[in] type type of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in] color a character array of 4 fields denoting the R,G,B and A component of the color of the plot ranging from 0 to 255. If this argument is not passed (or NULL is passed) the plot is colored based on a color scheme

Referenced by addFeatureHistogram().

void pcl::visualization::PCLPlotter::clearPlots (  ) 

Remove all plots from the window.

void pcl::visualization::PCLPlotter::close (  ) 

Stop the interaction and close the visualizaton window.

double* pcl::visualization::PCLPlotter::getBackgroundColor (  ) 

set/get method for the viewport's background color.

Returns:
[out] color the array containing the 3 component of the RGB color
int pcl::visualization::PCLPlotter::getColorScheme (  ) 

get the currently used color scheme

Returns:
[out] the currently used color scheme. Values include WARM, COOL, BLUES, WILD_FLOWER, CITRUS, CUSTOM
vtkSmartPointer<vtkRenderWindow> pcl::visualization::PCLPlotter::getRenderWindow (  ) 

Return a pointer to the underlying VTK RenderWindow used.

int* pcl::visualization::PCLPlotter::getWindowSize (  ) 

set/get method for the window size.

Returns:
[in] array containing the width and height of the window
void pcl::visualization::PCLPlotter::plot (  ) 

Draws all the plots added by addPlotData() or addHistogramData() till now.

void pcl::visualization::PCLPlotter::renderOnce (  ) 

Render the vtkWindow once.

void pcl::visualization::PCLPlotter::setBackgroundColor ( const double  color[3]  ) 

set/get method for the viewport's background color.

Parameters:
[in] color the array containing the 3 component of the RGB color
void pcl::visualization::PCLPlotter::setBackgroundColor ( const double  r,
const double  g,
const double  b 
)

set/get method for the viewport's background color.

Parameters:
[in] r the red component of the RGB color
[in] g the green component of the RGB color
[in] b the blue component of the RGB color
void pcl::visualization::PCLPlotter::setColorScheme ( int  scheme  ) 

Set method for the color scheme of the plot.

The plots gets autocolored differently based on the color scheme.

Parameters:
[in] scheme the color scheme. Possible values are vtkColorSeries::SPECTRUM, vtkColorSeries::WARM, vtkColorSeries::COOL, vtkColorSeries::BLUES, vtkColorSeries::WILD_FLOWER, vtkColorSeries::CITRUS
void pcl::visualization::PCLPlotter::setShowLegend ( bool  flag  ) 

Shows the legend of the graph.

Parameters:
[in] flag pass flag = true for the display of the legend of the graph
void pcl::visualization::PCLPlotter::setTitle ( const char *  title  ) 

Set the main title of the plot.

Parameters:
[in] title the title to set
void pcl::visualization::PCLPlotter::setViewInteractor ( vtkSmartPointer< vtkRenderWindowInteractor >  interactor  ) 

Set the view's interactor.

void pcl::visualization::PCLPlotter::setWindowSize ( int  w,
int  h 
)

set/get method for the window size.

Parameters:
[in] w the width of the window
[in] h the height of the window

Referenced by addFeatureHistogram().

void pcl::visualization::PCLPlotter::setXRange ( double  min,
double  max 
)

Set logical range of the X-Axis in plot coordinates.

Parameters:
[in] min the left boundary of the range
[in] max the right boundary of the range
void pcl::visualization::PCLPlotter::setXTitle ( const char *  title  ) 

Set the title of the X-Axis.

Parameters:
[in] title the title to set
void pcl::visualization::PCLPlotter::setYRange ( double  min,
double  max 
)

Set logical range of the Y-Axis in plot coordinates.

Parameters:
[in] min the left boundary of the range
[in] max the right boundary of the range
void pcl::visualization::PCLPlotter::setYTitle ( const char *  title  ) 

Set the title of the Y-Axis.

Parameters:
[in] title the title to set
void pcl::visualization::PCLPlotter::spin (  ) 

Spins (runs the event loop) the interactor indefinitely.

Same as plot() - added to retain the similarity between other existing visualization classes.

void pcl::visualization::PCLPlotter::spinOnce ( const int  spin_time = 1  ) 

Spins (runs the event loop) the interactor for spin_time amount of time.

The name is confusing and will be probably obsolete in the future release with a single overloaded spin()/display() function.

Parameters:
[in] spin_time - How long (in ms) should the visualization loop be allowed to run.
void pcl::visualization::PCLPlotter::startInteractor (  ) 

Initialize and Start the view's interactor.

bool pcl::visualization::PCLPlotter::wasStopped (  )  const

Returns true when the user tried to close the window.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends