Panda3D
Loading...
Searching...
No Matches
pStatStripChart.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 pStatStripChart.I
10 * @author drose
11 * @date 2000-07-15
12 */
13
14/**
15 * Returns the View this chart represents.
16 */
18get_view() const {
19 return _view;
20}
21
22/**
23 * Returns the particular collector whose data this strip chart reflects.
24 */
26get_collector_index() const {
27 return _collector_index;
28}
29
30/**
31 * Changes the amount of time the width of the horizontal axis represents.
32 * This may force a redraw.
33 */
35set_horizontal_scale(double time_width) {
36 if (_time_width != time_width) {
37 if (_scroll_mode) {
38 _start_time += _time_width - time_width;
39 } else {
40 force_reset();
41 }
42 _time_width = time_width;
43 }
44}
45
46/**
47 * Returns the amount of total time the width of the horizontal axis
48 * represents.
49 */
50INLINE double PStatStripChart::
52 return _time_width;
53}
54
55/**
56 * Changes the value the height of the vertical axis represents. This may
57 * force a redraw.
58 */
60set_vertical_scale(double value_height) {
61 if (_value_height != value_height) {
62 _value_height = value_height;
63 normal_guide_bars();
64 force_redraw();
65 }
66}
67
68/**
69 * Returns total value the height of the vertical axis represents.
70 */
71INLINE double PStatStripChart::
72get_vertical_scale() const {
73 return _value_height;
74}
75
76/**
77 * Changes the scroll_mode flag. When true, the strip chart will update
78 * itself by scrolling to the left; when false, the strip chart will wrap
79 * around at the right and restart at the left end without scrolling.
80 */
82set_scroll_mode(bool scroll_mode) {
83 if (_scroll_mode != scroll_mode) {
84 _scroll_mode = scroll_mode;
85 _first_data = true;
86 }
87}
88
89/**
90 * Returns the current state of the scroll_mode flag. When true, the strip
91 * chart will update itself by scrolling to the left; when false, the strip
92 * chart will wrap around at the right and restart at the left end without
93 * scrolling.
94 */
96get_scroll_mode() const {
97 return _scroll_mode;
98}
99
100/**
101 * Changes the average_mode flag. When true, the strip chart will average out
102 * the color values over pstats_average_time seconds, which hides spikes and
103 * makes the overall trends easier to read. When false, the strip chart shows
104 * the actual data as it is happening.
105 */
107set_average_mode(bool average_mode) {
108 if (_average_mode != average_mode) {
109 _average_mode = average_mode;
110 force_redraw();
111 }
112}
113
114/**
115 * Returns the current state of the average_mode flag. When true, the strip
116 * chart will average out the color values over pstats_average_time seconds,
117 * which hides spikes and makes the overall trends easier to read. When
118 * false, the strip chart shows the actual data as it is happening.
119 */
121get_average_mode() const {
122 return _average_mode;
123}
124
125/**
126 * Converts a timestamp to a horizontal pixel offset.
127 */
129timestamp_to_pixel(double time) const {
130 return (int)((double)get_xsize() * (time - _start_time) / _time_width);
131}
132
133/**
134 * Converts a horizontal pixel offset to a timestamp.
135 */
136INLINE double PStatStripChart::
137pixel_to_timestamp(int x) const {
138 return _time_width * (double)x / (double)get_xsize() + _start_time;
139}
140
141/**
142 * Converts a value (i.e. a "height" in the strip chart) to a vertical pixel
143 * offset.
144 */
146height_to_pixel(double value) const {
147 return get_ysize() - (int)((double)get_ysize() * value / _value_height);
148}
149
150/**
151 * Converts a vertical pixel offset to a value (a "height" in the strip
152 * chart).
153 */
154INLINE double PStatStripChart::
155pixel_to_height(int x) const {
156 return _value_height * (double)(get_ysize() - x) / (double)get_ysize();
157}
158
159/**
160 * Returns true if get_title_text() has never yet returned an answer, false if
161 * it has.
162 */
164is_title_unknown() const {
165 return _title_unknown;
166}
167
168/**
169 * Returns true if the indicated collector appears anywhere on the chart at
170 * the current time, false otherwise.
171 */
172INLINE bool PStatStripChart::
173is_label_used(int collector_index) const {
174 if (collector_index < (int)_label_usage.size()) {
175 return _label_usage[collector_index] > 0;
176 }
177 return false;
178}
int get_xsize() const
Returns the width of the chart in pixels.
Definition pStatGraph.I:82
int get_ysize() const
Returns the height of the chart in pixels.
Definition pStatGraph.I:90
void set_scroll_mode(bool scroll_mode)
Changes the scroll_mode flag.
bool is_title_unknown() const
Returns true if get_title_text() has never yet returned an answer, false if it has.
double get_horizontal_scale() const
Returns the amount of total time the width of the horizontal axis represents.
double get_vertical_scale() const
Returns total value the height of the vertical axis represents.
int height_to_pixel(double value) const
Converts a value (i.e.
void set_average_mode(bool average_mode)
Changes the average_mode flag.
void set_horizontal_scale(double time_width)
Changes the amount of time the width of the horizontal axis represents.
bool get_scroll_mode() const
Returns the current state of the scroll_mode flag.
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.
bool get_average_mode() const
Returns the current state of the average_mode flag.
PStatView & get_view() const
Returns the View this chart represents.
double pixel_to_height(int y) const
Converts a vertical pixel offset to a value (a "height" in the strip chart).
int get_collector_index() const
Returns the particular collector whose data this strip chart reflects.
void set_vertical_scale(double value_height)
Changes the value the height of the vertical axis represents.
A View boils down the frame data to a linear list of times spent in a number of different Collectors,...
Definition pStatView.h:31