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