Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

GtkStatsPianoRoll Class Reference

A special widget that draws a piano-roll style chart, which shows the collectors explicitly stopping and starting, one frame at a time. More...

#include <gtkStatsPianoRoll.h>

Inheritance diagram for GtkStatsPianoRoll:

PStatPianoRoll PStatGraph List of all members.

Public Types

enum  GuideBarUnits { GBU_hz = 0x0001, GBU_ms = 0x0002, GBU_named = 0x0004, GBU_show_units = 0x0008 }

Public Member Functions

 GtkStatsPianoRoll (GtkStatsMonitor *monitor, int thread_index, int xsize, int ysize)
void mark_dead ()
 Called when the client's connection has been lost, this should update the window in some obvious way to indicate that the window is no longer live.

Gtk::Alignment * get_labels ()
 Returns an alignment widget that contains all of the labels appropriate to this chart, already formatted and stacked up bottom-to-top.

Gdk_GC get_collector_gc (int collector_index)
 Returns a graphics context suitable for drawing in the indicated collector's color.

void update ()
 Updates the chart with the latest data.

void set_horizontal_scale (float time_width)
 Changes the amount of time the width of the horizontal axis represents.

float get_horizontal_scale () const
 Returns the amount of total time the width of the horizontal axis represents.

int timestamp_to_pixel (float time) const
 Converts a timestamp to a horizontal pixel offset.

float pixel_to_timestamp (int x) const
 Converts a horizontal pixel offset to a timestamp.

PStatMonitorget_monitor () const
 Returns the monitor associated with this chart.

int get_num_labels () const
 Returns the number of labels to be drawn for this chart.

int get_label_collector (int n) const
 Returns the collector index associated with the nth label.

string get_label_name (int n) const
 Returns the text associated with the nth label.

RGBColorf get_label_color (int n) const
 Returns the color associated with the nth label.

void set_target_frame_rate (float frame_rate)
 Sets the target frame rate of the application in Hz.

float get_target_frame_rate () const
 Returns the indicated target frame rate in Hz.

int get_xsize () const
 Returns the width of the chart in pixels.

int get_ysize () const
 Returns the height of the chart in pixels.

int get_num_guide_bars () const
 Returns the number of horizontal guide bars that should be drawn, based on the indicated target frame rate.

const GuideBar & get_guide_bar (int n) const
 Returns the nth horizontal guide bar.

void set_guide_bar_units (int unit_mask)
 Sets the units that are displayed for the guide bar labels.

int get_guide_bar_units () const
 Returns the units that are displayed for the guide bar labels.

void set_guide_bar_unit_name (const string &unit_name)
 Sets the name of the units to be used for the guide bars if the units type is set to GBU_named | GBU_show_units.

const string & get_guide_bar_unit_name () const
 Returns the name of the units to be used for the guide bars if the units type is set to GBU_named | GBU_show_units.


Static Public Member Functions

string format_number (float value)
 Returns a string representing the value nicely formatted for its range.

string format_number (float value, int guide_bar_units, const string &unit_name=string())
 Returns a string representing the value nicely formatted for its range, including the units as indicated.


Protected Types

typedef vector_int Labels
typedef pvector< GuideBar > GuideBars

Protected Member Functions

void changed_size (int xsize, int ysize)
 To be called by the user class when the widget size has changed.

void force_redraw ()
 To be called by the user class when the whole thing needs to be redrawn for some reason.

virtual void normal_guide_bars ()
 Calls update_guide_bars with parameters suitable to this kind of graph.

virtual void begin_row (int row)
 Should be overridden by the user class.

virtual void end_row (int row)
 Should be overridden by the user class.

void update_guide_bars (int num_bars, float scale)
 Resets the list of guide bars.

GuideBar make_guide_bar (float value) const
 Makes a guide bar for the indicated elapsed time or level units.


Protected Attributes

bool _labels_changed
bool _guide_bars_changed
PointerTo< PStatMonitor_monitor
float _target_frame_rate
int _xsize
int _ysize
Labels _labels
GuideBars _guide_bars
int _guide_bar_units
string _unit_name

Private Types

typedef pmap< int, Gdk_GC > GCs

Private Member Functions

virtual void begin_draw ()
 Erases the chart area in preparation for drawing it full of bars.

virtual void draw_bar (int row, int from_x, int to_x)
 Draws a single bar on the chart.

virtual void end_draw ()
 Called after all the bars have been drawn, this triggers a refresh event to draw it to the window.

virtual void idle ()
 Called at the end of the draw cycle.

virtual gint configure_event_impl (GdkEventConfigure *event)
 Creates a new backing pixmap of the appropriate size.

virtual gint expose_event_impl (GdkEventExpose *event)
 Redraw the screen from the backing pixmap.

void pack_labels ()
void setup_white_gc ()
 Sets the color on _white_gc to be either actually white (if the chart is still alive) or a light gray (if the chart is dead).


Private Attributes

Gdk_Pixmap _pixmap
Gdk_GC _white_gc
Gdk_GC _black_gc
Gdk_GC _dark_gc
Gdk_GC _light_gc
GCs _gcs
vector_int _y_positions
Gtk::Alignment * _label_align
Gtk::VBox * _label_box
bool _is_dead

Detailed Description

A special widget that draws a piano-roll style chart, which shows the collectors explicitly stopping and starting, one frame at a time.

Definition at line 49 of file gtkStatsPianoRoll.h.


Member Typedef Documentation

typedef pmap<int, Gdk_GC> GtkStatsPianoRoll::GCs [private]
 

Definition at line 85 of file gtkStatsPianoRoll.h.

typedef pvector<GuideBar> PStatGraph::GuideBars [protected, inherited]
 

Definition at line 115 of file pStatGraph.h.

typedef vector_int PStatGraph::Labels [protected, inherited]
 

Definition at line 112 of file pStatGraph.h.


Member Enumeration Documentation

enum PStatGraph::GuideBarUnits [inherited]
 

Enumeration values:
GBU_hz 
GBU_ms 
GBU_named 
GBU_show_units 

Definition at line 76 of file pStatGraph.h.


Constructor & Destructor Documentation

GtkStatsPianoRoll::GtkStatsPianoRoll GtkStatsMonitor monitor,
int  thread_index,
int  xsize,
int  ysize
 

Definition at line 42 of file gtkStatsPianoRoll.cxx.

References NULL.


Member Function Documentation

void GtkStatsPianoRoll::begin_draw  )  [private, virtual]
 

Erases the chart area in preparation for drawing it full of bars.

Reimplemented from PStatPianoRoll.

Definition at line 143 of file gtkStatsPianoRoll.cxx.

References _pixmap, _y_positions, get_collector_gc(), PStatGraph::get_label_collector(), height, and y.

void PStatPianoRoll::begin_row int  row  )  [protected, virtual, inherited]
 

Should be overridden by the user class.

This hook will be called before drawing any one row of bars. These bars correspond to the collector whose index is get_row_collector(row), and in the color get_row_color(row).

Definition at line 269 of file pStatPianoRoll.cxx.

References SortCollectorLabels1::_client_data.

void PStatPianoRoll::changed_size int  xsize,
int  ysize
[protected, inherited]
 

To be called by the user class when the widget size has changed.

This updates the chart's internal data and causes it to issue redraw commands to reflect the new size.

Definition at line 182 of file pStatPianoRoll.cxx.

gint GtkStatsPianoRoll::configure_event_impl GdkEventConfigure *  event  )  [private, virtual]
 

Creates a new backing pixmap of the appropriate size.

Definition at line 247 of file gtkStatsPianoRoll.cxx.

References _pixmap, and _white_gc.

void GtkStatsPianoRoll::draw_bar int  row,
int  from_x,
int  to_x
[private, virtual]
 

Draws a single bar on the chart.

Reimplemented from PStatPianoRoll.

Definition at line 176 of file gtkStatsPianoRoll.cxx.

References _black_gc, _pixmap, width, and x.

void GtkStatsPianoRoll::end_draw  )  [private, virtual]
 

Called after all the bars have been drawn, this triggers a refresh event to draw it to the window.

Reimplemented from PStatPianoRoll.

Definition at line 195 of file gtkStatsPianoRoll.cxx.

References pack_labels().

void PStatPianoRoll::end_row int  row  )  [protected, virtual, inherited]
 

Should be overridden by the user class.

This hook will be called after drawing a series of color bars for a single row.

Definition at line 301 of file pStatPianoRoll.cxx.

References PStatPianoRoll::_page_data.

gint GtkStatsPianoRoll::expose_event_impl GdkEventExpose *  event  )  [private, virtual]
 

Redraw the screen from the backing pixmap.

Definition at line 292 of file gtkStatsPianoRoll.cxx.

References y.

void PStatPianoRoll::force_redraw  )  [protected, inherited]
 

To be called by the user class when the whole thing needs to be redrawn for some reason.

Definition at line 203 of file pStatPianoRoll.cxx.

Referenced by PStatPianoRoll::update().

string PStatGraph::format_number float  value,
int  guide_bar_units,
const string &  unit_name = string()
[static, inherited]
 

Returns a string representing the value nicely formatted for its range, including the units as indicated.

Definition at line 182 of file pStatGraph.cxx.

string PStatGraph::format_number float  value  )  [static, inherited]
 

Returns a string representing the value nicely formatted for its range.

Definition at line 151 of file pStatGraph.cxx.

References PStatGraph::GBU_show_units.

Referenced by PStatGraph::update_guide_bars().

Gdk_GC GtkStatsPianoRoll::get_collector_gc int  collector_index  ) 
 

Returns a graphics context suitable for drawing in the indicated collector's color.

Definition at line 109 of file gtkStatsPianoRoll.cxx.

Referenced by begin_draw().

const PStatGraph::GuideBar & PStatGraph::get_guide_bar int  n  )  const [inherited]
 

Returns the nth horizontal guide bar.

This should be drawn as a horizontal line across the chart at the y pixel location determined by height_to_pixel(bar._height).

It is possible that this bar will be off the top of the chart.

Definition at line 131 of file pStatGraph.cxx.

const string & PStatGraph::get_guide_bar_unit_name  )  const [inline, inherited]
 

Returns the name of the units to be used for the guide bars if the units type is set to GBU_named | GBU_show_units.

Definition at line 223 of file pStatGraph.I.

int PStatGraph::get_guide_bar_units  )  const [inline, inherited]
 

Returns the units that are displayed for the guide bar labels.

This may be a union of one or more members of the GuideBarUnits enum.

Definition at line 189 of file pStatGraph.I.

float PStatPianoRoll::get_horizontal_scale  )  const [inline, inherited]
 

Returns the amount of total time the width of the horizontal axis represents.

Definition at line 52 of file pStatPianoRoll.I.

References PStatPianoRoll::_start_time, PStatPianoRoll::_time_width, and PStatGraph::_xsize.

int PStatGraph::get_label_collector int  n  )  const [inline, inherited]
 

Returns the collector index associated with the nth label.

Definition at line 62 of file pStatGraph.I.

Referenced by begin_draw().

RGBColorf PStatGraph::get_label_color int  n  )  const [inline, inherited]
 

Returns the color associated with the nth label.

Definition at line 90 of file pStatGraph.I.

References PStatGraph::_target_frame_rate, and INLINE.

string PStatGraph::get_label_name int  n  )  const [inline, inherited]
 

Returns the text associated with the nth label.

Definition at line 76 of file pStatGraph.I.

References PStatGraph::_target_frame_rate, INLINE, and PStatGraph::normal_guide_bars().

Gtk::Alignment * GtkStatsPianoRoll::get_labels  ) 
 

Returns an alignment widget that contains all of the labels appropriate to this chart, already formatted and stacked up bottom-to-top.

The window should pack this widget suitably near the strip chart.

Definition at line 94 of file gtkStatsPianoRoll.cxx.

PStatMonitor * PStatGraph::get_monitor  )  const [inline, inherited]
 

Returns the monitor associated with this chart.

Definition at line 32 of file pStatGraph.I.

References PStatGraph::_labels, and INLINE.

Referenced by GtkStatsStripChart::get_labels(), and PStatStripChart::new_data().

int PStatGraph::get_num_guide_bars  )  const [inherited]
 

Returns the number of horizontal guide bars that should be drawn, based on the indicated target frame rate.

Not all of these may be visible; some may be off the top of the chart because of the vertical scale.

Definition at line 108 of file pStatGraph.cxx.

References PStatGraph::_guide_bars.

int PStatGraph::get_num_labels  )  const [inline, inherited]
 

Returns the number of labels to be drawn for this chart.

Definition at line 47 of file pStatGraph.I.

References PStatGraph::_labels, INLINE, and nassertr.

float PStatGraph::get_target_frame_rate  )  const [inline, inherited]
 

Returns the indicated target frame rate in Hz.

See set_target_frame_rate().

Definition at line 126 of file pStatGraph.I.

References PStatGraph::_guide_bar_units, INLINE, and PStatGraph::normal_guide_bars().

int PStatGraph::get_xsize void   )  const [inline, inherited]
 

Returns the width of the chart in pixels.

Definition at line 139 of file pStatGraph.I.

References PStatGraph::_guide_bar_units, and INLINE.

Referenced by GtkStatsStripChart::end_draw(), GtkStatsStripChart::get_collector_gc(), GtkStatsStripWindow::menu_hscale(), and PStatStripChart::set_scroll_mode().

int PStatGraph::get_ysize void   )  const [inline, inherited]
 

Returns the height of the chart in pixels.

Definition at line 152 of file pStatGraph.I.

References PStatGraph::_unit_name, and INLINE.

Referenced by GtkStatsStripChart::copy_region(), GtkStatsStripChart::draw_slice(), GtkStatsStripChart::end_draw(), GtkStatsStripChart::get_collector_gc(), PStatStripChart::get_scroll_mode(), and GtkStatsStripWindow::menu_hscale().

void GtkStatsPianoRoll::idle  )  [private, virtual]
 

Called at the end of the draw cycle.

Reimplemented from PStatPianoRoll.

Definition at line 232 of file gtkStatsPianoRoll.cxx.

References _light_gc, and _pixmap.

PStatGraph::GuideBar PStatGraph::make_guide_bar float  value  )  const [protected, inherited]
 

Makes a guide bar for the indicated elapsed time or level units.

Definition at line 289 of file pStatGraph.cxx.

void GtkStatsPianoRoll::mark_dead  ) 
 

Called when the client's connection has been lost, this should update the window in some obvious way to indicate that the window is no longer live.

Definition at line 71 of file gtkStatsPianoRoll.cxx.

References _label_align.

void PStatPianoRoll::normal_guide_bars  )  [protected, virtual, inherited]
 

Calls update_guide_bars with parameters suitable to this kind of graph.

Implements PStatGraph.

Definition at line 233 of file pStatPianoRoll.cxx.

Referenced by PStatPianoRoll::update().

void GtkStatsPianoRoll::pack_labels  )  [private]
 

Definition at line 309 of file gtkStatsPianoRoll.cxx.

References _white_gc.

Referenced by end_draw().

float PStatPianoRoll::pixel_to_timestamp int  x  )  const [inline, inherited]
 

Converts a horizontal pixel offset to a timestamp.

Definition at line 78 of file pStatPianoRoll.I.

void PStatGraph::set_guide_bar_unit_name const string &  unit_name  )  [inline, inherited]
 

Sets the name of the units to be used for the guide bars if the units type is set to GBU_named | GBU_show_units.

Definition at line 206 of file pStatGraph.I.

void PStatGraph::set_guide_bar_units int  unit_mask  )  [inline, inherited]
 

Sets the units that are displayed for the guide bar labels.

This may be a union of one or more members of the GuideBarUnits enum.

Definition at line 169 of file pStatGraph.I.

References PStatGraph::_unit_name.

void PStatPianoRoll::set_horizontal_scale float  time_width  )  [inline, inherited]
 

Changes the amount of time the width of the horizontal axis represents.

This may force a redraw.

Definition at line 33 of file pStatPianoRoll.I.

References PStatPianoRoll::_time_width, and INLINE.

void PStatGraph::set_target_frame_rate float  frame_rate  )  [inline, inherited]
 

Sets the target frame rate of the application in Hz.

This only affects the choice of initial scale and the placement of guide bars.

Definition at line 108 of file pStatGraph.I.

References PStatGraph::_xsize.

void GtkStatsPianoRoll::setup_white_gc  )  [private]
 

Sets the color on _white_gc to be either actually white (if the chart is still alive) or a light gray (if the chart is dead).

Definition at line 354 of file gtkStatsPianoRoll.cxx.

int PStatPianoRoll::timestamp_to_pixel float  time  )  const [inline, inherited]
 

Converts a timestamp to a horizontal pixel offset.

Definition at line 65 of file pStatPianoRoll.I.

void PStatPianoRoll::update void   )  [inherited]
 

Updates the chart with the latest data.

Definition at line 145 of file pStatPianoRoll.cxx.

References PStatGraph::_xsize, PStatGraph::_ysize, PStatPianoRoll::force_redraw(), and PStatPianoRoll::normal_guide_bars().

Referenced by GtkStatsPianoWindow::mark_dead().

void PStatGraph::update_guide_bars int  num_bars,
float  scale
[protected, inherited]
 

Resets the list of guide bars.

Definition at line 247 of file pStatGraph.cxx.

References PStatGraph::_guide_bar_units, PStatGraph::_target_frame_rate, PStatGraph::_unit_name, PStatGraph::format_number(), PStatGraph::GBU_named, and IS_NEARLY_EQUAL.


Member Data Documentation

Gdk_GC GtkStatsPianoRoll::_black_gc [private]
 

Definition at line 80 of file gtkStatsPianoRoll.h.

Referenced by draw_bar().

Gdk_GC GtkStatsPianoRoll::_dark_gc [private]
 

Definition at line 81 of file gtkStatsPianoRoll.h.

GCs GtkStatsPianoRoll::_gcs [private]
 

Definition at line 86 of file gtkStatsPianoRoll.h.

int PStatGraph::_guide_bar_units [protected, inherited]
 

Definition at line 117 of file pStatGraph.h.

Referenced by PStatGraph::get_target_frame_rate(), PStatGraph::get_xsize(), PStatStripChart::PStatStripChart(), and PStatGraph::update_guide_bars().

GuideBars PStatGraph::_guide_bars [protected, inherited]
 

Definition at line 116 of file pStatGraph.h.

Referenced by PStatGraph::get_num_guide_bars(), and PStatGraph::~PStatGraph().

bool PStatGraph::_guide_bars_changed [protected, inherited]
 

Definition at line 101 of file pStatGraph.h.

Referenced by GtkStatsStripChart::draw_cursor().

bool GtkStatsPianoRoll::_is_dead [private]
 

Definition at line 94 of file gtkStatsPianoRoll.h.

Gtk::Alignment* GtkStatsPianoRoll::_label_align [private]
 

Definition at line 92 of file gtkStatsPianoRoll.h.

Referenced by mark_dead().

Gtk::VBox* GtkStatsPianoRoll::_label_box [private]
 

Definition at line 93 of file gtkStatsPianoRoll.h.

Labels PStatGraph::_labels [protected, inherited]
 

Definition at line 113 of file pStatGraph.h.

Referenced by PStatStripChart::draw_slice(), PStatPianoRoll::end_draw(), PStatGraph::get_monitor(), and PStatGraph::get_num_labels().

bool PStatGraph::_labels_changed [protected, inherited]
 

Definition at line 100 of file pStatGraph.h.

Referenced by PStatPianoRoll::end_draw().

Gdk_GC GtkStatsPianoRoll::_light_gc [private]
 

Definition at line 82 of file gtkStatsPianoRoll.h.

Referenced by idle().

PointerTo< PStatMonitor > PStatGraph::_monitor [protected, inherited]
 

Definition at line 103 of file pStatGraph.h.

Referenced by PStatGraph::GuideBar::GuideBar(), PStatPianoRoll::PStatPianoRoll(), and PStatStripChart::PStatStripChart().

Gdk_Pixmap GtkStatsPianoRoll::_pixmap [private]
 

Definition at line 74 of file gtkStatsPianoRoll.h.

Referenced by begin_draw(), configure_event_impl(), draw_bar(), and idle().

float PStatGraph::_target_frame_rate [protected, inherited]
 

Definition at line 105 of file pStatGraph.h.

Referenced by PStatGraph::get_label_color(), PStatGraph::get_label_name(), and PStatGraph::update_guide_bars().

string PStatGraph::_unit_name [protected, inherited]
 

Definition at line 118 of file pStatGraph.h.

Referenced by PStatGraph::get_ysize(), PStatStripChart::PStatStripChart(), PStatGraph::set_guide_bar_units(), and PStatGraph::update_guide_bars().

Gdk_GC GtkStatsPianoRoll::_white_gc [private]
 

Definition at line 79 of file gtkStatsPianoRoll.h.

Referenced by configure_event_impl(), and pack_labels().

int PStatGraph::_xsize [protected, inherited]
 

Definition at line 107 of file pStatGraph.h.

Referenced by PStatStripChart::get_frame_data(), PStatPianoRoll::get_horizontal_scale(), PStatGraph::GuideBar::GuideBar(), PStatStripChart::idle(), PStatStripChart::set_default_vertical_scale(), PStatGraph::set_target_frame_rate(), and PStatPianoRoll::update().

vector_int GtkStatsPianoRoll::_y_positions [private]
 

Definition at line 90 of file gtkStatsPianoRoll.h.

Referenced by begin_draw().

int PStatGraph::_ysize [protected, inherited]
 

Definition at line 108 of file pStatGraph.h.

Referenced by PStatStripChart::get_frame_data(), PStatGraph::GuideBar::GuideBar(), and PStatPianoRoll::update().


The documentation for this class was generated from the following files:
Generated on Fri May 2 03:27:12 2003 for Panda-Tool by doxygen1.3