- let the OSG on-screen-statistics function no longer be hard-coded
on the '*'-key, but allow to cycle it by setting /sim/rendering/on-screen-statistics to "true" - move that function to the Debug menu (no more key assigned!) - add "print-statistics" menu entry
This commit is contained in:
parent
9416c13477
commit
b61cc37e30
3 changed files with 36 additions and 7 deletions
|
@ -4,23 +4,32 @@
|
|||
#include <osg/Math>
|
||||
#include <osgViewer/Viewer>
|
||||
#include <plib/pu.h>
|
||||
#include <Main/fg_props.hxx>
|
||||
#include "FGManipulator.hxx"
|
||||
|
||||
#if !defined(X_DISPLAY_MISSING)
|
||||
#define X_DOUBLE_SCROLL_BUG 1
|
||||
#endif
|
||||
|
||||
const int displayStatsKey = 1;
|
||||
const int printStatsKey = 2;
|
||||
|
||||
|
||||
// The manipulator is responsible for updating a Viewer's camera. It's
|
||||
// event handling method is also a convenient place to run the the FG
|
||||
// idle and draw handlers.
|
||||
|
||||
FGManipulator::FGManipulator() :
|
||||
idleHandler(0), drawHandler(0), windowResizeHandler(0), keyHandler(0),
|
||||
mouseClickHandler(0), mouseMotionHandler(0), currentModifiers(0),
|
||||
osgModifiers(0), resizable(true), mouseWarped(false),
|
||||
mouseClickHandler(0), mouseMotionHandler(0),
|
||||
statsHandler(new osgViewer::StatsHandler), statsEvent(new osgGA::GUIEventAdapter),
|
||||
currentModifiers(0), osgModifiers(0), resizable(true), mouseWarped(false),
|
||||
scrollButtonPressed(false), useEventModifiers(false)
|
||||
{
|
||||
using namespace osgGA;
|
||||
statsHandler->setKeyEventTogglesOnScreenStats(displayStatsKey);
|
||||
statsHandler->setKeyEventPrintsOutStats(printStatsKey);
|
||||
statsEvent->setEventType(GUIEventAdapter::KEYDOWN);
|
||||
|
||||
keyMaskMap[GUIEventAdapter::KEY_Shift_L]
|
||||
= GUIEventAdapter::MODKEY_LEFT_SHIFT;
|
||||
|
@ -142,6 +151,8 @@ bool FGManipulator::handle(const osgGA::GUIEventAdapter& ea,
|
|||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
handleStats(us);
|
||||
|
||||
switch (ea.getEventType()) {
|
||||
case osgGA::GUIEventAdapter::FRAME:
|
||||
if (idleHandler)
|
||||
|
@ -309,3 +320,21 @@ void FGManipulator::handleKey(const osgGA::GUIEventAdapter& ea, int& key,
|
|||
}
|
||||
}
|
||||
|
||||
void FGManipulator::handleStats(osgGA::GUIActionAdapter& us)
|
||||
{
|
||||
static SGPropertyNode_ptr display = fgGetNode("/sim/rendering/on-screen-statistics", true);
|
||||
static SGPropertyNode_ptr print = fgGetNode("/sim/rendering/print-statistics", true);
|
||||
|
||||
if (display->getBoolValue()) {
|
||||
statsEvent->setKey(displayStatsKey);
|
||||
statsHandler->handle(*statsEvent, us);
|
||||
display->setBoolValue(false);
|
||||
}
|
||||
|
||||
if (print->getBoolValue()) {
|
||||
statsEvent->setKey(printStatsKey);
|
||||
statsHandler->handle(*statsEvent, us);
|
||||
print->setBoolValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <map>
|
||||
#include <osg/Quat>
|
||||
#include <osgGA/MatrixManipulator>
|
||||
#include <osgViewer/ViewerEventHandlers>
|
||||
|
||||
#include "fg_os.hxx"
|
||||
|
||||
|
@ -128,6 +129,8 @@ protected:
|
|||
fgKeyHandler keyHandler;
|
||||
fgMouseClickHandler mouseClickHandler;
|
||||
fgMouseMotionHandler mouseMotionHandler;
|
||||
osg::ref_ptr<osgViewer::StatsHandler> statsHandler;
|
||||
osg::ref_ptr<osgGA::GUIEventAdapter> statsEvent;
|
||||
int currentModifiers;
|
||||
// work-around for OSG bug
|
||||
int osgModifiers;
|
||||
|
@ -145,5 +148,6 @@ protected:
|
|||
// When the viewer is embedded, the host toolkit may deliver a
|
||||
// valid event mask but not control keys.
|
||||
bool useEventModifiers;
|
||||
void handleStats(osgGA::GUIActionAdapter& us);
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -248,10 +248,6 @@ void fgOSOpenWindow(int w, int h, int bpp,
|
|||
viewer->setCameraManipulator(globals->get_renderer()->getManipulator());
|
||||
// Let FG handle the escape key with a confirmation
|
||||
viewer->setKeyEventSetsDone(0);
|
||||
osgViewer::StatsHandler* statsHandler = new osgViewer::StatsHandler;
|
||||
statsHandler->setKeyEventTogglesOnScreenStats('*');
|
||||
statsHandler->setKeyEventPrintsOutStats(0);
|
||||
viewer->addEventHandler(statsHandler);
|
||||
// The viewer won't start without some root.
|
||||
viewer->setSceneData(new osg::Group);
|
||||
globals->get_renderer()->setViewer(viewer.get());
|
||||
|
|
Loading…
Reference in a new issue