mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-11 02:25:34 -04:00
improved display of graphs
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7614 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
01fdb95c30
commit
b51c34d23b
7 changed files with 74 additions and 20 deletions
|
@ -88,6 +88,17 @@ QString RttGraphSource::unitName() const
|
|||
{
|
||||
return QObject::tr("secs") ;
|
||||
}
|
||||
|
||||
QString RttGraphSource::displayName(int i) const
|
||||
{
|
||||
int n=0 ;
|
||||
for(std::map<std::string, std::list<std::pair<qint64,float> > >::const_iterator it=_points.begin();it!=_points.end();++it,++n)
|
||||
if(n==i)
|
||||
return QString::fromUtf8(rsPeers->getPeerName(RsPeerId(it->first)).c_str()) ;
|
||||
|
||||
return QString() ;
|
||||
}
|
||||
|
||||
void RttGraphSource::getValues(std::map<std::string,float>& vals) const
|
||||
{
|
||||
std::list<RsPeerId> idList;
|
||||
|
@ -111,13 +122,14 @@ RttStatisticsGraph::RttStatisticsGraph(QWidget *parent)
|
|||
|
||||
src->setCollectionTimeLimit(10*60*1000) ; // 10 mins
|
||||
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||
src->setDigits(1) ;
|
||||
src->start() ;
|
||||
|
||||
addSource(src) ;
|
||||
|
||||
setTimeScale(2.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) ;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
|
||||
virtual void getValues(std::map<std::string,float>& vals) const ;
|
||||
virtual QString unitName() const ;
|
||||
virtual QString displayName(int i) const ;
|
||||
};
|
||||
|
||||
class RttStatisticsGraph: public RSGraphWidget
|
||||
|
|
|
@ -11,11 +11,47 @@ public:
|
|||
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)) ;
|
||||
values.insert(std::make_pair(std::string("Bytes in"),1024 * (float)totalRates.mRateIn)) ;
|
||||
values.insert(std::make_pair(std::string("Bytes out"),1024 * (float)totalRates.mRateOut)) ;
|
||||
|
||||
_total_sent += 1024 * totalRates.mRateOut * _update_period_msecs/1000.0f ;
|
||||
_total_recv += 1024 * totalRates.mRateIn * _update_period_msecs/1000.0f ;
|
||||
}
|
||||
|
||||
virtual QString unitName() const { return tr("KB/s"); }
|
||||
|
||||
virtual QString displayValue(float v) const
|
||||
{
|
||||
if(v < 1000)
|
||||
return QString::number(v,'f',2) + " B/s" ;
|
||||
else if(v < 1000*1024)
|
||||
return QString::number(v/1024.0,'f',2) + " KB/s" ;
|
||||
else
|
||||
return QString::number(v/(1024.0*1024),'f',2) + " MB/s" ;
|
||||
}
|
||||
|
||||
virtual QString legend(int i,float v) const
|
||||
{
|
||||
if(i==0)
|
||||
return RSGraphSource::legend(i,v) + " Total: " + niceNumber(_total_recv) ;
|
||||
else
|
||||
return RSGraphSource::legend(i,v) + " Total: " + niceNumber(_total_sent) ;
|
||||
}
|
||||
private:
|
||||
QString niceNumber(float v) const
|
||||
{
|
||||
if(v < 1000)
|
||||
return QString::number(v,'f',2) + " B" ;
|
||||
else if(v < 1000*1024)
|
||||
return QString::number(v/1024.0,'f',2) + " KB" ;
|
||||
else if(v < 1000*1024*1024)
|
||||
return QString::number(v/(1024*1024.0),'f',2) + " MB" ;
|
||||
else
|
||||
return QString::number(v/(1024*1024.0*1024),'f',2) + " GB";
|
||||
}
|
||||
|
||||
mutable float _total_sent ;
|
||||
mutable float _total_recv ;
|
||||
};
|
||||
|
||||
class BWGraph: public RSGraphWidget
|
||||
|
@ -27,13 +63,13 @@ class BWGraph: public RSGraphWidget
|
|||
BWGraphSource *src = new BWGraphSource() ;
|
||||
|
||||
src->setCollectionTimeLimit(30*60*1000) ; // 30 mins
|
||||
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||
src->setDigits(2) ;
|
||||
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) ;
|
||||
|
|
|
@ -33,10 +33,6 @@
|
|||
class DHTGraphSource: public RSGraphSource
|
||||
{
|
||||
public:
|
||||
virtual int n_values() const
|
||||
{
|
||||
return 1 ;
|
||||
}
|
||||
virtual void getValues(std::map<std::string,float>& values) const
|
||||
{
|
||||
RsConfigNetStatus config;
|
||||
|
@ -67,13 +63,13 @@ class DhtGraph : public RSGraphWidget
|
|||
DHTGraphSource *src = new DHTGraphSource() ;
|
||||
|
||||
src->setCollectionTimeLimit(30*60*1000) ; // 30 mins
|
||||
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||
src->setDigits(0) ;
|
||||
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) ;
|
||||
|
|
|
@ -38,17 +38,18 @@ class TurtleGraph: public RSGraphWidget
|
|||
TurtleGraphSource *src = new TurtleGraphSource() ;
|
||||
|
||||
src->setCollectionTimeLimit(30*60*1000) ; // 30 mins
|
||||
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||
src->setCollectionTimePeriod(1000) ; // collect every second
|
||||
src->setDigits(2) ;
|
||||
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) ;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue