sceneGraphAnalyzerMeter.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. #ifndef SCENEGRAPHANALYZERMETER_H
  15. #define SCENEGRAPHANALYZERMETER_H
  16. #include "pandabase.h"
  17. #include "textNode.h"
  18. #include "nodePath.h"
  19. #include "graphicsOutput.h"
  20. #include "displayRegion.h"
  21. #include "pointerTo.h"
  22. #include "sceneGraphAnalyzer.h"
  23. #include "pStatCollector.h"
  24. class PandaNode;
  25. class GraphicsChannel;
  26. class ClockObject;
  27. ////////////////////////////////////////////////////////////////////
  28. // Class : SceneGraphAnalyzerMeter
  29. // Description : This is a special TextNode that automatically updates
  30. // itself with output from a SceneGraphAnalyzer instance.
  31. // It can be placed anywhere in the world where you'd like
  32. // to see the output from SceneGraphAnalyzer.
  33. //
  34. // It also has a special mode in which it may be
  35. // attached directly to a channel or window. If this is
  36. // done, it creates a DisplayRegion for itself and renders
  37. // itself in the upper-right-hand corner.
  38. ////////////////////////////////////////////////////////////////////
  39. class EXPCL_PANDA SceneGraphAnalyzerMeter : public TextNode {
  40. PUBLISHED:
  41. SceneGraphAnalyzerMeter(const string &name, PandaNode *node);
  42. virtual ~SceneGraphAnalyzerMeter();
  43. void setup_window(GraphicsOutput *window);
  44. void clear_window();
  45. INLINE GraphicsOutput *get_window() const;
  46. INLINE DisplayRegion *get_display_region() const;
  47. INLINE void set_update_interval(double update_interval);
  48. INLINE double get_update_interval() const;
  49. INLINE void set_node(PandaNode *node);
  50. INLINE PandaNode *get_node() const;
  51. INLINE void update();
  52. protected:
  53. virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
  54. private:
  55. void do_update(Thread *current_thread);
  56. private:
  57. PT(GraphicsOutput) _window;
  58. PT(DisplayRegion) _display_region;
  59. NodePath _root;
  60. SceneGraphAnalyzer _scene_graph_analyzer;
  61. double _update_interval;
  62. double _last_update;
  63. PandaNode *_node;
  64. ClockObject *_clock_object;
  65. static PStatCollector _show_analyzer_pcollector;
  66. public:
  67. static TypeHandle get_class_type() {
  68. return _type_handle;
  69. }
  70. static void init_type() {
  71. TextNode::init_type();
  72. register_type(_type_handle, "SceneGraphAnalyzerMeter",
  73. TextNode::get_class_type());
  74. }
  75. virtual TypeHandle get_type() const {
  76. return get_class_type();
  77. }
  78. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  79. private:
  80. static TypeHandle _type_handle;
  81. };
  82. #include "sceneGraphAnalyzerMeter.I"
  83. #endif