#include <graphframe.h>
Public Types | |
SolidLine = 0 | |
AreaGraph | |
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 |
Definition at line 40 of file graphframe.h.
Bandwidth graph style.
SolidLine | Plot bandwidth as solid lines. |
AreaGraph | Plot bandwidth as alpha blended area graphs. |
Definition at line 46 of file graphframe.h.
GraphFrame::GraphFrame | ( | QWidget * | parent = 0 |
) |
Default Constructor
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
Definition at line 43 of file graphframe.cpp.
void GraphFrame::addPoints | ( | qreal | recv, | |
qreal | send | |||
) |
Add data points.
Definition at line 62 of file graphframe.cpp.
References _maxPoints, _maxValue, _recvData, _sendData, _totalRecv, and _totalSend.
int GraphFrame::getNumPoints | ( | ) | [private] |
Gets the width of the desktop, the max # of points.
Definition at line 53 of file graphframe.cpp.
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 272 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.
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::paintEvent | ( | QPaintEvent * | event | ) | [protected] |
Overloaded QWidget::paintEvent()
Definition at line 111 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.
Definition at line 199 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.
Definition at line 212 of file graphframe.cpp.
References _painter.
Referenced by paintData().
void GraphFrame::paintScale | ( | ) | [private] |
Paints the scale in 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().
void GraphFrame::paintTotals | ( | ) | [private] |
Paints the send/receive totals.
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().
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::resetGraph | ( | ) |
Clears the graph.
Definition at line 87 of file graphframe.cpp.
References _maxValue, _recvData, _sendData, _totalRecv, _totalSend, and MIN_SCALE.
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::setShowCounters | ( | bool | showRecv, | |
bool | showSend | |||
) |
Toggles display of data counters.
Definition at line 101 of file graphframe.cpp.
QString GraphFrame::totalToStr | ( | qreal | total | ) | [private] |
Returns a formatted string representation of total.
Definition at line 254 of file graphframe.cpp.
Referenced by paintTotals().
GraphStyle GraphFrame::_graphStyle [private] |
Style with which the bandwidth data will be graphed.
Definition at line 94 of file graphframe.h.
Referenced by GraphFrame(), paintData(), and setGraphStyle().
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::_maxValue [private] |
The maximum data value plotted.
Definition at line 104 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 96 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 102 of file graphframe.h.
Referenced by paintEvent(), paintScale(), and pointsFromData().
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().
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().
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().
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().
qreal GraphFrame::_totalRecv [private] |
Definition at line 109 of file graphframe.h.
Referenced by addPoints(), paintTotals(), and resetGraph().
qreal GraphFrame::_totalSend [private] |
The total data sent/recv.
Definition at line 108 of file graphframe.h.
Referenced by addPoints(), paintTotals(), and resetGraph().