Robot Simulator of the Robotics Group for Self-Organization of Control: robotcameramanager.h Source File

# robotcameramanager.h

Go to the documentation of this file.

    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 #ifndef __ROBOTCAMERAMANAGER_H
    00025 #define __ROBOTCAMERAMANAGER_H
    00026
    00027 #include "camera.h"
    00028 #include <osgGA/GUIEventHandler>
    00029 #include <osgGA/GUIEventAdapter>
    00030 #include <osgGA/GUIActionAdapter>
    00031
    00032 namespace lpzrobots {
    00033
    00034   /**
    00035      Manages camera sensors. The cameras are rendered to texture offscreen,
    00036      meaning independent of the normal graphical rendering.
    00037      Additionally the view of the cameras is displayed as an overlay.
    00038    */
    00039   class RobotCameraManager : public osgGA::GUIEventHandler {
    00040     struct Overlay {
    00041       Overlay(const Camera::CameraImage& image);
    00042       ~Overlay();
    00043       Camera::CameraImage camImg;
    00044       osg::Texture2D* texture;
    00045       int overlayW;
    00046       int overlayH;
    00047       int overlayX;
    00048       int overlayY;
    00049       osg::Node* overlay;
    00050     };
    00051     typedef std::vector<Overlay> Overlays;
    00052     struct RobotCam {
    00053       Camera* cam;
    00054       Overlays overlays;
    00055     };
    00056     typedef std::vector<RobotCam> RobotCams;
    00057
    00058   public:
    00059     RobotCameraManager(int windowWidth, int windowHeight);
    00060     virtual void addCamera(Camera* cam);
    00061     virtual void removeCamera(Camera* cam);
    00062
    00063     virtual osg::Group* getDisplay() { return display; }
    00064     virtual osg::Group* getOffScreen()  { return offscreen; }
    00065
    00066     /* ** GUIEventHandler interface **/
    00067     virtual bool handle (const osgGA::GUIEventAdapter& ea,
    00068                          osgGA::GUIActionAdapter& aa,
    00069                          osg::Object* o, osg::NodeVisitor* nv);
    00070     virtual void getUsage (osg::ApplicationUsage &) const;
    00071
    00072   protected:
    00073
    00074     virtual void updateView();
    00075
    00076     osg::ref_ptr<osg::Group> display;
    00077     osg::ref_ptr<osg::Group> offscreen;
    00078     RobotCams cameras;
    00079
    00080     bool enabled;
    00081     float scale;
    00082     int windowWidth;
    00083     int windowHeight;
    00084   };
    00085
    00086
    00087 }
    00088
    00089 #endif