Refactored the view stats.

This commit is contained in:
Robert Osfield
2009-01-27 13:23:20 +00:00
parent 1787efc9a3
commit 29157f24d9
13 changed files with 269 additions and 106 deletions

View File

@@ -16,6 +16,7 @@
#include <osg/Camera>
#include <osg/Light>
#include <osg/Stats>
#include <OpenThreads/Mutex>
@@ -38,6 +39,17 @@ class OSG_EXPORT View : public virtual osg::Object
/** Take all the settings, Camera and Slaves from the passed in view, leaving it empty. */
virtual void take(View& rhs);
/** Set the Stats object used for collect various frame related timing and scene graph stats.*/
void setStats(osg::Stats* stats) { _stats = stats; }
/** Get the Viewers Stats object.*/
osg::Stats* getStats() { return _stats.get(); }
/** Get the Viewers Stats object.*/
const osg::Stats* getStats() const { return _stats.get(); }
/** Options for controlling the global lighting used for the view.*/
enum LightingMode
{
@@ -139,6 +151,8 @@ class OSG_EXPORT View : public virtual osg::Object
virtual osg::GraphicsOperation* createRenderer(osg::Camera*) { return 0; }
osg::ref_ptr<osg::Stats> _stats;
LightingMode _lightingMode;
osg::ref_ptr<osg::Light> _light;

View File

@@ -39,6 +39,17 @@ class OSGVIEWER_EXPORT CompositeViewer : public ViewerBase, public virtual osg::
/** read the viewer configuration from a configuration file.*/
bool readConfiguration(const std::string& filename);
/** Set the Stats object used for collect various frame related timing and scene graph stats.*/
virtual void setViewerStats(osg::Stats* stats) { _stats = stats; }
/** Get the Viewers Stats object.*/
virtual osg::Stats* getViewerStats() { return _stats.get(); }
/** Get the Viewers Stats object.*/
virtual const osg::Stats* getViewerStats() const { return _stats.get(); }
void addView(osgViewer::View* view);
void removeView(osgViewer::View* view);
@@ -114,6 +125,8 @@ class OSGVIEWER_EXPORT CompositeViewer : public ViewerBase, public virtual osg::
bool _firstFrame;
osg::ref_ptr<osg::Stats> _stats;
osg::Timer_t _startTick;
osg::ref_ptr<osg::FrameStamp> _frameStamp;

View File

@@ -41,6 +41,17 @@ class OSGVIEWER_EXPORT Viewer : public ViewerBase, public osgViewer::View
/** Take all the settings, Camera and Slaves from the passed in view(er), leaving it empty. */
virtual void take(View& rhs);
/** Set the Stats object used for collect various frame related timing and scene graph stats.*/
virtual void setViewerStats(osg::Stats* stats) { setStats(stats); }
/** Get the Viewers Stats object.*/
virtual osg::Stats* getViewerStats() { return getStats(); }
/** Get the Viewers Stats object.*/
virtual const osg::Stats* getViewerStats() const { return getStats(); }
/** read the viewer configuration from a configuration file.*/
virtual bool readConfiguration(const std::string& filename);

View File

@@ -41,13 +41,13 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
/** Set the Stats object used for collect various frame related timing and scene graph stats.*/
void setStats(osg::Stats* stats) { _stats = stats; }
virtual void setViewerStats(osg::Stats* stats) = 0;
/** Get the Viewers Stats object.*/
osg::Stats* getStats() { return _stats.get(); }
virtual osg::Stats* getViewerStats() = 0;
/** Get the Viewers Stats object.*/
const osg::Stats* getStats() const { return _stats.get(); }
virtual const osg::Stats* getViewerStats() const = 0;
/** read the viewer configuration from a configuration file.*/
@@ -259,9 +259,6 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
}
virtual void viewerInit() = 0;
osg::ref_ptr<osg::Stats> _stats;
bool _firstFrame;
bool _done;