46 #include <pcl/visualization/common/common.h>
48 #include <pcl/correspondence.h>
49 #include <pcl/point_cloud.h>
50 #include <pcl/common/io.h>
52 class vtkRenderWindow;
53 class vtkRenderWindowInteractor;
58 #include <vtkSmartPointer.h>
59 #include <vtkCommand.h>
64 namespace visualization
79 using Ptr = shared_ptr<PCLPlotter>;
108 double const *array_Y,
110 char const * name =
"Y Axis",
111 int type = vtkChart::LINE ,
112 char const *color=
nullptr);
123 std::vector<double>
const &array_y,
124 char const * name =
"Y Axis",
125 int type = vtkChart::LINE,
126 std::vector<char>
const &color = std::vector<char> ());
135 addPlotData (std::vector<std::pair<double, double> >
const &plot_data,
136 char const * name =
"Y Axis",
137 int type = vtkChart::LINE,
138 std::vector<char>
const &color = std::vector<char>());
151 double x_min,
double x_max,
152 char const *name =
"Y Axis",
153 int num_points = 100,
154 int type = vtkChart::LINE,
155 std::vector<char>
const &color = std::vector<char>());
168 double x_min,
double x_max,
169 char const *name =
"Y Axis",
170 int num_points = 100,
171 int type = vtkChart::LINE,
172 std::vector<char>
const &color = std::vector<char>());
185 double x_min,
double x_max,
186 char const *name =
"Y Axis",
187 int num_points = 100,
188 int type = vtkChart::LINE,
189 std::vector<char>
const &color = std::vector<char>());
197 int type = vtkChart::LINE);
207 int const nbins = 10,
208 char const * name =
"Histogram",
209 std::vector<char>
const &color = std::vector<char>());
219 template <
typename Po
intT>
bool
222 const std::string &
id =
"cloud",
int win_width = 640,
int win_height = 200);
233 const std::string &field_name,
234 const std::string &
id =
"cloud",
int win_width = 640,
int win_height = 200);
244 template <
typename Po
intT>
bool
246 const std::string &field_name,
248 const std::string &
id =
"cloud",
int win_width = 640,
int win_height = 200);
260 const std::string &field_name,
262 const std::string &
id =
"cloud",
int win_width = 640,
int win_height = 200);
408 int win_width_, win_height_;
410 double bkg_color_[3];
411 std::string win_name_;
414 struct ExitMainLoopTimerCallback :
public vtkCommand
416 static ExitMainLoopTimerCallback* New ()
418 return (
new ExitMainLoopTimerCallback);
421 Execute (vtkObject*,
unsigned long event_id,
void* call_data)
override;
424 vtkRenderWindowInteractor *interactor;
427 struct ExitCallback :
public vtkCommand
429 static ExitCallback* New ()
431 return new ExitCallback;
434 Execute (vtkObject*,
unsigned long event_id,
void*)
override;
452 compute (PolynomialFunction
const & p_function,
double val);
459 compute (RationalFunction
const & r_function,
double val);
468 computeHistogram (std::vector<double>
const & data,
int const nbins, std::vector<std::pair<double, double> > &histogram);
473 #include <pcl/visualization/impl/pcl_plotter.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
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.
void setWindowPosition(int x, int y)
Set the position in screen coordinates.
double * getBackgroundColor()
set/get method for the viewport's background color.
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.
std::pair< PolynomialFunction, PolynomialFunction > RationalFunction
A representation of rational function, defined as the ratio of two polynomial functions.
void plot()
Draws all the plots added by addPlotData() or addHistogramData() till now.
void startInteractor()
Initialize and Start the view's interactor.
void setColorScheme(int scheme)
Set method for the color scheme of the plot.
void setWindowName(const std::string &name)
Set the visualizer window name.
void setYTitle(const char *title)
Set the title of the Y-Axis.
void setBackgroundColor(const double r, const double g, const double b)
set/get method for the viewport's background color.
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(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.
void spinOnce(const int spin_time=1)
Spins (runs the event loop) the interactor for spin_time amount of time.
void renderOnce()
Render the vtkWindow once.
void setWindowSize(int w, int h)
set/get method for the window size.
PCLPlotter(char const *name="PCL Plotter")
PCL Plotter constructor.
void setYRange(double min, double max)
Set logical range of the Y-Axis in plot coordinates.
shared_ptr< PCLPlotter > Ptr
void setXRange(double min, double max)
Set logical range of the X-Axis in plot coordinates.
int * getWindowSize() const
set/get method for the window size.
void close()
Stop the interaction and close the visualizaton window.
void setBackgroundColor(const double color[3])
set/get method for the viewport's background color.
std::vector< double > PolynomialFunction
A representation of polynomial function.
void setTitle(const char *title)
Set the main title of the plot.
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 histogra...
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.
vtkSmartPointer< vtkRenderWindow > getRenderWindow()
Return a pointer to the underlying VTK RenderWindow used.
shared_ptr< const PCLPlotter > ConstPtr
bool wasStopped() const
Returns true when the user tried to close the window.
void clearPlots()
Remove all plots from the window.
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 setXTitle(const char *title)
Set the title of the X-Axis.
void setViewInteractor(vtkSmartPointer< vtkRenderWindowInteractor > interactor)
Set the view's interactor.
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 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 spin()
Spins (runs the event loop) the interactor indefinitely.
int getColorScheme()
get the currently used color scheme
void addPlotData(char const *filename, int type=vtkChart::LINE)
Adds a plot based on a space/tab delimited table provided in a file.
void setShowLegend(bool flag)
Shows the legend of the graph.
Defines all the PCL implemented PointT point type structures.