openscenegraph
StatsHandler
Go to the documentation of this file.
1/* -*-c++-*-
2 * Copyright (C) 2009 Cedric Pinson <mornifle@plopbyte.net>
3 *
4 * This library is open source and may be redistributed and/or modified under
5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6 * (at your option) any later version. The full license is in LICENSE file
7 * included with this distribution, and on the openscenegraph.org website.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * OpenSceneGraph Public License for more details.
13*/
14
15#ifndef OSGANIMATION_STATSHANDLER_H
16#define OSGANIMATION_STATSHANDLER_H
17
18#include <osgAnimation/Timeline>
19#include <osgGA/GUIEventHandler>
20#include <osgViewer/ViewerBase>
21#include <osgViewer/Viewer>
22#include <osgText/Text>
23
24namespace osgAnimation
25{
26#if 0
27 struct StatAction
28 {
29
30 std::string _name;
35
36 void init(osg::Stats* stats, const std::string& name, const osg::Vec3& pos, float width, float heigh, const osg::Vec4& color);
37 void setPosition(const osg::Vec3& pos);
38 void setAlpha(float v);
39 };
40
41#endif
42
45 {
46 public:
47
49
51 {
52 NO_STATS = 0,
53 FRAME_RATE = 1,
54 LAST = 2
55 };
56
57 void setKeyEventTogglesOnScreenStats(int key) { _keyEventTogglesOnScreenStats = key; }
58 int getKeyEventTogglesOnScreenStats() const { return _keyEventTogglesOnScreenStats; }
59
60 void setKeyEventPrintsOutStats(int key) { _keyEventPrintsOutStats = key; }
61 int getKeyEventPrintsOutStats() const { return _keyEventPrintsOutStats; }
62
63 double getBlockMultiplier() const { return _blockMultiplier; }
64
65 void reset();
66
67 osg::Camera* getCamera() { return _camera.get(); }
68 const osg::Camera* getCamera() const { return _camera.get(); }
69
71
73 virtual void getUsage(osg::ApplicationUsage& usage) const;
74
75 protected:
76
78
79 osg::Geometry* createBackgroundRectangle(const osg::Vec3& pos, const float width, const float height, osg::Vec4& color);
80
81 osg::Geometry* createGeometry(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numBlocks);
82
83 osg::Geometry* createFrameMarkers(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numBlocks);
84
85 osg::Geometry* createTick(const osg::Vec3& pos, float height, const osg::Vec4& colour, unsigned int numTicks);
86
87 osg::Node* createCameraTimeStats(const std::string& font, osg::Vec3& pos, float startBlocks, bool acquireGPUStats, float characterSize, osg::Stats* viewerStats, osg::Camera* camera);
88
90
93
95
98
101
102 unsigned int _frameRateChildNum;
103 unsigned int _numBlocks;
105
108
109// std::map<std::string, StatAction > _actions;
110 };
111
112}
113#endif
Definition StatsHandler:45
int _keyEventTogglesOnScreenStats
Definition StatsHandler:91
unsigned int _frameRateChildNum
Definition StatsHandler:102
double _blockMultiplier
Definition StatsHandler:104
float _statsHeight
Definition StatsHandler:107
int _keyEventPrintsOutStats
Definition StatsHandler:92
osg::Geometry * createGeometry(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numBlocks)
float _statsWidth
Definition StatsHandler:106
int getKeyEventPrintsOutStats() const
Definition StatsHandler:61
osg::Camera * getCamera()
Definition StatsHandler:67
osg::ref_ptr< osg::Group > _group
Definition StatsHandler:100
unsigned int _numBlocks
Definition StatsHandler:103
void setKeyEventPrintsOutStats(int key)
Definition StatsHandler:60
StatsType
Definition StatsHandler:51
osg::ref_ptr< osg::Switch > _switch
Definition StatsHandler:99
void setUpHUDCamera(osgViewer::ViewerBase *viewer)
void setKeyEventTogglesOnScreenStats(int key)
Definition StatsHandler:57
virtual void getUsage(osg::ApplicationUsage &usage) const
bool _initialized
Definition StatsHandler:96
osg::Geometry * createTick(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numTicks)
void setUpScene(osgViewer::Viewer *viewer)
osg::Geometry * createBackgroundRectangle(const osg::Vec3 &pos, const float width, const float height, osg::Vec4 &color)
osg::Node * createCameraTimeStats(const std::string &font, osg::Vec3 &pos, float startBlocks, bool acquireGPUStats, float characterSize, osg::Stats *viewerStats, osg::Camera *camera)
osg::ref_ptr< osg::Camera > _camera
Definition StatsHandler:97
const osg::Camera * getCamera() const
Definition StatsHandler:68
int _statsType
Definition StatsHandler:94
int getKeyEventTogglesOnScreenStats() const
Definition StatsHandler:58
double getBlockMultiplier() const
Definition StatsHandler:63
virtual bool handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa)
osg::Geometry * createFrameMarkers(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numBlocks)
Definition GUIActionAdapter:62
Definition GUIEventAdapter:82
Definition GUIEventHandler:50
Definition ViewerBase:36
Definition Viewer:28
Definition ApplicationUsage:26
Definition Camera:45
Definition Geometry:31
Definition Node:72
Definition Stats:29
Definition Vec3f:29
Definition Vec4f:28
Definition ref_ptr:32
Definition Action:34
#define OSGANIMATION_EXPORT
Definition osgAnimation/Export:40