Vidalia  0.3.1
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
GraphFrame Class Reference

#include <GraphFrame.h>

Inheritance diagram for GraphFrame:

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)
 
void resizeEvent (QResizeEvent *ev)
 

Private Attributes

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

Detailed Description

Definition at line 39 of file GraphFrame.h.

Member Enumeration Documentation

◆ GraphStyle

Bandwidth graph style.

Enumerator
SolidLine 

Plot bandwidth as solid lines.

AreaGraph 

Plot bandwidth as alpha blended area graphs.

Definition at line 45 of file GraphFrame.h.

Constructor & Destructor Documentation

◆ GraphFrame()

GraphFrame::GraphFrame ( QWidget *  parent = 0)

Default Constructor

Default contructor

Definition at line 22 of file GraphFrame.cpp.

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

◆ ~GraphFrame()

GraphFrame::~GraphFrame ( )

Default Destructor

Default destructor

Definition at line 43 of file GraphFrame.cpp.

References _painter, _recvData, and _sendData.

Member Function Documentation

◆ addPoints()

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

Add data points.

Adds new data points to the graph.

Definition at line 60 of file GraphFrame.cpp.

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

◆ getNumPoints()

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.

References _scaleWidth.

Referenced by GraphFrame().

◆ labelWidth()

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

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

Definition at line 296 of file GraphFrame.cpp.

References i().

Referenced by paintScale().

◆ paintData()

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 169 of file GraphFrame.cpp.

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

Referenced by paintEvent().

◆ paintEvent()

void GraphFrame::paintEvent ( QPaintEvent *  event)
protected

Overloaded QWidget::paintEvent()

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

Definition at line 135 of file GraphFrame.cpp.

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

◆ paintIntegral()

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 223 of file GraphFrame.cpp.

References _painter.

Referenced by paintData().

◆ paintLine()

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 236 of file GraphFrame.cpp.

References _painter.

Referenced by paintData().

◆ paintScale()

void GraphFrame::paintScale ( )
private

Paints the scale in the graph.

Paints the scale on the graph.

Definition at line 308 of file GraphFrame.cpp.

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

Referenced by paintEvent().

◆ paintTotals()

void GraphFrame::paintTotals ( )
private

Paints the send/receive totals.

Paints selected total indicators on the graph.

Definition at line 247 of file GraphFrame.cpp.

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

Referenced by paintEvent().

◆ pointsFromData()

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 196 of file GraphFrame.cpp.

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

Referenced by paintData().

◆ resetGraph()

void GraphFrame::resetGraph ( )

Clears the graph.

Definition at line 111 of file GraphFrame.cpp.

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

◆ resizeEvent()

void GraphFrame::resizeEvent ( QResizeEvent *  ev)
private

Definition at line 347 of file GraphFrame.cpp.

References _maxPoints, _scaleWidth, and SCROLL_STEP.

◆ setGraphStyle()

void GraphFrame::setGraphStyle ( GraphStyle  style)
inline

Sets the graph style used to display bandwidth data.

Definition at line 62 of file GraphFrame.h.

References _graphStyle.

◆ setShowCounters()

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

Toggles display of data counters.

Toggles display of respective graph lines and counters.

Definition at line 125 of file GraphFrame.cpp.

References _showRecv, and _showSend.

◆ totalToStr()

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 278 of file GraphFrame.cpp.

Referenced by paintTotals().

Member Data Documentation

◆ _graphStyle

GraphStyle GraphFrame::_graphStyle
private

Style with which the bandwidth data will be graphed.

Definition at line 95 of file GraphFrame.h.

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

◆ _maxPoints

int GraphFrame::_maxPoints
private

The maximum number of points to store.

Definition at line 109 of file GraphFrame.h.

Referenced by addPoints(), GraphFrame(), and resizeEvent().

◆ _maxPosition

int GraphFrame::_maxPosition
private

The position of the local maximum in the displayed bandwidth

Definition at line 107 of file GraphFrame.h.

Referenced by addPoints(), and GraphFrame().

◆ _maxValue

qreal GraphFrame::_maxValue
private

The maximum data value plotted.

Definition at line 105 of file GraphFrame.h.

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

◆ _painter

QPainter* GraphFrame::_painter
private

A QPainter object that handles drawing the various graph elements.

Definition at line 97 of file GraphFrame.h.

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

◆ _rec

QRect GraphFrame::_rec
private

The current dimensions of the graph.

Definition at line 103 of file GraphFrame.h.

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

◆ _recvData

QList<qreal>* GraphFrame::_recvData
private

Holds the received data points.

Definition at line 99 of file GraphFrame.h.

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

◆ _scaleWidth

int GraphFrame::_scaleWidth
private

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

Definition at line 118 of file GraphFrame.h.

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

◆ _sendData

QList<qreal>* GraphFrame::_sendData
private

Holds the sent data points.

Definition at line 101 of file GraphFrame.h.

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

◆ _showRecv

bool GraphFrame::_showRecv
private

Show the respective lines and counters.

Definition at line 114 of file GraphFrame.h.

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

◆ _showSend

bool GraphFrame::_showSend
private

Definition at line 115 of file GraphFrame.h.

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

◆ _totalRecv

qreal GraphFrame::_totalRecv
private

Definition at line 112 of file GraphFrame.h.

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

◆ _totalSend

qreal GraphFrame::_totalSend
private

The total data sent/recv.

Definition at line 111 of file GraphFrame.h.

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


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