Panda3D
pStatPianoRoll.I
1 // Filename: pStatPianoRoll.I
2 // Created by: drose (18Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 ////////////////////////////////////////////////////////////////////
16 // Function: PStatPianoRoll::set_horizontal_scale
17 // Access: Public
18 // Description: Changes the amount of time the width of the
19 // horizontal axis represents. This may force a redraw.
20 ////////////////////////////////////////////////////////////////////
21 INLINE void PStatPianoRoll::
22 set_horizontal_scale(double time_width) {
23  if (_time_width != time_width) {
24  _time_width = time_width;
25  normal_guide_bars();
26  force_redraw();
27  }
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: PStatPianoRoll::get_horizontal_scale
32 // Access: Public
33 // Description: Returns the amount of total time the width of the
34 // horizontal axis represents.
35 ////////////////////////////////////////////////////////////////////
36 INLINE double PStatPianoRoll::
38  return _time_width;
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: PStatPianoRoll::timestamp_to_pixel
43 // Access: Public
44 // Description: Converts a timestamp to a horizontal pixel offset.
45 ////////////////////////////////////////////////////////////////////
46 INLINE int PStatPianoRoll::
47 timestamp_to_pixel(double time) const {
48  return (int)((double)_xsize * (time - _start_time) / _time_width);
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: PStatPianoRoll::pixel_to_timestamp
53 // Access: Public
54 // Description: Converts a horizontal pixel offset to a timestamp.
55 ////////////////////////////////////////////////////////////////////
56 INLINE double PStatPianoRoll::
57 pixel_to_timestamp(int x) const {
58  return _time_width * (double)x / (double)_xsize + _start_time;
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function: PStatPianoRoll::height_to_pixel
63 // Access: Public
64 // Description: Converts a value (i.e. a "height" in the strip chart)
65 // to a horizontal pixel offset.
66 ////////////////////////////////////////////////////////////////////
67 INLINE int PStatPianoRoll::
68 height_to_pixel(double value) const {
69  return (int)((double)_xsize * value / _time_width);
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: PStatPianoRoll::pixel_to_height
74 // Access: Public
75 // Description: Converts a horizontal pixel offset to a value (a
76 // "height" in the strip chart).
77 ////////////////////////////////////////////////////////////////////
78 INLINE double PStatPianoRoll::
79 pixel_to_height(int x) const {
80  return _time_width * (double)x / (double)_xsize;
81 }
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.
double get_horizontal_scale() const
Returns the amount of total time the width of the horizontal axis represents.
int height_to_pixel(double value) const
Converts a value (i.e.
double pixel_to_timestamp(int x) const
Converts a horizontal pixel offset to a timestamp.
void set_horizontal_scale(double time_width)
Changes the amount of time the width of the horizontal axis represents.
double pixel_to_height(int y) const
Converts a horizontal pixel offset to a value (a "height" in the strip chart).