pcl::visualization::PCLPlotter Class Reference
Module visualization

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 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. More...
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. 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 ()
| 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 visualizaton 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 76 of file pcl_plotter.h.

## Member Typedef Documentation

## ConstPtr

using pcl::visualization::PCLPlotter::ConstPtr = shared_ptr<const PCLPlotter>

Definition at line 80 of file pcl_plotter.h.

## PolynomialFunction

using pcl::visualization::PCLPlotter::PolynomialFunction = std::vector<double>

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

## Ptr

using pcl::visualization::PCLPlotter::Ptr = shared_ptr<PCLPlotter>

Definition at line 79 of file pcl_plotter.h.

## RationalFunction

using pcl::visualization::PCLPlotter::RationalFunction = std::pair<PolynomialFunction, PolynomialFunction>

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

## Constructor & Destructor Documentation

## PCLPlotter()

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

PCL Plotter constructor.

Parameters

  [in] | name | Name 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 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

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

## addFeatureHistogram() [3/4]

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] | 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 pcl::PointCloud< PointT >::points.

## 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] | 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().

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

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

## 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_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().

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

## 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_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

## 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_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

## 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_x | X coordinates of point correspondence array
  [in] | array_y | Y coordinates of point correspondence array
  [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

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

## clearPlots()

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

Remove all plots from the window.

## close()

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

Stop the interaction and close the visualizaton 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 | ( |  | ) |

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

## 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] | scheme | the 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] | flag | pass 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] | title | the 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] | name | the name of the window

## setWindowPosition()

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

Set the position in screen coordinates.

Parameters

  [in] | x | where to move the window to (X)
  [in] | y | where 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] | w | the width of the window
  [in] | h | the 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] | min | the left boundary of the range
  [in] | max | the right boundary of the range

## setXTitle()

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

Set the title of the X-Axis.

Parameters

  [in] | title | the 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] | min | the left boundary of the range
  [in] | max | the right boundary of the range

## setYTitle()

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

Set the title of the Y-Axis.

Parameters

  [in] | title | the 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:

- pcl/visualization/pcl_plotter.h
- pcl/visualization/impl/pcl_plotter.hpp