27 PStatPianoRoll::BarBuilder::
35 void PStatPianoRoll::BarBuilder::
45 void PStatPianoRoll::BarBuilder::
46 add_data_point(
double time,
bool is_start) {
49 if (_color_bars.empty() || _color_bars.back()._end >= 0.0) {
53 _color_bars.push_back(bar);
58 if (_color_bars.empty()) {
63 _color_bars.push_back(bar);
66 _color_bars.back()._end = time;
75 void PStatPianoRoll::BarBuilder::
77 if (!_color_bars.empty() && _color_bars.back()._end < 0.0) {
78 _color_bars.back()._end = time;
86 PStatPianoRoll(
PStatMonitor *monitor,
int thread_index,
int xsize,
int ysize) :
88 _thread_index(thread_index)
90 _time_width = 1.0 / pstats_target_frame_rate;
94 _guide_bar_units = GBU_ms | GBU_hz | GBU_show_units;
120 if (frame_number != _current_frame) {
121 compute_page(thread_data->
get_frame(frame_number));
122 _current_frame = frame_number;
136 void PStatPianoRoll::
137 changed_size(
int xsize,
int ysize) {
138 if (xsize != _xsize || ysize != _ysize) {
151 void PStatPianoRoll::
153 if (!_labels.empty()) {
155 for (
int i = 0; i < (int)_labels.size(); i++) {
156 int collector_index = _labels[i];
157 const ColorBars &bars = _page_data[collector_index]._color_bars;
160 ColorBars::const_iterator bi;
161 for (bi = bars.begin(); bi != bars.end(); ++bi) {
162 const ColorBar &bar = (*bi);
174 void PStatPianoRoll::
175 normal_guide_bars() {
177 update_guide_bars(
get_xsize() / 100, _time_width);
184 void PStatPianoRoll::
193 void PStatPianoRoll::
201 void PStatPianoRoll::
202 draw_bar(
int,
int,
int) {
209 void PStatPianoRoll::
217 void PStatPianoRoll::
225 void PStatPianoRoll::
232 class SortCollectorLabels1 {
235 _client_data(client_data) {
237 bool operator () (
int a,
int b)
const {
239 _client_data->get_collector_def(a)._sort >
240 _client_data->get_collector_def(b)._sort;
248 void PStatPianoRoll::
255 _page_data.swap(previous);
258 for (
int i = 0; i < num_events; i++) {
260 double time = frame_data.
get_time(i);
261 bool is_start = frame_data.
is_start(i);
262 _page_data[collector_index].add_data_point(time, is_start);
266 bool changed_bars = (_page_data.size() != previous.size());
269 PageData::const_iterator ai, bi;
270 ai = _page_data.begin();
271 bi = previous.begin();
272 while (ai != _page_data.end() && !changed_bars) {
273 changed_bars = ((*ai).first == (*bi).first);
285 PageData::const_iterator pi;
286 for (pi = _page_data.begin(); pi != _page_data.end(); ++pi) {
287 int collector_index = (*pi).first;
289 _labels.push_back(collector_index);
293 SortCollectorLabels1 sort_labels(client_data);
294 sort(_labels.begin(), _labels.end(), sort_labels);
296 _labels_changed =
true;
300 double time = frame_data.
get_end();
301 PageData::iterator pi;
302 for (pi = _page_data.begin(); pi != _page_data.end(); ++pi) {
303 (*pi).second.finish(time);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_xsize() const
Returns the width of the chart in pixels.
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.
const PStatFrameData & get_frame(int frame_number) const
Returns a FrameData structure associated with the indicated frame number.
The data associated with a particular client, but not with any one particular frame or thread: the li...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract base class for several different kinds of graphs that have a few things in common...
void update()
Updates the chart with the latest data.
int get_num_threads() const
Returns the total number of threads the Data knows about.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an abstract class that presents the interface to any number of different front-ends for the s...
bool has_collector(int index) const
Returns true if the indicated collector has been defined by the client already, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Contains the raw timing and level data for a single frame.
double get_time(size_t n) const
Returns the timestamp of the nth event, in seconds elapsed since some undefined epoch (which is guara...
int get_num_collectors() const
Returns the total number of collectors the Data knows about.
A collection of FrameData structures for recently-received frames within a particular thread.
int get_time_collector(size_t n) const
Returns the index of the collector associated with the nth event.
const PStatThreadData * get_thread_data(int index) const
Returns the data associated with the indicated thread.
bool is_start(size_t n) const
Returns true if the nth event represents a start event, or false if it represents a stop event.
double get_end() const
Returns the time of the last data point in the frame data.
size_t get_num_events() const
Returns the number of individual events stored in the FrameData.
bool is_empty() const
Returns true if the structure contains no frames, false otherwise.
double get_start() const
Returns the time of the first data point in the frame data.
int get_latest_frame_number() const
Returns the frame number of the most recent frame stored in the data.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.