Added ability to customize the keys used to control stats

This commit is contained in:
Robert Osfield 2007-01-23 11:56:10 +00:00
parent affb8f1289
commit 691e4d7b88
2 changed files with 13 additions and 2 deletions

View File

@ -34,6 +34,12 @@ class StatsHandler : public osgGA::GUIEventHandler
SCENE_STATS = 3,
LAST = 4
};
void setKeyEventTogglesOnScreenStats(int key) { _keyEventTogglesOnScreenStats = key; }
int getKeyEventTogglesOnScreenStats() const { return _keyEventTogglesOnScreenStats; }
void setKeyEventPrintsOutStats(int key) { _keyEventPrintsOutStats = key; }
int getKeyEventPrintsOutStats() const { return _keyEventPrintsOutStats; }
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
@ -53,6 +59,9 @@ class StatsHandler : public osgGA::GUIEventHandler
void setUpScene(osgViewer::Viewer* viewer);
int _keyEventTogglesOnScreenStats;
int _keyEventPrintsOutStats;
int _statsType;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::Switch> _switch;

View File

@ -17,6 +17,8 @@ namespace osgViewer
{
StatsHandler::StatsHandler():
_keyEventTogglesOnScreenStats('s'),
_keyEventPrintsOutStats('S'),
_statsType(NO_STATS),
_frameRateChildNum(0),
_viewerChildNum(0),
@ -35,7 +37,7 @@ bool StatsHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdap
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
if (ea.getKey()=='s')
if (ea.getKey()==_keyEventTogglesOnScreenStats)
{
if (viewer->getStats())
{
@ -83,7 +85,7 @@ bool StatsHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdap
}
return true;
}
if (ea.getKey()=='S')
if (ea.getKey()==_keyEventPrintsOutStats)
{
if (viewer->getStats())
{