Point Cloud Library (PCL)  1.3.1
point_picking_event.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  */
00037 
00038 #ifndef PCL_VISUALIZATION_POINT_PICKING_EVENT_H_
00039 #define PCL_VISUALIZATION_POINT_PICKING_EVENT_H_
00040 
00041 #include <pcl/pcl_macros.h>
00042 #include <vtkRenderWindowInteractor.h>
00043 #include <vtkCommand.h>
00044 
00045 namespace pcl
00046 {
00047   namespace visualization
00048   {
00049     class PCL_EXPORTS PointPickingCallback : public vtkCommand
00050     {
00051       public:
00052         static PointPickingCallback *New () 
00053         { 
00054           return (new PointPickingCallback); 
00055         }
00056 
00057         PointPickingCallback () : x_ (0), y_ (0), z_ (0), idx_ (-1), pick_first_ (false) {}
00058 
00059         virtual void
00060         Execute (vtkObject *caller, unsigned long eventid, void*);
00061 
00062         int
00063         performSinglePick (vtkRenderWindowInteractor *iren);
00064 
00065         int
00066         performSinglePick (vtkRenderWindowInteractor *iren, float &x, float &y, float &z);
00067 
00068       private:
00069         float x_, y_, z_;
00070         int idx_;
00071         bool pick_first_;
00072      };
00073 
00075     class PCL_EXPORTS PointPickingEvent
00076     {
00077       public:
00078         PointPickingEvent (int idx) : idx_ (idx), idx2_ (-1) {}
00079         PointPickingEvent (int idx, float x, float y, float z) : idx_ (idx), idx2_ (-1), x_ (x), y_ (y), z_ (z) {}
00080 
00081         PointPickingEvent (int idx1, int idx2, float x1, float y1, float z1, float x2, float y2, float z2) :
00082           idx_ (idx1), idx2_ (idx2), x_ (x1), y_ (y1), z_ (z1), x2_ (x2), y2_ (y2), z2_ (z2) 
00083         {}
00084 
00086         inline int
00087         getPointIndex () const
00088         {
00089           return (idx_);
00090         }
00091 
00097         inline void
00098         getPoint (float &x, float &y, float &z) const
00099         {
00100           x = x_; y = y_; z = z_;
00101         }
00102 
00112         inline bool
00113         getPoints (float &x1, float &y1, float &z1, float &x2, float &y2, float &z2) const
00114         {
00115           if (idx2_ == -1)
00116             return (false);
00117           x1 = x_; y1 = y_; z1 = z_;
00118           x2 = x2_; y2 = y2_; z2 = z2_;
00119           return (true);
00120         }
00121 
00122       private:
00123         int idx_, idx2_;
00124 
00125         float x_, y_, z_;
00126         float x2_, y2_, z2_;
00127     };
00128   } //namespace visualization
00129 } //namespace pcl
00130 
00131 #endif  /* PCL_VISUALIZATION_POINT_PICKING_EVENT_H_ */
00132 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines