Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
pcl::visualization::PCLPlotter Class Reference

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. More...

#include <pcl_plotter.h>

List of all members.

Classes

struct  ExitCallback
struct  ExitMainLoopTimerCallback

Public Types

typedef std::vector< double > PolynomialFunction
 A representation of polynomial function. i'th element of the vector denotes the coefficient of x^i of the polynomial in variable x.
typedef std::pair
< PolynomialFunction,
PolynomialFunction
RationalFunction
 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.

Public Member Functions

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 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.
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. This is the vector version of the addPlotData function.
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. The the first and second field of the pairs of the vector forms the correspondence.
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 clearPlots ()
 Remove all plots from the window.
void close ()
 Stop the interaction and close the visualizaton window.
double * getBackgroundColor ()
 set/get method for the viewport's background color.
int getColorScheme ()
 get the currently used color scheme
vtkSmartPointer< vtkRenderWindow > getRenderWindow ()
 Return a pointer to the underlying VTK RenderWindow used.
int * getWindowSize ()
 set/get method for the window size.
 PCLPlotter (char const *name="PCL Plotter")
 PCL Plotter constructor.
void plot ()
 Draws all the plots added by addPlotData() or addHistogramData() till now.
void renderOnce ()
 Render the vtkWindow once.
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.
void setColorScheme (int scheme)
 Set method for the color scheme of the plot. The plots gets autocolored differently based on the color scheme.
void setShowLegend (bool flag)
 Shows the legend of the graph.
void setTitle (const char *title)
 Set the main title of the plot.
void setViewInteractor (vtkSmartPointer< vtkRenderWindowInteractor > interactor)
 Set the view's interactor.
void setWindowSize (int w, int h)
 set/get method for the window size.
void setXRange (double min, double max)
 Set logical range of the X-Axis in plot coordinates.
void setXTitle (const char *title)
 Set the title of the X-Axis.
void setYRange (double min, double max)
 Set logical range of the Y-Axis in plot coordinates.
void setYTitle (const char *title)
 Set the title of the Y-Axis.
void spin ()
 Spins (runs the event loop) the interactor indefinitely. Same as plot() - added to retain the similarity between other existing visualization classes.
void 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.
void startInteractor ()
 Initialize and Start the view's interactor.
bool wasStopped () const
 Returns true when the user tried to close the window.
 ~PCLPlotter ()
 Destructor.

Private Member Functions

double compute (PolynomialFunction const &p_function, double val)
 computes the value of the polynomial function at val
double compute (RationalFunction const &r_function, double val)
 computes the value of the rational function at val
void computeHistogram (std::vector< double > const &data, int const nbins, std::vector< std::pair< double, double > > &histogram)
 bins the elements in vector data into nbins equally spaced containers and returns the histogram form, ie, computes the histogram for 'data'

Private Attributes

double bkg_color_ [3]
vtkSmartPointer< vtkChartXY > chart_
vtkSmartPointer< vtkColorSeries > color_series_
int current_plot_
vtkSmartPointer< ExitCallbackexit_callback_
vtkSmartPointer
< ExitMainLoopTimerCallback
exit_loop_timer_
 Callback object enabling us to leave the main loop, when a timer fires.
bool stopped_
 Set to false if the interaction loop is running.
vtkSmartPointer< vtkContextView > view_
int win_height_
int win_width_

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 76 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 82 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 86 of file pcl_plotter.h.


Constructor & Destructor Documentation

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

PCL Plotter constructor.

Parameters:
[in]nameName of the window

Definition at line 63 of file pcl_plotter.cpp.

Destructor.

Definition at line 89 of file pcl_plotter.cpp.


Member Function Documentation

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 
)

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

Parameters:
[in]cloudthe PointCloud dataset containing the histogram
[in]hsizethe length of the histogram
[in]idthe point cloud object id (default: cloud)
[in]win_widththe width of the window
[in]win_heightthe height of the window

Definition at line 42 of file pcl_plotter.hpp.

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]cloudthe PointCloud dataset containing the histogram
[in]field_namethe field name containing the histogram
[in]idthe point cloud object id (default: cloud)
[in]win_widththe width of the window
[in]win_heightthe height of the window

Definition at line 298 of file pcl_plotter.cpp.

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 
)

Add a histogram feature to screen as a separate window.

Parameters:
[in]cloudthe PointCloud dataset containing the histogram
[in]field_namethe field name containing the histogram
[in]indexthe point index to extract the histogram from
[in]idthe point cloud object id (default: cloud)
[in]win_widththe width of the window
[in]win_heightthe height of the window

Definition at line 62 of file pcl_plotter.hpp.

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]cloudthe PointCloud dataset containing the histogram
[in]field_namethe field name containing the histogram
[in]indexthe point index to extract the histogram from
[in]idthe point cloud object id (default: cloud)
[in]win_widththe width of the window
[in]win_heightthe height of the window

Definition at line 330 of file pcl_plotter.cpp.

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]datathe raw data
[in]nbinsthe number of bins for the histogram
[in]namename of this histogram which will appear on legends if toggled on
[in]colora 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

Definition at line 285 of file pcl_plotter.cpp.

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_XX coordinates of point correspondence array
[in]array_YY coordinates of point correspondence array
[in]sizelength of the array arrayX and arrayY
[in]namename of the plot which appears in the legend when toggled on
[in]typetype of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in]colora 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

Definition at line 93 of file pcl_plotter.cpp.

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_XX coordinates of point correspondence array
[in]array_YY coordinates of point correspondence array
[in]sizelength of the array arrayX and arrayY
[in]namename of the plot which appears in the legend when toggled on
[in]typetype of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in]colora 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

Definition at line 137 of file pcl_plotter.cpp.

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]namename of the plot which appears in the legend when toggled on
[in]typetype of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in]colora 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

Definition at line 149 of file pcl_plotter.cpp.

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_functionA polynomial function which is represented by a vector which stores the coefficients. See description on the typedef.
[in]x_minthe left boundary of the range for displaying the plot
[in]x_maxthe right boundary of the range for displaying the plot
[in]namename of the plot which appears in the legend when toggled on
[in]num_pointsNumber of points plotted to show the graph. More this number, more is the resolution.
[in]typetype of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in]colora 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

Definition at line 168 of file pcl_plotter.cpp.

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_functionA rational function which is represented by the ratio of two polynomial functions. See description on the typedef for more details.
[in]x_minthe left boundary of the range for displaying the plot
[in]x_maxthe right boundary of the range for displaying the plot
[in]namename of the plot which appears in the legend when toggled on
[in]num_pointsNumber of points plotted to show the graph. More this number, more is the resolution.
[in]typetype of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in]colora 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

Definition at line 191 of file pcl_plotter.cpp.

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]functiona user defined callback function representing the relation y = function(x)
[in]x_minthe left boundary of the range for displaying the plot
[in]x_maxthe right boundary of the range for displaying the plot
[in]namename of the plot which appears in the legend when toggled on
[in]num_pointsNumber of points plotted to show the graph. More this number, more is the resolution.
[in]typetype of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot
[in]colora 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

Definition at line 217 of file pcl_plotter.cpp.

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]filenamename 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]typetype of the graph plotted. vtkChart::LINE for line plot, vtkChart::BAR for bar plot, and vtkChart::POINTS for a scattered point plot

Definition at line 239 of file pcl_plotter.cpp.

Remove all plots from the window.

Definition at line 447 of file pcl_plotter.cpp.

Stop the interaction and close the visualizaton window.

Definition at line 636 of file pcl_plotter.cpp.

double pcl::visualization::PCLPlotter::compute ( PolynomialFunction const &  p_function,
double  val 
) [private]

computes the value of the polynomial function at val

Parameters:
[in]p_functionpolynomial function
[in]valuethe value at which the function is to be computed

Definition at line 594 of file pcl_plotter.cpp.

double pcl::visualization::PCLPlotter::compute ( RationalFunction const &  r_function,
double  val 
) [private]

computes the value of the rational function at val

Parameters:
[in]r_functionthe rational function
[in]valuethe value at which the function is to be computed

Definition at line 606 of file pcl_plotter.cpp.

void pcl::visualization::PCLPlotter::computeHistogram ( std::vector< double > const &  data,
int const  nbins,
std::vector< std::pair< double, double > > &  histogram 
) [private]

bins the elements in vector data into nbins equally spaced containers and returns the histogram form, ie, computes the histogram for 'data'

Parameters:
[in]datadata who's frequency distribution is to be found
[in]nbinsnumber of bins for the histogram
[out]histogramvector of pairs containing the histogram. The first field of the pair represent the middle value of the corresponding bin. The second field denotes the frequency of data in that bin.

Definition at line 557 of file pcl_plotter.cpp.

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

Returns:
[out] color the array containing the 3 component of the RGB color

Definition at line 473 of file pcl_plotter.cpp.

get the currently used color scheme

Returns:
[out] the currently used color scheme. Values include WARM, COOL, BLUES, WILD_FLOWER, CITRUS, CUSTOM

Definition at line 385 of file pcl_plotter.cpp.

vtkSmartPointer< vtkRenderWindow > pcl::visualization::PCLPlotter::getRenderWindow ( )

Return a pointer to the underlying VTK RenderWindow used.

Definition at line 645 of file pcl_plotter.cpp.

set/get method for the window size.

Returns:
[in] array containing the width and height of the window

Definition at line 539 of file pcl_plotter.cpp.

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

Definition at line 392 of file pcl_plotter.cpp.

Render the vtkWindow once.

Definition at line 427 of file pcl_plotter.cpp.

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]rthe red component of the RGB color
[in]gthe green component of the RGB color
[in]bthe blue component of the RGB color

Definition at line 455 of file pcl_plotter.cpp.

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

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

Parameters:
[in]colorthe array containing the 3 component of the RGB color

Definition at line 464 of file pcl_plotter.cpp.

Set method for the color scheme of the plot. The plots gets autocolored differently based on the color scheme.

Parameters:
[in]schemethe color scheme. Possible values are vtkColorSeries::SPECTRUM, vtkColorSeries::WARM, vtkColorSeries::COOL, vtkColorSeries::BLUES, vtkColorSeries::WILD_FLOWER, vtkColorSeries::CITRUS

Definition at line 378 of file pcl_plotter.cpp.

Shows the legend of the graph.

Parameters:
[in]flagpass flag = true for the display of the legend of the graph

Definition at line 524 of file pcl_plotter.cpp.

void pcl::visualization::PCLPlotter::setTitle ( const char *  title)

Set the main title of the plot.

Parameters:
[in]titlethe title to set

Definition at line 500 of file pcl_plotter.cpp.

void pcl::visualization::PCLPlotter::setViewInteractor ( vtkSmartPointer< vtkRenderWindowInteractor >  interactor)

Set the view's interactor.

Definition at line 618 of file pcl_plotter.cpp.

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

set/get method for the window size.

Parameters:
[in]wthe width of the window
[in]hthe height of the window

Definition at line 531 of file pcl_plotter.cpp.

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

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

Parameters:
[in]minthe left boundary of the range
[in]maxthe right boundary of the range

Definition at line 492 of file pcl_plotter.cpp.

void pcl::visualization::PCLPlotter::setXTitle ( const char *  title)

Set the title of the X-Axis.

Parameters:
[in]titlethe title to set

Definition at line 508 of file pcl_plotter.cpp.

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

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

Parameters:
[in]minthe left boundary of the range
[in]maxthe right boundary of the range

Definition at line 484 of file pcl_plotter.cpp.

void pcl::visualization::PCLPlotter::setYTitle ( const char *  title)

Set the title of the Y-Axis.

Parameters:
[in]titlethe title to set

Definition at line 516 of file pcl_plotter.cpp.

Spins (runs the event loop) the interactor indefinitely. Same as plot() - added to retain the similarity between other existing visualization classes.

Definition at line 440 of file pcl_plotter.cpp.

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.

Definition at line 405 of file pcl_plotter.cpp.

Initialize and Start the view's interactor.

Definition at line 549 of file pcl_plotter.cpp.

Returns true when the user tried to close the window.

Definition at line 626 of file pcl_plotter.cpp.


Member Data Documentation

Definition at line 394 of file pcl_plotter.h.

vtkSmartPointer<vtkChartXY> pcl::visualization::PCLPlotter::chart_ [private]

Definition at line 388 of file pcl_plotter.h.

vtkSmartPointer<vtkColorSeries> pcl::visualization::PCLPlotter::color_series_ [private]

Definition at line 389 of file pcl_plotter.h.

Definition at line 392 of file pcl_plotter.h.

Definition at line 431 of file pcl_plotter.h.

Callback object enabling us to leave the main loop, when a timer fires.

Definition at line 430 of file pcl_plotter.h.

Set to false if the interaction loop is running.

Definition at line 427 of file pcl_plotter.h.

vtkSmartPointer<vtkContextView> pcl::visualization::PCLPlotter::view_ [private]

Definition at line 387 of file pcl_plotter.h.

Definition at line 393 of file pcl_plotter.h.

Definition at line 393 of file pcl_plotter.h.


The documentation for this class was generated from the following files:


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:47:19