Added keyboard mouse binding usage to the osg::ApplicationUsage and
osgGA::GUIEventHandler and its subclasses.
This commit is contained in:
@@ -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)
|
||||
|
||||
41
src/osgProducer/StatsEventHandler.cpp
Normal file
41
src/osgProducer/StatsEventHandler.cpp
Normal 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");
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user