15 #include "pStatPianoRoll.h"
17 #include "pStatFrameData.h"
18 #include "pStatCollectorDef.h"
19 #include "string_utils.h"
20 #include "config_pstats.h"
30 PStatPianoRoll::BarBuilder::
40 void PStatPianoRoll::BarBuilder::
53 void PStatPianoRoll::BarBuilder::
54 add_data_point(
double time,
bool is_start) {
57 if (_color_bars.empty() || _color_bars.back()._end >= 0.0) {
61 _color_bars.push_back(bar);
66 if (_color_bars.empty()) {
72 _color_bars.push_back(bar);
75 _color_bars.back()._end = time;
86 void PStatPianoRoll::BarBuilder::
88 if (!_color_bars.empty() && _color_bars.back()._end < 0.0) {
89 _color_bars.back()._end = time;
99 PStatPianoRoll(
PStatMonitor *monitor,
int thread_index,
int xsize,
int ysize) :
101 _thread_index(thread_index)
103 _time_width = 1.0 / pstats_target_frame_rate;
107 _guide_bar_units = GBU_ms | GBU_hz | GBU_show_units;
137 if (frame_number != _current_frame) {
138 compute_page(thread_data->
get_frame(frame_number));
139 _current_frame = frame_number;
156 void PStatPianoRoll::
157 changed_size(
int xsize,
int ysize) {
158 if (xsize != _xsize || ysize != _ysize) {
173 void PStatPianoRoll::
175 if (!_labels.empty()) {
177 for (
int i = 0; i < (int)_labels.size(); i++) {
178 int collector_index = _labels[i];
179 const ColorBars &bars = _page_data[collector_index]._color_bars;
182 ColorBars::const_iterator bi;
183 for (bi = bars.begin(); bi != bars.end(); ++bi) {
184 const ColorBar &bar = (*bi);
199 void PStatPianoRoll::
200 normal_guide_bars() {
202 update_guide_bars(
get_xsize() / 100, _time_width);
211 void PStatPianoRoll::
224 void PStatPianoRoll::
235 void PStatPianoRoll::
236 draw_bar(
int,
int,
int) {
246 void PStatPianoRoll::
257 void PStatPianoRoll::
268 void PStatPianoRoll::
278 _client_data(client_data) {
280 bool operator () (
int a,
int b)
const {
294 void PStatPianoRoll::
302 _page_data.swap(previous);
305 for (
int i = 0; i < num_events; i++) {
307 double time = frame_data.
get_time(i);
308 bool is_start = frame_data.
is_start(i);
309 _page_data[collector_index].add_data_point(time, is_start);
313 bool changed_bars = (_page_data.size() != previous.size());
316 PageData::const_iterator ai, bi;
317 ai = _page_data.begin();
318 bi = previous.begin();
319 while (ai != _page_data.end() && !changed_bars) {
320 changed_bars = ((*ai).first == (*bi).first);
332 PageData::const_iterator pi;
333 for (pi = _page_data.begin(); pi != _page_data.end(); ++pi) {
334 int collector_index = (*pi).first;
336 _labels.push_back(collector_index);
341 sort(_labels.begin(), _labels.end(), sort_labels);
343 _labels_changed =
true;
347 double time = frame_data.
get_end();
348 PageData::iterator pi;
349 for (pi = _page_data.begin(); pi != _page_data.end(); ++pi) {
350 (*pi).second.finish(time);
double get_end() const
Returns the time of the last data point in the frame data.
bool is_empty() const
Returns true if the structure contains no frames, false otherwise.
The data associated with a particular client, but not with any one particular frame or thread: the li...
This is an abstract base class for several different kinds of graphs that have a few things in common...
int get_num_collectors() const
Returns the total number of collectors the Data knows about.
void update()
Updates the chart with the latest data.
int get_time_collector(int n) const
Returns the index of the collector associated with the nth event.
bool has_collector(int index) const
Returns true if the indicated collector has been defined by the client already, false otherwise...
This is an abstract class that presents the interface to any number of different front-ends for the s...
bool is_start(int n) const
Returns true if the nth event represents a start event, or false if it represents a stop event...
int get_num_events() const
Returns the number of individual events stored in the FrameData.
double get_start() const
Returns the time of the first data point in the frame data.
const PStatCollectorDef & get_collector_def(int index) const
Returns the nth collector definition.
Contains the raw timing and level data for a single frame.
A collection of FrameData structures for recently-received frames within a particular thread...
int get_xsize() const
Returns the width of the chart in pixels.
const PStatThreadData * get_thread_data(int index) const
Returns the data associated with the indicated thread.
int timestamp_to_pixel(double time) const
Converts a timestamp to a horizontal pixel offset.
double get_time(int n) const
Returns the timestamp of the nth event, in seconds elapsed since some undefined epoch (which is guara...
int get_num_threads() const
Returns the total number of threads the Data knows about.
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.