Go to the documentation of this file.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
00038
00039 #ifndef PCL_VISUALIZER_WINDOW_H__
00040 #define PCL_VISUALIZER_WINDOW_H__
00041
00042 #include <pcl/pcl_macros.h>
00043 #include <boost/signals2/signal.hpp>
00044
00045 #include <vtkCommand.h>
00046
00047 template <typename T> class vtkSmartPointer;
00048 class vtkObject;
00049 class vtkRenderWindow;
00050 class vtkRenderWindowInteractor;
00051 class vtkCallbackCommand;
00052 class vtkRendererCollection;
00053 class PCLVisualizerInteractorStyle;
00054
00055 namespace pcl
00056 {
00057 namespace visualization
00058 {
00059 class MouseEvent;
00060 class KeyboardEvent;
00061
00062 class PCL_EXPORTS Window
00063 {
00064 public:
00065 Window (const std::string& window_name = "");
00066 Window (const Window &src);
00067 Window& operator = (const Window &src);
00068
00069 virtual ~Window ();
00070
00072 void
00073 spin ();
00074
00080 void
00081 spinOnce (int time = 1, bool force_redraw = false);
00082
00084 bool
00085 wasStopped () const { return (stopped_); }
00086
00093 boost::signals2::connection
00094 registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*),
00095 void* cookie = NULL)
00096 {
00097 return registerKeyboardCallback (boost::bind (callback, _1, cookie));
00098 }
00099
00107 template<typename T> boost::signals2::connection
00108 registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*),
00109 T& instance, void* cookie = NULL)
00110 {
00111 return registerKeyboardCallback (boost::bind (callback, boost::ref (instance), _1, cookie));
00112 }
00113
00120 boost::signals2::connection
00121 registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*),
00122 void* cookie = NULL)
00123 {
00124 return registerMouseCallback (boost::bind (callback, _1, cookie));
00125 }
00126
00134 template<typename T> boost::signals2::connection
00135 registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*),
00136 T& instance, void* cookie = NULL)
00137 {
00138 return registerMouseCallback (boost::bind (callback, boost::ref (instance), _1, cookie));
00139 }
00140
00141 protected:
00142
00144 void
00145 resetStoppedFlag () { stopped_ = false; }
00146
00152 boost::signals2::connection
00153 registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)> );
00154
00160 boost::signals2::connection
00161 registerKeyboardCallback (boost::function<void (const pcl::visualization::KeyboardEvent&)> );
00162
00163 void
00164 emitMouseEvent (unsigned long event_id);
00165
00166 void
00167 emitKeyboardEvent (unsigned long event_id);
00168
00169
00170 static void
00171 MouseCallback (vtkObject*, unsigned long eid, void* clientdata, void *calldata);
00172 static void
00173 KeyboardCallback (vtkObject*, unsigned long eid, void* clientdata, void *calldata);
00174
00175 protected:
00176 struct ExitMainLoopTimerCallback : public vtkCommand
00177 {
00178 static ExitMainLoopTimerCallback* New ()
00179 {
00180 return (new ExitMainLoopTimerCallback);
00181 }
00182
00183 ExitMainLoopTimerCallback ();
00184 ExitMainLoopTimerCallback (const ExitMainLoopTimerCallback& src);
00185 ExitMainLoopTimerCallback& operator = (const ExitMainLoopTimerCallback& src);
00186
00187 virtual void
00188 Execute (vtkObject*, unsigned long event_id, void* call_data);
00189
00190 int right_timer_id;
00191 Window* window;
00192 };
00193
00194 struct ExitCallback : public vtkCommand
00195 {
00196 static ExitCallback* New ()
00197 {
00198 return (new ExitCallback);
00199 }
00200
00201 ExitCallback ();
00202 ExitCallback (const ExitCallback &src);
00203 ExitCallback& operator = (const ExitCallback &src);
00204
00205 virtual void
00206 Execute (vtkObject*, unsigned long event_id, void*);
00207
00208 Window* window;
00209 };
00210
00211 bool stopped_;
00212 int timer_id_;
00213
00214 protected:
00215 boost::signals2::signal<void (const pcl::visualization::MouseEvent&)> mouse_signal_;
00216 boost::signals2::signal<void (const pcl::visualization::KeyboardEvent&)> keyboard_signal_;
00217
00218 vtkSmartPointer<vtkRenderWindow> win_;
00219 vtkSmartPointer<vtkRenderWindowInteractor> interactor_;
00220 vtkCallbackCommand* mouse_command_;
00221 vtkCallbackCommand* keyboard_command_;
00223 vtkSmartPointer<PCLVisualizerInteractorStyle> style_;
00225 vtkSmartPointer<vtkRendererCollection> rens_;
00226 vtkSmartPointer<ExitMainLoopTimerCallback> exit_main_loop_timer_callback_;
00227 vtkSmartPointer<ExitCallback> exit_callback_;
00228 };
00229 }
00230 }
00231
00232 #endif
00233