Added keyboard mouse binding usage to the osg::ApplicationUsage and

osgGA::GUIEventHandler and its subclasses.
This commit is contained in:
Robert Osfield
2003-02-19 10:43:02 +00:00
parent 73f741d16f
commit 0d3f78350a
20 changed files with 202 additions and 39 deletions

View File

@@ -6,6 +6,7 @@ CXXFILES =\
EventAdapter.cpp\
KeyboardMouseCallback.cpp\
SceneHandler.cpp\
StatsEventHandler.cpp\
Viewer.cpp\
LIBS += -lProducer $(GL_LIBS) -losgGA -losgUtil -losgDB -losg $(OTHER_LIBS)

View File

@@ -0,0 +1,41 @@
#include <osgProducer/StatsEventHandler>
using namespace osgProducer;
bool StatsEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&)
{
if(!_cg) return false;
if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN)
{
switch( ea.getKey() )
{
case 's' :
_cg->setInstrumentationMode(!_cg->getInstrumentationMode());
return true;
case 'v' :
_cg->setBlockOnVsync(!_cg->getBlockOnVsync());
//std::cout<<"_cg->getBlockOnVsync()="<<_cg->getBlockOnVsync()<<std::endl;
return true;
default:
break;
}
}
return false;
}
void StatsEventHandler::accept(osgGA::GUIEventHandlerVisitor& gehv)
{
gehv.visit(*this);
}
void StatsEventHandler::getUsage(osg::ApplicationUsage& usage) const
{
usage.addKeyboardMouseBinding("s","Toggle intrumention");
usage.addKeyboardMouseBinding("v","Toggle block and vsync");
}

View File

@@ -241,3 +241,12 @@ void Viewer::requestWarpPointer(int x,int y)
}
void Viewer::getUsage(osg::ApplicationUsage& usage) const
{
for(EventHandlerList::const_iterator itr=_eventHandlerList.begin();
itr!=_eventHandlerList.end();
++itr)
{
(*itr)->getUsage(usage);
}
}