Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cloud_viewer.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  */
36 #ifndef PCL_CLOUD_VIEWER_H_
37 #define PCL_CLOUD_VIEWER_H_
38 
39 #include <pcl/visualization/pcl_visualizer.h> //pcl vis
40 #include <pcl/point_cloud.h> //basic pcl includes
41 #include <pcl/point_types.h>
42 
43 #include <boost/function.hpp>
44 
45 #include <string>
46 
47 namespace pcl
48 {
49  namespace visualization
50  {
55  class PCL_EXPORTS CloudViewer : boost::noncopyable
56  {
57  public:
62 
66  CloudViewer (const std::string& window_name);
67 
72  ~CloudViewer ();
73 
78  void
79  showCloud (const ColorCloud::ConstPtr &cloud, const std::string& cloudname = "cloud");
80 
85  void
86  showCloud (const ColorACloud::ConstPtr &cloud, const std::string& cloudname = "cloud");
87 
92  void
93  showCloud (const GrayCloud::ConstPtr &cloud, const std::string& cloudname = "cloud");
94 
95 
100  void
101  showCloud (const MonochromeCloud::ConstPtr &cloud, const std::string& cloudname = "cloud");
102 
107  bool
108  wasStopped (int millis_to_wait = 1);
109 
112  typedef boost::function1<void, pcl::visualization::PCLVisualizer&> VizCallable;
113 
118  void
119  runOnVisualizationThread (VizCallable x, const std::string& key = "callable");
120 
124  void
125  runOnVisualizationThreadOnce (VizCallable x);
126 
130  void
131  removeVisualizationCallable (const std::string& key = "callable");
132 
138  inline boost::signals2::connection
139  registerKeyboardCallback (void (*callback) (const pcl::visualization::KeyboardEvent&, void*), void* cookie = NULL)
140  {
141  return (registerKeyboardCallback (boost::bind (callback, _1, cookie)));
142  }
143 
150  template<typename T> inline boost::signals2::connection
151  registerKeyboardCallback (void (T::*callback) (const pcl::visualization::KeyboardEvent&, void*), T& instance, void* cookie = NULL)
152  {
153  return (registerKeyboardCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
154  }
155 
161  inline boost::signals2::connection
162  registerMouseCallback (void (*callback) (const pcl::visualization::MouseEvent&, void*), void* cookie = NULL)
163  {
164  return (registerMouseCallback (boost::bind (callback, _1, cookie)));
165  }
166 
173  template<typename T> inline boost::signals2::connection
174  registerMouseCallback (void (T::*callback) (const pcl::visualization::MouseEvent&, void*), T& instance, void* cookie = NULL)
175  {
176  return (registerMouseCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
177  }
178 
179 
185  inline boost::signals2::connection
186  registerPointPickingCallback (void (*callback) (const pcl::visualization::PointPickingEvent&, void*), void* cookie = NULL)
187  {
188  return (registerPointPickingCallback (boost::bind (callback, _1, cookie)));
189  }
190 
197  template<typename T> inline boost::signals2::connection
198  registerPointPickingCallback (void (T::*callback) (const pcl::visualization::PointPickingEvent&, void*), T& instance, void* cookie = NULL)
199  {
200  return (registerPointPickingCallback (boost::bind (callback, boost::ref (instance), _1, cookie)));
201  }
202 
203  private:
205  struct CloudViewer_impl;
206  std::auto_ptr<CloudViewer_impl> impl_;
207 
208  boost::signals2::connection
209  registerMouseCallback (boost::function<void (const pcl::visualization::MouseEvent&)>);
210 
211  boost::signals2::connection
212  registerKeyboardCallback (boost::function<void (const pcl::visualization::KeyboardEvent&)>);
213 
214  boost::signals2::connection
215  registerPointPickingCallback (boost::function<void (const pcl::visualization::PointPickingEvent&)>);
216  };
217  }
218 }
219 
220 #endif /* CLOUD_VIEWER_H_ */