03ee77a315
explanations of how each of the classes operates.
71 lines
2.3 KiB
Plaintext
71 lines
2.3 KiB
Plaintext
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
//as published by the Free Software Foundation.
|
|
|
|
#ifndef OSGUTIL_KEYSWITCCAMERAMANIPULATORHER
|
|
#define OSGUTIL_KEYSWITCHCAMERAMANIPULATORER 1
|
|
|
|
#include <osgGA/Export>
|
|
#include <osgGA/CameraManipulator>
|
|
#include <osgGA/GUIEventHandler>
|
|
#include <osgGA/GUIEventHandlerVisitor>
|
|
|
|
namespace osgGA{
|
|
|
|
class GUIEventAdapter;
|
|
class GUIActionAdapter;
|
|
|
|
/**
|
|
KeySwitchCameraManipulator is a decorator which allows the type of camera manipulator
|
|
being used to be switched by pressing a key. E.g. '1' for a TrackballManipultor,
|
|
'2' for a DriveManipulator, '3' for a FlightManipulator. The manipulators available,
|
|
and the associated switch keys, can be configured.
|
|
*/
|
|
class OSGGA_EXPORT KeySwitchCameraManipulator : public CameraManipulator
|
|
{
|
|
public:
|
|
|
|
/**
|
|
Add a camera manipulator with an associated name, and a key to
|
|
trigger the switch,
|
|
*/
|
|
void addCameraManipulator(int key, std::string name, CameraManipulator *cm);
|
|
|
|
/**
|
|
Add a camera manipulator with an autogenerated keybinding which is '1' + previous number of camera's registerd.
|
|
*/
|
|
void addNumberedCameraManipulator(CameraManipulator *cm);
|
|
|
|
// Overrides from CameraManipulator...
|
|
|
|
virtual void setCamera(osg::Camera* c) { _current->setCamera(c); }
|
|
|
|
virtual const osg::Camera * getCamera() const { return _current->getCamera(); }
|
|
|
|
virtual osg::Camera * getCamera() { return _current->getCamera(); }
|
|
|
|
virtual void setNode(osg::Node* n) { _current->setNode(n); }
|
|
|
|
virtual const osg::Node* getNode() const { return _current->getNode(); }
|
|
|
|
virtual osg::Node* getNode() { return _current->getNode(); }
|
|
|
|
virtual void home(const GUIEventAdapter& ee,GUIActionAdapter& aa) { _current->home(ee,aa); }
|
|
|
|
virtual void init(const GUIEventAdapter& ee,GUIActionAdapter& aa) { _current->init(ee,aa); }
|
|
|
|
virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
|
|
|
|
private:
|
|
|
|
typedef std::pair<std::string, osg::ref_ptr<CameraManipulator> > NamedManipulator;
|
|
typedef std::map<int, NamedManipulator> KeyManipMap;
|
|
KeyManipMap _manips;
|
|
|
|
osg::ref_ptr<CameraManipulator> _current;
|
|
};
|
|
|
|
};
|
|
|
|
#endif
|