Vidalia
0.2.15
|
#include <GraphFrame.h>
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 |
Definition at line 39 of file GraphFrame.h.
Bandwidth graph style.
SolidLine |
Plot bandwidth as solid lines. |
AreaGraph |
Plot bandwidth as alpha blended area graphs. |
Definition at line 45 of file GraphFrame.h.
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 | ( | ) |
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.
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().
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().
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().
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().
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().
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().
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().
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().
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().
void GraphFrame::resetGraph | ( | ) |
Clears the graph.
Definition at line 111 of file GraphFrame.cpp.
References _maxValue, _recvData, _sendData, _totalRecv, _totalSend, and MIN_SCALE.
void GraphFrame::resizeEvent | ( | QResizeEvent * | ev | ) | [private] |
Definition at line 347 of file GraphFrame.cpp.
References _maxPoints, _scaleWidth, and SCROLL_STEP.
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.
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.
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().
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().
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().
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().
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().
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().
QRect GraphFrame::_rec [private] |
The current dimensions of the graph.
Definition at line 103 of file GraphFrame.h.
Referenced by paintEvent(), paintScale(), and pointsFromData().
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().
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().
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().
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().
bool GraphFrame::_showSend [private] |
Definition at line 115 of file GraphFrame.h.
Referenced by GraphFrame(), paintData(), paintTotals(), and setShowCounters().
qreal GraphFrame::_totalRecv [private] |
Definition at line 112 of file GraphFrame.h.
Referenced by addPoints(), paintTotals(), and resetGraph().
qreal GraphFrame::_totalSend [private] |
The total data sent/recv.
Definition at line 111 of file GraphFrame.h.
Referenced by addPoints(), paintTotals(), and resetGraph().