Panda3D

pStatStripChart.I

00001 // Filename: pStatStripChart.I
00002 // Created by:  drose (15Jul00)
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: PStatStripChart::get_view
00018 //       Access: Public
00019 //  Description: Returns the View this chart represents.
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE PStatView &PStatStripChart::
00022 get_view() const {
00023   return _view;
00024 }
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: PStatStripChart::get_collector_index
00028 //       Access: Public
00029 //  Description: Returns the particular collector whose data this
00030 //               strip chart reflects.
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE int PStatStripChart::
00033 get_collector_index() const {
00034   return _collector_index;
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: PStatStripChart::set_horizontal_scale
00039 //       Access: Public
00040 //  Description: Changes the amount of time the width of the
00041 //               horizontal axis represents.  This may force a redraw.
00042 ////////////////////////////////////////////////////////////////////
00043 INLINE void PStatStripChart::
00044 set_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_scale
00057 //       Access: Public
00058 //  Description: Returns the amount of total time the width of the
00059 //               horizontal axis represents.
00060 ////////////////////////////////////////////////////////////////////
00061 INLINE double PStatStripChart::
00062 get_horizontal_scale() const {
00063   return _time_width;
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: PStatStripChart::set_vertical_scale
00068 //       Access: Public
00069 //  Description: Changes the value the height of the vertical axis
00070 //               represents.  This may force a redraw.
00071 ////////////////////////////////////////////////////////////////////
00072 INLINE void PStatStripChart::
00073 set_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_scale
00083 //       Access: Public
00084 //  Description: Returns total value the height of the vertical axis
00085 //               represents.
00086 ////////////////////////////////////////////////////////////////////
00087 INLINE double PStatStripChart::
00088 get_vertical_scale() const {
00089   return _value_height;
00090 }
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: PStatStripChart::set_scroll_mode
00094 //       Access: Public
00095 //  Description: Changes the scroll_mode flag.  When true, the strip
00096 //               chart will update itself by scrolling to the left;
00097 //               when false, the strip chart will wrap around at the
00098 //               right and restart at the left end without scrolling.
00099 ////////////////////////////////////////////////////////////////////
00100 INLINE void PStatStripChart::
00101 set_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_mode
00110 //       Access: Public
00111 //  Description: Returns the current state of the scroll_mode flag.
00112 //               When true, the strip chart will update itself by
00113 //               scrolling to the left; when false, the strip chart
00114 //               will wrap around at the right and restart at the left
00115 //               end without scrolling.
00116 ////////////////////////////////////////////////////////////////////
00117 INLINE bool PStatStripChart::
00118 get_scroll_mode() const {
00119   return _scroll_mode;
00120 }
00121 
00122 ////////////////////////////////////////////////////////////////////
00123 //     Function: PStatStripChart::set_average_mode
00124 //       Access: Public
00125 //  Description: Changes the average_mode flag.  When true, the strip
00126 //               chart will average out the color values over
00127 //               pstats_average_time seconds, which hides spikes and
00128 //               makes the overall trends easier to read.  When false,
00129 //               the strip chart shows the actual data as it is
00130 //               happening.
00131 ////////////////////////////////////////////////////////////////////
00132 INLINE void PStatStripChart::
00133 set_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_mode
00142 //       Access: Public
00143 //  Description: Returns the current state of the average_mode flag.
00144 //               When true, the strip chart will average out the color
00145 //               values over pstats_average_time seconds, which hides
00146 //               spikes and makes the overall trends easier to read.
00147 //               When false, the strip chart shows the actual data as
00148 //               it is happening.
00149 ////////////////////////////////////////////////////////////////////
00150 INLINE bool PStatStripChart::
00151 get_average_mode() const {
00152   return _average_mode;
00153 }
00154 
00155 ////////////////////////////////////////////////////////////////////
00156 //     Function: PStatStripChart::timestamp_to_pixel
00157 //       Access: Public
00158 //  Description: Converts a timestamp to a horizontal pixel offset.
00159 ////////////////////////////////////////////////////////////////////
00160 INLINE int PStatStripChart::
00161 timestamp_to_pixel(double time) const {
00162   return (int)((double)get_xsize() * (time - _start_time) / _time_width);
00163 }
00164 
00165 ////////////////////////////////////////////////////////////////////
00166 //     Function: PStatStripChart::pixel_to_timestamp
00167 //       Access: Public
00168 //  Description: Converts a horizontal pixel offset to a timestamp.
00169 ////////////////////////////////////////////////////////////////////
00170 INLINE double PStatStripChart::
00171 pixel_to_timestamp(int x) const {
00172   return _time_width * (double)x / (double)get_xsize() + _start_time;
00173 }
00174 
00175 ////////////////////////////////////////////////////////////////////
00176 //     Function: PStatStripChart::height_to_pixel
00177 //       Access: Public
00178 //  Description: Converts a value (i.e. a "height" in the strip chart)
00179 //               to a vertical pixel offset.
00180 ////////////////////////////////////////////////////////////////////
00181 INLINE int PStatStripChart::
00182 height_to_pixel(double value) const {
00183   return get_ysize() - (int)((double)get_ysize() * value / _value_height);
00184 }
00185 
00186 ////////////////////////////////////////////////////////////////////
00187 //     Function: PStatStripChart::pixel_to_height
00188 //       Access: Public
00189 //  Description: Converts a vertical pixel offset to a value (a
00190 //               "height" in the strip chart).
00191 ////////////////////////////////////////////////////////////////////
00192 INLINE double PStatStripChart::
00193 pixel_to_height(int x) const {
00194   return _value_height * (double)(get_ysize() - x) / (double)get_ysize();
00195 }
00196 
00197 ////////////////////////////////////////////////////////////////////
00198 //     Function: PStatStripChart::is_label_used
00199 //       Access: Protected
00200 //  Description: Returns true if the indicated collector appears
00201 //               anywhere on the chart at the current time, false
00202 //               otherwise.
00203 ////////////////////////////////////////////////////////////////////
00204 INLINE bool PStatStripChart::
00205 is_label_used(int collector_index) const {
00206   if (collector_index < (int)_label_usage.size()) {
00207     return _label_usage[collector_index] > 0;
00208   }
00209   return false;
00210 }
 All Classes Functions Variables Enumerations