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
00040 #ifndef PCL_PCL_VISUALIZER_INTERACTOR_STYLE_H_
00041 #define PCL_PCL_VISUALIZER_INTERACTOR_STYLE_H_
00042
00043 #include <pcl/console/print.h>
00044 #include <pcl/visualization/common/actor_map.h>
00045 #include <pcl/visualization/common/ren_win_interact_map.h>
00046 #include <pcl/visualization/keyboard_event.h>
00047 #include <pcl/visualization/mouse_event.h>
00048 #include <pcl/visualization/point_picking_event.h>
00049 #include <pcl/visualization/area_picking_event.h>
00050 #include <boost/signals2/signal.hpp>
00051
00052 #include <vtkInteractorStyleRubberBandPick.h>
00053
00054 class vtkRendererCollection;
00055 class vtkLegendScaleActor;
00056 class vtkScalarBarActor;
00057 class vtkPNGWriter;
00058 class vtkWindowToImageFilter;
00059 class vtkPointPicker;
00060
00061 namespace pcl
00062 {
00063 namespace visualization
00064 {
00065
00069 enum InteractorKeyboardModifier
00070 {
00071 INTERACTOR_KB_MOD_ALT,
00072 INTERACTOR_KB_MOD_CTRL,
00073 INTERACTOR_KB_MOD_SHIFT
00074 };
00075
00105 class PCL_EXPORTS PCLVisualizerInteractorStyle : public vtkInteractorStyleRubberBandPick
00106 {
00107 typedef boost::shared_ptr<CloudActorMap> CloudActorMapPtr;
00108
00109 public:
00110 static PCLVisualizerInteractorStyle *New ();
00111
00113 PCLVisualizerInteractorStyle () :
00114 init_ (), rens_ (), actors_ (), win_height_ (), win_width_ (), win_pos_x_ (), win_pos_y_ (),
00115 max_win_height_ (), max_win_width_ (), grid_enabled_ (), grid_actor_ (), lut_enabled_ (),
00116 lut_actor_ (), snapshot_writer_ (), wif_ (), mouse_signal_ (), keyboard_signal_ (),
00117 point_picking_signal_ (), area_picking_signal_ (), stereo_anaglyph_mask_default_ (),
00118 mouse_callback_ (), modifier_ ()
00119 {}
00120
00122 virtual ~PCLVisualizerInteractorStyle () {}
00123
00124
00125 vtkTypeMacro (PCLVisualizerInteractorStyle, vtkInteractorStyleRubberBandPick);
00126
00128 virtual void
00129 Initialize ();
00130
00134 inline void
00135 setCloudActorMap (const CloudActorMapPtr &actors) { actors_ = actors; }
00136
00138 inline CloudActorMapPtr
00139 getCloudActorMap () { return (actors_); }
00140
00144 void
00145 setRendererCollection (vtkSmartPointer<vtkRendererCollection> &rens) { rens_ = rens; }
00146
00150 inline void
00151 setUseVbos (const bool use_vbos) { use_vbos_ = use_vbos; }
00152
00157 boost::signals2::connection
00158 registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)> cb);
00159
00164 boost::signals2::connection
00165 registerKeyboardCallback (boost::function<void (const pcl::visualization::KeyboardEvent&)> cb);
00166
00171 boost::signals2::connection
00172 registerPointPickingCallback (boost::function<void (const pcl::visualization::PointPickingEvent&)> cb);
00173
00178 boost::signals2::connection
00179 registerAreaPickingCallback (boost::function<void (const pcl::visualization::AreaPickingEvent&)> cb);
00180
00184 void
00185 saveScreenshot (const std::string &file);
00186
00194 inline void
00195 setKeyboardModifier (const InteractorKeyboardModifier &modifier)
00196 {
00197 modifier_ = modifier;
00198 }
00199
00200 protected:
00202 bool init_;
00203
00205 vtkSmartPointer<vtkRendererCollection> rens_;
00206
00208 CloudActorMapPtr actors_;
00209
00211 int win_height_, win_width_;
00212
00214 int win_pos_x_, win_pos_y_;
00215
00217 int max_win_height_, max_win_width_;
00218
00220 bool use_vbos_;
00221
00223 bool grid_enabled_;
00225 vtkSmartPointer<vtkLegendScaleActor> grid_actor_;
00226
00228 bool lut_enabled_;
00230 vtkSmartPointer<vtkScalarBarActor> lut_actor_;
00231
00233 vtkSmartPointer<vtkPNGWriter> snapshot_writer_;
00235 vtkSmartPointer<vtkWindowToImageFilter> wif_;
00237 vtkSmartPointer<vtkPointPicker> point_picker_;
00238
00239 boost::signals2::signal<void (const pcl::visualization::MouseEvent&)> mouse_signal_;
00240 boost::signals2::signal<void (const pcl::visualization::KeyboardEvent&)> keyboard_signal_;
00241 boost::signals2::signal<void (const pcl::visualization::PointPickingEvent&)> point_picking_signal_;
00242 boost::signals2::signal<void (const pcl::visualization::AreaPickingEvent&)> area_picking_signal_;
00243
00245 virtual void
00246 OnChar ();
00247
00248
00249 virtual void
00250 OnKeyDown ();
00251 virtual void
00252 OnKeyUp ();
00253
00254
00255 virtual void
00256 OnMouseMove ();
00257 virtual void
00258 OnLeftButtonDown ();
00259 virtual void
00260 OnLeftButtonUp ();
00261 virtual void
00262 OnMiddleButtonDown ();
00263 virtual void
00264 OnMiddleButtonUp ();
00265 virtual void
00266 OnRightButtonDown ();
00267 virtual void
00268 OnRightButtonUp ();
00269 virtual void
00270 OnMouseWheelForward ();
00271 virtual void
00272 OnMouseWheelBackward ();
00273
00274
00276 virtual void
00277 OnTimer ();
00278
00280 void
00281 zoomIn ();
00282
00284 void
00285 zoomOut ();
00286
00288 bool stereo_anaglyph_mask_default_;
00289
00291 vtkSmartPointer<PointPickingCallback> mouse_callback_;
00292
00294 InteractorKeyboardModifier modifier_;
00295
00296 friend class PointPickingCallback;
00297 };
00298
00302 class PCLHistogramVisualizerInteractorStyle : public vtkInteractorStyleTrackballCamera
00303 {
00304 public:
00305 static PCLHistogramVisualizerInteractorStyle *New ();
00306
00308 PCLHistogramVisualizerInteractorStyle () : wins_ (), init_ (false) {}
00309
00311 void
00312 Initialize ();
00313
00317 void
00318 setRenWinInteractMap (const RenWinInteractMap &wins) { wins_ = wins; }
00319
00320 private:
00322 RenWinInteractMap wins_;
00323
00325 bool init_;
00326
00328 void OnKeyDown ();
00329
00331 void OnTimer ();
00332 };
00333 }
00334 }
00335
00336 #endif