Panda3D
|
00001 // Filename: sceneGraphAnalyzerMeter.h 00002 // Created by: pratt (14Feb07) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef SCENEGRAPHANALYZERMETER_H 00016 #define SCENEGRAPHANALYZERMETER_H 00017 00018 #include "pandabase.h" 00019 #include "textNode.h" 00020 #include "nodePath.h" 00021 #include "graphicsOutput.h" 00022 #include "displayRegion.h" 00023 #include "pointerTo.h" 00024 #include "sceneGraphAnalyzer.h" 00025 #include "pStatCollector.h" 00026 00027 class PandaNode; 00028 class GraphicsChannel; 00029 class ClockObject; 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Class : SceneGraphAnalyzerMeter 00033 // Description : This is a special TextNode that automatically updates 00034 // itself with output from a SceneGraphAnalyzer instance. 00035 // It can be placed anywhere in the world where you'd like 00036 // to see the output from SceneGraphAnalyzer. 00037 // 00038 // It also has a special mode in which it may be 00039 // attached directly to a channel or window. If this is 00040 // done, it creates a DisplayRegion for itself and renders 00041 // itself in the upper-right-hand corner. 00042 //////////////////////////////////////////////////////////////////// 00043 class EXPCL_PANDA SceneGraphAnalyzerMeter : public TextNode { 00044 PUBLISHED: 00045 SceneGraphAnalyzerMeter(const string &name, PandaNode *node); 00046 virtual ~SceneGraphAnalyzerMeter(); 00047 00048 void setup_window(GraphicsOutput *window); 00049 void clear_window(); 00050 00051 INLINE GraphicsOutput *get_window() const; 00052 INLINE DisplayRegion *get_display_region() const; 00053 00054 INLINE void set_update_interval(double update_interval); 00055 INLINE double get_update_interval() const; 00056 00057 INLINE void set_node(PandaNode *node); 00058 INLINE PandaNode *get_node() const; 00059 00060 INLINE void update(); 00061 00062 protected: 00063 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data); 00064 00065 private: 00066 void do_update(Thread *current_thread); 00067 00068 private: 00069 PT(GraphicsOutput) _window; 00070 PT(DisplayRegion) _display_region; 00071 NodePath _root; 00072 SceneGraphAnalyzer _scene_graph_analyzer; 00073 00074 double _update_interval; 00075 double _last_update; 00076 PandaNode *_node; 00077 ClockObject *_clock_object; 00078 00079 static PStatCollector _show_analyzer_pcollector; 00080 00081 public: 00082 static TypeHandle get_class_type() { 00083 return _type_handle; 00084 } 00085 static void init_type() { 00086 TextNode::init_type(); 00087 register_type(_type_handle, "SceneGraphAnalyzerMeter", 00088 TextNode::get_class_type()); 00089 } 00090 virtual TypeHandle get_type() const { 00091 return get_class_type(); 00092 } 00093 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00094 00095 private: 00096 static TypeHandle _type_handle; 00097 }; 00098 00099 #include "sceneGraphAnalyzerMeter.I" 00100 00101 #endif