28 PStatGraph::GuideBar::
29 GuideBar(
double height,
const string &label, PStatGraph::GuideBarStyle style) :
39 PStatGraph::GuideBar::
41 _height(copy._height),
51 PStatGraph(
PStatMonitor *monitor,
int xsize,
int ysize) :
56 _target_frame_rate = pstats_target_frame_rate;
57 _labels_changed =
false;
58 _guide_bars_changed =
false;
59 _guide_bar_units = GBU_ms;
76 return _guide_bars.size();
89 static GuideBar bogus_bar(0.0,
"bogus", GBS_normal);
90 nassertr(n >= 0 && n < (
int)_guide_bars.size(), bogus_bar);
92 return _guide_bars[n];
101 return _monitor->get_server()->get_num_user_guide_bars();
109 double height = _monitor->get_server()->get_user_guide_bar_height(n);
110 return make_guide_bar(height, GBS_user);
118 _monitor->get_server()->move_user_guide_bar(n, height);
126 return _monitor->get_server()->add_user_guide_bar(height);
135 _monitor->get_server()->remove_user_guide_bar(n);
145 return _monitor->get_server()->find_user_guide_bar(from_height, to_height);
157 sprintf(buffer,
"%0.4f", value);
158 }
else if (value < 0.1) {
159 sprintf(buffer,
"%0.3f", value);
160 }
else if (value < 1.0) {
161 sprintf(buffer,
"%0.2f", value);
162 }
else if (value < 10.0) {
163 sprintf(buffer,
"%0.1f", value);
165 sprintf(buffer,
"%0.0f", value);
179 if ((guide_bar_units & GBU_named) != 0) {
182 if ((guide_bar_units & GBU_show_units) != 0 && !unit_name.empty()) {
189 if ((guide_bar_units & GBU_ms) != 0) {
190 double ms = value * 1000.0;
192 if ((guide_bar_units & GBU_show_units) != 0) {
197 if ((guide_bar_units & GBU_hz) != 0) {
198 double hz = 1.0 / value;
200 if ((guide_bar_units & GBU_ms) != 0) {
204 if ((guide_bar_units & GBU_show_units) != 0) {
207 if ((guide_bar_units & GBU_ms) != 0) {
220 update_guide_bars(
int num_bars,
double scale) {
231 double bottom = (double)num_bars / scale;
234 if (_target_frame_rate < bottom) {
236 harmonic = floor(bottom / _target_frame_rate + 0.5) * _target_frame_rate;
240 harmonic = _target_frame_rate / floor(_target_frame_rate / bottom + 0.5);
244 for (
int k = 1; k / harmonic <= scale; k++) {
245 _guide_bars.push_back(make_guide_bar(k / harmonic));
248 _guide_bars_changed =
true;
255 make_guide_bar(
double value, PStatGraph::GuideBarStyle style)
const {
256 string label =
format_number(value, _guide_bar_units, _unit_name);
258 if ((style == GBS_normal) &&
259 (_guide_bar_units & GBU_named) == 0) {
261 double hz = 1.0 / value;
262 if (IS_THRESHOLD_EQUAL(hz, _target_frame_rate, 0.001)) {
267 return GuideBar(value, label, style);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void move_user_guide_bar(int n, double height)
Adjusts the height of the nth user-defined guide bar.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract class that presents the interface to any number of different front-ends for the s...
const GuideBar & get_guide_bar(int n) const
Returns the nth horizontal guide bar.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_guide_bars() const
Returns the number of horizontal guide bars that should be drawn, based on the indicated target frame...
int add_user_guide_bar(double height)
Creates a new user guide bar and returns its index number.
static std::string format_number(double value)
Returns a string representing the value nicely formatted for its range.
GuideBar get_user_guide_bar(int n) const
Returns the nth user-defined guide bar.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_user_guide_bars() const
Returns the current number of user-defined guide bars.
void remove_user_guide_bar(int n)
Removes the user guide bar with the indicated index number.