fw4spl
Event.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWRENDERQT_DATA_EVENT_HPP__
8 #define __FWRENDERQT_DATA_EVENT_HPP__
9 
10 #include "fwRenderQt/data/Coord.hpp"
11 #include "fwRenderQt/data/Size.hpp"
12 
13 #include <Qt>
14 
15 namespace fwRenderQt
16 {
17 namespace data
18 {
19 
20 //-----------------------------------------------------------------------------
21 
26 class Event
27 {
28 
29 public:
30 
31  typedef enum
32  {
33  NoType,
34  Resize, // change within the size of the widget/view
35  Viewport, // change within the size of the sene (contained into the widget/view)
36  MouseButtonDoubleClick,
37  MouseButtonPress,
38  MouseButtonRelease,
39  MouseMove,
40  MouseWheelUp,
41  MouseWheelDown,
42  KeyPress,
43  KeyRelease
44  } Type;
45 
46  typedef enum
47  {
48  NoButton,
49  LeftButton,
50  RightButton,
51  MidButton
52  } Button;
53 
54  typedef enum
55  {
56  NoModifier,
57  ShiftModifier,
58  ControlModifier,
59  AltModifier
60  } Modifier;
61 
66  Event() :
67  m_type(NoType),
68  m_button(NoButton),
69  m_modifier(NoModifier),
70  m_accepted(false),
71  m_key(Qt::Key_unknown)
72  {
73  }
74 
75  bool isAccepted() const;
76  void setAccepted(bool accepted);
77 
78  Button getButton() const;
79  void setButton(Button button);
80 
81  const Coord& getCoord() const;
82  void setCoord(const Coord& coord);
83 
84  int getKey() const;
85  void setKey(int key);
86 
87  Modifier getModifier() const;
88  void setModifier(Modifier modifier);
89 
90  const Size& getOldSize() const;
91  void setOldSize(const Size& oldSize);
92 
93  const Size& getSize() const;
94  void setSize(const Size& size);
95 
96  Type getType() const;
97  void setType(Type type);
98 
99 private:
100 
101  Coord m_coord;
102  Type m_type;
103  Button m_button;
104  Modifier m_modifier;
105  Size m_size;
106  Size m_oldSize;
107  bool m_accepted;
108  int m_key;
109 };
110 
111 //------------------------------------------------------------------------------
112 
113 inline bool Event::isAccepted() const
114 {
115  return m_accepted;
116 }
117 
118 //------------------------------------------------------------------------------
119 
120 inline void Event::setAccepted(bool accepted)
121 {
122  m_accepted = accepted;
123 }
124 
125 //------------------------------------------------------------------------------
126 
127 inline Event::Button Event::getButton() const
128 {
129  return m_button;
130 }
131 
132 //------------------------------------------------------------------------------
133 
134 inline void Event::setButton(Button button)
135 {
136  m_button = button;
137 }
138 
139 //------------------------------------------------------------------------------
140 
141 inline const Coord& Event::getCoord() const
142 {
143  return m_coord;
144 }
145 
146 //------------------------------------------------------------------------------
147 
148 inline void Event::setCoord(const Coord& coord)
149 {
150  m_coord = coord;
151 }
152 
153 //------------------------------------------------------------------------------
154 
155 inline int Event::getKey() const
156 {
157  return m_key;
158 }
159 
160 //------------------------------------------------------------------------------
161 
162 inline void Event::setKey(int key)
163 {
164  m_key = key;
165 }
166 
167 //------------------------------------------------------------------------------
168 
169 inline Event::Modifier Event::getModifier() const
170 {
171  return m_modifier;
172 }
173 
174 //------------------------------------------------------------------------------
175 
176 inline void Event::setModifier(Modifier modifier)
177 {
178  m_modifier = modifier;
179 }
180 
181 //------------------------------------------------------------------------------
182 
183 inline const Size& Event::getOldSize() const
184 {
185  return m_oldSize;
186 }
187 
188 //------------------------------------------------------------------------------
189 
190 inline void Event::setOldSize(const Size& oldSize)
191 {
192  m_oldSize = oldSize;
193 }
194 
195 //------------------------------------------------------------------------------
196 
197 inline const Size& Event::getSize() const
198 {
199  return m_size;
200 }
201 
202 //------------------------------------------------------------------------------
203 
204 inline void Event::setSize(const Size& size)
205 {
206  m_size = size;
207 }
208 
209 //------------------------------------------------------------------------------
210 
211 inline Event::Type Event::getType() const
212 {
213  return m_type;
214 }
215 
216 //------------------------------------------------------------------------------
217 
218 inline void Event::setType(Type type)
219 {
220  m_type = type;
221 }
222 
223 } // namespace data
224 } // namespace fwRenderQt
225 
226 #endif // __FWRENDERQT_DATA_EVENT_HPP__
227 
Event()
Constructor.
Definition: Event.hpp:66
Manage the current viewport of the fwRenderQt.
Definition: Viewport.hpp:23
The namespace fwRenderQt contains classes for rendering with Qt.
Definition: Axis.hpp:12
This class manage events on the scene 2D (mouse event, keyboard event , ...).
Definition: Event.hpp:26