GraphFrame Class Reference

#include <graphframe.h>

List of all members.

Public Types

enum  GraphStyle { SolidLine = 0, AreaGraph }

Public Member Functions

 GraphFrame (QWidget *parent=0)
 ~GraphFrame ()
void addPoints (qreal recv, qreal send)
void resetGraph ()
void setShowCounters (bool showRecv, bool showSend)
void setGraphStyle (GraphStyle style)

Protected Member Functions

void paintEvent (QPaintEvent *event)

Private Member Functions

int labelWidth (const QString &label)
int getNumPoints ()
void paintData ()
void paintTotals ()
void paintScale ()
QString totalToStr (qreal total)
QVector< QPointF > pointsFromData (QList< qreal > *list)
void paintLine (QVector< QPointF > points, QColor color, Qt::PenStyle lineStyle=Qt::SolidLine)
void paintIntegral (QVector< QPointF > points, QColor color, qreal alpha=1.0)

Private Attributes

GraphStyle _graphStyle
QPainter * _painter
QList< qreal > * _recvData
QList< qreal > * _sendData
QRect _rec
qreal _maxValue
int _maxPoints
qreal _totalSend
qreal _totalRecv
bool _showRecv
bool _showSend
int _scaleWidth


Detailed Description

Definition at line 40 of file graphframe.h.


Member Enumeration Documentation

Bandwidth graph style.

Enumerator:
SolidLine  Plot bandwidth as solid lines.
AreaGraph  Plot bandwidth as alpha blended area graphs.

Definition at line 46 of file graphframe.h.


Constructor & Destructor Documentation

GraphFrame::GraphFrame ( QWidget *  parent = 0  ) 

Default Constructor

Default contructor

Definition at line 23 of file graphframe.cpp.

References _graphStyle, _maxPoints, _maxValue, _painter, _recvData, _scaleWidth, _sendData, _showRecv, _showSend, getNumPoints(), MIN_SCALE, and SolidLine.

GraphFrame::~GraphFrame (  ) 

Default Destructor

Default destructor

Definition at line 43 of file graphframe.cpp.

References _painter, _recvData, and _sendData.


Member Function Documentation

void GraphFrame::addPoints ( qreal  recv,
qreal  send 
)

Add data points.

Adds new data points to the graph.

Definition at line 62 of file graphframe.cpp.

References _maxPoints, _maxValue, _recvData, _sendData, _totalRecv, and _totalSend.

void GraphFrame::resetGraph (  ) 

Clears the graph.

Definition at line 87 of file graphframe.cpp.

References _maxValue, _recvData, _sendData, _totalRecv, _totalSend, and MIN_SCALE.

void GraphFrame::setShowCounters ( bool  showRecv,
bool  showSend 
)

Toggles display of data counters.

Toggles display of respective graph lines and counters.

Definition at line 101 of file graphframe.cpp.

References _showRecv, and _showSend.

void GraphFrame::setGraphStyle ( GraphStyle  style  )  [inline]

Sets the graph style used to display bandwidth data.

Definition at line 63 of file graphframe.h.

References _graphStyle.

void GraphFrame::paintEvent ( QPaintEvent *  event  )  [protected]

Overloaded QWidget::paintEvent()

Overloads default QWidget::paintEvent. Draws the actual bandwidth graph.

Definition at line 111 of file graphframe.cpp.

References _painter, _rec, BACK_COLOR, paintData(), paintScale(), and paintTotals().

int GraphFrame::labelWidth ( const QString &  label  )  [private]

Returns the width in pixels of label using the current painter's font.

Definition at line 272 of file graphframe.cpp.

References i().

Referenced by paintScale().

int GraphFrame::getNumPoints (  )  [private]

Gets the width of the desktop, the max # of points.

Gets the width of the desktop, which is the maximum number of points we can plot in the graph.

Definition at line 53 of file graphframe.cpp.

Referenced by GraphFrame().

void GraphFrame::paintData (  )  [private]

Paints an integral and an outline of that integral for each data set (send and/or receive) that is to be displayed.

Paints an integral and an outline of that integral for each data set (send and/or receive) that is to be displayed. The integrals will be drawn first, followed by the outlines, since we want the area of overlapping integrals to blend, but not the outlines of those integrals.

Definition at line 145 of file graphframe.cpp.

References _graphStyle, _recvData, _sendData, _showRecv, _showSend, AreaGraph, paintIntegral(), paintLine(), pointsFromData(), RECV_COLOR, and SEND_COLOR.

Referenced by paintEvent().

void GraphFrame::paintTotals (  )  [private]

Paints the send/receive totals.

Paints selected total indicators on the graph.

Definition at line 223 of file graphframe.cpp.

References _painter, _recvData, _scaleWidth, _sendData, _showRecv, _showSend, _totalRecv, _totalSend, FONT_SIZE, RECV_COLOR, SEND_COLOR, and totalToStr().

Referenced by paintEvent().

void GraphFrame::paintScale (  )  [private]

Paints the scale in the graph.

Paints the scale on the graph.

Definition at line 284 of file graphframe.cpp.

References _maxValue, _painter, _rec, _scaleWidth, GRID_COLOR, i(), labelWidth(), and SCALE_COLOR.

Referenced by paintEvent().

QString GraphFrame::totalToStr ( qreal  total  )  [private]

Returns a formatted string representation of total.

Returns a formatted string with the correct size suffix.

Definition at line 254 of file graphframe.cpp.

Referenced by paintTotals().

QVector< QPointF > GraphFrame::pointsFromData ( QList< qreal > *  list  )  [private]

Returns a list of points on the bandwidth graph based on the supplied set of send or receive values.

Definition at line 172 of file graphframe.cpp.

References _maxValue, _rec, _scaleWidth, i(), and SCROLL_STEP.

Referenced by paintData().

void GraphFrame::paintLine ( QVector< QPointF >  points,
QColor  color,
Qt::PenStyle  lineStyle = Qt::SolidLine 
) [private]

Paints a line with the data in points.

Iterates the input list and draws a line on the graph in the appropriate color.

Definition at line 212 of file graphframe.cpp.

References _painter.

Referenced by paintData().

void GraphFrame::paintIntegral ( QVector< QPointF >  points,
QColor  color,
qreal  alpha = 1.0 
) [private]

Paints an integral using the supplied data.

Plots an integral using the data points in points. The area will be filled in using color and an alpha-blending level of alpha (default is opaque).

Definition at line 199 of file graphframe.cpp.

References _painter.

Referenced by paintData().


Member Data Documentation

Style with which the bandwidth data will be graphed.

Definition at line 94 of file graphframe.h.

Referenced by GraphFrame(), paintData(), and setGraphStyle().

QPainter* GraphFrame::_painter [private]

A QPainter object that handles drawing the various graph elements.

Definition at line 96 of file graphframe.h.

Referenced by GraphFrame(), paintEvent(), paintIntegral(), paintLine(), paintScale(), paintTotals(), and ~GraphFrame().

QList<qreal>* GraphFrame::_recvData [private]

Holds the received data points.

Definition at line 98 of file graphframe.h.

Referenced by addPoints(), GraphFrame(), paintData(), paintTotals(), resetGraph(), and ~GraphFrame().

QList<qreal>* GraphFrame::_sendData [private]

Holds the sent data points.

Definition at line 100 of file graphframe.h.

Referenced by addPoints(), GraphFrame(), paintData(), paintTotals(), resetGraph(), and ~GraphFrame().

QRect GraphFrame::_rec [private]

The current dimensions of the graph.

Definition at line 102 of file graphframe.h.

Referenced by paintEvent(), paintScale(), and pointsFromData().

qreal GraphFrame::_maxValue [private]

The maximum data value plotted.

Definition at line 104 of file graphframe.h.

Referenced by addPoints(), GraphFrame(), paintScale(), pointsFromData(), and resetGraph().

int GraphFrame::_maxPoints [private]

The maximum number of points to store.

Definition at line 106 of file graphframe.h.

Referenced by addPoints(), and GraphFrame().

qreal GraphFrame::_totalSend [private]

The total data sent/recv.

Definition at line 108 of file graphframe.h.

Referenced by addPoints(), paintTotals(), and resetGraph().

qreal GraphFrame::_totalRecv [private]

Definition at line 109 of file graphframe.h.

Referenced by addPoints(), paintTotals(), and resetGraph().

bool GraphFrame::_showRecv [private]

Show the respective lines and counters.

Definition at line 111 of file graphframe.h.

Referenced by GraphFrame(), paintData(), paintTotals(), and setShowCounters().

bool GraphFrame::_showSend [private]

Definition at line 112 of file graphframe.h.

Referenced by GraphFrame(), paintData(), paintTotals(), and setShowCounters().

int GraphFrame::_scaleWidth [private]

Width (in pixels) of the scale marker area on the left side of the graph.

Definition at line 115 of file graphframe.h.

Referenced by GraphFrame(), paintScale(), paintTotals(), and pointsFromData().


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

Generated on Wed Nov 26 21:03:59 2008 for Vidalia by  doxygen 1.5.6