Panda3D
sceneGraphAnalyzerMeter.h
1 // Filename: sceneGraphAnalyzerMeter.h
2 // Created by: pratt (14Feb07)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef SCENEGRAPHANALYZERMETER_H
16 #define SCENEGRAPHANALYZERMETER_H
17 
18 #include "pandabase.h"
19 #include "textNode.h"
20 #include "nodePath.h"
21 #include "graphicsOutput.h"
22 #include "displayRegion.h"
23 #include "pointerTo.h"
24 #include "sceneGraphAnalyzer.h"
25 #include "pStatCollector.h"
26 
27 class PandaNode;
28 class GraphicsChannel;
29 class ClockObject;
30 
31 ////////////////////////////////////////////////////////////////////
32 // Class : SceneGraphAnalyzerMeter
33 // Description : This is a special TextNode that automatically updates
34 // itself with output from a SceneGraphAnalyzer instance.
35 // It can be placed anywhere in the world where you'd like
36 // to see the output from SceneGraphAnalyzer.
37 //
38 // It also has a special mode in which it may be
39 // attached directly to a channel or window. If this is
40 // done, it creates a DisplayRegion for itself and renders
41 // itself in the upper-right-hand corner.
42 ////////////////////////////////////////////////////////////////////
43 class EXPCL_PANDA SceneGraphAnalyzerMeter : public TextNode {
44 PUBLISHED:
45  SceneGraphAnalyzerMeter(const string &name, PandaNode *node);
46  virtual ~SceneGraphAnalyzerMeter();
47 
48  void setup_window(GraphicsOutput *window);
49  void clear_window();
50 
51  INLINE GraphicsOutput *get_window() const;
52  INLINE DisplayRegion *get_display_region() const;
53 
54  INLINE void set_update_interval(double update_interval);
55  INLINE double get_update_interval() const;
56 
57  INLINE void set_node(PandaNode *node);
58  INLINE PandaNode *get_node() const;
59 
60  INLINE void update();
61 
62 protected:
63  virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
64 
65 private:
66  void do_update(Thread *current_thread);
67 
68 private:
69  PT(GraphicsOutput) _window;
70  PT(DisplayRegion) _display_region;
71  NodePath _root;
72  SceneGraphAnalyzer _scene_graph_analyzer;
73 
74  double _update_interval;
75  double _last_update;
76  PandaNode *_node;
77  ClockObject *_clock_object;
78 
79  static PStatCollector _show_analyzer_pcollector;
80 
81 public:
82  static TypeHandle get_class_type() {
83  return _type_handle;
84  }
85  static void init_type() {
86  TextNode::init_type();
87  register_type(_type_handle, "SceneGraphAnalyzerMeter",
88  TextNode::get_class_type());
89  }
90  virtual TypeHandle get_type() const {
91  return get_class_type();
92  }
93  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
94 
95 private:
96  static TypeHandle _type_handle;
97 };
98 
99 #include "sceneGraphAnalyzerMeter.I"
100 
101 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is a special TextNode that automatically updates itself with output from a SceneGraphAnalyzer in...
This collects together the pieces of data that are accumulated for each node while walking the scene ...
A lightweight class that represents a single element that may be timed and/or counted via stats...
A handy class that can scrub over a scene graph and collect interesting statistics on it...
A ClockObject keeps track of elapsed real time and discrete time.
Definition: clockObject.h:66
void update()
Can be called after the TextNode has been fully configured, to force the node to recompute its text i...
Definition: textNode.I:1421
This is a base class for the various different classes that represent the result of a frame of render...
A thread; that is, a lightweight process.
Definition: thread.h:51
The primary interface to this module.
Definition: textNode.h:52
A rectangular subregion within a window for rendering into.
Definition: displayRegion.h:61
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48