mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 08:59:50 -05:00
improved RSGraph class. Used it for Turtle statistics and bandwidth statistics as well
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7612 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
bd96859704
commit
8c1bf3cf8d
@ -65,6 +65,32 @@ void RSGraphSource::start()
|
|||||||
|
|
||||||
int RSGraphSource::n_values() const { return _points.size() ; }
|
int RSGraphSource::n_values() const { return _points.size() ; }
|
||||||
|
|
||||||
|
QString RSGraphSource::displayName(int i) const
|
||||||
|
{
|
||||||
|
std::map<std::string,std::list<std::pair<qint64,float> > >::const_iterator it = _points.begin();
|
||||||
|
|
||||||
|
int n=0;
|
||||||
|
for(it = _points.begin();it!=_points.end() && n<i;++it,++n) ;
|
||||||
|
|
||||||
|
if(n != i)
|
||||||
|
return QString("[error]");
|
||||||
|
|
||||||
|
return QString::fromStdString(it->first) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RSGraphSource::displayValue(float v) const
|
||||||
|
{
|
||||||
|
return QString::number(v,'g',2) + " " + unitName() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSGraphSource::getCurrentValues(std::vector<float>& vals) const
|
||||||
|
{
|
||||||
|
std::map<std::string,std::list<std::pair<qint64,float> > >::const_iterator it = _points.begin();
|
||||||
|
|
||||||
|
for(it = _points.begin();it!=_points.end();++it)
|
||||||
|
vals.push_back(it->second.back().second) ;
|
||||||
|
}
|
||||||
|
|
||||||
void RSGraphSource::getDataPoints(int index,std::vector<QPointF>& pts) const
|
void RSGraphSource::getDataPoints(int index,std::vector<QPointF>& pts) const
|
||||||
{
|
{
|
||||||
pts.clear() ;
|
pts.clear() ;
|
||||||
@ -222,6 +248,9 @@ void RSGraphWidget::paintEvent(QPaintEvent *)
|
|||||||
/* Paint the rsDHT/allDHT totals */
|
/* Paint the rsDHT/allDHT totals */
|
||||||
paintTotals();
|
paintTotals();
|
||||||
|
|
||||||
|
if(_flags & RSGRAPH_FLAGS_SHOW_LEGEND)
|
||||||
|
paintLegend() ;
|
||||||
|
|
||||||
/* Stop the painter */
|
/* Stop the painter */
|
||||||
_painter->end();
|
_painter->end();
|
||||||
}
|
}
|
||||||
@ -229,7 +258,7 @@ void RSGraphWidget::paintEvent(QPaintEvent *)
|
|||||||
QColor RSGraphWidget::getColor(int i)
|
QColor RSGraphWidget::getColor(int i)
|
||||||
{
|
{
|
||||||
// shuffle the colors a little bit
|
// shuffle the colors a little bit
|
||||||
int h = (i*44497)%359 ;
|
int h = (i*86243)%359 ;
|
||||||
|
|
||||||
return QColor::fromHsv(h,128+127*(i&1),255) ;
|
return QColor::fromHsv(h,128+127*(i&1),255) ;
|
||||||
}
|
}
|
||||||
@ -430,8 +459,10 @@ void RSGraphWidget::paintScale()
|
|||||||
|
|
||||||
scale = pixelsToValue(i * paintStep);
|
scale = pixelsToValue(i * paintStep);
|
||||||
|
|
||||||
|
QString text = _source->displayValue(scale) ;
|
||||||
|
|
||||||
_painter->setPen(SCALE_COLOR);
|
_painter->setPen(SCALE_COLOR);
|
||||||
_painter->drawText(QPointF(5, pos+0.5*FONT_SIZE), tr("%1 %2").arg(scale, 0, 'f', _precision_digits).arg(unit_name));
|
_painter->drawText(QPointF(5, pos+0.5*FONT_SIZE), text);
|
||||||
_painter->setPen(GRID_COLOR);
|
_painter->setPen(GRID_COLOR);
|
||||||
_painter->drawLine(QPointF(SCALE_WIDTH, pos), QPointF(_rec.width(), pos));
|
_painter->drawLine(QPointF(SCALE_WIDTH, pos), QPointF(_rec.width(), pos));
|
||||||
}
|
}
|
||||||
@ -440,3 +471,26 @@ void RSGraphWidget::paintScale()
|
|||||||
_painter->drawLine(SCALE_WIDTH, top, SCALE_WIDTH, bottom);
|
_painter->drawLine(SCALE_WIDTH, top, SCALE_WIDTH, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSGraphWidget::paintLegend()
|
||||||
|
{
|
||||||
|
int bottom = _rec.height();
|
||||||
|
|
||||||
|
std::vector<float> vals ;
|
||||||
|
_source->getCurrentValues(vals) ;
|
||||||
|
|
||||||
|
for(uint i=0;i<vals.size();++i)
|
||||||
|
{
|
||||||
|
qreal paintStep = 4+FONT_SIZE;
|
||||||
|
qreal pos = 20+i*paintStep;
|
||||||
|
QString text = _source->displayName(i) + " (" + _source->displayValue(vals[i]) + " )";
|
||||||
|
|
||||||
|
QPen oldPen = _painter->pen();
|
||||||
|
_painter->setPen(QPen(getColor(i), Qt::SolidLine));
|
||||||
|
_painter->drawLine(QPointF(SCALE_WIDTH+10.0, pos), QPointF(SCALE_WIDTH+30.0, pos));
|
||||||
|
_painter->setPen(oldPen);
|
||||||
|
|
||||||
|
_painter->setPen(SCALE_COLOR);
|
||||||
|
_painter->drawText(QPointF(SCALE_WIDTH + 40,pos + 0.5*FONT_SIZE), text) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -59,19 +59,29 @@ public:
|
|||||||
void stop() ;
|
void stop() ;
|
||||||
void clear() ;
|
void clear() ;
|
||||||
|
|
||||||
virtual int n_values() const ;
|
virtual QString unitName() const { return "" ; }// overload to give your own unit name (KB/s, Users, etc)
|
||||||
|
|
||||||
|
int n_values() const ;
|
||||||
|
|
||||||
|
// Might be overloaded in order to show a fancy digit number with adaptive units.
|
||||||
|
// The default is to return v + unitName()
|
||||||
|
virtual QString displayValue(float v) const ;
|
||||||
|
|
||||||
|
// return the vector of last values up to date
|
||||||
|
virtual void getCurrentValues(std::vector<float>& vals) const ;
|
||||||
|
|
||||||
// Returns the n^th interpolated value at the given time in floating point seconds backward.
|
// Returns the n^th interpolated value at the given time in floating point seconds backward.
|
||||||
virtual void getDataPoints(int index, std::vector<QPointF>& pts) const ;
|
virtual void getDataPoints(int index, std::vector<QPointF>& pts) const ;
|
||||||
|
|
||||||
|
// returns the name to give to the nth entry in the graph
|
||||||
|
virtual QString displayName(int index) const ;
|
||||||
|
|
||||||
// Sets the maximum time for keeping values. Units=seconds.
|
// Sets the maximum time for keeping values. Units=seconds.
|
||||||
void setCollectionTimeLimit(qint64 msecs) ;
|
void setCollectionTimeLimit(qint64 msecs) ;
|
||||||
|
|
||||||
// Sets the time period for collecting new values. Units=milliseconds.
|
// Sets the time period for collecting new values. Units=milliseconds.
|
||||||
void setCollectionTimePeriod(qint64 msecs) ;
|
void setCollectionTimePeriod(qint64 msecs) ;
|
||||||
|
|
||||||
virtual QString unitName() const =0;// overload to give your own unit name (KB/s, Users, etc)
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
// Calls the internal source for a new data points; called by the timer. You might want to overload this
|
// Calls the internal source for a new data points; called by the timer. You might want to overload this
|
||||||
// if the collection system needs it. Otherwise, the default method will call getValues()
|
// if the collection system needs it. Otherwise, the default method will call getValues()
|
||||||
@ -102,6 +112,7 @@ class RSGraphWidget: public QFrame
|
|||||||
static const uint32_t RSGRAPH_FLAGS_LOG_SCALE_Y = 0x0002 ;// log scale in Y
|
static const uint32_t RSGRAPH_FLAGS_LOG_SCALE_Y = 0x0002 ;// log scale in Y
|
||||||
static const uint32_t RSGRAPH_FLAGS_ALWAYS_COLLECT = 0x0004 ;// keep collecting while not displayed
|
static const uint32_t RSGRAPH_FLAGS_ALWAYS_COLLECT = 0x0004 ;// keep collecting while not displayed
|
||||||
static const uint32_t RSGRAPH_FLAGS_PAINT_STYLE_PLAIN = 0x0008 ;// use plain / line drawing style
|
static const uint32_t RSGRAPH_FLAGS_PAINT_STYLE_PLAIN = 0x0008 ;// use plain / line drawing style
|
||||||
|
static const uint32_t RSGRAPH_FLAGS_SHOW_LEGEND = 0x0010 ;// show legend in the graph
|
||||||
|
|
||||||
/** Bandwidth graph style. */
|
/** Bandwidth graph style. */
|
||||||
enum GraphStyle
|
enum GraphStyle
|
||||||
@ -149,6 +160,8 @@ class RSGraphWidget: public QFrame
|
|||||||
/** Paints the rsdht/alldht totals. */
|
/** Paints the rsdht/alldht totals. */
|
||||||
void paintTotals();
|
void paintTotals();
|
||||||
/** Paints the scale in the graph. */
|
/** Paints the scale in the graph. */
|
||||||
|
void paintLegend();
|
||||||
|
/** Paints the scale in the graph. */
|
||||||
void paintScale();
|
void paintScale();
|
||||||
|
|
||||||
QColor getColor(int i) ;
|
QColor getColor(int i) ;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include "BwCtrlWindow.h"
|
#include "BwCtrlWindow.h"
|
||||||
|
#include "gui/common/RSGraphWidget.h"
|
||||||
#include "ui_BwCtrlWindow.h"
|
#include "ui_BwCtrlWindow.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@ -37,14 +38,21 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
class BWListDelegate: public QAbstractItemDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BWListDelegate(QObject *parent=0);
|
||||||
|
virtual ~BWListDelegate();
|
||||||
|
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||||
|
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const;
|
||||||
|
};
|
||||||
|
|
||||||
BWListDelegate::BWListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
|
BWListDelegate::BWListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
|
||||||
{
|
{
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BWListDelegate::~BWListDelegate(void)
|
BWListDelegate::~BWListDelegate(void)
|
||||||
{
|
{
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BWListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
void BWListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||||
@ -163,31 +171,25 @@ QSize BWListDelegate::sizeHint(const QStyleOptionViewItem & /*option*/, const QM
|
|||||||
return QSize(50,17);
|
return QSize(50,17);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BwCtrlWindow::BwCtrlWindow(QWidget *parent)
|
BwCtrlWindow::BwCtrlWindow(QWidget *parent)
|
||||||
: RsAutoUpdatePage(1000,parent)
|
: RsAutoUpdatePage(1000,parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
|
||||||
BWDelegate = new BWListDelegate();
|
BWDelegate = new BWListDelegate();
|
||||||
bwTreeWidget->setItemDelegate(BWDelegate);
|
bwTreeWidget->setItemDelegate(BWDelegate);
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes Peer TreeView*/
|
/* Set header resize modes and initial section sizes Peer TreeView*/
|
||||||
QHeaderView * _header = bwTreeWidget->header () ;
|
QHeaderView * _header = bwTreeWidget->header () ;
|
||||||
_header->resizeSection ( COLUMN_RSNAME, 170 );
|
_header->resizeSection ( COLUMN_RSNAME, 170 );
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BwCtrlWindow::~BwCtrlWindow()
|
BwCtrlWindow::~BwCtrlWindow()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BwCtrlWindow::updateDisplay()
|
void BwCtrlWindow::updateDisplay()
|
||||||
{
|
{
|
||||||
|
|
||||||
/* do nothing if locked, or not visible */
|
/* do nothing if locked, or not visible */
|
||||||
if (RsAutoUpdatePage::eventsLocked() == true)
|
if (RsAutoUpdatePage::eventsLocked() == true)
|
||||||
{
|
{
|
||||||
@ -205,12 +207,7 @@ void BwCtrlWindow::updateDisplay()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsAutoUpdatePage::lockAllEvents();
|
|
||||||
|
|
||||||
//std::cerr << "BwCtrlWindow::update()" << std::endl;
|
|
||||||
updateBandwidth();
|
updateBandwidth();
|
||||||
|
|
||||||
RsAutoUpdatePage::unlockAllEvents() ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BwCtrlWindow::updateBandwidth()
|
void BwCtrlWindow::updateBandwidth()
|
||||||
@ -231,8 +228,6 @@ void BwCtrlWindow::updateBandwidth()
|
|||||||
peerTreeWidget->addTopLevelItem(item);
|
peerTreeWidget->addTopLevelItem(item);
|
||||||
peerTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
peerTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
|
|
||||||
updateGraph(totalRates.mRateIn,totalRates.mRateOut);
|
|
||||||
|
|
||||||
/* do Totals */
|
/* do Totals */
|
||||||
item -> setData(COLUMN_PEERID, Qt::DisplayRole, tr("TOTALS"));
|
item -> setData(COLUMN_PEERID, Qt::DisplayRole, tr("TOTALS"));
|
||||||
item -> setData(COLUMN_RSNAME, Qt::DisplayRole, tr("Totals"));
|
item -> setData(COLUMN_RSNAME, Qt::DisplayRole, tr("Totals"));
|
||||||
@ -369,10 +364,4 @@ void BwCtrlWindow::updateBandwidth()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds new data to the graph. */
|
|
||||||
void BwCtrlWindow::updateGraph(qreal bytesRead, qreal bytesWritten)
|
|
||||||
{
|
|
||||||
/* Graph only cares about kilobytes */
|
|
||||||
frmGraph->addPoints(bytesRead/*/1024.0*/, bytesWritten/*/1024.0*/);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#ifndef RSBWCTRL_WINDOW_H
|
|
||||||
#define RSBWCTRL_WINDOW_H
|
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* RetroShare is distributed under the following license:
|
* RetroShare is distributed under the following license:
|
||||||
*
|
*
|
||||||
@ -22,11 +19,14 @@
|
|||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
|
|
||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
|
#include "gui/common/RSGraphWidget.h"
|
||||||
#include "ui_BwCtrlWindow.h"
|
#include "ui_BwCtrlWindow.h"
|
||||||
|
|
||||||
// Defines for download list list columns
|
// Defines for download list list columns
|
||||||
@ -48,25 +48,10 @@
|
|||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
class BWListDelegate ;
|
||||||
|
|
||||||
class BWListDelegate: public QAbstractItemDelegate {
|
class BwCtrlWindow : public RsAutoUpdatePage, public Ui::BwCtrlWindow
|
||||||
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
BWListDelegate(QObject *parent=0);
|
|
||||||
~BWListDelegate();
|
|
||||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
|
||||||
QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
signals:
|
|
||||||
};
|
|
||||||
|
|
||||||
class BwCtrlWindow : public RsAutoUpdatePage, public Ui::BwCtrlWindow {
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -78,17 +63,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
virtual void updateDisplay() ;
|
virtual void updateDisplay() ;
|
||||||
|
|
||||||
/** Adds new data to the graph */
|
|
||||||
void updateGraph(qreal bytesRead, qreal bytesWritten);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
|
||||||
BWListDelegate *BWDelegate;
|
BWListDelegate *BWDelegate;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSBWCTRL_WINDOW_H
|
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="GraphFrame" name="frmGraph">
|
<widget class="BWGraph" name="frmGraph" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>120</width>
|
<width>120</width>
|
||||||
@ -99,12 +99,6 @@
|
|||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::NoContextMenu</enum>
|
<enum>Qt::NoContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Box</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -112,9 +106,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>GraphFrame</class>
|
<class>BWGraph</class>
|
||||||
<extends>QFrame</extends>
|
<extends>QWidget</extends>
|
||||||
<header>gui/graphframe.h</header>
|
<header>gui/statistics/bwgraph.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
@ -695,10 +695,3 @@ void DhtWindow::getDHTStatus()
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adds new data to the graph. */
|
|
||||||
void DhtWindow::updateGraph(qreal rsDHT, qreal allDHT)
|
|
||||||
{
|
|
||||||
// ui.frmGraph->addPoints(rsDHT, allDHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -42,8 +42,6 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
virtual void updateDisplay() ;
|
virtual void updateDisplay() ;
|
||||||
|
|
||||||
void updateGraph(qreal rsDHT, qreal allDHT);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//void changeEvent(QEvent *e);
|
//void changeEvent(QEvent *e);
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -242,7 +242,6 @@ void TurtleRouterStatistics::updateDisplay()
|
|||||||
//updateTunnelRequests(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
|
//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->updateTunnelStatistics(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
|
||||||
_tst_CW->update();
|
_tst_CW->update();
|
||||||
updateTunnelGraph();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TurtleRouterStatistics::getPeerName(const RsPeerId &peer_id)
|
QString TurtleRouterStatistics::getPeerName(const RsPeerId &peer_id)
|
||||||
@ -355,17 +354,3 @@ void TurtleRouterStatisticsWidget::resizeEvent(QResizeEvent *event)
|
|||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurtleRouterStatistics::updateTunnelGraph()
|
|
||||||
{
|
|
||||||
TurtleTrafficStatisticsInfo info ;
|
|
||||||
rsTurtle->getTrafficStatistics(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 );
|
|
||||||
}
|
|
||||||
|
@ -33,19 +33,14 @@ class TurtleRouterStatistics: public RsAutoUpdatePage, public Ui::TurtleRouterSt
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TurtleRouterStatistics(QWidget *parent = NULL) ;
|
TurtleRouterStatistics(QWidget *parent = NULL) ;
|
||||||
~TurtleRouterStatistics();
|
~TurtleRouterStatistics();
|
||||||
|
|
||||||
// Cache for peer names.
|
// Cache for peer names.
|
||||||
static QString getPeerName(const RsPeerId& peer_id) ;
|
static QString getPeerName(const RsPeerId& peer_id) ;
|
||||||
|
|
||||||
public slots:
|
private:
|
||||||
void updateTunnelGraph();
|
|
||||||
void updateGraph(qreal bytesTrup, qreal bytesTrdown, qreal bytesDatadown, qreal bytesDataup, qreal bytesunknownupdn);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void processSettings(bool bLoad);
|
void processSettings(bool bLoad);
|
||||||
bool m_bProcessSettings;
|
bool m_bProcessSettings;
|
||||||
|
@ -47,8 +47,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>638</width>
|
<width>640</width>
|
||||||
<height>255</height>
|
<height>248</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
@ -59,7 +59,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="GraphFrameTunnel" name="frmGraph">
|
<widget class="TurtleGraph" name="frmGraph" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>120</width>
|
<width>120</width>
|
||||||
@ -74,12 +74,6 @@
|
|||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::NoContextMenu</enum>
|
<enum>Qt::NoContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Box</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -90,9 +84,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>GraphFrameTunnel</class>
|
<class>TurtleGraph</class>
|
||||||
<extends>QFrame</extends>
|
<extends>QWidget</extends>
|
||||||
<header>gui/graphframetunnel.h</header>
|
<header>gui/statistics/turtlegraph.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
45
retroshare-gui/src/gui/statistics/bwgraph.h
Normal file
45
retroshare-gui/src/gui/statistics/bwgraph.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "retroshare/rsconfig.h"
|
||||||
|
#include <gui/common/RSGraphWidget.h>
|
||||||
|
|
||||||
|
class BWGraphSource: public RSGraphSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void getValues(std::map<std::string,float>& values) const
|
||||||
|
{
|
||||||
|
RsConfigDataRates totalRates;
|
||||||
|
rsConfig->getTotalBandwidthRates(totalRates);
|
||||||
|
|
||||||
|
values.insert(std::make_pair(std::string("Bytes in"),(float)totalRates.mRateIn)) ;
|
||||||
|
values.insert(std::make_pair(std::string("Bytes out"),(float)totalRates.mRateOut)) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QString unitName() const { return tr("KB/s"); }
|
||||||
|
};
|
||||||
|
|
||||||
|
class BWGraph: public RSGraphWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BWGraph(QWidget *parent)
|
||||||
|
: RSGraphWidget(parent)
|
||||||
|
{
|
||||||
|
BWGraphSource *src = new BWGraphSource() ;
|
||||||
|
|
||||||
|
src->setCollectionTimeLimit(30*60*1000) ; // 30 mins
|
||||||
|
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||||
|
src->start() ;
|
||||||
|
|
||||||
|
addSource(src) ;
|
||||||
|
|
||||||
|
setTimeScale(1.0f) ; // 1 pixels per second of time.
|
||||||
|
setScaleParams(2) ;
|
||||||
|
|
||||||
|
resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
|
||||||
|
resetFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
|
||||||
|
|
||||||
|
setFlags(RSGRAPH_FLAGS_SHOW_LEGEND) ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -26,26 +26,56 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <gui/common/RSGraphWidget.h>
|
#include <gui/common/RSGraphWidget.h>
|
||||||
|
|
||||||
#define HOR_SPC 2 /** Space between data points */
|
#include <retroshare/rsdht.h>
|
||||||
#define SCALE_WIDTH 75 /** Width of the scale */
|
#include <retroshare/rsconfig.h>
|
||||||
#define MINUSER_SCALE 2000 /** 2000 users is the minimum scale */
|
#include "dhtgraph.h"
|
||||||
#define SCROLL_STEP 4 /** Horizontal change on graph update */
|
|
||||||
|
|
||||||
#define BACK_COLOR Qt::white
|
class DHTGraphSource: public RSGraphSource
|
||||||
#define SCALE_COLOR Qt::black
|
{
|
||||||
#define GRID_COLOR Qt::black
|
public:
|
||||||
#define RSDHT_COLOR Qt::magenta
|
virtual int n_values() const
|
||||||
#define ALLDHT_COLOR Qt::yellow
|
{
|
||||||
|
return 1 ;
|
||||||
|
}
|
||||||
|
virtual void getValues(std::map<std::string,float>& values) const
|
||||||
|
{
|
||||||
|
RsConfigNetStatus config;
|
||||||
|
rsConfig->getConfigNetStatus(config);
|
||||||
|
|
||||||
|
if (config.DHTActive && config.netDhtOk)
|
||||||
|
{
|
||||||
|
values.insert(std::make_pair(std::string("RS Net size"),(float)config.netDhtRsNetSize)) ;
|
||||||
|
//values.insert(std::make_pair(std::string("GLobal Net size"),(float)config.netDhtNetSize)) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
values.insert(std::make_pair(std::string("RS Net size"),0.0f)) ;
|
||||||
|
//values.insert(std::make_pair(std::string("GLobal Net size"),0.0f)) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QString unitName() const { return tr("users"); }
|
||||||
|
};
|
||||||
|
|
||||||
#define FONT_SIZE 11
|
|
||||||
|
|
||||||
class DhtGraph : public RSGraphWidget
|
class DhtGraph : public RSGraphWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DhtGraph(QWidget *parent = 0);
|
DhtGraph(QWidget *parent = 0)
|
||||||
|
: RSGraphWidget(parent)
|
||||||
|
{
|
||||||
|
DHTGraphSource *src = new DHTGraphSource() ;
|
||||||
|
|
||||||
/** Show the respective lines and counters. */
|
src->setCollectionTimeLimit(30*60*1000) ; // 30 mins
|
||||||
bool _showRSDHT;
|
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||||
bool _showALLDHT;
|
src->start() ;
|
||||||
|
|
||||||
|
addSource(src) ;
|
||||||
|
|
||||||
|
setTimeScale(1.0f) ; // 1 pixels per second of time.
|
||||||
|
setScaleParams(0) ;
|
||||||
|
|
||||||
|
resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
|
||||||
|
setFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
54
retroshare-gui/src/gui/statistics/turtlegraph.h
Normal file
54
retroshare-gui/src/gui/statistics/turtlegraph.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "retroshare/rsturtle.h"
|
||||||
|
#include <gui/common/RSGraphWidget.h>
|
||||||
|
|
||||||
|
class TurtleGraphSource: public RSGraphSource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void getValues(std::map<std::string,float>& values) const
|
||||||
|
{
|
||||||
|
TurtleTrafficStatisticsInfo info ;
|
||||||
|
rsTurtle->getTrafficStatistics(info) ;
|
||||||
|
|
||||||
|
values.insert(std::make_pair(QObject::tr("TR up").toStdString(),(float)info.tr_up_Bps)) ;
|
||||||
|
values.insert(std::make_pair(QObject::tr("TR dn").toStdString(),(float)info.tr_dn_Bps)) ;
|
||||||
|
values.insert(std::make_pair(QObject::tr("Data up").toStdString(),(float)info.data_up_Bps)) ;
|
||||||
|
values.insert(std::make_pair(QObject::tr("Data dn").toStdString(),(float)info.data_dn_Bps)) ;
|
||||||
|
values.insert(std::make_pair(QObject::tr("Data forward").toStdString(),(float)info.unknown_updn_Bps)) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QString displayValue(float v) const
|
||||||
|
{
|
||||||
|
if(v < 1000)
|
||||||
|
return QString::number(v,'g',2) + " B/s" ;
|
||||||
|
else if(v < 1000*1024)
|
||||||
|
return QString::number(v/1024.0,'g',2) + " KB/s" ;
|
||||||
|
else
|
||||||
|
return QString::number(v/(1024.0*1024),'g',2) + " MB/s" ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class TurtleGraph: public RSGraphWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TurtleGraph(QWidget *parent)
|
||||||
|
: RSGraphWidget(parent)
|
||||||
|
{
|
||||||
|
TurtleGraphSource *src = new TurtleGraphSource() ;
|
||||||
|
|
||||||
|
src->setCollectionTimeLimit(30*60*1000) ; // 30 mins
|
||||||
|
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||||
|
src->start() ;
|
||||||
|
|
||||||
|
addSource(src) ;
|
||||||
|
|
||||||
|
setTimeScale(1.0f) ; // 1 pixels per second of time.
|
||||||
|
setScaleParams(2) ;
|
||||||
|
|
||||||
|
resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
|
||||||
|
resetFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -344,6 +344,8 @@ HEADERS += rshare.h \
|
|||||||
gui/statistics/TurtleRouterDialog.h \
|
gui/statistics/TurtleRouterDialog.h \
|
||||||
gui/statistics/TurtleRouterStatistics.h \
|
gui/statistics/TurtleRouterStatistics.h \
|
||||||
gui/statistics/dhtgraph.h \
|
gui/statistics/dhtgraph.h \
|
||||||
|
gui/statistics/bwgraph.h \
|
||||||
|
gui/statistics/turtlegraph.h \
|
||||||
gui/FileTransfer/TransferUserNotify.h \
|
gui/FileTransfer/TransferUserNotify.h \
|
||||||
gui/plugins/PluginInterface.h \
|
gui/plugins/PluginInterface.h \
|
||||||
gui/im_history/ImHistoryBrowser.h \
|
gui/im_history/ImHistoryBrowser.h \
|
||||||
@ -684,7 +686,6 @@ SOURCES += main.cpp \
|
|||||||
gui/FileTransfer/xprogressbar.cpp \
|
gui/FileTransfer/xprogressbar.cpp \
|
||||||
gui/statistics/TurtleRouterDialog.cpp \
|
gui/statistics/TurtleRouterDialog.cpp \
|
||||||
gui/statistics/TurtleRouterStatistics.cpp \
|
gui/statistics/TurtleRouterStatistics.cpp \
|
||||||
gui/statistics/dhtgraph.cpp \
|
|
||||||
gui/statistics/GlobalRouterStatistics.cpp \
|
gui/statistics/GlobalRouterStatistics.cpp \
|
||||||
gui/FileTransfer/DetailsDialog.cpp \
|
gui/FileTransfer/DetailsDialog.cpp \
|
||||||
gui/FileTransfer/TransferUserNotify.cpp \
|
gui/FileTransfer/TransferUserNotify.cpp \
|
||||||
|
Loading…
Reference in New Issue
Block a user