OpenSceneGraph 3.6.5
KeySwitchMatrixManipulator
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>
19#include <osgGA/GUIEventHandler>
20
21namespace osgGA{
22
23class 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
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
71
73 const CameraManipulator* getMatrixManipulatorWithIndex(unsigned int key) const;
74
77
79 const CameraManipulator* getMatrixManipulatorWithKey(unsigned int key) const;
80
81
82 // Overrides from CameraManipulator...
83
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
The 'GA' in osgGA stands for 'GUI Abstraction'; the osgGA namespace provides facilities to help devel...
Definition Callback:21
Definition ApplicationUsage:26
Definition Matrixd:27
Base class for all internal nodes in the scene graph.
Definition Node:72
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
callback class to use to allow matrix manipulators to query the application for the local coordinate ...
Definition CameraManipulator:51
Definition GUIActionAdapter:62
Event class for storing Keyboard, mouse and window events.
Definition GUIEventAdapter:82
KeySwitchMatrixManipulator is a decorator which allows the type of camera manipulator being used to b...
Definition KeySwitchMatrixManipulator:32
const CameraManipulator * getCurrentMatrixManipulator() const
Get the const current active manipulators.
Definition KeySwitchMatrixManipulator:66
virtual void setByMatrix(const osg::Matrixd &matrix)
Set the position of the matrix manipulator using a 4x4 Matrix.
Definition KeySwitchMatrixManipulator:88
virtual const osg::Node * getNode() const
Return const node if attached.
Definition KeySwitchMatrixManipulator:108
CameraManipulator * getCurrentMatrixManipulator()
Get the current active manipulators.
Definition KeySwitchMatrixManipulator:63
virtual void setByInverseMatrix(const osg::Matrixd &matrix)
set the position of the matrix manipulator using a 4x4 Matrix.
Definition KeySwitchMatrixManipulator:91
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const
Get the FusionDistanceMode.
Definition KeySwitchMatrixManipulator:100
virtual void setHomePosition(const osg::Vec3d &eye, const osg::Vec3d &center, const osg::Vec3d &up, bool autoComputeHomePosition=false)
Manually set the home position, and set the automatic compute of home position.
CameraManipulator * getMatrixManipulatorWithIndex(unsigned int key)
Get manipulator assigned to a specified index.
const KeyManipMap & getKeyManipMap() const
Get the const complete list of manipulators attached to this keyswitch manipulator.
Definition KeySwitchMatrixManipulator:59
virtual float getFusionDistanceValue() const
Get the FusionDistanceValue.
Definition KeySwitchMatrixManipulator:103
virtual bool handle(const GUIEventAdapter &ea, GUIActionAdapter &us)
Handle events, return true if handled, false otherwise.
virtual void finishAnimation()
finish any active manipulator animations.
KeyManipMap & getKeyManipMap()
Get the complete list of manipulators attached to this keyswitch manipulator.
Definition KeySwitchMatrixManipulator:56
const CameraManipulator * getMatrixManipulatorWithKey(unsigned int key) const
Get const manipulator assigned to a specified key.
virtual void setNode(osg::Node *n)
Attach a node to the manipulator, automatically detaching any previously attached node.
const CameraManipulator * getMatrixManipulatorWithIndex(unsigned int key) const
Get const manipulator assigned to a specified index.
virtual osg::Matrixd getInverseMatrix() const
get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model...
Definition KeySwitchMatrixManipulator:97
virtual void init(const GUIEventAdapter &ee, GUIActionAdapter &aa)
Start/restart the manipulator.
Definition KeySwitchMatrixManipulator:122
std::map< int, NamedManipulator > KeyManipMap
Definition KeySwitchMatrixManipulator:36
CameraManipulator * getMatrixManipulatorWithKey(unsigned int key)
Get manipulator assigned to a specified key.
virtual void setCoordinateFrameCallback(CoordinateFrameCallback *cb)
set the coordinate frame which callback tells the manipulator which way is up, east and north.
void addNumberedMatrixManipulator(CameraManipulator *cm)
Add a camera manipulator with an autogenerated keybinding which is '1' + previous number of camera's ...
virtual osg::Node * getNode()
Return node if attached.
Definition KeySwitchMatrixManipulator:110
virtual void getUsage(osg::ApplicationUsage &usage) const
Get the keyboard and mouse usage of this manipulator.
virtual void setAutoComputeHomePosition(bool flag)
Set whether the automatic compute of the home position is enabled.
virtual void home(const GUIEventAdapter &ee, GUIActionAdapter &aa)
Move the camera to the default position.
std::pair< std::string, osg::ref_ptr< CameraManipulator > > NamedManipulator
Definition KeySwitchMatrixManipulator:35
virtual osg::Matrixd getMatrix() const
get the position of the manipulator as 4x4 Matrix.
Definition KeySwitchMatrixManipulator:94
void selectMatrixManipulator(unsigned int num)
virtual const char * className() const
return the name of the object's class type.
Definition KeySwitchMatrixManipulator:38
void addMatrixManipulator(int key, std::string name, CameraManipulator *cm)
Add a camera manipulator with an associated name, and a key to trigger the switch,...
unsigned int getNumMatrixManipulators() const
Definition KeySwitchMatrixManipulator:51
FusionDistanceMode
FusionDistanceMode is used only when working in stereo.
Definition SceneView:339
#define OSGGA_EXPORT
Definition Export:40

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.