00001 /*************************************************************************** 00002 * Copyright (C) 2005-2011 LpzRobots development team * 00003 * Georg Martius <georg dot martius at web dot de> * 00004 * Frank Guettler <guettler at informatik dot uni-leipzig dot de * 00005 * Frank Hesse <frank at nld dot ds dot mpg dot de> * 00006 * Ralf Der <ralfder at mis dot mpg dot de> * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 * * 00023 ***************************************************************************/ 00024 00025 #ifndef LPZHELPHANDLER_H 00026 #define LPZHELPHANDLER_H 00027 00028 #include <osgViewer/ViewerEventHandlers> 00029 00030 namespace lpzrobots { 00031 00032 00033 /** Event handler for adding on screen help to Viewers.*/ 00034 class LpzHelpHandler : public osgGA::GUIEventHandler 00035 { 00036 public: 00037 00038 LpzHelpHandler(osg::ApplicationUsage* au=0); 00039 00040 void setApplicationUsage(osg::ApplicationUsage* au) { _applicationUsage = au; } 00041 osg::ApplicationUsage* getApplicationUsage() { return _applicationUsage.get(); } 00042 const osg::ApplicationUsage* getApplicationUsage() const { return _applicationUsage.get(); } 00043 00044 void setKeyEventTogglesOnScreenHelp(int key) { _keyEventTogglesOnScreenHelp = key; } 00045 int getKeyEventTogglesOnScreenHelp() const { return _keyEventTogglesOnScreenHelp; } 00046 00047 void reset(); 00048 00049 osg::Camera* getCamera() { return _camera.get(); } 00050 const osg::Camera* getCamera() const { return _camera.get(); } 00051 00052 bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa); 00053 00054 /** Get the keyboard and mouse usage of this manipulator.*/ 00055 virtual void getUsage(osg::ApplicationUsage& usage) const; 00056 00057 protected: 00058 00059 void setUpHUDCamera(osgViewer::ViewerBase* viewer); 00060 00061 void setUpScene(osgViewer::ViewerBase* viewer); 00062 00063 osg::ref_ptr<osg::ApplicationUsage> _applicationUsage; 00064 00065 int _keyEventTogglesOnScreenHelp; 00066 00067 bool _helpEnabled; 00068 00069 bool _initialized; 00070 osg::ref_ptr<osg::Camera> _camera; 00071 osg::ref_ptr<osg::Switch> _switch; 00072 00073 }; 00074 00075 } 00076 #endif