From 29a11b021eee2c250fc3260ba28449211863ec21 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 29 Aug 2014 14:18:50 +0000 Subject: [PATCH] Added a graphframe to Bandwidth Control Window and Turtle Router Statistics Dialog git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7500 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../FileTransfer/TurtleRouterStatistics.cpp | 17 +- .../gui/FileTransfer/TurtleRouterStatistics.h | 5 + .../FileTransfer/TurtleRouterStatistics.ui | 42 +- .../src/gui/bwctrl/BwCtrlWindow.cpp | 10 +- retroshare-gui/src/gui/bwctrl/BwCtrlWindow.h | 2 + retroshare-gui/src/gui/bwctrl/BwCtrlWindow.ui | 149 ++++--- retroshare-gui/src/gui/graphframetunnel.cpp | 384 ++++++++++++++++++ retroshare-gui/src/gui/graphframetunnel.h | 143 +++++++ .../gui/settings/GlobalRouterStatistics.cpp | 72 ++-- retroshare-gui/src/retroshare-gui.pro | 44 +- 10 files changed, 751 insertions(+), 117 deletions(-) create mode 100644 retroshare-gui/src/gui/graphframetunnel.cpp create mode 100644 retroshare-gui/src/gui/graphframetunnel.h diff --git a/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.cpp b/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.cpp index 32ae00e29..302e1ed2f 100644 --- a/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.cpp @@ -239,6 +239,7 @@ void TurtleRouterStatistics::updateDisplay() //updateTunnelRequests(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ; _tst_CW->updateTunnelStatistics(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ; _tst_CW->update(); + updateTunnelGraph(); } QString TurtleRouterStatistics::getPeerName(const RsPeerId &peer_id) @@ -306,8 +307,8 @@ void TurtleRouterStatisticsWidget::updateTunnelStatistics(const std::vectorgetTrafficStatistics(info) ; + + updateGraph(info.tr_up_Bps,info.tr_dn_Bps,info.data_dn_Bps,info.data_up_Bps,info.unknown_updn_Bps); +} + +void TurtleRouterStatistics::updateGraph(qreal bytesTrup, qreal bytesTrdown, qreal bytesDatadown, qreal bytesDataup, qreal bytesunknownupdn) +{ + /* Graph only cares about kilobytes */ + frmGraph->addPoints(bytesTrup/1024.0, bytesTrdown/1024.0, bytesDatadown/1024.0, bytesDataup/1024.0, bytesunknownupdn/1024.0 ); +} diff --git a/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.h b/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.h index 7fcfc0891..bf005e80c 100644 --- a/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.h +++ b/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.h @@ -39,6 +39,11 @@ class TurtleRouterStatistics: public RsAutoUpdatePage, public Ui::TurtleRouterSt // Cache for peer names. static QString getPeerName(const RsPeerId& peer_id) ; + + public slots: + void updateTunnelGraph(); + void updateGraph(qreal bytesTrup, qreal bytesTrdown, qreal bytesDatadown, qreal bytesDataup, qreal bytesunknownupdn); + private: diff --git a/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.ui b/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.ui index dccc3e0b3..6145d29c2 100644 --- a/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.ui +++ b/retroshare-gui/src/gui/FileTransfer/TurtleRouterStatistics.ui @@ -7,7 +7,7 @@ 0 0 611 - 408 + 513 @@ -20,6 +20,9 @@ Qt::Vertical + + + QFrame::NoFrame @@ -35,15 +38,50 @@ 0 0 593 - 390 + 289 + + true + + + + + + 120 + 200 + + + + + 10 + + + + Qt::NoContextMenu + + + QFrame::Box + + + QFrame::Plain + + + + + + GraphFrameTunnel + QFrame +
gui/graphframetunnel.h
+ 1 +
+
diff --git a/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.cpp b/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.cpp index 9a8555c11..a46ad79bb 100644 --- a/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.cpp +++ b/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.cpp @@ -283,6 +283,9 @@ void BwCtrlWindow::updateBandwidth() /* insert */ QTreeWidgetItem *item = new QTreeWidgetItem(); peerTreeWidget->addTopLevelItem(item); + peerTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection); + + updateGraph(totalRates.mRateIn,totalRates.mRateOut); /* do Totals */ item -> setData(COLUMN_PEERID, Qt::DisplayRole, tr("TOTALS")); @@ -420,5 +423,10 @@ void BwCtrlWindow::updateBandwidth() } } - +/** Adds new data to the graph. */ +void BwCtrlWindow::updateGraph(qreal bytesRead, qreal bytesWritten) +{ + /* Graph only cares about kilobytes */ + ui->frmGraph->addPoints(bytesRead/*/1024.0*/, bytesWritten/*/1024.0*/); +} diff --git a/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.h b/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.h index 0c92d4be6..85d3d5f1e 100644 --- a/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.h +++ b/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.h @@ -83,6 +83,8 @@ public: public slots: void update(); + /** Adds new data to the graph */ + void updateGraph(qreal bytesRead, qreal bytesWritten); protected: //void changeEvent(QEvent *e); diff --git a/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.ui b/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.ui index 2fbe8c638..5166fb4d1 100644 --- a/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.ui +++ b/retroshare-gui/src/gui/bwctrl/BwCtrlWindow.ui @@ -15,74 +15,109 @@ - - - true + + + Qt::Vertical - - - Name + + + true - - - - ID + + + Name + + + + + ID + + + + + In (KB/s) + + + + + InMax (KB/s) + + + + + InQueue + + + + + InAllocated (KB/s) + + + + + Allocated Sent + + + + + Out (KB/s) + + + + + OutMax (KB/s) + + + + + OutQueue + + + + + OutAllowed (KB/s) + + + + + Allowed Recvd + + + + + + + 120 + 80 + - - - - In (KB/s) + + + 10 + - - - - InMax (KB/s) + + Qt::NoContextMenu - - - - InQueue + + QFrame::Box - - - - InAllocated (KB/s) + + QFrame::Plain - - - - Allocated Sent - - - - - Out (KB/s) - - - - - OutMax (KB/s) - - - - - OutQueue - - - - - OutAllowed (KB/s) - - - - - Allowed Recvd - - + + + + GraphFrame + QFrame +
gui/graphframe.h
+ 1 +
+
diff --git a/retroshare-gui/src/gui/graphframetunnel.cpp b/retroshare-gui/src/gui/graphframetunnel.cpp new file mode 100644 index 000000000..14adaab4a --- /dev/null +++ b/retroshare-gui/src/gui/graphframetunnel.cpp @@ -0,0 +1,384 @@ +/**************************************************************** + * This file is distributed under the following license: + * + * Copyright (c) 2006-2007, crypton + * Copyright (c) 2006, Matt Edman, Justin Hipple + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + + + +#include + +#include "graphframetunnel.h" + + +/** Default contructor */ +GraphFrameTunnel::GraphFrameTunnel(QWidget *parent) +: QFrame(parent) +{ + /* Create Graph Frame related objects */ + _tunnelrequestdownData = new QList(); + _tunnelrequestupData = new QList(); + _incomingfileData = new QList(); + _outgoingfileData = new QList(); + _forwardedData = new QList(); + + _painter = new QPainter(); + _graphStyle = SolidLine; + + /* Initialize graph values */ + _tunnelrequestdownData->prepend(0); + _tunnelrequestupData->prepend(0); + _incomingfileData->prepend(0); + _outgoingfileData->prepend(0); + _forwardedData->prepend(0); + + _maxPoints = getNumPoints(); + _showTrdown = true; + _showTrup = true; + _showIncoming = true; + _showOutgoing = true; + _showForwarded = true; + _maxValue = MIN_SCALE; +} + +/** Default destructor */ +GraphFrameTunnel::~GraphFrameTunnel() +{ + delete _painter; + delete _tunnelrequestdownData; + delete _tunnelrequestupData; + delete _incomingfileData; + delete _outgoingfileData; + delete _forwardedData; +} + +/** Gets the width of the desktop, which is the maximum number of points + * we can plot in the graph. */ +int +GraphFrameTunnel::getNumPoints() +{ + QDesktopWidget *desktop = QApplication::desktop(); + int width = desktop->width(); + return width; +} + +/** Adds new data points to the graph. */ +void +GraphFrameTunnel::addPoints(qreal trup, qreal trdown, qreal datadown,qreal dataup, qreal forwardupdown) +{ + /* If maximum number of points plotted, remove oldest */ + if (_tunnelrequestupData->size() == _maxPoints) { + _tunnelrequestdownData->removeLast(); + _tunnelrequestupData->removeLast(); + _incomingfileData->removeLast(); + _outgoingfileData->removeLast(); + _forwardedData->removeLast(); + } + + /* Add the points to their respective lists */ + _tunnelrequestupData->prepend(trup); + _tunnelrequestdownData->prepend(trdown); + _incomingfileData->prepend(datadown); + _outgoingfileData->prepend(dataup); + _forwardedData->prepend(forwardupdown); + + /* Add to the total counters */ + /* These are not the real total values, but should be close enough. */ + _totalTrup += GRAPH_REFRESH_RATE * trup / 1000; + _totalTrdown += GRAPH_REFRESH_RATE * trdown / 1000; + _totalInFileData += GRAPH_REFRESH_RATE * datadown / 1000; + _totalOutgoingFileData += GRAPH_REFRESH_RATE * dataup / 1000; + _totalForwardedData += GRAPH_REFRESH_RATE * forwardupdown / 1000; + + /* Check for a new maximum value */ + if (trup > _maxValue) _maxValue = trup; + if (trdown > _maxValue) _maxValue = trdown; + if (datadown > _maxValue) _maxValue = datadown; + if (dataup > _maxValue) _maxValue = dataup; + if (forwardupdown > _maxValue) _maxValue = forwardupdown; + + this->update(); +} + +/** Clears the graph. */ +void +GraphFrameTunnel::resetGraph() +{ + _tunnelrequestupData->clear(); + _tunnelrequestdownData->clear(); + _incomingfileData->clear(); + _outgoingfileData->clear(); + _forwardedData->clear(); + + _tunnelrequestdownData->prepend(0); + _tunnelrequestupData->prepend(0); + _incomingfileData->prepend(0); + _outgoingfileData->prepend(0); + _forwardedData->prepend(0); + + _maxValue = MIN_SCALE; + + _totalTrup = 0; + _totalTrdown = 0; + _totalInFileData = 0; + _totalOutgoingFileData = 0; + _totalForwardedData = 0; + + + this->update(); +} + +/** Toggles display of respective graph lines and counters. */ +void +GraphFrameTunnel::setShowCounters(bool showTrdown, bool showTrup, bool showIncoming, bool showOutgoing) +{ + _showTrdown = showTrdown; + _showTrup = showTrup; + _showIncoming = showIncoming; + _showOutgoing = showOutgoing; + this->update(); +} + +/** Overloads default QWidget::paintEvent. Draws the actual + * bandwidth graph. */ +void +GraphFrameTunnel::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + + /* Set current graph dimensions */ + _rec = this->frameRect(); + + /* Start the painter */ + _painter->begin(this); + + /* We want antialiased lines and text */ + _painter->setRenderHint(QPainter::Antialiasing); + _painter->setRenderHint(QPainter::TextAntialiasing); + + /* Fill in the background */ + _painter->fillRect(_rec, QBrush(BACK_COLOR)); + _painter->drawRect(_rec); + + /* Paint the scale */ + paintScale(); + /* Plot the send/receive data */ + paintData(); + /* Paint the send/recv totals */ + paintTotals(); + + /* Stop the painter */ + _painter->end(); +} + +/** 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. */ +void +GraphFrameTunnel::paintData() +{ + //QVector recvPoints, sendPoints; + QVector trdownPoints, trupPoints, infilePoints, outfilePoints, forwardedPoints; + + /* Convert the bandwidth data points to graph points */ + trdownPoints = pointsFromData( _tunnelrequestupData); + trupPoints = pointsFromData( _tunnelrequestdownData); + infilePoints = pointsFromData(_incomingfileData); + outfilePoints = pointsFromData(_outgoingfileData); + forwardedPoints = pointsFromData(_forwardedData); + + if (_graphStyle == AreaGraph) { + /* Plot the bandwidth data as area graphs */ + if (_showTrdown) + paintIntegral(trdownPoints, TRDOWN_COLOR, 0.6); + if (_showTrup) + paintIntegral(trupPoints, TRUP_COLOR, 0.4); + + paintIntegral(infilePoints, INFILEDATA_COLOR, 0.6); + paintIntegral(outfilePoints, OUTFILEDATA_COLOR, 0.4); + //paintIntegral(forwardedPoints, FORWARDED_COLOR, 0.6); + } + + /* Plot the bandwidth as solid lines. If the graph style is currently an + * area graph, we end up outlining the integrals. */ + if (_showTrdown) + paintLine(trdownPoints, TRDOWN_COLOR); + if (_showTrup) + paintLine(trupPoints, TRUP_COLOR); + + paintLine(infilePoints, INFILEDATA_COLOR); + paintLine(outfilePoints, OUTFILEDATA_COLOR); + //paintLine(forwardedPoints, FORWARDED_COLOR); +} + +/** Returns a list of points on the bandwidth graph based on the supplied set + * of send or receive values. */ +QVector +GraphFrameTunnel::pointsFromData(QList* list) +{ + QVector points; + int x = _rec.width(); + int y = _rec.height(); + qreal scale = (y - (y/10)) / _maxValue; + qreal currValue; + + /* Translate all data points to points on the graph frame */ + points << QPointF(x, y); + for (int i = 0; i < list->size(); i++) { + currValue = y - (list->at(i) * scale); + if (x - SCROLL_STEP < SCALE_WIDTH) { + points << QPointF(SCALE_WIDTH, currValue); + break; + } + points << QPointF(x, currValue); + x -= SCROLL_STEP; + } + points << QPointF(SCALE_WIDTH, y); + return points; +} + +/** 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). */ +void +GraphFrameTunnel::paintIntegral(QVector points, QColor color, qreal alpha) +{ + /* Save the current brush, plot the integral, and restore the old brush */ + QBrush oldBrush = _painter->brush(); + color.setAlphaF(alpha); + _painter->setBrush(QBrush(color)); + _painter->drawPolygon(points.data(), points.size()); + _painter->setBrush(oldBrush); +} + +/** Iterates the input list and draws a line on the graph in the appropriate + * color. */ +void +GraphFrameTunnel::paintLine(QVector points, QColor color, Qt::PenStyle lineStyle) +{ + /* Save the current brush, plot the line, and restore the old brush */ + QPen oldPen = _painter->pen(); + _painter->setPen(QPen(color, lineStyle)); + _painter->drawPolyline(points.data(), points.size()); + _painter->setPen(oldPen); +} + +/** Paints selected total indicators on the graph. */ +void +GraphFrameTunnel::paintTotals() +{ + int x = SCALE_WIDTH + FONT_SIZE, y = 0; + int rowHeight = FONT_SIZE; + +#if !defined(Q_WS_MAC) + /* On Mac, we don't need vertical spacing between the text rows. */ + rowHeight += 5; +#endif + + /* If total received is selected */ + if (_showTrdown) { + y = rowHeight; + _painter->setPen(TRDOWN_COLOR); + _painter->drawText(x, y, + tr("Tunnel requests Down: ") + totalToStr(_totalTrdown) + + " ("+tr("%1 KB/s").arg(_tunnelrequestdownData->first(), 0, 'f', 2)+")"); + } + + /* If total sent is selected */ + if (_showTrup) { + y += rowHeight; + _painter->setPen(TRUP_COLOR); + _painter->drawText(x, y, + tr("Tunnel requests Up: ") + totalToStr(_totalTrup) + + " ("+tr("%1 KB/s").arg(_tunnelrequestupData->first(), 0, 'f', 2)+")"); + } + + /* If total received is selected */ + if (_showIncoming) { + y += rowHeight; + _painter->setPen(INFILEDATA_COLOR); + _painter->drawText(x, y, + tr("Incoming file data: ") + totalToStr(_totalInFileData) + + " ("+tr("%1 KB/s").arg(_incomingfileData->first(), 0, 'f', 2)+")"); + } + + /* If total sent is selected */ + if (_showOutgoing) { + y += rowHeight; + _painter->setPen(OUTFILEDATA_COLOR); + _painter->drawText(x, y, + tr("Outgoing file data: ") + totalToStr(_totalOutgoingFileData) + + " ("+tr("%1 KB/s").arg(_outgoingfileData->first(), 0, 'f', 2)+")"); + } + + /* If total sent is selected */ + /*if (_showForwarded) { + y += rowHeight; + _painter->setPen(FORWARDED_COLOR); + _painter->drawText(x, y, + tr("Forwarded data: ") + totalToStr(_totalOutgoingFileData) + + " ("+tr("%1 KB/s").arg(_outgoingfileData->first(), 0, 'f', 2)+")"); + }*/ +} + +/** Returns a formatted string with the correct size suffix. */ +QString +GraphFrameTunnel::totalToStr(qreal total) +{ + /* Determine the correct size suffix */ + if (total < 1024) { + /* Use KB suffix */ + return tr("%1 KB").arg(total, 0, 'f', 2); + } else if (total < 1048576) { + /* Use MB suffix */ + return tr("%1 MB").arg(total/1024.0, 0, 'f', 2); + } else { + /* Use GB suffix */ + return tr("%1 GB").arg(total/1048576.0, 0, 'f', 2); + } +} + +/** Paints the scale on the graph. */ +void +GraphFrameTunnel::paintScale() +{ + qreal markStep = _maxValue * .25; + int top = _rec.y(); + int bottom = _rec.height(); + qreal paintStep = (bottom - (bottom/10)) / 4; + + /* Draw the other marks in their correctly scaled locations */ + qreal scale; + qreal pos; + for (int i = 1; i < 5; i++) { + pos = bottom - (i * paintStep); + scale = i * markStep; + _painter->setPen(SCALE_COLOR); + _painter->drawText(QPointF(5, pos+FONT_SIZE), + tr("%1 KB/s").arg(scale, 0, 'f', 2)); + _painter->setPen(GRID_COLOR); + _painter->drawLine(QPointF(SCALE_WIDTH, pos), + QPointF(_rec.width(), pos)); + } + + /* Draw vertical separator */ + _painter->drawLine(SCALE_WIDTH, top, SCALE_WIDTH, bottom); +} + diff --git a/retroshare-gui/src/gui/graphframetunnel.h b/retroshare-gui/src/gui/graphframetunnel.h new file mode 100644 index 000000000..07381efc0 --- /dev/null +++ b/retroshare-gui/src/gui/graphframetunnel.h @@ -0,0 +1,143 @@ +/**************************************************************** + * This file is distributed under the following license: + * + * Copyright (c) 2006-2007, crypton + * Copyright (c) 2006, Matt Edman, Justin Hipple + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + ****************************************************************/ + + +#ifndef _GRAPHFRAMETUNNEL_H +#define _GRAPHFRAMETUNNEL_H + +#include +#include +#include +#include +#include +#include + +#define HOR_SPC 2 /** Space between data points */ +#define SCALE_WIDTH 75 /** Width of the scale */ +#define MIN_SCALE 10 /** 10 kB/s is the minimum scale */ +#define SCROLL_STEP 4 /** Horizontal change on graph update */ + +#define BACK_COLOR Qt::black +#define SCALE_COLOR Qt::green +#define GRID_COLOR Qt::darkGreen +#define TRDOWN_COLOR Qt::cyan +#define TRUP_COLOR Qt::yellow +#define INFILEDATA_COLOR Qt::magenta +#define OUTFILEDATA_COLOR Qt::blue +#define FORWARDED_COLOR qt::red + +#define FONT_SIZE 11 + +/** Redraw graph every BWGRAPH_REFRESH_RATE ms **/ +#define GRAPH_REFRESH_RATE 5113 + + +class GraphFrameTunnel : public QFrame +{ + Q_OBJECT + +public: + /** Bandwidth graph style. */ + enum GraphStyle { + SolidLine = 0, /**< Plot bandwidth as solid lines. */ + AreaGraph /**< Plot bandwidth as alpha blended area graphs. */ + }; + + /** Default Constructor */ + GraphFrameTunnel(QWidget *parent = 0); + /** Default Destructor */ + ~GraphFrameTunnel(); + + /** Add data points. */ + void addPoints(qreal trup, qreal trdown, qreal datadown,qreal dataup, qreal forwardupdown ); + /** Clears the graph. */ + void resetGraph(); + /** Toggles display of data counters. */ + void setShowCounters(bool showTrdown, bool showTrup, bool showIncoming, bool showOutgoing); + /** Sets the graph style used to display bandwidth data. */ + void setGraphStyle(GraphStyle style) { _graphStyle = style; } + +protected: + /** Overloaded QWidget::paintEvent() */ + void paintEvent(QPaintEvent *event); + +private: + /** Gets the width of the desktop, the max # of points. */ + int getNumPoints(); + + /** Paints an integral and an outline of that integral for each data set + * (send and/or receive) that is to be displayed. */ + void paintData(); + /** Paints the send/receive totals. */ + void paintTotals(); + /** Paints the scale in the graph. */ + void paintScale(); + /** Returns a formatted string representation of total. */ + QString totalToStr(qreal total); + /** Returns a list of points on the bandwidth graph based on the supplied set + * of send or receive values. */ + QVector pointsFromData(QList* list); + /** Paints a line with the data in points. */ + void paintLine(QVector points, QColor color, + Qt::PenStyle lineStyle = Qt::SolidLine); + /** Paints an integral using the supplied data. */ + void paintIntegral(QVector points, QColor color, qreal alpha = 1.0); + + /** Style with which the bandwidth data will be graphed. */ + GraphStyle _graphStyle; + /** A QPainter object that handles drawing the various graph elements. */ + QPainter* _painter; + /** Holds the tunnel request down data points. */ + QList *_tunnelrequestdownData; + /** Holds the tunnel request up data points. */ + QList *_tunnelrequestupData; + /** Holds the incoming file data points. */ + QList *_incomingfileData; + /** Holds the outgoin file data points. */ + QList *_outgoingfileData; + /** Holds the received data points. */ + QList *_forwardedData; + + + /** The current dimensions of the graph. */ + QRect _rec; + /** The maximum data value plotted. */ + qreal _maxValue; + /** The maximum number of points to store. */ + int _maxPoints; + /** The total data sent/recv. */ + + qreal _totalTrup; + qreal _totalTrdown; + qreal _totalInFileData; + qreal _totalOutgoingFileData; + qreal _totalForwardedData; + + /** Show the respective lines and counters. */ + bool _showTrdown; + bool _showTrup; + bool _showIncoming; + bool _showOutgoing; + bool _showForwarded; +}; + +#endif diff --git a/retroshare-gui/src/gui/settings/GlobalRouterStatistics.cpp b/retroshare-gui/src/gui/settings/GlobalRouterStatistics.cpp index 29309524f..2ac28862f 100644 --- a/retroshare-gui/src/gui/settings/GlobalRouterStatistics.cpp +++ b/retroshare-gui/src/gui/settings/GlobalRouterStatistics.cpp @@ -164,41 +164,8 @@ void GlobalRouterStatisticsWidget::updateContent() // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; // draw... int ox=5,oy=5 ; - - painter.setFont(times_f) ; - painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ; - - painter.setFont(monospace_f) ; - - static const QString status_string[5] = { "UNKN", "PEND","SENT","ACKN","DEAD" } ; - time_t now = time(NULL) ; - std::map > tos ; - - for(uint32_t i=0;i >::const_iterator it(tos.begin());it!=tos.end();++it) - { - painter.drawText(ox+2*cellx,oy+celly,tr("To: ")+it->first ) ; oy += celly ; - - for(uint32_t i=0;isecond.size();++i) - { - painter.drawText(ox+4*cellx,oy+celly,it->second[i] ) ; - oy += celly ; - } - } - - oy += celly ; - + + painter.setFont(times_f) ; painter.drawText(ox,oy+celly,tr("Managed keys")+":" + QString::number(matrix_info.published_keys.size())) ; oy += celly*2 ; @@ -247,6 +214,41 @@ void GlobalRouterStatisticsWidget::updateContent() oy += celly ; } + + oy += celly ; + + painter.setFont(times_f) ; + painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ; + + painter.setFont(monospace_f) ; + + static const QString status_string[5] = { "UNKN", "PEND","SENT","ACKN","DEAD" } ; + time_t now = time(NULL) ; + std::map > tos ; + + for(uint32_t i=0;i >::const_iterator it(tos.begin());it!=tos.end();++it) + { + painter.drawText(ox+2*cellx,oy+celly,tr("To: ")+it->first ) ; oy += celly ; + + for(uint32_t i=0;isecond.size();++i) + { + painter.drawText(ox+4*cellx,oy+celly,it->second[i] ) ; + oy += celly ; + } + } + oy += celly ; oy += celly ; diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index dcfd2809e..f3f04fe92 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -323,6 +323,7 @@ HEADERS += rshare.h \ gui/NetworkDialog.h \ gui/GenCertDialog.h \ gui/graphframe.h \ + gui/graphframetunnel.h \ gui/linetypes.h \ gui/mainpagestack.h \ gui/MainWindow.h \ @@ -424,15 +425,15 @@ HEADERS += rshare.h \ gui/settings/PluginItem.h \ gui/settings/AppearancePage.h \ gui/settings/FileAssociationsPage.h \ - gui/settings/SoundPage.h \ - gui/settings/TransferPage.h \ - gui/settings/ChatPage.h \ - gui/settings/ChannelPage.h \ + gui/settings/SoundPage.h \ + gui/settings/TransferPage.h \ + gui/settings/ChatPage.h \ + gui/settings/ChannelPage.h \ gui/settings/PostedPage.h \ - gui/settings/RelayPage.h \ - gui/settings/ServicePermissionsPage.h \ + gui/settings/RelayPage.h \ + gui/settings/ServicePermissionsPage.h \ gui/settings/AddFileAssociationDialog.h \ - gui/settings/GroupFrameSettingsWidget.h \ + gui/settings/GroupFrameSettingsWidget.h \ gui/toaster/MessageToaster.h \ gui/toaster/OnlineToaster.h \ gui/toaster/DownloadToaster.h \ @@ -589,14 +590,14 @@ FORMS += gui/StartDialog.ui \ gui/settings/ForumPage.ui \ gui/settings/PluginsPage.ui \ gui/settings/AppearancePage.ui \ - gui/settings/TransferPage.ui \ - gui/settings/SoundPage.ui \ - gui/settings/ChatPage.ui \ - gui/settings/ChannelPage.ui \ + gui/settings/TransferPage.ui \ + gui/settings/SoundPage.ui \ + gui/settings/ChatPage.ui \ + gui/settings/ChannelPage.ui \ gui/settings/PostedPage.ui \ - gui/settings/RelayPage.ui \ - gui/settings/ServicePermissionsPage.ui \ - gui/settings/GlobalRouterStatistics.ui \ + gui/settings/RelayPage.ui \ + gui/settings/ServicePermissionsPage.ui \ + gui/settings/GlobalRouterStatistics.ui \ gui/settings/PluginItem.ui \ gui/settings/GroupFrameSettingsWidget.ui \ gui/toaster/MessageToaster.ui \ @@ -657,6 +658,7 @@ SOURCES += main.cpp \ gui/GenCertDialog.cpp \ gui/NetworkDialog.cpp \ gui/graphframe.cpp \ + gui/graphframetunnel.cpp \ gui/mainpagestack.cpp \ gui/MainWindow.cpp \ gui/NetworkView.cpp \ @@ -795,14 +797,14 @@ SOURCES += main.cpp \ gui/settings/PluginItem.cpp \ gui/settings/AppearancePage.cpp \ gui/settings/FileAssociationsPage.cpp \ - gui/settings/SoundPage.cpp \ - gui/settings/TransferPage.cpp \ - gui/settings/ChatPage.cpp \ - gui/settings/ChannelPage.cpp \ + gui/settings/SoundPage.cpp \ + gui/settings/TransferPage.cpp \ + gui/settings/ChatPage.cpp \ + gui/settings/ChannelPage.cpp \ gui/settings/PostedPage.cpp \ - gui/settings/RelayPage.cpp \ - gui/settings/ServicePermissionsPage.cpp \ - gui/settings/AddFileAssociationDialog.cpp \ + gui/settings/RelayPage.cpp \ + gui/settings/ServicePermissionsPage.cpp \ + gui/settings/AddFileAssociationDialog.cpp \ gui/settings/GroupFrameSettingsWidget.cpp \ gui/statusbar/peerstatus.cpp \ gui/statusbar/natstatus.cpp \