Panda3D
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
PStatGraph Class Referenceabstract

This is an abstract base class for several different kinds of graphs that have a few things in common, like labels and guide bars. More...

#include "pStatGraph.h"

Inheritance diagram for PStatGraph:
PStatPianoRoll PStatStripChart GtkStatsPianoRoll WinStatsPianoRoll GtkStatsStripChart WinStatsStripChart

Classes

class  GuideBar
 

Public Types

enum  GuideBarStyle { GBS_normal, GBS_target, GBS_user }
 
enum  GuideBarUnits { GBU_hz = 0x0001, GBU_ms = 0x0002, GBU_named = 0x0004, GBU_show_units = 0x0008 }
 

Public Member Functions

 PStatGraph (PStatMonitor *monitor, int xsize, int ysize)
 
int add_user_guide_bar (double height)
 Creates a new user guide bar and returns its index number. More...
 
int find_user_guide_bar (double from_height, double to_height) const
 Returns the index number of the first user guide bar found whose height is within the indicated range, or -1 if no user guide bars fall within the range. More...
 
const GuideBarget_guide_bar (int n) const
 Returns the nth horizontal guide bar. More...
 
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. More...
 
int get_guide_bar_units () const
 Returns the units that are displayed for the guide bar labels. More...
 
int get_label_collector (int n) const
 Returns the collector index associated with the nth label. More...
 
LRGBColor get_label_color (int n) const
 Returns the color associated with the nth label. More...
 
string get_label_name (int n) const
 Returns the text associated with the nth label. More...
 
PStatMonitorget_monitor () const
 Returns the monitor associated with this chart. More...
 
int get_num_guide_bars () const
 Returns the number of horizontal guide bars that should be drawn, based on the indicated target frame rate. More...
 
int get_num_labels () const
 Returns the number of labels to be drawn for this chart. More...
 
int get_num_user_guide_bars () const
 Returns the current number of user-defined guide bars. More...
 
double get_target_frame_rate () const
 Returns the indicated target frame rate in Hz. More...
 
GuideBar get_user_guide_bar (int n) const
 Returns the nth user-defined guide bar. More...
 
int get_xsize () const
 Returns the width of the chart in pixels. More...
 
int get_ysize () const
 Returns the height of the chart in pixels. More...
 
void move_user_guide_bar (int n, double height)
 Adjusts the height of the nth user-defined guide bar. More...
 
void remove_user_guide_bar (int n)
 Removes the user guide bar with the indicated index number. More...
 
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. More...
 
void set_guide_bar_units (int unit_mask)
 Sets the units that are displayed for the guide bar labels. More...
 
void set_target_frame_rate (double frame_rate)
 Sets the target frame rate of the application in Hz. More...
 

Static Public Member Functions

static string format_number (double value)
 Returns a string representing the value nicely formatted for its range. More...
 
static string format_number (double 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. More...
 

Detailed Description

This is an abstract base class for several different kinds of graphs that have a few things in common, like labels and guide bars.

Definition at line 36 of file pStatGraph.h.

Member Function Documentation

◆ add_user_guide_bar()

int PStatGraph::add_user_guide_bar ( double  height)

Creates a new user guide bar and returns its index number.

Definition at line 148 of file pStatGraph.cxx.

References remove_user_guide_bar().

Referenced by move_user_guide_bar().

◆ find_user_guide_bar()

int PStatGraph::find_user_guide_bar ( double  from_height,
double  to_height 
) const

Returns the index number of the first user guide bar found whose height is within the indicated range, or -1 if no user guide bars fall within the range.

Definition at line 172 of file pStatGraph.cxx.

References format_number().

Referenced by remove_user_guide_bar().

◆ format_number() [1/2]

string PStatGraph::format_number ( double  value)
static

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

Definition at line 184 of file pStatGraph.cxx.

Referenced by find_user_guide_bar().

◆ format_number() [2/2]

string PStatGraph::format_number ( double  value,
int  guide_bar_units,
const string &  unit_name = string() 
)
static

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

Definition at line 210 of file pStatGraph.cxx.

◆ get_guide_bar()

const PStatGraph::GuideBar & PStatGraph::get_guide_bar ( int  n) const

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 101 of file pStatGraph.cxx.

References get_num_user_guide_bars().

Referenced by get_num_guide_bars().

◆ get_guide_bar_unit_name()

const string & PStatGraph::get_guide_bar_unit_name ( ) const
inline

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 164 of file pStatGraph.I.

Referenced by set_guide_bar_unit_name().

◆ get_guide_bar_units()

int PStatGraph::get_guide_bar_units ( ) const
inline

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 140 of file pStatGraph.I.

References set_guide_bar_unit_name().

Referenced by set_guide_bar_units().

◆ get_label_collector()

int PStatGraph::get_label_collector ( int  n) const
inline

Returns the collector index associated with the nth label.

Definition at line 44 of file pStatGraph.I.

References get_label_name().

Referenced by get_num_labels().

◆ get_label_color()

LRGBColor PStatGraph::get_label_color ( int  n) const
inline

Returns the color associated with the nth label.

Definition at line 66 of file pStatGraph.I.

References set_target_frame_rate().

Referenced by get_label_name().

◆ get_label_name()

string PStatGraph::get_label_name ( int  n) const
inline

Returns the text associated with the nth label.

Definition at line 55 of file pStatGraph.I.

References get_label_color().

Referenced by get_label_collector().

◆ get_monitor()

PStatMonitor * PStatGraph::get_monitor ( ) const
inline

Returns the monitor associated with this chart.

Definition at line 22 of file pStatGraph.I.

References get_num_labels().

◆ get_num_guide_bars()

int PStatGraph::get_num_guide_bars ( ) const

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 86 of file pStatGraph.cxx.

References get_guide_bar().

◆ get_num_labels()

int PStatGraph::get_num_labels ( ) const
inline

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

Definition at line 33 of file pStatGraph.I.

References get_label_collector().

Referenced by get_monitor().

◆ get_num_user_guide_bars()

int PStatGraph::get_num_user_guide_bars ( ) const

Returns the current number of user-defined guide bars.

Not all of these may be visible.

Definition at line 116 of file pStatGraph.cxx.

References get_user_guide_bar().

Referenced by get_guide_bar().

◆ get_target_frame_rate()

double PStatGraph::get_target_frame_rate ( ) const
inline

Returns the indicated target frame rate in Hz.

See set_target_frame_rate().

Definition at line 93 of file pStatGraph.I.

References get_xsize().

Referenced by set_target_frame_rate().

◆ get_user_guide_bar()

PStatGraph::GuideBar PStatGraph::get_user_guide_bar ( int  n) const

Returns the nth user-defined guide bar.

Definition at line 126 of file pStatGraph.cxx.

References move_user_guide_bar().

Referenced by get_num_user_guide_bars().

◆ get_xsize()

int PStatGraph::get_xsize ( ) const
inline

Returns the width of the chart in pixels.

Definition at line 103 of file pStatGraph.I.

References get_ysize().

Referenced by get_target_frame_rate(), PStatStripChart::pixel_to_timestamp(), and PStatStripChart::timestamp_to_pixel().

◆ get_ysize()

int PStatGraph::get_ysize ( ) const
inline

Returns the height of the chart in pixels.

Definition at line 113 of file pStatGraph.I.

References set_guide_bar_units().

Referenced by get_xsize(), PStatStripChart::height_to_pixel(), and PStatStripChart::pixel_to_height().

◆ move_user_guide_bar()

void PStatGraph::move_user_guide_bar ( int  n,
double  height 
)

Adjusts the height of the nth user-defined guide bar.

Definition at line 137 of file pStatGraph.cxx.

References add_user_guide_bar().

Referenced by get_user_guide_bar().

◆ remove_user_guide_bar()

void PStatGraph::remove_user_guide_bar ( int  n)

Removes the user guide bar with the indicated index number.

All subsequent index numbers are adjusted down one.

Definition at line 160 of file pStatGraph.cxx.

References find_user_guide_bar().

Referenced by add_user_guide_bar().

◆ set_guide_bar_unit_name()

void PStatGraph::set_guide_bar_unit_name ( const string &  unit_name)
inline

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 152 of file pStatGraph.I.

References get_guide_bar_unit_name().

Referenced by get_guide_bar_units().

◆ set_guide_bar_units()

void PStatGraph::set_guide_bar_units ( int  guide_bar_units)
inline

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 125 of file pStatGraph.I.

References get_guide_bar_units().

Referenced by get_ysize().

◆ set_target_frame_rate()

void PStatGraph::set_target_frame_rate ( double  frame_rate)
inline

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 79 of file pStatGraph.I.

References get_target_frame_rate().

Referenced by get_label_color().


The documentation for this class was generated from the following files: