cc7b90167c1a65ae0c3a64c7da7b51698ac62a5f
[pcl.git] /
1 /*
2  * Software License Agreement  (BSD License)
3  *
4  *  Point Cloud Library  (PCL) - www.pointclouds.org
5  *  Copyright  (c) 2012, Jeremie Papon.
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 #pragma once
39
40 #include <pcl/apps/cloud_composer/point_selectors/interactor_style_switch.h>
41
42 namespace pcl
43 {
44   namespace cloud_composer
45   {
46       
47     class ClickTrackballStyleInteractor : public vtkInteractorStyleTrackballActor
48     {     
49       public:
50         static ClickTrackballStyleInteractor* New();
51         vtkTypeMacro(ClickTrackballStyleInteractor,vtkInteractorStyleTrackballActor);
52         
53         ClickTrackballStyleInteractor ();
54         
55         ~ClickTrackballStyleInteractor ();
56                
57         /** \brief Pass a pointer to the actor map
58           * \param[in] actors the actor map that will be used with this style
59           */
60         inline void 
61         setCloudActorMap (const pcl::visualization::CloudActorMapPtr &actors) { actors_ = actors; }
62
63         /** \brief Get the cloud actor map pointer. */
64         inline pcl::visualization::CloudActorMapPtr 
65         getCloudActorMap () const { return (actors_); }
66
67         /** \brief Pass a set of renderers to the interactor style. 
68           * \param[in] rens the vtkRendererCollection to use
69           */
70         void 
71         setRendererCollection (vtkSmartPointer<vtkRendererCollection> &rens) { renderers_ = rens; }
72
73         /** \brief Function called on left mouse button release, ie, end of rectangular drag */
74         void
75         OnLeftButtonDown () override;
76         
77         /** \brief Function called on left mouse button release, ie, end of rectangular drag */
78         void
79         OnLeftButtonUp () override;
80         
81         void
82         OnRightButtonDown () override;
83         
84         void
85         OnRightButtonUp () override;
86
87         /** \brief Event emitted once a valid selection has been made */
88         int manipulation_complete_event_;
89         
90         inline void 
91         setProjectModel (ProjectModel* model) { model_ = model; }
92       private:
93
94         
95         /** \brief Actor map stored internally. */
96         pcl::visualization::CloudActorMapPtr actors_;
97         
98         /** \brief Collection of vtkRenderers stored internally. */
99         vtkSmartPointer<vtkRendererCollection> renderers_;
100         
101         /** \brief Internal Pointer to Project Model */
102         ProjectModel* model_;
103         
104         vtkSmartPointer<vtkMatrix4x4> start_matrix_;
105         vtkSmartPointer<vtkMatrix4x4> end_matrix_;
106         
107         vtkSmartPointer<vtkTransform> transform_;
108           
109     };
110     
111   }
112   
113 }