Panda3D
pStatStripChart.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file pStatStripChart.I
10  * @author drose
11  * @date 2000-07-15
12  */
13 
14 /**
15  * Returns the View this chart represents.
16  */
18 get_view() const {
19  return _view;
20 }
21 
22 /**
23  * Returns the particular collector whose data this strip chart reflects.
24  */
25 INLINE int PStatStripChart::
27  return _collector_index;
28 }
29 
30 /**
31  * Changes the amount of time the width of the horizontal axis represents.
32  * This may force a redraw.
33  */
34 INLINE void PStatStripChart::
35 set_horizontal_scale(double time_width) {
36  if (_time_width != time_width) {
37  if (_scroll_mode) {
38  _start_time += _time_width - time_width;
39  } else {
40  force_reset();
41  }
42  _time_width = time_width;
43  }
44 }
45 
46 /**
47  * Returns the amount of total time the width of the horizontal axis
48  * represents.
49  */
50 INLINE double PStatStripChart::
52  return _time_width;
53 }
54 
55 /**
56  * Changes the value the height of the vertical axis represents. This may
57  * force a redraw.
58  */
59 INLINE void PStatStripChart::
60 set_vertical_scale(double value_height) {
61  if (_value_height != value_height) {
62  _value_height = value_height;
63  normal_guide_bars();
64  force_redraw();
65  }
66 }
67 
68 /**
69  * Returns total value the height of the vertical axis represents.
70  */
71 INLINE double PStatStripChart::
73  return _value_height;
74 }
75 
76 /**
77  * Changes the scroll_mode flag. When true, the strip chart will update
78  * itself by scrolling to the left; when false, the strip chart will wrap
79  * around at the right and restart at the left end without scrolling.
80  */
81 INLINE void PStatStripChart::
82 set_scroll_mode(bool scroll_mode) {
83  if (_scroll_mode != scroll_mode) {
84  _scroll_mode = scroll_mode;
85  _first_data = true;
86  }
87 }
88 
89 /**
90  * Returns the current state of the scroll_mode flag. When true, the strip
91  * chart will update itself by scrolling to the left; when false, the strip
92  * chart will wrap around at the right and restart at the left end without
93  * scrolling.
94  */
95 INLINE bool PStatStripChart::
96 get_scroll_mode() const {
97  return _scroll_mode;
98 }
99 
100 /**
101  * Changes the average_mode flag. When true, the strip chart will average out
102  * the color values over pstats_average_time seconds, which hides spikes and
103  * makes the overall trends easier to read. When false, the strip chart shows
104  * the actual data as it is happening.
105  */
106 INLINE void PStatStripChart::
107 set_average_mode(bool average_mode) {
108  if (_average_mode != average_mode) {
109  _average_mode = average_mode;
110  force_redraw();
111  }
112 }
113 
114 /**
115  * Returns the current state of the average_mode flag. When true, the strip
116  * chart will average out the color values over pstats_average_time seconds,
117  * which hides spikes and makes the overall trends easier to read. When
118  * false, the strip chart shows the actual data as it is happening.
119  */
120 INLINE bool PStatStripChart::
122  return _average_mode;
123 }
124 
125 /**
126  * Converts a timestamp to a horizontal pixel offset.
127  */
128 INLINE int PStatStripChart::
129 timestamp_to_pixel(double time) const {
130  return (int)((double)get_xsize() * (time - _start_time) / _time_width);
131 }
132 
133 /**
134  * Converts a horizontal pixel offset to a timestamp.
135  */
136 INLINE double PStatStripChart::
137 pixel_to_timestamp(int x) const {
138  return _time_width * (double)x / (double)get_xsize() + _start_time;
139 }
140 
141 /**
142  * Converts a value (i.e. a "height" in the strip chart) to a vertical pixel
143  * offset.
144  */
145 INLINE int PStatStripChart::
146 height_to_pixel(double value) const {
147  return get_ysize() - (int)((double)get_ysize() * value / _value_height);
148 }
149 
150 /**
151  * Converts a vertical pixel offset to a value (a "height" in the strip
152  * chart).
153  */
154 INLINE double PStatStripChart::
155 pixel_to_height(int x) const {
156  return _value_height * (double)(get_ysize() - x) / (double)get_ysize();
157 }
158 
159 /**
160  * Returns true if the indicated collector appears anywhere on the chart at
161  * the current time, false otherwise.
162  */
163 INLINE bool PStatStripChart::
164 is_label_used(int collector_index) const {
165  if (collector_index < (int)_label_usage.size()) {
166  return _label_usage[collector_index] > 0;
167  }
168  return false;
169 }
void set_horizontal_scale(double time_width)
Changes the amount of time the width of the horizontal axis represents.
int get_xsize() const
Returns the width of the chart in pixels.
Definition: pStatGraph.I:82
double get_horizontal_scale() const
Returns the amount of total time the width of the horizontal axis represents.
int get_ysize() const
Returns the height of the chart in pixels.
Definition: pStatGraph.I:90
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.
void set_vertical_scale(double value_height)
Changes the value the height of the vertical axis represents.
double pixel_to_height(int y) const
Converts a vertical pixel offset to a value (a "height" in the strip chart).
int get_collector_index() const
Returns the particular collector whose data this strip chart reflects.
PStatView & get_view() const
Returns the View this chart represents.
int height_to_pixel(double value) const
Converts a value (i.e.
A View boils down the frame data to a linear list of times spent in a number of different Collectors,...
Definition: pStatView.h:31
bool get_average_mode() const
Returns the current state of the average_mode flag.
double pixel_to_timestamp(int x) const
Converts a horizontal pixel offset to a timestamp.
void set_average_mode(bool average_mode)
Changes the average_mode flag.
double get_vertical_scale() const
Returns total value the height of the vertical axis represents.
bool get_scroll_mode() const
Returns the current state of the scroll_mode flag.
void set_scroll_mode(bool scroll_mode)
Changes the scroll_mode flag.