Panda3D
Loading...
Searching...
No Matches
pStatPianoRoll.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 pStatPianoRoll.I
10 * @author drose
11 * @date 2000-07-18
12 */
13
14/**
15 * Changes the amount of time the width of the horizontal axis represents.
16 * This may force a redraw.
17 */
19set_horizontal_scale(double time_width) {
20 if (_time_width != time_width) {
21 _time_width = time_width;
22 normal_guide_bars();
23 force_redraw();
24 }
25}
26
27/**
28 * Returns the amount of total time the width of the horizontal axis
29 * represents.
30 */
31INLINE double PStatPianoRoll::
33 return _time_width;
34}
35
36/**
37 * Converts a timestamp to a horizontal pixel offset.
38 */
40timestamp_to_pixel(double time) const {
41 return (int)((double)_xsize * (time - _start_time) / _time_width);
42}
43
44/**
45 * Converts a horizontal pixel offset to a timestamp.
46 */
47INLINE double PStatPianoRoll::
48pixel_to_timestamp(int x) const {
49 return _time_width * (double)x / (double)_xsize + _start_time;
50}
51
52/**
53 * Converts a value (i.e. a "height" in the strip chart) to a horizontal
54 * pixel offset.
55 */
57height_to_pixel(double value) const {
58 return (int)((double)_xsize * value / _time_width);
59}
60
61/**
62 * Converts a horizontal pixel offset to a value (a "height" in the strip
63 * chart).
64 */
65INLINE double PStatPianoRoll::
66pixel_to_height(int x) const {
67 return _time_width * (double)x / (double)_xsize;
68}
void set_horizontal_scale(double time_width)
Changes the amount of time the width of the horizontal axis represents.
double get_horizontal_scale() const
Returns the amount of total 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).
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.
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.