VR-Forces 4.10 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) 2021 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
5 
6 #pragma once
7 
11 
12 #include <vrvOsg/vrvOsg.h>
15 
16 #include <osgViewer/ViewerEventHandlers>
17 #include <osg/Matrix>
18 
19 namespace osg
20 {
21  class Switch;
22  class MatrixTransform;
23  class Geode;
24 }
25 
26 namespace osgViewer
27 {
28  class View;
29 }
30 
31 namespace osgText
32 {
33  class Text;
34 }
35 
36 
37 
38 
39 namespace makVrv
40 {
41  class DtDe;
42  class DtBaseConnection;
43  class DtProfileNode;
44  class DtOsgPerformanceStats;
45  class DtOsgProfilerStats;
46 
53  class DT_DLL_VRVOSG DtStatsHandler : public osgViewer::StatsHandler
54  {
55  public: // public typedefs and enumerations
57  {
58  NO_PROFILER_STATS = 0,
60  FUNCTION_STATS = 2,
61  BOTH_STATS = 3,
62  LAST_PROFILER_STATS = 4
63  };
64 
65  public: // public constructors and destructors
67  DtStatsHandler(DtDe& de);
68 
69  //This is used to extend the current transform ability of osg stats
70  //It will add a matrix transform to the end of the list, then use the key to toggle
71  //between the matrix lists.
72  virtual void addTransform(const osg::Matrix& transform);
73 
74  //This will clear the default added transforms,
75  //Then user can use addTransform to add their own matrixs
76  virtual void clearTransforms();
77 
78  //set the key toggle the Profiler Stats, default is F3
79  virtual void setKeyEventTogglesProfilerStats(int key);
80 
81  //get the key toggle the Profiler Stats, default is F3
82  virtual int getKeyEventTogglesProfilerStats(void);
83 
84  //set the key toggle the Profiler recording, default is F9
85  virtual void setKeyEventTogglesProfilerRecording(int key);
86 
87  //get the key toggle the Profiler recording, default is F9
88  virtual int getKeyEventTogglesProfilerRecording(void);
89 
91  virtual DtOsgPerformanceStats* osgPerformanceStats();
92 
94  virtual DtOsgProfilerStats* osgProfilerStats();
95 
96  protected:
98  virtual ~DtStatsHandler();
99 
100  //create a matrix that map 2DRectangle(lowerLeft1,upperRight1)-->2DRectangle(lowerLeft1,upperRight1)
101  osg::Matrix make2DWindowingTransform(osg::Vec2 lowerLeft1, osg::Vec2 upperRight1,
102  osg::Vec2 lowerLeft2, osg::Vec2 upperRight2);
103 
104  //update the matrix used to transform the osg stats
105  virtual void updateTransformMatrix();
106 
107  //Add all the matrixs to the osg stats,so we can toggle between them.
108  //It will be called when you first hit the transform osg stats key
109  virtual void initializeTransforms();
110 
111  //turn off the osg stats
112  virtual void turnOffOsgStats(osgViewer::View* view);
113 
114  //turn off the performance and profiler stats and stop profiling
115  virtual void turnOffBothProfilerStats(bool sendSettingsToGui);
116 
117  //This will create a instance of DtOsgPerformanceStats and connect the necessary signals
118  //only if the instance is 0,It will also start profiling
119  virtual void createPerformanceStats();
120 
121  //This will delete the instance of DtOsgPerformanceStats and disconnect the necessary signals
122  //It will also stop profilinng
123  virtual void deletePerformanceStats();
124 
125  //Send the performance stats to update the GUI
126  virtual void sendPerformanceStatsToGUI(unsigned int state);
127 
128  //turn off the performance stats
129  virtual void turnOffPerformanceStats(bool sendSettingsToGui);
130 
131  //This will create a instance of DtOsgProfilerStats and connect the necessary signals
132  //only if the instance is 0, It will also start profiling
133  virtual void createProfilerStats();
134 
135  //This will create the instance of DtOsgProfilerStats and disconnect the necessary signals
136  //It will also stop profiling
137  virtual void deleteProfilerStats();
138 
139  //Send the profiler stats to update the GUI
140  virtual void sendProfilerStatsToGUI(bool enabled);
141 
142  //turn off the profiler stats
143  virtual void turnOffProfilerStats(bool sendSettingsToGui);
144 
145  //toggle between the Performance stats and Function stats
146  virtual void updateProfilerStats(bool sendSettingsToGui);
147 
148  //set up the text node of the profiler stats
149  virtual void setUpProfilerStatsScene();
150 
153  virtual void initialize();
154 
156  virtual void passKeyEventToStats(int key, int modifier);
157 
159  virtual void setPerformanceStatsOverlayEnabled(bool show, bool sendSettingsToGui = true);
160 
162  virtual bool performanceStatsOverlayEnabled() const;
163 
165  virtual void setProfilerOverlayEnabled(bool show,bool sendSettingsToGui = true);
166 
168  virtual bool profilerOverlayEnabled() const;
169 
171  virtual void slot_updateDtOsgPerformanceStats(const std::string& string);
172 
175  virtual void slot_updateDtOsgProfilerStats(const std::string& string, int numOfLines);
176 
178  virtual void slot_onPerformanceStatsOverlayOnChanged(bool mode);
179 
181  virtual void slot_onProfilerOverlayOnChanged(bool mode);
182 
183  private:
185  DtStatsHandler(const DtStatsHandler &other) = delete;
187  DtStatsHandler &operator=(const DtStatsHandler &other) = delete;
188 
189  public:
190 
192  virtual int getStatsType();
193 
195  virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
196 
197  protected:
199  osg::GraphicsContext* findValidContext(osg::GraphicsContext* context, osgViewer::View* view);
200 
201  protected:
204  osg::observer_ptr<osgViewer::View> myOsgView;
207  std::vector<osg::Matrix> myMatrixs;
216  std::string myProfilerStatsFont;
221  unsigned int myOsgStatsChildNum;
231  };
232 
238  {
239  public: // public typedefs and enumerations
240  public: // public constructors and destructors
241  protected:
242 
245 
247  virtual ~DtStatsHandlerManager();
248 
249  private:
250 
252  DtStatsHandlerManager(const DtStatsHandlerManager &other) = delete;
254  DtStatsHandlerManager &operator=(const DtStatsHandlerManager &other) = delete;
255 
256  public:
257 
259  virtual void toggleOnScreenStats();
260 
262  virtual void toggleProfilerStats();
263 
265  virtual void printStats();
266 
267  //sends the command to the stats handler for transforming the stats
268  virtual void transformStats();
269 
271  virtual void recreateStatsHandler();
272 
273  public:
274 
276  static DtStatsHandlerManager& instance(DtDe& de);
277 
278  protected:
279 
281 
283  };
284 }
A stats which shows the osg profiler.
Definition: DtOsgProfilerStats.h:22
DtDe & myDe
Definition: DtStatsHandlerManager.h:202
Virtual base class.
Definition: DtVirtualBaseClass.h:19
DtOsgPerformanceStats * myDtOsgPerformanceStats
Definition: DtStatsHandlerManager.h:225
unsigned int myPerformanceStatsChildNum
Definition: DtStatsHandlerManager.h:222
osg::Vec4 myProfilerStatsTextColor
Definition: DtStatsHandlerManager.h:213
bool myStatsActive
Definition: DtStatsHandlerManager.h:229
A stats which shows the IG&#39;s performance stats.
Definition: DtOsgPerformanceStats.h:28
osg::ref_ptr< osg::Switch > myStatsSwitch
Definition: DtStatsHandlerManager.h:214
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
int myKeyEventTogglesProfilerStats
Definition: DtStatsHandlerManager.h:209
bool myNeedEnableOsgProfilerInStartup
Definition: DtStatsHandlerManager.h:228
bool myFixedText
Definition: DtStatsHandlerManager.h:208
osg::ref_ptr< osg::Geode > myPerformanceGeode
Definition: DtStatsHandlerManager.h:217
ProfilerStatsType
Definition: DtStatsHandlerManager.h:56
DtOsgProfilerStats * myDtOsgProfilerStats
Definition: DtStatsHandlerManager.h:226
int myKeyEventTogglesProfilerRecording
Definition: DtStatsHandlerManager.h:210
osg::ref_ptr< osgText::Text > myPerformanceStatsText
Definition: DtStatsHandlerManager.h:218
osg::ref_ptr< osg::Switch > myProfilerStatsSwitch
Definition: DtStatsHandlerManager.h:215
int myProfilerStatsType
Definition: DtStatsHandlerManager.h:211
Contains makVrv::DtVirtualBaseClass class.
Definition: vrvControlToolkitDataTypes_v0.h:54
osg::ref_ptr< DtStatsHandler > myStatsHandler
Definition: DtStatsHandlerManager.h:282
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
bool mySetUpProfilerStatsScene
Definition: DtStatsHandlerManager.h:224
bool myNeedEnableOsgPerformanceInStartup
Definition: DtStatsHandlerManager.h:227
DtDe & myDe
Definition: DtStatsHandlerManager.h:280
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
int myMaximumTransform
Definition: DtStatsHandlerManager.h:206
std::string myProfilerStatsFont
Definition: DtStatsHandlerManager.h:216
DtSignalConnectionManager myConnections
Definition: DtStatsHandlerManager.h:230
Class for managing the creation and recreation of the stats handler.
Definition: DtStatsHandlerManager.h:237
osg::ref_ptr< osg::Geode > myProfilerGeode
Definition: DtStatsHandlerManager.h:219
Base class to provide boost signal/slot management.
unsigned int myProfilerStatsChildNum
Definition: DtStatsHandlerManager.h:223
osg::ref_ptr< osg::MatrixTransform > myMatrixTransform
Definition: DtStatsHandlerManager.h:203
const char int mode
Definition: ioapi.h:38
std::vector< osg::Matrix > myMatrixs
Definition: DtStatsHandlerManager.h:207
int myTransformType
Definition: DtStatsHandlerManager.h:205
unsigned int myOsgStatsChildNum
Definition: DtStatsHandlerManager.h:221
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
osgViewer::StatsHandler derived class used to fix a few problems that class has in VR-Vantage More sp...
Definition: DtStatsHandlerManager.h:53
osg::observer_ptr< osgViewer::View > myOsgView
Definition: DtStatsHandlerManager.h:204
osg::ref_ptr< osgText::Text > myProfilerStatsText
Definition: DtStatsHandlerManager.h:220
float myProfilerStatsTextSize
Definition: DtStatsHandlerManager.h:212

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)