Image Component Library (ICL)
MouseEvent.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLQt/src/ICLQt/MouseEvent.h **
10 ** Module : ICLQt **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Point.h>
35 #include <ICLUtils/Point32f.h>
36 #include <ICLCore/Img.h>
37 #include <QtCore/Qt>
38 #include <vector>
39 
40 namespace icl{
41  namespace qt{
42 
44  class ICLWidget;
47  enum MouseEventType {
57  };
58 
60 
67  };
68 
77  };
78 
80 
89 
92 
95 
98 
101 
103  bool m_downMask[3];
104 
106  std::vector<double> m_color;
107 
110 
113 
116 
117  public:
118 
120  MouseEvent(const utils::Point &widgetPos,
121  const utils::Point &imagePos,
122  const utils::Point32f &imagePos32f,
123  const utils::Point32f &relImagePos,
124  const bool downMask[3],
125  const std::vector<double> &color,
126  const utils::Point &wheelDelta,
127  MouseEventType type,
128  ICLWidget *widget);
129 
130 
132  MouseEvent();
133 
135  inline int getWidgetX() const { return m_widgetPos.x; }
136 
138  inline int getWidgetY() const { return m_widgetPos.y; }
139 
141  inline const utils::Point &getWidgetPos() const { return m_widgetPos; }
142 
144  inline int getX() const { return m_imagePos.x; }
145 
147  inline int getY() const { return m_imagePos.y; }
148 
150  inline const utils::Point &getPos() const { return m_imagePos; }
151 
153  inline float getX32f() const { return m_imagePos32f.x; }
154 
156  inline float getY32f() const { return m_imagePos32f.y; }
157 
159  inline const utils::Point32f &getPos32f() const { return m_imagePos32f; }
160 
162 
170  inline const utils::Point &getWheelDelta() const { return m_wheelDelta; }
171 
173  inline float getRelX() const { return m_relImagePos.x; }
174 
176  inline float getRelY() const { return m_relImagePos.y; }
177 
179  inline const utils::Point32f getRelPos() const { return m_relImagePos; }
180 
182  inline const std::vector<double> &getColor() const { return m_color; }
183 
185  inline bool hitImage() const { return m_color.size(); }
186 
188  inline std::vector<bool> getDownMask() const { return std::vector<bool>(m_downMask,m_downMask+3); }
189 
191  inline bool isLeft() const { return m_downMask[LeftMouseButton]; }
192 
194  inline bool isMiddle() const { return m_downMask[MiddleMouseButton]; }
195 
197  inline bool isRight() const { return m_downMask[RightMouseButton]; }
198 
200  inline bool isLeftOnly() const { return (isLeft() && !isMiddle() & !isRight()); }
201 
203  inline bool isMiddleOnly() const { return (!isLeft() && isMiddle() && !isRight()); }
204 
206  inline bool isRightOnly() const { return (!isLeft() && !isMiddle() && isRight()); }
207 
209  inline const MouseEventType getType() const { return m_type; }
210 
212  inline bool isMoveEvent() const { return m_type == MouseMoveEvent; }
213 
215  inline bool isDragEvent() const { return m_type == MouseDragEvent; }
216 
218  inline bool isPressEvent() const { return m_type == MousePressEvent; }
219 
221  inline bool isReleaseEvent() const { return m_type == MouseReleaseEvent; }
222 
224  inline bool isEnterEvent() const { return m_type == MouseEnterEvent; }
225 
227  inline bool isLeaveEvent() const { return m_type == MouseLeaveEvent; }
228 
230  inline bool isWheelEvent() const { return m_type == MouseWheelEvent; }
231 
233  inline ICLWidget *getWidget() const { return m_widget; }
234 
236 
242  inline int getKeyboardModifiers() const { return m_keyboardModifiers; }
243 
245  inline bool isModifierActive(KeyboardModifier m) const { return m & m_keyboardModifiers; }
246 
248 
250  inline MouseEvent remapEvent(const utils::Point32f &imagePos) const {
251  qt::MouseEvent cpy = *this;
252  cpy.m_imagePos32f = imagePos;
253  cpy.m_imagePos = imagePos;
254  return cpy;
255  }
256  };
257  } // namespace qt
258 }
259 
const utils::Point32f getRelPos() const
returns event's relative location wrt. image frame
Definition: MouseEvent.h:179
mouse left area
Definition: MouseEvent.h:54
A keypad button is pressed.
Definition: MouseEvent.h:75
bool isModifierActive(KeyboardModifier m) const
returns whether a certain modifier is currently active
Definition: MouseEvent.h:245
const utils::Point & getWheelDelta() const
wheel delta (x: horizontal wheel, y: vertical wheel (common))
Definition: MouseEvent.h:170
bool isMoveEvent() const
convenience function for special event type
Definition: MouseEvent.h:212
bool isReleaseEvent() const
convenience function for special event type
Definition: MouseEvent.h:221
undocument this line if you encounter any issues!
Definition: Any.h:37
MouseEvent remapEvent(const utils::Point32f &imagePos) const
creates a new MouseEvent instance with a different image position
Definition: MouseEvent.h:250
bool isLeftOnly() const
convenience function for left button
Definition: MouseEvent.h:200
Class for openGL-based image visualization components.
Definition: Widget.h:66
bool isDragEvent() const
convenience function for special event type
Definition: MouseEvent.h:215
int getWidgetY() const
returns event's y coordinate wrt. widget frame
Definition: MouseEvent.h:138
float y
y position of this point
Definition: Point32f.h:48
bool isLeft() const
convenience function for left button
Definition: MouseEvent.h:191
MouseEventType
list of supported mouse event types
Definition: MouseEvent.h:48
A Ctrl key on the keyboard is pressed.
Definition: MouseEvent.h:72
const utils::Point & getPos() const
returns event's location wrt. image frame
Definition: MouseEvent.h:150
A Shift key on the keyboard is pressed.
Definition: MouseEvent.h:71
A Meta key on the keyboard is pressed.
Definition: MouseEvent.h:74
utils::Point32f m_relImagePos
relative image coordinates
Definition: MouseEvent.h:97
mouse entered area
Definition: MouseEvent.h:53
utils::Point m_wheelDelta
wheel delta (x: horizontal wheel, y: vertical wheel)
Definition: MouseEvent.h:100
float getRelX() const
returns event's relative x coordinate wrt. image frame
Definition: MouseEvent.h:173
bool isRightOnly() const
convenience function for right button
Definition: MouseEvent.h:206
MouseButton
list of supported mouse buttons
Definition: MouseEvent.h:62
bool isLeaveEvent() const
convenience function for special event type
Definition: MouseEvent.h:227
bool isRight() const
convenience function for right button
Definition: MouseEvent.h:197
KeyboardModifier
Definition: MouseEvent.h:69
An Alt key on the keyboard is pressed.
Definition: MouseEvent.h:73
bool isMiddleOnly() const
convenience function for middle button
Definition: MouseEvent.h:203
int getX() const
returns event's x coordinate wrt. image frame
Definition: MouseEvent.h:144
X11 only. A Mode_switch key on the keyboard is pressed.
Definition: MouseEvent.h:76
bool isWheelEvent() const
convenience function for special event type
Definition: MouseEvent.h:230
utils::Point32f m_imagePos32f
event location in image coordinates in float
Definition: MouseEvent.h:94
float getY32f() const
returns event's y coordinate wrt. image frame
Definition: MouseEvent.h:156
std::vector< double > m_color
clicked color
Definition: MouseEvent.h:106
ICLWidget * getWidget() const
returns the ICLWidget, which produced this event
Definition: MouseEvent.h:233
utils::Point m_widgetPos
event location in widget coordinates
Definition: MouseEvent.h:88
int getY() const
returns event's y coordinate wrt. image frame
Definition: MouseEvent.h:147
mouse button released
Definition: MouseEvent.h:52
float getX32f() const
returns event's x coordinate wrt. image frame
Definition: MouseEvent.h:153
left mouse button
Definition: MouseEvent.h:63
No modifier key is pressed.
Definition: MouseEvent.h:70
const std::vector< double > & getColor() const
returns clicked pixels color (or a zero length vector, if there was no pixel)
Definition: MouseEvent.h:182
float getRelY() const
returns event's relative y coordinate wrt. image frame
Definition: MouseEvent.h:176
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
mouse button pressed
Definition: MouseEvent.h:51
utils::Point m_imagePos
event location in image coordinates (common)
Definition: MouseEvent.h:91
#define ICLQt_API
Definition: CompatMacros.h:178
MouseEventType m_type
Type of this event (press, release, move, ...)
Definition: MouseEvent.h:112
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
ICLQt_API void color(float r, float g=-1, float b=-1, float alpha=255)
sets the current color to given r,g,b,alpha value
int getWidgetX() const
returns event's x coordinate wrt. widget frame
Definition: MouseEvent.h:135
highest enum value (enum value count = MAX_MOUSE_EVENT + 1)
Definition: MouseEvent.h:56
Provided by interface MouseGrabber.
Definition: MouseEvent.h:86
const utils::Point32f & getPos32f() const
returns event's location wrt. image frame
Definition: MouseEvent.h:159
float x
x position of this point
Definition: Point32f.h:45
bool hitImage() const
returns if the widget's image was hit (and a color is available)
Definition: MouseEvent.h:185
const MouseEventType getType() const
returns the event type
Definition: MouseEvent.h:209
const utils::Point & getWidgetPos() const
returns event's location wrt. widget frame
Definition: MouseEvent.h:141
int getKeyboardModifiers() const
returns all active keyboard modifiers (ored)
Definition: MouseEvent.h:242
bool isPressEvent() const
convenience function for special event type
Definition: MouseEvent.h:218
mouse button pressed down and held
Definition: MouseEvent.h:50
middle mouse button
Definition: MouseEvent.h:64
mouse wheel
Definition: MouseEvent.h:55
int m_keyboardModifiers
ored list of active keyboard modifiers
Definition: MouseEvent.h:115
right moouse button
Definition: MouseEvent.h:65
bool isMiddle() const
convenience function for middle button
Definition: MouseEvent.h:194
std::vector< bool > getDownMask() const
returns the downmask in order [left, middle, right]- button
Definition: MouseEvent.h:188
ICLWidget * m_widget
ICLWidget where the event occured.
Definition: MouseEvent.h:109
mouse moved
Definition: MouseEvent.h:49
bool isEnterEvent() const
convenience function for special event type
Definition: MouseEvent.h:224
highest enum value (enum value count = MAX_MOUSE_BUTTON + 1)
Definition: MouseEvent.h:66