00001 // Filename: pStatStripChart.I00002 // Created by: drose (15Jul00)00003 //00004 ////////////////////////////////////////////////////////////////////00005 //00006 // PANDA 3D SOFTWARE00007 // Copyright (c) Carnegie Mellon University. All rights reserved.00008 //00009 // All use of this software is subject to the terms of the revised BSD00010 // license. You should have received a copy of this license along00011 // with this source code in a file named "LICENSE."00012 //00013 ////////////////////////////////////////////////////////////////////00014
00015
00016 ////////////////////////////////////////////////////////////////////00017 // Function: PStatStripChart::get_view00018 // Access: Public00019 // Description: Returns the View this chart represents.00020 ////////////////////////////////////////////////////////////////////00021 INLINE PStatView &PStatStripChart::00022get_view() const {
00023 return _view;
00024 }
00025
00026 ////////////////////////////////////////////////////////////////////00027 // Function: PStatStripChart::get_collector_index00028 // Access: Public00029 // Description: Returns the particular collector whose data this00030 // strip chart reflects.00031 ////////////////////////////////////////////////////////////////////00032 INLINE intPStatStripChart::00033get_collector_index() const {
00034 return _collector_index;
00035 }
00036
00037 ////////////////////////////////////////////////////////////////////00038 // Function: PStatStripChart::set_horizontal_scale00039 // Access: Public00040 // Description: Changes the amount of time the width of the00041 // horizontal axis represents. This may force a redraw.00042 ////////////////////////////////////////////////////////////////////00043 INLINE voidPStatStripChart::00044set_horizontal_scale(double time_width) {
00045 if (_time_width != time_width) {
00046 if (_scroll_mode) {
00047 _start_time += _time_width - time_width;
00048 } else {
00049 force_reset();
00050 }
00051 _time_width = time_width;
00052 }
00053 }
00054
00055 ////////////////////////////////////////////////////////////////////00056 // Function: PStatStripChart::get_horizontal_scale00057 // Access: Public00058 // Description: Returns the amount of total time the width of the00059 // horizontal axis represents.00060 ////////////////////////////////////////////////////////////////////00061 INLINE doublePStatStripChart::00062get_horizontal_scale() const {
00063 return _time_width;
00064 }
00065
00066 ////////////////////////////////////////////////////////////////////00067 // Function: PStatStripChart::set_vertical_scale00068 // Access: Public00069 // Description: Changes the value the height of the vertical axis00070 // represents. This may force a redraw.00071 ////////////////////////////////////////////////////////////////////00072 INLINE voidPStatStripChart::00073set_vertical_scale(double value_height) {
00074 if (_value_height != value_height) {
00075 _value_height = value_height;
00076 normal_guide_bars();
00077 force_redraw();
00078 }
00079 }
00080
00081 ////////////////////////////////////////////////////////////////////00082 // Function: PStatStripChart::get_vertical_scale00083 // Access: Public00084 // Description: Returns total value the height of the vertical axis00085 // represents.00086 ////////////////////////////////////////////////////////////////////00087 INLINE doublePStatStripChart::00088get_vertical_scale() const {
00089 return _value_height;
00090 }
00091
00092 ////////////////////////////////////////////////////////////////////00093 // Function: PStatStripChart::set_scroll_mode00094 // Access: Public00095 // Description: Changes the scroll_mode flag. When true, the strip00096 // chart will update itself by scrolling to the left;00097 // when false, the strip chart will wrap around at the00098 // right and restart at the left end without scrolling.00099 ////////////////////////////////////////////////////////////////////00100 INLINE voidPStatStripChart::00101set_scroll_mode(bool scroll_mode) {
00102 if (_scroll_mode != scroll_mode) {
00103 _scroll_mode = scroll_mode;
00104 _first_data = true;
00105 }
00106 }
00107
00108 ////////////////////////////////////////////////////////////////////00109 // Function: PStatStripChart::get_scroll_mode00110 // Access: Public00111 // Description: Returns the current state of the scroll_mode flag.00112 // When true, the strip chart will update itself by00113 // scrolling to the left; when false, the strip chart00114 // will wrap around at the right and restart at the left00115 // end without scrolling.00116 ////////////////////////////////////////////////////////////////////00117 INLINE boolPStatStripChart::00118get_scroll_mode() const {
00119 return _scroll_mode;
00120 }
00121
00122 ////////////////////////////////////////////////////////////////////00123 // Function: PStatStripChart::set_average_mode00124 // Access: Public00125 // Description: Changes the average_mode flag. When true, the strip00126 // chart will average out the color values over00127 // pstats_average_time seconds, which hides spikes and00128 // makes the overall trends easier to read. When false,00129 // the strip chart shows the actual data as it is00130 // happening.00131 ////////////////////////////////////////////////////////////////////00132 INLINE voidPStatStripChart::00133set_average_mode(bool average_mode) {
00134 if (_average_mode != average_mode) {
00135 _average_mode = average_mode;
00136 force_redraw();
00137 }
00138 }
00139
00140 ////////////////////////////////////////////////////////////////////00141 // Function: PStatStripChart::get_average_mode00142 // Access: Public00143 // Description: Returns the current state of the average_mode flag.00144 // When true, the strip chart will average out the color00145 // values over pstats_average_time seconds, which hides00146 // spikes and makes the overall trends easier to read.00147 // When false, the strip chart shows the actual data as00148 // it is happening.00149 ////////////////////////////////////////////////////////////////////00150 INLINE boolPStatStripChart::00151get_average_mode() const {
00152 return _average_mode;
00153 }
00154
00155 ////////////////////////////////////////////////////////////////////00156 // Function: PStatStripChart::timestamp_to_pixel00157 // Access: Public00158 // Description: Converts a timestamp to a horizontal pixel offset.00159 ////////////////////////////////////////////////////////////////////00160 INLINE intPStatStripChart::00161timestamp_to_pixel(double time) const {
00162 return (int)((double)get_xsize() * (time - _start_time) / _time_width);
00163 }
00164
00165 ////////////////////////////////////////////////////////////////////00166 // Function: PStatStripChart::pixel_to_timestamp00167 // Access: Public00168 // Description: Converts a horizontal pixel offset to a timestamp.00169 ////////////////////////////////////////////////////////////////////00170 INLINE doublePStatStripChart::00171pixel_to_timestamp(int x) const {
00172 return _time_width * (double)x / (double)get_xsize() + _start_time;
00173 }
00174
00175 ////////////////////////////////////////////////////////////////////00176 // Function: PStatStripChart::height_to_pixel00177 // Access: Public00178 // Description: Converts a value (i.e. a "height" in the strip chart)00179 // to a vertical pixel offset.00180 ////////////////////////////////////////////////////////////////////00181 INLINE intPStatStripChart::00182height_to_pixel(double value) const {
00183 returnget_ysize() - (int)((double)get_ysize() * value / _value_height);
00184 }
00185
00186 ////////////////////////////////////////////////////////////////////00187 // Function: PStatStripChart::pixel_to_height00188 // Access: Public00189 // Description: Converts a vertical pixel offset to a value (a00190 // "height" in the strip chart).00191 ////////////////////////////////////////////////////////////////////00192 INLINE doublePStatStripChart::00193pixel_to_height(int x) const {
00194 return _value_height * (double)(get_ysize() - x) / (double)get_ysize();
00195 }
00196
00197 ////////////////////////////////////////////////////////////////////00198 // Function: PStatStripChart::is_label_used00199 // Access: Protected00200 // Description: Returns true if the indicated collector appears00201 // anywhere on the chart at the current time, false00202 // otherwise.00203 ////////////////////////////////////////////////////////////////////00204 INLINE boolPStatStripChart::00205is_label_used(int collector_index) const {
00206 if (collector_index < (int)_label_usage.size()) {
00207 return _label_usage[collector_index] > 0;
00208 }
00209 returnfalse;
00210 }