00001 // Filename: pStatPianoRoll.I 00002 // Created by: drose (18Jul00) 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 // Function: PStatPianoRoll::set_horizontal_scale 00017 // Access: Public 00018 // Description: Changes the amount of time the width of the 00019 // horizontal axis represents. This may force a redraw. 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE void PStatPianoRoll:: 00022 set_horizontal_scale(double time_width) { 00023 if (_time_width != time_width) { 00024 _time_width = time_width; 00025 normal_guide_bars(); 00026 force_redraw(); 00027 } 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: PStatPianoRoll::get_horizontal_scale 00032 // Access: Public 00033 // Description: Returns the amount of total time the width of the 00034 // horizontal axis represents. 00035 //////////////////////////////////////////////////////////////////// 00036 INLINE double PStatPianoRoll:: 00037 get_horizontal_scale() const { 00038 return _time_width; 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: PStatPianoRoll::timestamp_to_pixel 00043 // Access: Public 00044 // Description: Converts a timestamp to a horizontal pixel offset. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE int PStatPianoRoll:: 00047 timestamp_to_pixel(double time) const { 00048 return (int)((double)_xsize * (time - _start_time) / _time_width); 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: PStatPianoRoll::pixel_to_timestamp 00053 // Access: Public 00054 // Description: Converts a horizontal pixel offset to a timestamp. 00055 //////////////////////////////////////////////////////////////////// 00056 INLINE double PStatPianoRoll:: 00057 pixel_to_timestamp(int x) const { 00058 return _time_width * (double)x / (double)_xsize + _start_time; 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: PStatPianoRoll::height_to_pixel 00063 // Access: Public 00064 // Description: Converts a value (i.e. a "height" in the strip chart) 00065 // to a horizontal pixel offset. 00066 //////////////////////////////////////////////////////////////////// 00067 INLINE int PStatPianoRoll:: 00068 height_to_pixel(double value) const { 00069 return (int)((double)_xsize * value / _time_width); 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function: PStatPianoRoll::pixel_to_height 00074 // Access: Public 00075 // Description: Converts a horizontal pixel offset to a value (a 00076 // "height" in the strip chart). 00077 //////////////////////////////////////////////////////////////////// 00078 INLINE double PStatPianoRoll:: 00079 pixel_to_height(int x) const { 00080 return _time_width * (double)x / (double)_xsize; 00081 }