45 #include <pcl/visualization/common/common.h>
47 #include <pcl/correspondence.h>
48 #include <pcl/point_cloud.h>
49 #include <pcl/common/io.h>
51 #include <vtkContextView.h>
52 #include <vtkChartXY.h>
53 #include <vtkColorSeries.h>
54 #include <vtkSmartPointer.h>
55 #include <vtkCommand.h>
58 class vtkRenderWindow;
59 class vtkRenderWindowInteractor;
63 namespace visualization
78 using Ptr = shared_ptr<PCLPlotter>;
107 double const *array_Y,
109 char const * name =
"Y Axis",
110 int type = vtkChart::LINE ,
111 char const *color=
nullptr);
122 std::vector<double>
const &array_y,
123 char const * name =
"Y Axis",
124 int type = vtkChart::LINE,
125 std::vector<char>
const &color = std::vector<char> ());
134 addPlotData (std::vector<std::pair<double, double> >
const &plot_data,
135 char const * name =
"Y Axis",
136 int type = vtkChart::LINE,
137 std::vector<char>
const &color = std::vector<char>());
150 double x_min,
double x_max,
151 char const *name =
"Y Axis",
152 int num_points = 100,
153 int type = vtkChart::LINE,
154 std::vector<char>
const &color = std::vector<char>());
167 double x_min,
double x_max,
168 char const *name =
"Y Axis",
169 int num_points = 100,
170 int type = vtkChart::LINE,
171 std::vector<char>
const &color = std::vector<char>());
184 double x_min,
double x_max,
185 char const *name =
"Y Axis",
186 int num_points = 100,
187 int type = vtkChart::LINE,
188 std::vector<char>
const &color = std::vector<char>());
196 int type = vtkChart::LINE);
206 int const nbins = 10,
207 char const * name =
"Histogram",
208 std::vector<char>
const &color = std::vector<char>());
218 template <
typename Po
intT>
bool
221 const std::string &
id =
"cloud",
int win_width = 640,
int win_height = 200);
232 const std::string &field_name,
233 const std::string &
id =
"cloud",
int win_width = 640,
int win_height = 200);
243 template <
typename Po
intT>
bool
245 const std::string &field_name,
247 const std::string &
id =
"cloud",
int win_width = 640,
int win_height = 200);
259 const std::string &field_name,
261 const std::string &
id =
"cloud",
int win_width = 640,
int win_height = 200);
407 int win_width_, win_height_;
409 double bkg_color_[3];
410 std::string win_name_;
413 struct ExitMainLoopTimerCallback :
public vtkCommand
415 static ExitMainLoopTimerCallback* New ()
417 return (
new ExitMainLoopTimerCallback);
420 Execute (vtkObject*,
unsigned long event_id,
void* call_data)
override;
423 vtkRenderWindowInteractor *interactor;
426 struct ExitCallback :
public vtkCommand
428 static ExitCallback* New ()
430 return new ExitCallback;
433 Execute (vtkObject*,
unsigned long event_id,
void*)
override;
451 compute (PolynomialFunction
const & p_function,
double val);
458 compute (RationalFunction
const & r_function,
double val);
467 computeHistogram (std::vector<double>
const & data,
int const nbins, std::vector<std::pair<double, double> > &histogram);
472 #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.
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.
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 visualization 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.
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.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.