OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
coVRStatsDisplay.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef CO_coVRStatsDisplay_h
9 #define CO_coVRStatsDisplay_h
10 
11 #include <util/coTypes.h>
12 #include <osg/AnimationPath>
13 #include <osgText/Text>
14 #include <osgGA/GUIEventHandler>
15 #include <osgGA/AnimationPathManipulator>
16 
17 #include <osgViewer/GraphicsWindow>
18 #include <osgViewer/Viewer>
19 
20 //#include <osgDB/fstream>
21 namespace opencover
22 {
23 class COVEREXPORT coVRStatsDisplay
24 {
25  friend class VRViewer;
26 public:
28  virtual ~coVRStatsDisplay(){};
29 
30  enum StatsType
31  {
32  NO_STATS = 0,
33  FRAME_RATE = 1,
34  VIEWER_STATS = 2,
35  CAMERA_SCENE_STATS = 3,
36  VIEWER_SCENE_STATS = 4,
37  LAST = 5
38  };
39 
40  double getBlockMultiplier() const
41  {
42  return _blockMultiplier;
43  }
44 
45  void reset();
46 
47  osg::Camera *getCamera()
48  {
49  return _camera.get();
50  }
51  const osg::Camera *getCamera() const
52  {
53  return _camera.get();
54  }
55 
56  void showStats(int whichStats, osgViewer::ViewerBase *viewer);
57 
58  void enableGpuStats(bool enable, const std::string &devname = std::string());
59  void enableRhrStats(bool enable);
60  void enableFinishStats(bool enable);
61  void enableSyncStats(bool enable);
62 
64  virtual void getUsage(osg::ApplicationUsage &usage) const;
65 
66 protected:
67  void setUpHUDCamera(osgViewer::ViewerBase *viewer);
68 
69  osg::Geometry *createBackgroundRectangle(const osg::Vec3 &pos, const float width, const float height, osg::Vec4 &color);
70 
71  osg::Geometry *createGeometry(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numBlocks);
72 
73  osg::Geometry *createFrameMarkers(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numBlocks);
74 
75  osg::Geometry *createTick(const osg::Vec3 &pos, float height, const osg::Vec4 &colour, unsigned int numTicks);
76 
77  osg::Node *createCameraTimeStats(const std::string &font, osg::Vec3 &pos, float startBlocks, bool acquireGPUStats, float characterSize, osg::Stats *viewerStats, osg::Camera *camera);
78 
79  void setUpScene(osgViewer::ViewerBase *viewer);
80 
81  void updateThreadingModelText(osgViewer::ViewerBase::ThreadingModel tm);
82 
84 
86  osg::ref_ptr<osg::Camera> _camera;
87 
88  osg::ref_ptr<osg::Switch> _switch;
89 
90  osgViewer::ViewerBase::ThreadingModel _threadingModel;
91  osg::ref_ptr<osgText::Text> _threadingModelText;
92 
93  bool _finishStats = true;
94  bool _syncStats = true;
95  bool _gpuStats = false;
96  std::string _gpuName;
97  bool _rhrStats = false;
98  unsigned int _frameRateChildNum;
99  unsigned int _gpuMemChildNum;
100  unsigned int _gpuPCIeChildNum;
101  unsigned int _gpuClockChildNum;
102  unsigned int _gpuUtilChildNum;
104  unsigned int _rhrFpsChildNum;
105  unsigned int _rhrBandwidthChildNum;
106  unsigned int _rhrDelayChildNum;
107  unsigned int _rhrSkippedChildNum;
108  unsigned int _viewerChildNum;
109  unsigned int _gpuChildNum;
110  unsigned int _cameraSceneChildNum;
111  unsigned int _viewerSceneChildNum;
112  unsigned int _numBlocks;
114 
115  float _statsWidth;
117 };
118 }
119 #endif
unsigned int _viewerSceneChildNum
Definition: coVRStatsDisplay.h:111
unsigned int _gpuClockChildNum
Definition: coVRStatsDisplay.h:101
Definition: VRViewer.h:52
osg::Camera * getCamera()
Definition: coVRStatsDisplay.h:47
osgViewer::ViewerBase::ThreadingModel _threadingModel
Definition: coVRStatsDisplay.h:90
unsigned int _gpuChildNum
Definition: coVRStatsDisplay.h:109
osg::ref_ptr< osgText::Text > _threadingModelText
Definition: coVRStatsDisplay.h:91
unsigned int _rhrDelayChildNum
Definition: coVRStatsDisplay.h:106
unsigned int _cameraSceneChildNum
Definition: coVRStatsDisplay.h:110
unsigned int _rhrBandwidthChildNum
Definition: coVRStatsDisplay.h:105
unsigned int _gpuPCIeChildNum
Definition: coVRStatsDisplay.h:100
int _statsType
Definition: coVRStatsDisplay.h:83
unsigned int _viewerChildNum
Definition: coVRStatsDisplay.h:108
osg::ref_ptr< osg::Camera > _camera
Definition: coVRStatsDisplay.h:86
const osg::Camera * getCamera() const
Definition: coVRStatsDisplay.h:51
unsigned int _threadingModelChildNum
Definition: coVRStatsDisplay.h:103
unsigned int _gpuMemChildNum
Definition: coVRStatsDisplay.h:99
float _statsWidth
Definition: coVRStatsDisplay.h:115
unsigned int _frameRateChildNum
Definition: coVRStatsDisplay.h:98
unsigned int _numBlocks
Definition: coVRStatsDisplay.h:112
virtual ~coVRStatsDisplay()
Definition: coVRStatsDisplay.h:28
unsigned int _rhrSkippedChildNum
Definition: coVRStatsDisplay.h:107
unsigned int _rhrFpsChildNum
Definition: coVRStatsDisplay.h:104
std::string _gpuName
Definition: coVRStatsDisplay.h:96
double getBlockMultiplier() const
Definition: coVRStatsDisplay.h:40
float _statsHeight
Definition: coVRStatsDisplay.h:116
StatsType
Definition: coVRStatsDisplay.h:30
Definition: coVRStatsDisplay.h:23
osg::ref_ptr< osg::Switch > _switch
Definition: coVRStatsDisplay.h:88
unsigned int _gpuUtilChildNum
Definition: coVRStatsDisplay.h:102
bool _initialized
Definition: coVRStatsDisplay.h:85
double _blockMultiplier
Definition: coVRStatsDisplay.h:113