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 struct ViewportMouseEvent
00047 {
00048 ViewportMouseEvent() {}
00049
00051 ViewportMouseEvent(RenderPanel* p, Ogre::Viewport* vp, QMouseEvent* e, int lx, int ly)
00052 : panel( p )
00053 , viewport( vp )
00054 , type( e->type() )
00055 , x( e->x() )
00056 , y( e->y() )
00057 , wheel_delta( 0 )
00058 , acting_button( e->button() )
00059 , buttons_down( e->buttons() )
00060 , modifiers( e->modifiers() )
00061 , last_x( lx )
00062 , last_y( ly )
00063 {
00064 }
00065
00066
00067
00068
00070 ViewportMouseEvent(RenderPanel* p, Ogre::Viewport* vp, QWheelEvent* e, int lx, int ly)
00071 : panel( p )
00072 , viewport( vp )
00073 , type( e->type() )
00074 , x( e->x() )
00075 , y( e->y() )
00076 , wheel_delta( e->delta() )
00077 , acting_button( Qt::NoButton )
00078 , buttons_down( e->buttons() )
00079 , modifiers( e->modifiers() )
00080 , last_x( lx )
00081 , last_y( ly )
00082 {
00083 }
00084
00085
00086
00087
00088 bool left() { return buttons_down & Qt::LeftButton; }
00089 bool middle() { return buttons_down & Qt::MidButton; }
00090 bool right() { return buttons_down & Qt::RightButton; }
00091
00092 bool shift() { return modifiers & Qt::ShiftModifier; }
00093 bool control() { return modifiers & Qt::ControlModifier; }
00094 bool alt() { return modifiers & Qt::AltModifier; }
00095
00096
00097
00098 bool leftUp() { return type == QEvent::MouseButtonRelease && acting_button == Qt::LeftButton; }
00099 bool middleUp() { return type == QEvent::MouseButtonRelease && acting_button == Qt::MidButton; }
00100 bool rightUp() { return type == QEvent::MouseButtonRelease && acting_button == Qt::RightButton; }
00101
00102 bool leftDown() { return type == QEvent::MouseButtonPress && acting_button == Qt::LeftButton; }
00103 bool middleDown() { return type == QEvent::MouseButtonPress && acting_button == Qt::MidButton; }
00104 bool rightDown() { return type == QEvent::MouseButtonPress && acting_button == Qt::RightButton; }
00105
00106 RenderPanel* panel;
00107 Ogre::Viewport* viewport;
00108 QEvent::Type type;
00109 int x;
00110 int y;
00111 int wheel_delta;
00112 Qt::MouseButton acting_button;
00113 Qt::MouseButtons buttons_down;
00114 Qt::KeyboardModifiers modifiers;
00115 int last_x;
00116 int last_y;
00117 };
00118
00119 }
00120
00121 #endif // VIEWPORT_MOUSE_EVENT_H