GUIOverlay.hh
00001 #ifndef GUI_OVERLAY 00002 #define GUI_OVERLAY 00003 00004 #include <string> 00005 #include "gazebo_config.h" 00006 00007 #ifdef HAVE_CEGUI 00008 #include "CEGUI/CEGUI.h" 00009 #include "CEGUI/CEGUIEventArgs.h" 00010 #endif 00011 00012 #include "common/MouseEvent.hh" 00013 #include "common/Events.hh" 00014 00015 #include "math/MathTypes.hh" 00016 00017 #include "rendering/RenderTypes.hh" 00018 #include "msgs/MessageTypes.hh" 00019 #include "transport/TransportTypes.hh" 00020 00021 namespace Ogre 00022 { 00023 class RenderTarget; 00024 } 00025 00026 namespace CEGUI 00027 { 00028 class OgreRenderer; 00029 class Window; 00030 } 00031 00032 namespace gazebo 00033 { 00034 namespace rendering 00035 { 00036 class GUIOverlay 00037 { 00038 public: GUIOverlay(); 00039 public: virtual ~GUIOverlay(); 00040 00041 public: void Init(Ogre::RenderTarget *_renderTarget); 00042 00043 public: void Hide(); 00044 public: void Show(); 00045 00046 public: void Update(); 00047 00048 public: bool IsInitialized(); 00049 00050 public: void CreateWindow( const std::string &_type, 00051 const std::string &_name, 00052 const std::string &_parent, 00053 const math::Vector2d &_position, 00054 const math::Vector2d &_size, 00055 const std::string &_text); 00056 00057 public: bool HandleMouseEvent( const common::MouseEvent &_evt); 00058 public: bool HandleKeyPressEvent( const std::string &_key); 00059 public: bool HandleKeyReleaseEvent( const std::string &_key); 00060 00062 public: void LoadLayout( const std::string &_filename ); 00063 00064 public: bool AttachCameraToImage(CameraPtr &_camera, 00065 const std::string &_windowName); 00066 00067 public: bool AttachCameraToImage(DepthCameraPtr &_camera, 00068 const std::string &_windowName); 00069 00070 00071 public: void Resize( unsigned int _width, unsigned int _height ); 00072 private: void PreRender(); 00073 00074 00075 public: template<typename T> 00076 void ButtonCallback( const std::string &_buttonName, 00077 void (T::*_fp)(), T *_obj ) 00078 { 00079 #ifdef HAVE_CEGUI 00080 CEGUI::Window *buttonWindow; 00081 buttonWindow = CEGUI::WindowManager::getSingletonPtr()->getWindow(_buttonName); 00082 buttonWindow->subscribeEvent( CEGUI::PushButton::EventClicked, 00083 CEGUI::Event::Subscriber(&GUIOverlay::OnButtonClicked, this)); 00084 00085 this->callbacks[_buttonName] = boost::bind(_fp, _obj); 00086 #endif 00087 } 00088 00089 #ifdef HAVE_CEGUI 00090 public: CEGUI::Window *GetWindow( const std::string &_name ); 00091 00093 private: CEGUI::Window *LoadLayoutImpl( const std::string &_filename ); 00094 00095 private: bool OnButtonClicked(const CEGUI::EventArgs& _e); 00096 private: int GetKeyCode(const std::string &_unicode); 00097 00098 private: CEGUI::OgreRenderer *guiRenderer; 00099 #endif 00100 00101 private: std::vector<event::ConnectionPtr> connections; 00102 private: std::string layoutFilename; 00103 private: std::map<std::string, boost::function<void()> > callbacks; 00104 00105 private: unsigned int rttImageSetCount; 00106 private: bool initialized; 00107 }; 00108 } 00109 } 00110 00111 #endif

1.7.5.1