Panda3D
|
00001 // Filename: pStatGraph.h 00002 // Created by: drose (19Jul00) 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 PSTATGRAPH_H 00016 #define PSTATGRAPH_H 00017 00018 #include "pandatoolbase.h" 00019 00020 #include "pStatMonitor.h" 00021 #include "pStatClientData.h" 00022 00023 #include "luse.h" 00024 #include "vector_int.h" 00025 00026 #include "pmap.h" 00027 00028 class PStatView; 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Class : PStatGraph 00032 // Description : This is an abstract base class for several different 00033 // kinds of graphs that have a few things in common, 00034 // like labels and guide bars. 00035 //////////////////////////////////////////////////////////////////// 00036 class PStatGraph { 00037 public: 00038 PStatGraph(PStatMonitor *monitor, int xsize, int ysize); 00039 virtual ~PStatGraph(); 00040 00041 INLINE PStatMonitor *get_monitor() const; 00042 00043 INLINE int get_num_labels() const; 00044 INLINE int get_label_collector(int n) const; 00045 INLINE string get_label_name(int n) const; 00046 INLINE LRGBColor get_label_color(int n) const; 00047 00048 INLINE void set_target_frame_rate(double frame_rate); 00049 INLINE double get_target_frame_rate() const; 00050 00051 INLINE int get_xsize() const; 00052 INLINE int get_ysize() const; 00053 00054 enum GuideBarStyle { 00055 GBS_normal, 00056 GBS_target, 00057 GBS_user, 00058 }; 00059 00060 class GuideBar { 00061 public: 00062 GuideBar(double height, const string &label, GuideBarStyle style); 00063 GuideBar(const GuideBar ©); 00064 00065 double _height; 00066 string _label; 00067 GuideBarStyle _style; 00068 }; 00069 00070 enum GuideBarUnits { 00071 GBU_hz = 0x0001, 00072 GBU_ms = 0x0002, 00073 GBU_named = 0x0004, 00074 GBU_show_units = 0x0008, 00075 }; 00076 00077 int get_num_guide_bars() const; 00078 const GuideBar &get_guide_bar(int n) const; 00079 00080 int get_num_user_guide_bars() const; 00081 GuideBar get_user_guide_bar(int n) const; 00082 void move_user_guide_bar(int n, double height); 00083 int add_user_guide_bar(double height); 00084 void remove_user_guide_bar(int n); 00085 int find_user_guide_bar(double from_height, double to_height) const; 00086 00087 INLINE void set_guide_bar_units(int unit_mask); 00088 INLINE int get_guide_bar_units() const; 00089 INLINE void set_guide_bar_unit_name(const string &unit_name); 00090 INLINE const string &get_guide_bar_unit_name() const; 00091 00092 static string format_number(double value); 00093 static string format_number(double value, int guide_bar_units, 00094 const string &unit_name = string()); 00095 00096 protected: 00097 virtual void normal_guide_bars()=0; 00098 void update_guide_bars(int num_bars, double scale); 00099 GuideBar make_guide_bar(double value, GuideBarStyle style = GBS_normal) const; 00100 00101 bool _labels_changed; 00102 bool _guide_bars_changed; 00103 00104 PT(PStatMonitor) _monitor; 00105 00106 double _target_frame_rate; 00107 00108 int _xsize; 00109 int _ysize; 00110 00111 // Table of the collectors that should be drawn as labels, in order 00112 // from bottom to top. 00113 typedef vector_int Labels; 00114 Labels _labels; 00115 00116 typedef pvector<GuideBar> GuideBars; 00117 GuideBars _guide_bars; 00118 int _guide_bar_units; 00119 string _unit_name; 00120 }; 00121 00122 #include "pStatGraph.I" 00123 00124 #endif