Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mouse_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) 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  * Author: Suat Gedikli (gedikli@willowgarage.com)
37  *
38  */
39 
40 #ifndef PCL_VISUALIZATION_MOUSE_EVENT_H_
41 #define PCL_VISUALIZATION_MOUSE_EVENT_H_
42 
43 #include "keyboard_event.h"
44 
45 namespace pcl
46 {
47  namespace visualization
48  {
49  class MouseEvent
50  {
51  public:
52  typedef enum
53  {
54  MouseMove = 1,
60  } Type;
61 
62  typedef enum
63  {
64  NoButton = 0,
68  VScroll /*other buttons, scroll wheels etc. may follow*/
69  } MouseButton;
70 
80  inline MouseEvent (const Type& type, const MouseButton& button,
81  unsigned int x, unsigned int y,
82  bool alt, bool ctrl, bool shift);
83 
87  inline const Type&
88  getType () const;
89 
93  inline void
94  setType (const Type& type);
95 
99  inline const MouseButton&
100  getButton () const;
101 
103  inline void
104  setButton (const MouseButton& button);
105 
109  inline unsigned int
110  getX () const;
111 
115  inline unsigned int
116  getY () const;
117 
121  inline unsigned int
122  getKeyboardModifiers () const;
123 
124  protected:
125  Type type_;
126  MouseButton button_;
127  unsigned int pointer_x_;
128  unsigned int pointer_y_;
129  unsigned int key_state_;
130  };
131 
132  MouseEvent::MouseEvent (const Type& type, const MouseButton& button,
133  unsigned x, unsigned y,
134  bool alt, bool ctrl, bool shift)
135  : type_ (type)
136  , button_ (button)
137  , pointer_x_ (x)
138  , pointer_y_ (y)
139  , key_state_ (0)
140  {
141  if (alt)
142  key_state_ = KeyboardEvent::Alt;
143 
144  if (ctrl)
145  key_state_ |= KeyboardEvent::Ctrl;
146 
147  if (shift)
148  key_state_ |= KeyboardEvent::Shift;
149  }
150 
151  const MouseEvent::Type&
153  {
154  return (type_);
155  }
156 
157  void
158  MouseEvent::setType (const Type& type)
159  {
160  type_ = type;
161  }
162 
165  {
166  return (button_);
167  }
168 
169  void
171  {
172  button_ = button;
173  }
174 
175  unsigned int
177  {
178  return (pointer_x_);
179  }
180 
181  unsigned int
183  {
184  return (pointer_y_);
185  }
186 
187  unsigned int
189  {
190  return (key_state_);
191  }
192 
193  } //namespace visualization
194 } //namespace pcl
195 
196 #endif /* PCL_VISUALIZATION_MOUSE_EVENT_H_ */
197