Added Viewer::setKeySetsDone(int) to allow developers to specify which
key should set done and cause the main loop to exit.
This commit is contained in:
parent
abdb1741a4
commit
1fd2047cf5
@ -49,6 +49,15 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
|
||||
/** Get the threading model the rendering traversals will use.*/
|
||||
ThreadingModel getThreadingModel() const { return _threadingModel; }
|
||||
|
||||
/** Set the key value that the viewer checks on each frame to see if the viewer's done flag should be set to
|
||||
* signal end of viewers main loop.
|
||||
* Default value is Escape (osgGA::GUIEVentAdapter::KEY_Escape).
|
||||
* Setting to 0 switches off the feature.*/
|
||||
void setKeySetsDone(int key) { _keySetsDone = key; }
|
||||
|
||||
/** Set the key value that the viewer checks on each frame to see if the viewer's done flag.*/
|
||||
int getKeySetsDone() const { return _keySetsDone; }
|
||||
|
||||
/** Render a complete new frame.
|
||||
* Calls frameAdvance(), frameEventTraversal(), frameUpateTraversal(), frameRenderingTraversals(). */
|
||||
virtual void frame();
|
||||
@ -86,7 +95,9 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
|
||||
void checkWindowStatus();
|
||||
|
||||
bool _firstFrame;
|
||||
|
||||
bool _done;
|
||||
int _keySetsDone;
|
||||
|
||||
ThreadingModel _threadingModel;
|
||||
|
||||
|
@ -25,6 +25,7 @@ using namespace osgViewer;
|
||||
Viewer::Viewer():
|
||||
_firstFrame(true),
|
||||
_done(false),
|
||||
_keySetsDone(osgGA::GUIEventAdapter::KEY_Escape),
|
||||
_threadingModel(ThreadPerContext),
|
||||
_numThreadsOnBarrier(0)
|
||||
{
|
||||
@ -601,18 +602,22 @@ void Viewer::frameEventTraversal()
|
||||
#endif
|
||||
|
||||
// osg::notify(osg::NOTICE)<<"Events "<<events.size()<<std::endl;
|
||||
for(osgGA::EventQueue::Events::iterator itr = events.begin();
|
||||
itr != events.end();
|
||||
++itr)
|
||||
|
||||
if (_keySetsDone!=0)
|
||||
{
|
||||
osgGA::GUIEventAdapter* event = itr->get();
|
||||
switch(event->getEventType())
|
||||
for(osgGA::EventQueue::Events::iterator itr = events.begin();
|
||||
itr != events.end();
|
||||
++itr)
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::KEYUP):
|
||||
if (event->getKey()==osgGA::GUIEventAdapter::KEY_Escape) _done = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
osgGA::GUIEventAdapter* event = itr->get();
|
||||
switch(event->getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::KEYUP):
|
||||
if (event->getKey()==_keySetsDone) _done = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user