|
Point Cloud Library (PCL)
1.5.1
|
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 4702 2012-02-23 09:39:33Z gedikli $ 00037 * 00038 */ 00039 #ifndef PCL_PCL_VISUALIZER_INTERACTOR_STYLE_H_ 00040 #define PCL_PCL_VISUALIZER_INTERACTOR_STYLE_H_ 00041 00042 // VTK includes 00043 #include <vtkSmartPointer.h> 00044 #include <vtkRendererCollection.h> 00045 #include <vtkLegendScaleActor.h> 00046 #include <vtkPNGWriter.h> 00047 #include <vtkWindowToImageFilter.h> 00048 #include <vtkInteractorStyleTrackballCamera.h> 00049 #include <vtkRenderWindowInteractor.h> 00050 #include <vtkRenderWindow.h> 00051 #include <vtkAssemblyPath.h> 00052 #include <vtkCommand.h> 00053 #include <vtkProperty.h> 00054 #include <vtkCamera.h> 00055 #include <vtkObjectFactory.h> 00056 #include <vtkScalarBarActor.h> 00057 #include <vtkScalarsToColors.h> 00058 #include <vtkBoxRepresentation.h> 00059 #include <vtkBoxWidget.h> 00060 #include <vtkBoxWidget2.h> 00061 #include <vtkClipPolyData.h> 00062 #include <vtkPlanes.h> 00063 00064 #include <boost/shared_ptr.hpp> 00065 #include <pcl/console/print.h> 00066 #include <pcl/visualization/common/actor_map.h> 00067 #include <pcl/visualization/common/ren_win_interact_map.h> 00068 #include <boost/shared_ptr.hpp> 00069 #include <boost/signals2.hpp> 00070 //#include <boost/signals2/slot.hpp> 00071 #include <pcl/visualization/keyboard_event.h> 00072 #include <pcl/visualization/mouse_event.h> 00073 #include <pcl/visualization/point_picking_event.h> 00074 00075 namespace pcl 00076 { 00077 namespace visualization 00078 { 00079 00083 enum InteractorKeyboardModifier 00084 { 00085 INTERACTOR_KB_MOD_ALT, 00086 INTERACTOR_KB_MOD_CTRL, 00087 INTERACTOR_KB_MOD_SHIFT 00088 }; 00089 00118 class PCL_EXPORTS PCLVisualizerInteractorStyle : public vtkInteractorStyleTrackballCamera 00119 { 00120 typedef boost::shared_ptr<CloudActorMap> CloudActorMapPtr; 00121 00122 public: 00123 static PCLVisualizerInteractorStyle *New (); 00124 // this macro defines Superclass, the isA functionality and the safe downcast method 00125 vtkTypeMacro (PCLVisualizerInteractorStyle, vtkInteractorStyleTrackballCamera); 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 00151 boost::signals2::connection 00152 registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)> cb); 00153 00158 boost::signals2::connection 00159 registerKeyboardCallback (boost::function<void (const pcl::visualization::KeyboardEvent&)> cb); 00160 00165 boost::signals2::connection 00166 registerPointPickingCallback (boost::function<void (const pcl::visualization::PointPickingEvent&)> cb); 00167 00171 void 00172 saveScreenshot (const std::string &file); 00173 00181 inline void 00182 setKeyboardModifier (const InteractorKeyboardModifier &modifier) 00183 { 00184 modifier_ = modifier; 00185 } 00186 00187 protected: 00189 bool init_; 00190 00192 vtkSmartPointer<vtkRendererCollection> rens_; 00193 00195 CloudActorMapPtr actors_; 00196 00198 int win_height_, win_width_; 00199 00201 int win_pos_x_, win_pos_y_; 00202 00204 int max_win_height_, max_win_width_; 00205 00207 bool grid_enabled_; 00209 vtkSmartPointer<vtkLegendScaleActor> grid_actor_; 00210 00212 bool lut_enabled_; 00214 vtkSmartPointer<vtkScalarBarActor> lut_actor_; 00215 00217 vtkSmartPointer<vtkPNGWriter> snapshot_writer_; 00219 vtkSmartPointer<vtkWindowToImageFilter> wif_; 00220 00221 boost::signals2::signal<void (const pcl::visualization::MouseEvent&)> mouse_signal_; 00222 boost::signals2::signal<void (const pcl::visualization::KeyboardEvent&)> keyboard_signal_; 00223 boost::signals2::signal<void (const pcl::visualization::PointPickingEvent&)> point_picking_signal_; 00224 00226 virtual void 00227 OnChar (); 00228 00229 // Keyboard events 00230 virtual void 00231 OnKeyDown (); 00232 virtual void 00233 OnKeyUp (); 00234 00235 // mouse button events 00236 virtual void 00237 OnMouseMove (); 00238 virtual void 00239 OnLeftButtonDown (); 00240 virtual void 00241 OnLeftButtonUp (); 00242 virtual void 00243 OnMiddleButtonDown (); 00244 virtual void 00245 OnMiddleButtonUp (); 00246 virtual void 00247 OnRightButtonDown (); 00248 virtual void 00249 OnRightButtonUp (); 00250 virtual void 00251 OnMouseWheelForward (); 00252 virtual void 00253 OnMouseWheelBackward (); 00254 00255 // mouse move event 00257 virtual void 00258 OnTimer (); 00259 00261 void 00262 zoomIn (); 00263 00265 void 00266 zoomOut (); 00267 00269 bool stereo_anaglyph_mask_default_; 00270 00272 vtkSmartPointer<PointPickingCallback> mouse_callback_; 00273 00275 InteractorKeyboardModifier modifier_; 00276 00277 friend class PointPickingCallback; 00278 }; 00279 00283 class PCLHistogramVisualizerInteractorStyle : public vtkInteractorStyleTrackballCamera 00284 { 00285 public: 00286 static PCLHistogramVisualizerInteractorStyle *New (); 00287 00289 void 00290 Initialize (); 00291 00295 void 00296 setRenWinInteractMap (const RenWinInteractMap &wins) { wins_ = wins; } 00297 00298 private: 00300 RenWinInteractMap wins_; 00301 00303 bool init_; 00304 00306 void OnKeyDown (); 00307 00309 void OnTimer (); 00310 }; 00311 } 00312 } 00313 00314 #endif
1.8.0