Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
point_picking_event.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef PCL_VISUALIZATION_POINT_PICKING_EVENT_H_
39 #define PCL_VISUALIZATION_POINT_PICKING_EVENT_H_
40 
41 #include <pcl/pcl_macros.h>
42 #include <pcl/visualization/vtk.h>
43 
44 namespace pcl
45 {
46  namespace visualization
47  {
48  class PCL_EXPORTS PointPickingCallback : public vtkCommand
49  {
50  public:
51  static PointPickingCallback *New ()
52  {
53  return (new PointPickingCallback);
54  }
55 
56  PointPickingCallback () : x_ (0), y_ (0), z_ (0), idx_ (-1), pick_first_ (false) {}
57 
58  virtual void
59  Execute (vtkObject *caller, unsigned long eventid, void*);
60 
61  int
62  performSinglePick (vtkRenderWindowInteractor *iren);
63 
64  int
65  performSinglePick (vtkRenderWindowInteractor *iren, float &x, float &y, float &z);
66 
67  private:
68  float x_, y_, z_;
69  int idx_;
70  bool pick_first_;
71  };
72 
75  {
76  public:
77  PointPickingEvent (int idx) : idx_ (idx), idx2_ (-1), x_ (), y_ (), z_ (), x2_ (), y2_ (), z2_ () {}
78  PointPickingEvent (int idx, float x, float y, float z) : idx_ (idx), idx2_ (-1), x_ (x), y_ (y), z_ (z), x2_ (), y2_ (), z2_ () {}
79 
80  PointPickingEvent (int idx1, int idx2, float x1, float y1, float z1, float x2, float y2, float z2) :
81  idx_ (idx1), idx2_ (idx2), x_ (x1), y_ (y1), z_ (z1), x2_ (x2), y2_ (y2), z2_ (z2)
82  {}
83 
85  inline int
86  getPointIndex () const
87  {
88  return (idx_);
89  }
90 
96  inline void
97  getPoint (float &x, float &y, float &z) const
98  {
99  x = x_; y = y_; z = z_;
100  }
101 
111  inline bool
112  getPoints (float &x1, float &y1, float &z1, float &x2, float &y2, float &z2) const
113  {
114  if (idx2_ == -1)
115  return (false);
116  x1 = x_; y1 = y_; z1 = z_;
117  x2 = x2_; y2 = y2_; z2 = z2_;
118  return (true);
119  }
120 
121  private:
122  int idx_, idx2_;
123 
124  float x_, y_, z_;
125  float x2_, y2_, z2_;
126  };
127  } //namespace visualization
128 } //namespace pcl
129 
130 #endif /* PCL_VISUALIZATION_POINT_PICKING_EVENT_H_ */
131