Point Cloud Library (PCL)  1.8.0
mouse_event.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2011, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
38 
39 #ifndef PCL_VISUALIZATION_MOUSE_EVENT_H_
40 #define PCL_VISUALIZATION_MOUSE_EVENT_H_
41 
42 #include <pcl/visualization/keyboard_event.h>
43 
44 namespace pcl
45 {
46  namespace visualization
47  {
48  class MouseEvent
49  {
50  public:
51  typedef enum
52  {
53  MouseMove = 1,
59  } Type;
60 
61  typedef enum
62  {
63  NoButton = 0,
67  VScroll /*other buttons, scroll wheels etc. may follow*/
68  } MouseButton;
69 
70  /** Constructor.
71  * \param[in] type event type
72  * \param[in] button The Button that causes the event
73  * \param[in] x x position of mouse pointer at that time where event got fired
74  * \param[in] y y position of mouse pointer at that time where event got fired
75  * \param[in] alt whether the ALT key was pressed at that time where event got fired
76  * \param[in] ctrl whether the CTRL key was pressed at that time where event got fired
77  * \param[in] shift whether the Shift key was pressed at that time where event got fired
78  * \param[in] selection_mode whether we are in selection mode
79  */
80  inline MouseEvent (const Type& type, const MouseButton& button,
81  unsigned int x, unsigned int y,
82  bool alt, bool ctrl, bool shift,
83  bool selection_mode = false);
84 
85  /**
86  * \return type of mouse event
87  */
88  inline const Type&
89  getType () const;
90 
91  /**
92  * \brief Sets the mouse event type
93  */
94  inline void
95  setType (const Type& type);
96 
97  /**
98  * \return the Button that caused the action
99  */
100  inline const MouseButton&
101  getButton () const;
102 
103  /** \brief Set the button that caused the event */
104  inline void
105  setButton (const MouseButton& button);
106 
107  /**
108  * \return the x position of the mouse pointer at that time where the event got fired
109  */
110  inline unsigned int
111  getX () const;
112 
113  /**
114  * \return the y position of the mouse pointer at that time where the event got fired
115  */
116  inline unsigned int
117  getY () const;
118 
119  /**
120  * \return returns the keyboard modifiers state at that time where the event got fired
121  */
122  inline unsigned int
123  getKeyboardModifiers () const;
124 
125  /**
126  * \return selection mode status
127  */
128  inline bool
129  getSelectionMode () const;
130 
131  protected:
132  Type type_;
133  MouseButton button_;
134  unsigned int pointer_x_;
135  unsigned int pointer_y_;
136  unsigned int key_state_;
138  };
139 
140  MouseEvent::MouseEvent (const Type& type, const MouseButton& button,
141  unsigned x, unsigned y,
142  bool alt, bool ctrl, bool shift,
143  bool selection_mode)
144  : type_ (type)
145  , button_ (button)
146  , pointer_x_ (x)
147  , pointer_y_ (y)
148  , key_state_ (0)
149  , selection_mode_ (selection_mode)
150  {
151  if (alt)
153 
154  if (ctrl)
156 
157  if (shift)
159  }
160 
161  const MouseEvent::Type&
163  {
164  return (type_);
165  }
166 
167  void
168  MouseEvent::setType (const Type& type)
169  {
170  type_ = type;
171  }
172 
175  {
176  return (button_);
177  }
178 
179  void
181  {
182  button_ = button;
183  }
184 
185  unsigned int
187  {
188  return (pointer_x_);
189  }
190 
191  unsigned int
193  {
194  return (pointer_y_);
195  }
196 
197  unsigned int
199  {
200  return (key_state_);
201  }
202 
203  bool
205  {
206  return (selection_mode_);
207  }
208 
209  } //namespace visualization
210 } //namespace pcl
211 
212 #endif /* PCL_VISUALIZATION_MOUSE_EVENT_H_ */
213 
unsigned int getY() const
Definition: mouse_event.h:192
unsigned int getKeyboardModifiers() const
Definition: mouse_event.h:198
const Type & getType() const
Definition: mouse_event.h:162
unsigned int getX() const
Definition: mouse_event.h:186
static const unsigned int Shift
bit patter for the Shift key
MouseEvent(const Type &type, const MouseButton &button, unsigned int x, unsigned int y, bool alt, bool ctrl, bool shift, bool selection_mode=false)
Constructor.
Definition: mouse_event.h:140
void setButton(const MouseButton &button)
Set the button that caused the event.
Definition: mouse_event.h:180
const MouseButton & getButton() const
Definition: mouse_event.h:174
static const unsigned int Ctrl
bit patter for the Control key
static const unsigned int Alt
bit patter for the ALT key
void setType(const Type &type)
Sets the mouse event type.
Definition: mouse_event.h:168