Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef VIEWPORT_MOUSE_EVENT_H
00031 #define VIEWPORT_MOUSE_EVENT_H
00032
00033 #include <QMouseEvent>
00034 #include <QWheelEvent>
00035
00036 namespace Ogre
00037 {
00038 class Viewport;
00039 }
00040
00041 namespace rviz
00042 {
00043
00044 class RenderPanel;
00045
00046 class ViewportMouseEvent
00047 {
00048 public:
00049 ViewportMouseEvent() {}
00050
00052 ViewportMouseEvent(RenderPanel* p, Ogre::Viewport* vp, QMouseEvent* e, int lx, int ly)
00053 : panel( p )
00054 , viewport( vp )
00055 , type( e->type() )
00056 , x( e->x() )
00057 , y( e->y() )
00058 , wheel_delta( 0 )
00059 , acting_button( e->button() )
00060 , buttons_down( e->buttons() )
00061 , modifiers( e->modifiers() )
00062 , last_x( lx )
00063 , last_y( ly )
00064 {
00065 }
00066
00067
00068
00069
00071 ViewportMouseEvent(RenderPanel* p, Ogre::Viewport* vp, QWheelEvent* e, int lx, int ly)
00072 : panel( p )
00073 , viewport( vp )
00074 , type( e->type() )
00075 , x( e->x() )
00076 , y( e->y() )
00077 , wheel_delta( e->delta() )
00078 , acting_button( Qt::NoButton )
00079 , buttons_down( e->buttons() )
00080 , modifiers( e->modifiers() )
00081 , last_x( lx )
00082 , last_y( ly )
00083 {
00084 }
00085
00086
00087
00088
00089 bool left() { return buttons_down & Qt::LeftButton; }
00090 bool middle() { return buttons_down & Qt::MidButton; }
00091 bool right() { return buttons_down & Qt::RightButton; }
00092
00093 bool shift() { return modifiers & Qt::ShiftModifier; }
00094 bool control() { return modifiers & Qt::ControlModifier; }
00095 bool alt() { return modifiers & Qt::AltModifier; }
00096
00097
00098
00099 bool leftUp() { return type == QEvent::MouseButtonRelease && acting_button == Qt::LeftButton; }
00100 bool middleUp() { return type == QEvent::MouseButtonRelease && acting_button == Qt::MidButton; }
00101 bool rightUp() { return type == QEvent::MouseButtonRelease && acting_button == Qt::RightButton; }
00102
00103 bool leftDown() { return type == QEvent::MouseButtonPress && acting_button == Qt::LeftButton; }
00104 bool middleDown() { return type == QEvent::MouseButtonPress && acting_button == Qt::MidButton; }
00105 bool rightDown() { return type == QEvent::MouseButtonPress && acting_button == Qt::RightButton; }
00106
00107 RenderPanel* panel;
00108 Ogre::Viewport* viewport;
00109 QEvent::Type type;
00110 int x;
00111 int y;
00112 int wheel_delta;
00113 Qt::MouseButton acting_button;
00114 Qt::MouseButtons buttons_down;
00115 Qt::KeyboardModifiers modifiers;
00116 int last_x;
00117 int last_y;
00118 };
00119
00120 }
00121
00122 #endif // VIEWPORT_MOUSE_EVENT_H