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


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:15:30