StatsHandler
Go to the documentation of this file.
/* -*-c++-*-
* Copyright (C) 2009 Cedric Pinson <mornifle@plopbyte.net>
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGANIMATION_STATSHANDLER_H
#define OSGANIMATION_STATSHANDLER_H
#include <osgAnimation/Timeline>
#include <osgGA/GUIEventHandler>
#include <osgViewer/ViewerBase>
#include <osgViewer/Viewer>
#include <osgText/Text>
namespace osgAnimation
{
#if 0
struct StatAction
{
std::string _name;
osg::ref_ptr<osg::Group> _group;
osg::ref_ptr<osg::Geode> _label;
osg::ref_ptr<osg::MatrixTransform> _graph;
osg::ref_ptr<osgText::Text> _textLabel;
void init(osg::Stats* stats, const std::string& name, const osg::Vec3& pos, float width, float heigh, const osg::Vec4& color);
void setPosition(const osg::Vec3& pos);
void setAlpha(float v);
};
#endif
class OSGANIMATION_EXPORT StatsHandler : public osgGA::GUIEventHandler
{
public:
StatsHandler();
enum StatsType
{
NO_STATS = 0,
FRAME_RATE = 1,
LAST = 2
};
void setKeyEventTogglesOnScreenStats(int key) { _keyEventTogglesOnScreenStats = key; }
int getKeyEventTogglesOnScreenStats() const { return _keyEventTogglesOnScreenStats; }
void setKeyEventPrintsOutStats(int key) { _keyEventPrintsOutStats = key; }
int getKeyEventPrintsOutStats() const { return _keyEventPrintsOutStats; }
double getBlockMultiplier() const { return _blockMultiplier; }
void reset();
osg::Camera* getCamera() { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera.get(); }
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
virtual void getUsage(osg::ApplicationUsage& usage) const;
protected:
void setUpHUDCamera(osgViewer::ViewerBase* viewer);
osg::Geometry* createBackgroundRectangle(const osg::Vec3& pos, const float width, const float height, osg::Vec4& color);
osg::Geometry* createGeometry(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numBlocks);
osg::Geometry* createFrameMarkers(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numBlocks);
osg::Geometry* createTick(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numTicks);
osg::Node* createCameraTimeStats(const std::string& font, osg::Vec3& pos, float startBlocks, bool acquireGPUStats, float characterSize, osg::Stats* viewerStats, osg::Camera* camera);
void setUpScene(osgViewer::Viewer* viewer);
int _keyEventTogglesOnScreenStats;
int _keyEventPrintsOutStats;
int _statsType;
bool _initialized;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::Switch> _switch;
osg::ref_ptr<osg::Group> _group;
unsigned int _frameRateChildNum;
unsigned int _numBlocks;
double _blockMultiplier;
float _statsWidth;
float _statsHeight;
// std::map<std::string, StatAction > _actions;
};
}
#endif
GUIEventHandler
Text
Timeline
ViewerBase
Viewer
osgAnimation::StatsHandler::_keyEventTogglesOnScreenStats
int _keyEventTogglesOnScreenStats
Definition StatsHandler:91
osgAnimation::StatsHandler::_frameRateChildNum
unsigned int _frameRateChildNum
Definition StatsHandler:102
osgAnimation::StatsHandler::_blockMultiplier
double _blockMultiplier
Definition StatsHandler:104
osgAnimation::StatsHandler::StatsHandler
StatsHandler()
osgAnimation::StatsHandler::_statsHeight
float _statsHeight
Definition StatsHandler:107
osgAnimation::StatsHandler::_keyEventPrintsOutStats
int _keyEventPrintsOutStats
Definition StatsHandler:92
osgAnimation::StatsHandler::createGeometry
osg::Geometry * createGeometry(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numBlocks)
osgAnimation::StatsHandler::_statsWidth
float _statsWidth
Definition StatsHandler:106
osgAnimation::StatsHandler::getKeyEventPrintsOutStats
int getKeyEventPrintsOutStats() const
Definition StatsHandler:61
osgAnimation::StatsHandler::reset
void reset()
osgAnimation::StatsHandler::getCamera
osg::Camera * getCamera()
Definition StatsHandler:67
osgAnimation::StatsHandler::_group
osg::ref_ptr< osg::Group > _group
Definition StatsHandler:100
osgAnimation::StatsHandler::_numBlocks
unsigned int _numBlocks
Definition StatsHandler:103
osgAnimation::StatsHandler::setKeyEventPrintsOutStats
void setKeyEventPrintsOutStats(int key)
Definition StatsHandler:60
osgAnimation::StatsHandler::StatsType
StatsType
Definition StatsHandler:51
osgAnimation::StatsHandler::NO_STATS
@ NO_STATS
Definition StatsHandler:52
osgAnimation::StatsHandler::LAST
@ LAST
Definition StatsHandler:54
osgAnimation::StatsHandler::FRAME_RATE
@ FRAME_RATE
Definition StatsHandler:53
osgAnimation::StatsHandler::_switch
osg::ref_ptr< osg::Switch > _switch
Definition StatsHandler:99
osgAnimation::StatsHandler::setUpHUDCamera
void setUpHUDCamera(osgViewer::ViewerBase *viewer)
osgAnimation::StatsHandler::setKeyEventTogglesOnScreenStats
void setKeyEventTogglesOnScreenStats(int key)
Definition StatsHandler:57
osgAnimation::StatsHandler::getUsage
virtual void getUsage(osg::ApplicationUsage &usage) const
osgAnimation::StatsHandler::_initialized
bool _initialized
Definition StatsHandler:96
osgAnimation::StatsHandler::createTick
osg::Geometry * createTick(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numTicks)
osgAnimation::StatsHandler::setUpScene
void setUpScene(osgViewer::Viewer *viewer)
osgAnimation::StatsHandler::createBackgroundRectangle
osg::Geometry * createBackgroundRectangle(const osg::Vec3 &pos, const float width, const float height, osg::Vec4 &color)
osgAnimation::StatsHandler::createCameraTimeStats
osg::Node * createCameraTimeStats(const std::string &font, osg::Vec3 &pos, float startBlocks, bool acquireGPUStats, float characterSize, osg::Stats *viewerStats, osg::Camera *camera)
osgAnimation::StatsHandler::_camera
osg::ref_ptr< osg::Camera > _camera
Definition StatsHandler:97
osgAnimation::StatsHandler::getCamera
const osg::Camera * getCamera() const
Definition StatsHandler:68
osgAnimation::StatsHandler::_statsType
int _statsType
Definition StatsHandler:94
osgAnimation::StatsHandler::getKeyEventTogglesOnScreenStats
int getKeyEventTogglesOnScreenStats() const
Definition StatsHandler:58
osgAnimation::StatsHandler::getBlockMultiplier
double getBlockMultiplier() const
Definition StatsHandler:63
osgAnimation::StatsHandler::handle
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
osgAnimation::StatsHandler::createFrameMarkers
osg::Geometry * createFrameMarkers(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numBlocks)
osgGA::GUIActionAdapter
Definition GUIActionAdapter:62
osgGA::GUIEventAdapter
Definition GUIEventAdapter:82
osgGA::GUIEventHandler
Definition GUIEventHandler:50
osgViewer::ViewerBase
Definition ViewerBase:36
osgViewer::Viewer
Definition Viewer:28
osg::ApplicationUsage
Definition ApplicationUsage:26
osg::Camera
Definition Camera:45
osg::Geometry
Definition Geometry:31
osg::Node
Definition Node:72
osg::Stats
Definition Stats:29
osg::ref_ptr
Definition ref_ptr:32
osgAnimation
Definition Action:34
osg::Vec3
Vec3f Vec3
Definition Vec3:21
osg::Vec4
Vec4f Vec4
Definition Vec4:21
OSGANIMATION_EXPORT
#define OSGANIMATION_EXPORT
Definition osgAnimation/Export:40