OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KeySwitchMatrixManipulator.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGUTIL_KEYSWITCMATRIXMANIPULATOR
15 #define OSGUTIL_KEYSWITCMATRIXMANIPULATOR 1
16 
17 #include <osgGA/Export>
18 #include <osgGA/CameraManipulator>
19 #include <osgGA/GUIEventHandler>
20 
21 namespace osgGA{
22 
23 class GUIActionAdapter;
24 
32 {
33  public:
34 
35  typedef std::pair<std::string, osg::ref_ptr<CameraManipulator> > NamedManipulator;
36  typedef std::map<int, NamedManipulator> KeyManipMap;
37 
38  virtual const char* className() const { return "KeySwitchMatrixManipulator"; }
39 
44  void addMatrixManipulator(int key, std::string name, CameraManipulator *cm);
45 
49  void addNumberedMatrixManipulator(CameraManipulator *cm);
50 
51  unsigned int getNumMatrixManipulators() const { return _manips.size(); }
52 
53  void selectMatrixManipulator(unsigned int num);
54 
56  KeyManipMap& getKeyManipMap() { return _manips; }
57 
59  const KeyManipMap& getKeyManipMap() const { return _manips; }
60 
61 
63  CameraManipulator* getCurrentMatrixManipulator() { return _current.get(); }
64 
66  const CameraManipulator* getCurrentMatrixManipulator() const { return _current.get(); }
67 
68 
70  CameraManipulator* getMatrixManipulatorWithIndex(unsigned int key);
71 
73  const CameraManipulator* getMatrixManipulatorWithIndex(unsigned int key) const;
74 
76  CameraManipulator* getMatrixManipulatorWithKey(unsigned int key);
77 
79  const CameraManipulator* getMatrixManipulatorWithKey(unsigned int key) const;
80 
81 
82  // Overrides from CameraManipulator...
83 
85  virtual void setCoordinateFrameCallback(CoordinateFrameCallback* cb);
86 
88  virtual void setByMatrix(const osg::Matrixd& matrix) { _current->setByMatrix(matrix); }
89 
91  virtual void setByInverseMatrix(const osg::Matrixd& matrix) { _current->setByInverseMatrix(matrix); }
92 
94  virtual osg::Matrixd getMatrix() const { return _current->getMatrix(); }
95 
97  virtual osg::Matrixd getInverseMatrix() const { return _current->getInverseMatrix(); }
98 
100  virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return _current->getFusionDistanceMode(); }
101 
103  virtual float getFusionDistanceValue() const { return _current->getFusionDistanceValue(); }
104 
105 
106  virtual void setNode(osg::Node* n);
107 
108  virtual const osg::Node* getNode() const { return _current->getNode(); }
109 
110  virtual osg::Node* getNode() { return _current->getNode(); }
111 
112  virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, bool autoComputeHomePosition=false);
113 
114  virtual void setAutoComputeHomePosition(bool flag);
115 
116  virtual void computeHomePosition();
117 
118  virtual void finishAnimation();
119 
120  virtual void home(const GUIEventAdapter& ee,GUIActionAdapter& aa);
121 
122  virtual void init(const GUIEventAdapter& ee,GUIActionAdapter& aa) { if (_current.valid()) _current->init(ee,aa); }
123 
124  virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
125 
127  virtual void getUsage(osg::ApplicationUsage& usage) const;
128 
129  private:
130 
131  KeyManipMap _manips;
132 
134 };
135 
136 }
137 
138 #endif
virtual const char * className() const
virtual osg::Matrixd getInverseMatrix() const
const CameraManipulator * getCurrentMatrixManipulator() const
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
std::map< int, NamedManipulator > KeyManipMap
virtual void init(const GUIEventAdapter &ee, GUIActionAdapter &aa)
#define OSGGA_EXPORT
Definition: Export.h:40
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const
virtual const osg::Node * getNode() const
virtual void setByMatrix(const osg::Matrixd &matrix)
Definition: Node.h:71
std::pair< std::string, osg::ref_ptr< CameraManipulator > > NamedManipulator
virtual osg::Matrixd getMatrix() const
const KeyManipMap & getKeyManipMap() const