interactor_style.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2011, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  * $Id$
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         // this macro defines Superclass, the isA functionality and the safe downcast method
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         // Keyboard events
00249         virtual void 
00250         OnKeyDown ();
00251         virtual void 
00252         OnKeyUp ();
00253         
00254         // mouse button events
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         // mouse move event
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


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:25:02