VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtStatsHandlerManager.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2017 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
5 
6 #pragma once
7 
11 
12 #include <vrvOsg/vrvOsg.h>
14 
15 #include <osgViewer/ViewerEventHandlers>
16 #include <osg/Matrix>
17 
18 namespace osg
19 {
20  class Switch;
21  class MatrixTransform;
22  class Geode;
23 }
24 
25 namespace osgViewer
26 {
27  class View;
28 }
29 
30 namespace osgText
31 {
32  class Text;
33 }
34 
35 
36 
37 
38 namespace makVrv
39 {
40  class DtDe;
41  class DtBaseConnection;
42  class DtProfileNode;
43  class DtOsgPerformanceStats;
44  class DtOsgProfilerStats;
45 
52  class DT_DLL_VRVOSG DtStatsHandler : public osgViewer::StatsHandler
53  {
54  public: // public typedefs and enumerations
56  {
57  NO_PROFILER_STATS = 0,
59  FUNCTION_STATS = 2,
60  BOTH_STATS = 3,
61  LAST_PROFILER_STATS = 4
62  };
63 
64  public: // public constructors and destructors
66  DtStatsHandler(DtDe& de);
67 
68  //This is used to extend the current transform ability of osg stats
69  //It will add a matrix transform to the end of the list, then use the key to toggle
70  //between the matrix lists.
71  virtual void addTransform(const osg::Matrix& transform);
72 
73  //This will clear the default added transforms,
74  //Then user can use addTransform to add their own matrixs
75  virtual void clearTransforms();
76 
77  //set the key toggale the Profiler Stats, default is F3
78  virtual void setKeyEventTogglesProfilerStats(int key);
79 
80  virtual int getKeyEventTogglesProfilerStats();
81 
82  protected:
84  virtual ~DtStatsHandler();
85 
86  //create a matrix that map 2DRectangle(lowerLeft1,upperRight1)-->2DRectangle(lowerLeft1,upperRight1)
87  osg::Matrix make2DWindowingTransform(osg::Vec2 lowerLeft1, osg::Vec2 upperRight1,
88  osg::Vec2 lowerLeft2, osg::Vec2 upperRight2);
89 
90  //update the matrix used to transform the osg stats
91  virtual void updateTransformMatrix();
92 
93  //Add all the matrixs to the osg stats,so we can toggle between them.
94  //It will be called when you first hit the transform osg stats key
95  virtual void initializeTransforms();
96 
97  //turn off the osg stats
98  virtual void turnOffOsgStats(osgViewer::View* view);
99 
100  //turn off the performance and profiler stats and stop profiling
101  virtual void turnOffBothProfilerStats(bool sendSettingsToGui);
102 
103  //This will create a instance of DtOsgPerformanceStats and connect the necessary signals
104  //only if the instance is 0,It will also start profilinng
105  virtual void createPerformanceStats();
106 
107  //This will delete the instance of DtOsgPerformanceStats and disconnect the necessary signals
108  //It will also stop profilinng
109  virtual void deletePerformanceStats();
110 
111  //Send the performance stats to update the GUI
112  virtual void sendPerformanceStatsToGUI(bool enabled);
113 
114  //turn off the performance stats
115  virtual void turnOffPerformanceStats(bool sendSettingsToGui);
116 
117  //This will create a instance of DtOsgProfilerStats and connect the necessary signals
118  //only if the instance is 0,It will also start profilinng
119  virtual void createProfilerStats();
120 
121  //This will create the instance of DtOsgProfilerStats and disconnect the necessary signals
122  //It will also stop profilinng
123  virtual void deleteProfilerStats();
124 
125  //Send the profiler stats to update the GUI
126  virtual void sendProfilerStatsToGUI(bool enabled);
127 
128  //turn off the profiler stats
129  virtual void turnOffProfilerStats(bool sendSettingsToGui);
130 
131  //toggle between the Performance stats and Funtion stats
132  virtual void updateProfilerStats(bool sendSettingsToGui);
133 
134  //set up the text node of the profiler stats
135  virtual void setUpProfilerStatsScene();
136 
139  virtual void initialize();
140 
142  virtual void passKeyEventToStats(int key, int modifier);
143 
145  virtual void setPerformanceStatsOverlayEnabled(bool show, bool sendSettingsToGui = true);
146 
148  virtual bool performanceStatsOverlayEnabled() const;
149 
151  virtual void setProfilerOverlayEnabled(bool show,bool sendSettingsToGui = true);
152 
154  virtual bool profilerOverlayEnabled() const;
155 
157  virtual void slot_updateDtOsgPerformanceStats(const std::string& string);
158 
161  virtual void slot_updateDtOsgProfilerStats(const std::string& string, int numOfLines);
162 
164  virtual void slot_onPerformanceStatsOverlayOnChanged(bool mode);
165 
167  virtual void slot_onProfilerOverlayOnChanged(bool mode);
168 
169  private:
171  DtStatsHandler(const DtStatsHandler &other);
173  DtStatsHandler &operator=(const DtStatsHandler &other);
174 
175  public:
176 
178  virtual int getStatsType();
179 
181  virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
182 
183  protected:
185  osg::ref_ptr<osg::MatrixTransform> myMatrixTransform;
186  osg::observer_ptr<osgViewer::View> myOsgView;
189  std::vector<osg::Matrix> myMatrixs;
195  osg::ref_ptr<osg::Switch> myStatsSwitch;
196  osg::ref_ptr<osg::Switch> myProfilerStatsSwitch;
197  std::string myProfilerStatsFont;
198  osg::ref_ptr<osg::Geode> myPerformanceGeode;
199  osg::ref_ptr<osgText::Text> myPerformanceStatsText;
200  osg::ref_ptr<osg::Geode> myProfilerGeode;
201  osg::ref_ptr<osgText::Text> myProfilerStatsText;
202  unsigned int myOsgStatsChildNum;
211  };
212 
218  {
219  public: // public typedefs and enumerations
220  public: // public constructors and destructors
221  protected:
222 
225 
227  virtual ~DtStatsHandlerManager();
228 
229  private:
230 
234  DtStatsHandlerManager &operator=(const DtStatsHandlerManager &other);
235 
236  public:
237 
239  virtual void toggleOnScreenStats();
240 
242  virtual void toggleProfilerStats();
243 
245  virtual void printStats();
246 
247  //sends the command to the stats handler for transforming the stats
248  virtual void transformStats();
249 
251  virtual void recreateStatsHandler();
252 
253  public:
254 
256  static DtStatsHandlerManager& instance(DtDe& de);
257 
258  protected:
259 
261 
262  osg::ref_ptr<DtStatsHandler> myStatsHandler;
263  };
264 }

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)