27PStatPianoRoll::BarBuilder::
35void PStatPianoRoll::BarBuilder::
45void PStatPianoRoll::BarBuilder::
46add_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;
75void PStatPianoRoll::BarBuilder::
77 if (!_color_bars.empty() && _color_bars.back()._end < 0.0) {
78 _color_bars.back()._end = time;
86PStatPianoRoll(
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;
137changed_size(
int xsize,
int ysize) {
138 if (xsize != _xsize || ysize != _ysize) {
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);
177 update_guide_bars(
get_xsize() / 100, _time_width);
202draw_bar(
int,
int,
int) {
232class SortCollectorLabels1 {
235 _client_data(client_data) {
237 bool operator () (
int a,
int b)
const {
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);
The data associated with a particular client, but not with any one particular frame or thread: the li...
const PStatCollectorDef & get_collector_def(int index) const
Returns the nth collector definition.
int get_num_threads() const
Returns the total number of threads the Data knows about.
const PStatThreadData * get_thread_data(int index) const
Returns the data associated with the indicated thread.
int get_num_collectors() const
Returns the total number of collectors the Data knows about.
bool has_collector(int index) const
Returns true if the indicated collector has been defined by the client already, false otherwise.
Contains the raw timing and level data for a single frame.
double get_end() const
Returns the time of the last data point in the frame data.
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_time_collector(size_t n) const
Returns the index of the collector associated with the nth event.
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_start() const
Returns the time of the first data point in the frame data.
size_t get_num_events() const
Returns the number of individual events stored in the FrameData.
This is an abstract base class for several different kinds of graphs that have a few things in common...
int get_xsize() const
Returns the width of the chart in pixels.
This is an abstract class that presents the interface to any number of different front-ends for the s...
void update()
Updates the chart with the latest data.
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.
A collection of FrameData structures for recently-received frames within a particular thread.
bool is_empty() const
Returns true if the structure contains no frames, false otherwise.
const PStatFrameData & get_frame(int frame_number) const
Returns a FrameData structure associated with the indicated frame number.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.