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_PCL_VISUALIZER_INTERACTOR_STYLE_H_
00040 #define PCL_PCL_VISUALIZER_INTERACTOR_STYLE_H_
00041
00042 #include <pcl/visualization/vtk.h>
00043 #include <boost/shared_ptr.hpp>
00044 #include <pcl/console/print.h>
00045 #include <pcl/visualization/common/actor_map.h>
00046 #include <pcl/visualization/common/ren_win_interact_map.h>
00047 #include <boost/shared_ptr.hpp>
00048 #include <boost/signals2.hpp>
00049 #include <pcl/visualization/keyboard_event.h>
00050 #include <pcl/visualization/mouse_event.h>
00051 #include <pcl/visualization/point_picking_event.h>
00052
00053 namespace pcl
00054 {
00055 namespace visualization
00056 {
00057
00061 enum InteractorKeyboardModifier
00062 {
00063 INTERACTOR_KB_MOD_ALT,
00064 INTERACTOR_KB_MOD_CTRL,
00065 INTERACTOR_KB_MOD_SHIFT
00066 };
00067
00096 class PCL_EXPORTS PCLVisualizerInteractorStyle : public vtkInteractorStyleTrackballCamera
00097 {
00098 typedef boost::shared_ptr<CloudActorMap> CloudActorMapPtr;
00099
00100 public:
00101 static PCLVisualizerInteractorStyle *New ();
00102
00104 PCLVisualizerInteractorStyle () :
00105 init_ (), rens_ (), actors_ (), win_height_ (), win_width_ (), win_pos_x_ (), win_pos_y_ (),
00106 max_win_height_ (), max_win_width_ (), grid_enabled_ (), grid_actor_ (), lut_enabled_ (),
00107 lut_actor_ (), snapshot_writer_ (), wif_ (), mouse_signal_ (), keyboard_signal_ (),
00108 point_picking_signal_ (), stereo_anaglyph_mask_default_ (), mouse_callback_ (), modifier_ ()
00109 {}
00110
00111
00112 vtkTypeMacro (PCLVisualizerInteractorStyle, vtkInteractorStyleTrackballCamera);
00113
00115 virtual void
00116 Initialize ();
00117
00121 inline void
00122 setCloudActorMap (const CloudActorMapPtr &actors) { actors_ = actors; }
00123
00125 inline CloudActorMapPtr
00126 getCloudActorMap () { return (actors_); }
00127
00131 void
00132 setRendererCollection (vtkSmartPointer<vtkRendererCollection> &rens) { rens_ = rens; }
00133
00138 boost::signals2::connection
00139 registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)> cb);
00140
00145 boost::signals2::connection
00146 registerKeyboardCallback (boost::function<void (const pcl::visualization::KeyboardEvent&)> cb);
00147
00152 boost::signals2::connection
00153 registerPointPickingCallback (boost::function<void (const pcl::visualization::PointPickingEvent&)> cb);
00154
00158 void
00159 saveScreenshot (const std::string &file);
00160
00168 inline void
00169 setKeyboardModifier (const InteractorKeyboardModifier &modifier)
00170 {
00171 modifier_ = modifier;
00172 }
00173
00174 protected:
00176 bool init_;
00177
00179 vtkSmartPointer<vtkRendererCollection> rens_;
00180
00182 CloudActorMapPtr actors_;
00183
00185 int win_height_, win_width_;
00186
00188 int win_pos_x_, win_pos_y_;
00189
00191 int max_win_height_, max_win_width_;
00192
00194 bool grid_enabled_;
00196 vtkSmartPointer<vtkLegendScaleActor> grid_actor_;
00197
00199 bool lut_enabled_;
00201 vtkSmartPointer<vtkScalarBarActor> lut_actor_;
00202
00204 vtkSmartPointer<vtkPNGWriter> snapshot_writer_;
00206 vtkSmartPointer<vtkWindowToImageFilter> wif_;
00207
00208 boost::signals2::signal<void (const pcl::visualization::MouseEvent&)> mouse_signal_;
00209 boost::signals2::signal<void (const pcl::visualization::KeyboardEvent&)> keyboard_signal_;
00210 boost::signals2::signal<void (const pcl::visualization::PointPickingEvent&)> point_picking_signal_;
00211
00213 virtual void
00214 OnChar ();
00215
00216
00217 virtual void
00218 OnKeyDown ();
00219 virtual void
00220 OnKeyUp ();
00221
00222
00223 virtual void
00224 OnMouseMove ();
00225 virtual void
00226 OnLeftButtonDown ();
00227 virtual void
00228 OnLeftButtonUp ();
00229 virtual void
00230 OnMiddleButtonDown ();
00231 virtual void
00232 OnMiddleButtonUp ();
00233 virtual void
00234 OnRightButtonDown ();
00235 virtual void
00236 OnRightButtonUp ();
00237 virtual void
00238 OnMouseWheelForward ();
00239 virtual void
00240 OnMouseWheelBackward ();
00241
00242
00244 virtual void
00245 OnTimer ();
00246
00248 void
00249 zoomIn ();
00250
00252 void
00253 zoomOut ();
00254
00256 bool stereo_anaglyph_mask_default_;
00257
00259 vtkSmartPointer<PointPickingCallback> mouse_callback_;
00260
00262 InteractorKeyboardModifier modifier_;
00263
00264 friend class PointPickingCallback;
00265 vtkSmartPointer<vtkPolyData> full_data_;
00266 };
00267
00271 class PCLHistogramVisualizerInteractorStyle : public vtkInteractorStyleTrackballCamera
00272 {
00273 public:
00274 static PCLHistogramVisualizerInteractorStyle *New ();
00275
00277 PCLHistogramVisualizerInteractorStyle () : wins_ (), init_ (false) {}
00278
00280 void
00281 Initialize ();
00282
00286 void
00287 setRenWinInteractMap (const RenWinInteractMap &wins) { wins_ = wins; }
00288
00289 private:
00291 RenWinInteractMap wins_;
00292
00294 bool init_;
00295
00297 void OnKeyDown ();
00298
00300 void OnTimer ();
00301 };
00302 }
00303 }
00304
00305 #endif