Panda3D
 All Classes Functions Variables Enumerations
pStatGraph.h
1 // Filename: pStatGraph.h
2 // Created by: drose (19Jul00)
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 PSTATGRAPH_H
16 #define PSTATGRAPH_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "pStatMonitor.h"
21 #include "pStatClientData.h"
22 
23 #include "luse.h"
24 #include "vector_int.h"
25 
26 #include "pmap.h"
27 
28 class PStatView;
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : PStatGraph
32 // Description : This is an abstract base class for several different
33 // kinds of graphs that have a few things in common,
34 // like labels and guide bars.
35 ////////////////////////////////////////////////////////////////////
36 class PStatGraph {
37 public:
38  PStatGraph(PStatMonitor *monitor, int xsize, int ysize);
39  virtual ~PStatGraph();
40 
41  INLINE PStatMonitor *get_monitor() const;
42 
43  INLINE int get_num_labels() const;
44  INLINE int get_label_collector(int n) const;
45  INLINE string get_label_name(int n) const;
46  INLINE LRGBColor get_label_color(int n) const;
47 
48  INLINE void set_target_frame_rate(double frame_rate);
49  INLINE double get_target_frame_rate() const;
50 
51  INLINE int get_xsize() const;
52  INLINE int get_ysize() const;
53 
54  enum GuideBarStyle {
55  GBS_normal,
56  GBS_target,
57  GBS_user,
58  };
59 
60  class GuideBar {
61  public:
62  GuideBar(double height, const string &label, GuideBarStyle style);
63  GuideBar(const GuideBar &copy);
64 
65  double _height;
66  string _label;
67  GuideBarStyle _style;
68  };
69 
70  enum GuideBarUnits {
71  GBU_hz = 0x0001,
72  GBU_ms = 0x0002,
73  GBU_named = 0x0004,
74  GBU_show_units = 0x0008,
75  };
76 
77  int get_num_guide_bars() const;
78  const GuideBar &get_guide_bar(int n) const;
79 
80  int get_num_user_guide_bars() const;
81  GuideBar get_user_guide_bar(int n) const;
82  void move_user_guide_bar(int n, double height);
83  int add_user_guide_bar(double height);
84  void remove_user_guide_bar(int n);
85  int find_user_guide_bar(double from_height, double to_height) const;
86 
87  INLINE void set_guide_bar_units(int unit_mask);
88  INLINE int get_guide_bar_units() const;
89  INLINE void set_guide_bar_unit_name(const string &unit_name);
90  INLINE const string &get_guide_bar_unit_name() const;
91 
92  static string format_number(double value);
93  static string format_number(double value, int guide_bar_units,
94  const string &unit_name = string());
95 
96 protected:
97  virtual void normal_guide_bars()=0;
98  void update_guide_bars(int num_bars, double scale);
99  GuideBar make_guide_bar(double value, GuideBarStyle style = GBS_normal) const;
100 
101  bool _labels_changed;
102  bool _guide_bars_changed;
103 
104  PT(PStatMonitor) _monitor;
105 
106  double _target_frame_rate;
107 
108  int _xsize;
109  int _ysize;
110 
111  // Table of the collectors that should be drawn as labels, in order
112  // from bottom to top.
113  typedef vector_int Labels;
114  Labels _labels;
115 
116  typedef pvector<GuideBar> GuideBars;
117  GuideBars _guide_bars;
118  int _guide_bar_units;
119  string _unit_name;
120 };
121 
122 #include "pStatGraph.I"
123 
124 #endif
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
int get_ysize() const
Returns the height of the chart in pixels.
Definition: pStatGraph.I:113
void set_guide_bar_units(int unit_mask)
Sets the units that are displayed for the guide bar labels.
Definition: pStatGraph.I:125
int get_label_collector(int n) const
Returns the collector index associated with the nth label.
Definition: pStatGraph.I:44
void move_user_guide_bar(int n, double height)
Adjusts the height of the nth user-defined guide bar.
Definition: pStatGraph.cxx:137
This is an abstract base class for several different kinds of graphs that have a few things in common...
Definition: pStatGraph.h:36
double get_target_frame_rate() const
Returns the indicated target frame rate in Hz.
Definition: pStatGraph.I:93
int get_num_guide_bars() const
Returns the number of horizontal guide bars that should be drawn, based on the indicated target frame...
Definition: pStatGraph.cxx:86
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
This is an abstract class that presents the interface to any number of different front-ends for the s...
Definition: pStatMonitor.h:43
const GuideBar & get_guide_bar(int n) const
Returns the nth horizontal guide bar.
Definition: pStatGraph.cxx:101
A View boils down the frame data to a linear list of times spent in a number of different Collectors...
Definition: pStatView.h:34
int find_user_guide_bar(double from_height, double to_height) const
Returns the index number of the first user guide bar found whose height is within the indicated range...
Definition: pStatGraph.cxx:172
GuideBar get_user_guide_bar(int n) const
Returns the nth user-defined guide bar.
Definition: pStatGraph.cxx:126
int get_num_labels() const
Returns the number of labels to be drawn for this chart.
Definition: pStatGraph.I:33
PStatMonitor * get_monitor() const
Returns the monitor associated with this chart.
Definition: pStatGraph.I:22
int get_xsize() const
Returns the width of the chart in pixels.
Definition: pStatGraph.I:103
int get_guide_bar_units() const
Returns the units that are displayed for the guide bar labels.
Definition: pStatGraph.I:140
const string & get_guide_bar_unit_name() const
Returns the name of the units to be used for the guide bars if the units type is set to GBU_named | G...
Definition: pStatGraph.I:164
string get_label_name(int n) const
Returns the text associated with the nth label.
Definition: pStatGraph.I:55
void set_guide_bar_unit_name(const string &unit_name)
Sets the name of the units to be used for the guide bars if the units type is set to GBU_named | GBU_...
Definition: pStatGraph.I:152
void set_target_frame_rate(double frame_rate)
Sets the target frame rate of the application in Hz.
Definition: pStatGraph.I:79
LRGBColor get_label_color(int n) const
Returns the color associated with the nth label.
Definition: pStatGraph.I:66
int add_user_guide_bar(double height)
Creates a new user guide bar and returns its index number.
Definition: pStatGraph.cxx:148
static string format_number(double value)
Returns a string representing the value nicely formatted for its range.
Definition: pStatGraph.cxx:184
int get_num_user_guide_bars() const
Returns the current number of user-defined guide bars.
Definition: pStatGraph.cxx:116
void remove_user_guide_bar(int n)
Removes the user guide bar with the indicated index number.
Definition: pStatGraph.cxx:160