Point Cloud Library (PCL)  1.14.1-dev
List of all members | Classes | Public Types | Public Member Functions
pcl::visualization::PCLPlotter Class Reference

PCL Plotter main class. More...

#include <pcl/visualization/pcl_plotter.h>

Public Types

using Ptr = shared_ptr< PCLPlotter >
 
using ConstPtr = shared_ptr< const PCLPlotter >
 
using PolynomialFunction = std::vector< double >
 A representation of polynomial function. More...
 
using RationalFunction = std::pair< PolynomialFunction, PolynomialFunction >
 A representation of rational function, defined as the ratio of two polynomial functions. More...
 

Public Member Functions

 PCLPlotter (char const *name="PCL Plotter")
 PCL Plotter constructor. More...
 
 ~PCLPlotter ()
 Destructor. More...
 
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=nullptr)
 Adds a plot with correspondences in the arrays arrayX and arrayY. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void addPlotData (char const *filename, int type=vtkChart::LINE)
 Adds a plot based on a space/tab delimited table provided in a file. More...
 
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. More...
 
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. More...
 
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. More...
 
template<typename PointT >
bool addFeatureHistogram (const pcl::PointCloud< PointT > &cloud, const std::string &field_name, const pcl::index_t index, const std::string &id="cloud", int win_width=640, int win_height=200)
 Add a histogram feature to screen as a separate window. More...
 
bool addFeatureHistogram (const pcl::PCLPointCloud2 &cloud, const std::string &field_name, const pcl::index_t index, const std::string &id="cloud", int win_width=640, int win_height=200)
 Add a histogram feature to screen as a separate window. More...
 
void plot ()
 Draws all the plots added by addPlotData() or addHistogramData() till now. More...
 
void spinOnce (const int spin_time=1)
 Spins (runs the event loop) the interactor for spin_time amount of time. More...
 
void spin ()
 Spins (runs the event loop) the interactor indefinitely. More...
 
void clearPlots ()
 Remove all plots from the window. More...
 
void setColorScheme (int scheme)
 Set method for the color scheme of the plot. More...
 
int getColorScheme ()
 get the currently used color scheme More...
 
void setBackgroundColor (const double r, const double g, const double b)
 set/get method for the viewport's background color. More...
 
void setBackgroundColor (const double color[3])
 set/get method for the viewport's background color. More...
 
double * getBackgroundColor ()
 set/get method for the viewport's background color. More...
 
void setXRange (double min, double max)
 Set logical range of the X-Axis in plot coordinates. More...
 
void setYRange (double min, double max)
 Set logical range of the Y-Axis in plot coordinates. More...
 
void setTitle (const char *title)
 Set the main title of the plot. More...
 
void setXTitle (const char *title)
 Set the title of the X-Axis. More...
 
void setYTitle (const char *title)
 Set the title of the Y-Axis. More...
 
void setShowLegend (bool flag)
 Shows the legend of the graph. More...
 
void setWindowSize (int w, int h)
 set/get method for the window size. More...
 
void setWindowPosition (int x, int y)
 Set the position in screen coordinates. More...
 
void setWindowName (const std::string &name)
 Set the visualizer window name. More...
 
int * getWindowSize () const
 set/get method for the window size. More...
 
vtkSmartPointer< vtkRenderWindow > getRenderWindow ()
 Return a pointer to the underlying VTK RenderWindow used. More...
 
void setViewInteractor (vtkSmartPointer< vtkRenderWindowInteractor > interactor)
 Set the view's interactor. More...
 
void startInteractor ()
 Initialize and Start the view's interactor. More...
 
void renderOnce ()
 Render the vtkWindow once. More...
 
bool wasStopped () const
 Returns true when the user tried to close the window. More...
 
void close ()
 Stop the interaction and close the visualization window. More...
 

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 75 of file pcl_plotter.h.

Member Typedef Documentation

◆ ConstPtr

Definition at line 79 of file pcl_plotter.h.

◆ PolynomialFunction

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.

◆ Ptr

Definition at line 78 of file pcl_plotter.h.

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

Definition at line 87 of file pcl_plotter.h.

Constructor & Destructor Documentation

◆ PCLPlotter()

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

PCL Plotter constructor.


Parameters
[in]nameName of the window

◆ ~PCLPlotter()

pcl::visualization::PCLPlotter::~PCLPlotter ( )

Destructor.

Member Function Documentation

◆ addFeatureHistogram() [1/4]

bool pcl::visualization::PCLPlotter::addFeatureHistogram ( const pcl::PCLPointCloud2 cloud,
const std::string &  field_name,
const pcl::index_t  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

◆ addFeatureHistogram() [2/4]

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

◆ addFeatureHistogram() [3/4]

template<typename PointT >
bool pcl::visualization::PCLPlotter::addFeatureHistogram ( const pcl::PointCloud< PointT > &  cloud,
const std::string &  field_name,
const pcl::index_t  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 69 of file pcl_plotter.hpp.

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

◆ addFeatureHistogram() [4/4]

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 49 of file pcl_plotter.hpp.

References addPlotData(), and setWindowSize().

◆ addHistogramData()

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

◆ addPlotData() [1/7]

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 considered for naming/labeling 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

◆ addPlotData() [2/7]

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 = nullptr 
)

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

Referenced by addFeatureHistogram().

◆ addPlotData() [3/7]

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

◆ addPlotData() [4/7]

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

◆ addPlotData() [5/7]

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

◆ addPlotData() [6/7]

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]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

◆ addPlotData() [7/7]

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
plot_data
[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

◆ clearPlots()

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

Remove all plots from the window.

◆ close()

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

Stop the interaction and close the visualization window.

◆ getBackgroundColor()

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

◆ getColorScheme()

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

◆ getRenderWindow()

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

Return a pointer to the underlying VTK RenderWindow used.

◆ getWindowSize()

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

set/get method for the window size.

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

◆ plot()

void pcl::visualization::PCLPlotter::plot ( )

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

◆ renderOnce()

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

Render the vtkWindow once.

◆ setBackgroundColor() [1/2]

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

◆ setBackgroundColor() [2/2]

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

◆ setColorScheme()

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]schemethe color scheme. Possible values are vtkColorSeries::SPECTRUM, vtkColorSeries::WARM, vtkColorSeries::COOL, vtkColorSeries::BLUES, vtkColorSeries::WILD_FLOWER, vtkColorSeries::CITRUS

◆ setShowLegend()

void pcl::visualization::PCLPlotter::setShowLegend ( bool  flag)

Shows the legend of the graph.

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

◆ setTitle()

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

Set the main title of the plot.

Parameters
[in]titlethe title to set

◆ setViewInteractor()

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

Set the view's interactor.

◆ setWindowName()

void pcl::visualization::PCLPlotter::setWindowName ( const std::string &  name)

Set the visualizer window name.

Parameters
[in]namethe name of the window

◆ setWindowPosition()

void pcl::visualization::PCLPlotter::setWindowPosition ( int  x,
int  y 
)

Set the position in screen coordinates.

Parameters
[in]xwhere to move the window to (X)
[in]ywhere to move the window to (Y)

◆ setWindowSize()

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

Referenced by addFeatureHistogram().

◆ setXRange()

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

◆ setXTitle()

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

Set the title of the X-Axis.

Parameters
[in]titlethe title to set

◆ setYRange()

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

◆ setYTitle()

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

Set the title of the Y-Axis.

Parameters
[in]titlethe title to set

◆ spin()

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.

◆ spinOnce()

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.

◆ startInteractor()

void pcl::visualization::PCLPlotter::startInteractor ( )

Initialize and Start the view's interactor.

◆ wasStopped()

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: