$search
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * $Id: pcl_histogram_visualizer.h 31709 2010-08-11 08:11:54Z rusu $ 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 // Stop vtk loop and send notification to app to wake it up 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