00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef PCL_PCL_HISTOGRAM_VISUALIZER_H_
00038 #define PCL_PCL_HISTOGRAM_VISUALIZER_H_
00039
00040 #include <pcl_visualization/interactor.h>
00041 #include <pcl_visualization/interactor_style.h>
00042 #include <pcl_visualization/common/common.h>
00043 #include <pcl_visualization/common/ren_win_interact_map.h>
00044 #include <vtkCommand.h>
00045 #include <vtkXYPlotActor.h>
00046 #include <vtkTextProperty.h>
00047 #include <vtkProperty2D.h>
00048 #include <vtkFieldData.h>
00049 #include <vtkDoubleArray.h>
00050
00051 namespace pcl_visualization
00052 {
00054
00057 class PCLHistogramVisualizer
00058 {
00059 public:
00061 PCLHistogramVisualizer ();
00062
00068 void spinOnce (int time = 1, bool force_redraw = false);
00069
00071 void spin ();
00072
00079 void setBackgroundColor (const double &r, const double &g, const double &b, int viewport = 0);
00080
00088 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);
00089
00097 bool addFeatureHistogram (const sensor_msgs::PointCloud2 &cloud, const std::string &field_name, const std::string &id = "cloud", int win_width = 640, int win_height = 200);
00098
00103 void setGlobalYRange (float minp, float maxp);
00104
00106 void updateWindowPositions ();
00107
00109 bool wasStopped ();
00111 void resetStoppedFlag ();
00112
00113 private:
00115 RenWinInteractMap wins_;
00116
00117 struct ExitMainLoopTimerCallback : public vtkCommand
00118 {
00119 static ExitMainLoopTimerCallback* New()
00120 {
00121 return new ExitMainLoopTimerCallback;
00122 }
00123 virtual void Execute(vtkObject* vtkNotUsed(caller), unsigned long event_id, void* call_data)
00124 {
00125 if (event_id != vtkCommand::TimerEvent)
00126 return;
00127 int timer_id = *(int*)call_data;
00128
00129 if (timer_id != right_timer_id)
00130 return;
00131
00132
00133 interact->stopLoop ();
00134 }
00135 int right_timer_id;
00136 PCLVisualizerInteractor *interact;
00137 };
00138 struct ExitCallback : public vtkCommand
00139 {
00140 static ExitCallback* New ()
00141 {
00142 return new ExitCallback;
00143 }
00144 virtual void Execute (vtkObject* caller, unsigned long event_id, void* call_data)
00145 {
00146 if (event_id != vtkCommand::ExitEvent)
00147 return;
00148
00149 interact->stopped = true;
00150 }
00151 PCLVisualizerInteractor *interact;
00152 };
00153
00155 vtkSmartPointer<ExitMainLoopTimerCallback> exit_main_loop_timer_callback_;
00156 vtkSmartPointer<ExitCallback> exit_callback_;
00157
00158 };
00159 }
00160
00161 #include "libpcl_visualization/histogram_visualizer.hpp"
00162
00163 #endif