Updraft  1.0
Open source glider flight visualisation tool.
pickhandler.h
Go to the documentation of this file.
00001 #ifndef UPDRAFT_SRC_CORE_PICKHANDLER_H_
00002 #define UPDRAFT_SRC_CORE_PICKHANDLER_H_
00003 
00004 #include <osgGA/GUIEventHandler>
00005 #include <osgViewer/Viewer>
00006 #include <QtGui>
00007 #include "../mapobject.h"
00008 
00009 namespace Updraft {
00010 
00011 class SettingInterface;
00012 
00013 namespace Core {
00014 
00015 typedef QPair<MapObject*, osg::Vec3> Pair;
00016 
00018 class PickHandler: public osgGA::GUIEventHandler {
00019   Q_DECLARE_TR_FUNCTIONS(PickHandler)
00020 
00021  public:
00022   PickHandler();
00023 
00031   bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
00032 
00033  protected:
00035   float mX, mY;
00036 
00040   void raiseLeftClick(QVector<Pair> mapObjects);
00041 
00045   void raiseRightClick(QVector<Pair> mapObjects);
00046   MapObject* getMapObject(osg::Node* node);
00047 
00054   bool eventsCloseEnough(float x1, float y1, float x2, float y2);
00055 
00058   SettingInterface* mouseEventTolerance;
00059 
00066   QVector<Pair> getIntersectedMapObjects(
00067     const double x,
00068     const double y,
00069     osgViewer::Viewer* viewer);
00070 
00071   // List of all owned QActions that is used for destruction of these actions.
00072   QList<QAction*> ownedActions;
00073 };
00074 
00075 }  // End namespace Core
00076 }  // End namespace Updraft
00077 
00078 #endif  // UPDRAFT_SRC_CORE_PICKHANDLER_H_
00079 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines