Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
robotcameramanager.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __ROBOTCAMERAMANAGER_H
25 #define __ROBOTCAMERAMANAGER_H
26 
27 #include "camera.h"
28 #include <osgGA/GUIEventHandler>
29 #include <osgGA/GUIEventAdapter>
30 #include <osgGA/GUIActionAdapter>
31 
32 namespace lpzrobots {
33 
34  /**
35  Manages camera sensors. The cameras are rendered to texture offscreen,
36  meaning independent of the normal graphical rendering.
37  Additionally the view of the cameras is displayed as an overlay.
38  */
39  class RobotCameraManager : public osgGA::GUIEventHandler {
40  struct Overlay {
41  Overlay(const Camera::CameraImage& image);
42  ~Overlay();
43  Camera::CameraImage camImg;
44  osg::Texture2D* texture;
45  int overlayW;
46  int overlayH;
47  int overlayX;
48  int overlayY;
49  osg::Node* overlay;
50  };
51  typedef std::vector<Overlay> Overlays;
52  struct RobotCam {
53  Camera* cam;
54  Overlays overlays;
55  };
56  typedef std::vector<RobotCam> RobotCams;
57 
58  public:
60  virtual void addCamera(Camera* cam);
61  virtual void removeCamera(Camera* cam);
62 
63  virtual osg::Group* getDisplay() { return display; }
64  virtual osg::Group* getOffScreen() { return offscreen; }
65 
66  /* ** GUIEventHandler interface **/
67  virtual bool handle (const osgGA::GUIEventAdapter& ea,
68  osgGA::GUIActionAdapter& aa,
69  osg::Object* o, osg::NodeVisitor* nv);
70  virtual void getUsage (osg::ApplicationUsage &) const;
71 
72  protected:
73 
74  virtual void updateView();
75 
76  osg::ref_ptr<osg::Group> display;
77  osg::ref_ptr<osg::Group> offscreen;
78  RobotCams cameras;
79 
80  bool enabled;
81  float scale;
84  };
85 
86 
87 }
88 
89 #endif
virtual osg::Group * getOffScreen()
Definition: robotcameramanager.h:64
bool enabled
Definition: robotcameramanager.h:80
A Robot Camera.
Definition: camera.h:69
float scale
Definition: robotcameramanager.h:81
virtual osg::Group * getDisplay()
Definition: robotcameramanager.h:63
int windowHeight
Definition: robotcameramanager.h:83
structure to store the image data and information for display
Definition: camera.h:80
RobotCameraManager(int windowWidth, int windowHeight)
Definition: robotcameramanager.cpp:49
osg::ref_ptr< osg::Group > display
Definition: robotcameramanager.h:76
Manages camera sensors.
Definition: robotcameramanager.h:39
osg::ref_ptr< osg::Group > offscreen
Definition: robotcameramanager.h:77
RobotCams cameras
Definition: robotcameramanager.h:78
virtual void addCamera(Camera *cam)
Definition: robotcameramanager.cpp:58
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa, osg::Object *o, osg::NodeVisitor *nv)
Definition: robotcameramanager.cpp:152
virtual void getUsage(osg::ApplicationUsage &) const
Definition: robotcameramanager.cpp:189
int windowWidth
Definition: robotcameramanager.h:82
virtual void removeCamera(Camera *cam)
Definition: robotcameramanager.cpp:72
virtual void updateView()
Definition: robotcameramanager.cpp:85