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