Added Stats::collectStats(string,bool) controls, getAveragedAttribute methods into osg::Stats class, and

related support into osgViewer::Viewer and osgViewer::StatsHandler.

Added lazy updating of text in StatsHandler HUD to minimize the impact of
slow text updating on observed frame rates.
This commit is contained in:
Robert Osfield
2007-01-30 11:40:23 +00:00
parent 7b9b13b6c0
commit ecedc8d86a
14 changed files with 253 additions and 26 deletions

View File

@@ -27,7 +27,7 @@ class OSG_EXPORT Stats : public osg::Referenced
{
public:
Stats(const std::string& name, unsigned int numberOfFrames=100);
Stats(const std::string& name, unsigned int numberOfFrames=50);
void setName(const std::string& name) { _name = name; }
const std::string& getName() const { return _name; }
@@ -42,10 +42,23 @@ class OSG_EXPORT Stats : public osg::Referenced
bool setAttribute(int frameNumber, const std::string& attributeName, double value);
bool getAttribute(int frameNumber, const std::string& attributeName, double& value) const;
bool getAveragedAttribute(const std::string& attributeName, double& value) const;
bool getAveragedAttribute(int startFrameNumber, int endFrameNumber, const std::string& attributeName, double& value) const;
AttributeMap& getAttributeMap(int frameNumber);
const AttributeMap& getAttributeMap(int frameNumber) const;
typedef std::map<std::string, bool> CollectMap;
void collectStats(const std::string& str, bool flag) { _collectMap[str] = flag; }
inline bool collectStats(const std::string& str) const
{
CollectMap::const_iterator itr = _collectMap.find(str);
return (itr != _collectMap.end()) ? itr->second : false;
}
void report(std::ostream& out, const char* indent=0) const ;
void report(std::ostream& out, unsigned int frameNumber, const char* indent=0) const;
@@ -73,6 +86,8 @@ class OSG_EXPORT Stats : public osg::Referenced
AttributeMapList _attributeMapList;
AttributeMap _invalidAttributeMap;
CollectMap _collectMap;
};

View File

@@ -129,6 +129,9 @@ class OSGVIEWER_EXPORT Viewer : public osgViewer::View
typedef std::vector<osgViewer::GraphicsWindow*> Windows;
void getWindows(Windows& windows, bool onlyValid=true);
typedef std::vector<osg::Camera*> Cameras;
void getCameras(Cameras& cameras, bool onlyActive=true);
/** Set the graphics operation to call on realization of the viewers graphics windows.*/
void setRealizeOperation(osg::GraphicsOperation* op) { _realizeOperation = op; }