mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
small fixes in global router gui
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7213 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fd16899fde
commit
25a3178ca4
@ -43,149 +43,6 @@ static QColor colorScale(float f)
|
||||
return QColor::fromHsv((int)((1.0-f)*280),200,255) ;
|
||||
}
|
||||
|
||||
|
||||
// class TRHistogram
|
||||
// {
|
||||
// public:
|
||||
// TRHistogram(const std::vector<TurtleRequestDisplayInfo >& info) :_infos(info) {}
|
||||
//
|
||||
// QColor colorScale(float f)
|
||||
// {
|
||||
// if(f == 0)
|
||||
// return QColor::fromHsv(0,0,192) ;
|
||||
// else
|
||||
// return QColor::fromHsv((int)((1.0-f)*280),200,255) ;
|
||||
// }
|
||||
//
|
||||
// virtual void draw(QPainter *painter,int& ox,int& oy,const QString& title)
|
||||
// {
|
||||
// static const int MaxTime = 61 ;
|
||||
// static const int MaxDepth = 8 ;
|
||||
// static const int cellx = 7 ;
|
||||
// static const int celly = 12 ;
|
||||
//
|
||||
// int save_ox = ox ;
|
||||
// painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
// painter->drawText(2+ox,celly+oy,title) ;
|
||||
// oy+=2+2*celly ;
|
||||
//
|
||||
// if(_infos.empty())
|
||||
// return ;
|
||||
//
|
||||
// ox += 10 ;
|
||||
// std::map<RsPeerId,std::vector<int> > hits ;
|
||||
// std::map<RsPeerId,std::vector<int> > depths ;
|
||||
// std::map<RsPeerId,std::vector<int> >::iterator it ;
|
||||
//
|
||||
// int max_hits = 1;
|
||||
// int max_depth = 1;
|
||||
//
|
||||
// for(uint32_t i=0;i<_infos.size();++i)
|
||||
// {
|
||||
// std::vector<int>& h(hits[_infos[i].source_peer_id]) ;
|
||||
// std::vector<int>& g(depths[_infos[i].source_peer_id]) ;
|
||||
//
|
||||
// if(h.size() <= _infos[i].age)
|
||||
// h.resize(MaxTime,0) ;
|
||||
//
|
||||
// if(g.empty())
|
||||
// g.resize(MaxDepth,0) ;
|
||||
//
|
||||
// if(_infos[i].age < h.size())
|
||||
// {
|
||||
// h[_infos[i].age]++ ;
|
||||
// if(h[_infos[i].age] > max_hits)
|
||||
// max_hits = h[_infos[i].age] ;
|
||||
// }
|
||||
// if(_infos[i].depth < g.size())
|
||||
// {
|
||||
// g[_infos[i].depth]++ ;
|
||||
//
|
||||
// if(g[_infos[i].depth] > max_depth)
|
||||
// max_depth = g[_infos[i].depth] ;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// int max_bi = std::max(max_hits,max_depth) ;
|
||||
// int p=0 ;
|
||||
//
|
||||
// for(it=depths.begin();it!=depths.end();++it,++p)
|
||||
// for(int i=0;i<MaxDepth;++i)
|
||||
// painter->fillRect(ox+MaxTime*cellx+20+i*cellx,oy+p*celly,cellx,celly,colorScale(it->second[i]/(float)max_bi)) ;
|
||||
//
|
||||
// painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
// painter->drawRect(ox+MaxTime*cellx+20,oy,MaxDepth*cellx,p*celly) ;
|
||||
//
|
||||
// for(int i=0;i<MaxTime;i+=5)
|
||||
// painter->drawText(ox+i*cellx,oy+(p+1)*celly+4,QString::number(i)) ;
|
||||
//
|
||||
// p=0 ;
|
||||
// int great_total = 0 ;
|
||||
//
|
||||
// for(it=hits.begin();it!=hits.end();++it,++p)
|
||||
// {
|
||||
// int total = 0 ;
|
||||
//
|
||||
// for(int i=0;i<MaxTime;++i)
|
||||
// {
|
||||
// painter->fillRect(ox+i*cellx,oy+p*celly,cellx,celly,colorScale(it->second[i]/(float)max_bi)) ;
|
||||
// total += it->second[i] ;
|
||||
// }
|
||||
//
|
||||
// painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
// painter->drawText(ox+MaxDepth*cellx+30+(MaxTime+1)*cellx,oy+(p+1)*celly,TurtleRouterStatistics::getPeerName(it->first)) ;
|
||||
// painter->drawText(ox+MaxDepth*cellx+30+(MaxTime+1)*cellx+120,oy+(p+1)*celly,"("+QString::number(total)+")") ;
|
||||
// great_total += total ;
|
||||
// }
|
||||
//
|
||||
// painter->drawRect(ox,oy,MaxTime*cellx,p*celly) ;
|
||||
//
|
||||
// for(int i=0;i<MaxTime;i+=5)
|
||||
// painter->drawText(ox+i*cellx,oy+(p+1)*celly+4,QString::number(i)) ;
|
||||
// for(int i=0;i<MaxDepth;i++)
|
||||
// painter->drawText(ox+MaxTime*cellx+20+i*cellx,oy+(p+1)*celly+4,QString::number(i)) ;
|
||||
// painter->setPen(QColor::fromRgb(255,130,80)) ;
|
||||
// painter->drawText(ox+MaxDepth*cellx+30+(MaxTime+1)*cellx+120,oy+(p+1)*celly+4,"("+QString::number(great_total)+")");
|
||||
//
|
||||
// oy += (p+1)*celly+6 ;
|
||||
//
|
||||
// painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
// painter->drawText(ox,oy+celly,"("+QApplication::translate("TurtleRouterStatistics", "Age in seconds")+")");
|
||||
// painter->drawText(ox+MaxTime*cellx+20,oy+celly,"("+QApplication::translate("TurtleRouterStatistics", "Depth")+")");
|
||||
//
|
||||
// painter->drawText(ox+MaxDepth*cellx+30+(MaxTime+1)*cellx+120,oy+celly,"("+QApplication::translate("TurtleRouterStatistics", "total")+")");
|
||||
//
|
||||
// oy += 3*celly ;
|
||||
//
|
||||
// // now, draw a scale
|
||||
//
|
||||
// int last_hts = -1 ;
|
||||
// int cellid = 0 ;
|
||||
//
|
||||
// for(int i=0;i<=10;++i)
|
||||
// {
|
||||
// int hts = (int)(max_bi*i/10.0) ;
|
||||
//
|
||||
// if(hts > last_hts)
|
||||
// {
|
||||
// painter->fillRect(ox+cellid*(cellx+22),oy,cellx,celly,colorScale(i/10.0f)) ;
|
||||
// painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
// painter->drawRect(ox+cellid*(cellx+22),oy,cellx,celly) ;
|
||||
// painter->drawText(ox+cellid*(cellx+22)+cellx+4,oy+celly,QString::number(hts)) ;
|
||||
// last_hts = hts ;
|
||||
// ++cellid ;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// oy += celly*2 ;
|
||||
//
|
||||
// ox = save_ox ;
|
||||
// }
|
||||
//
|
||||
// private:
|
||||
// const std::vector<TurtleRequestDisplayInfo>& _infos ;
|
||||
// };
|
||||
|
||||
GlobalRouterStatistics::GlobalRouterStatistics(QWidget *parent)
|
||||
: RsAutoUpdatePage(2000,parent)
|
||||
{
|
||||
@ -195,13 +52,6 @@ GlobalRouterStatistics::GlobalRouterStatistics(QWidget *parent)
|
||||
|
||||
_router_F->setWidget( _tst_CW = new GlobalRouterStatisticsWidget() ) ;
|
||||
|
||||
//_tunnel_statistics_F->setWidgetResizable(true);
|
||||
//_tunnel_statistics_F->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
//_tunnel_statistics_F->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
//_tunnel_statistics_F->viewport()->setBackgroundRole(QPalette::NoRole);
|
||||
//_tunnel_statistics_F->setFrameStyle(QFrame::NoFrame);
|
||||
//_tunnel_statistics_F->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
}
|
||||
@ -239,15 +89,7 @@ void GlobalRouterStatistics::processSettings(bool bLoad)
|
||||
|
||||
void GlobalRouterStatistics::updateDisplay()
|
||||
{
|
||||
std::vector<RsGRouter::GRouterRoutingCacheInfo> cache_infos ;
|
||||
RsGRouter::GRouterRoutingMatrixInfo matrix_info ;
|
||||
|
||||
rsGRouter->getRoutingCacheInfo(cache_infos) ;
|
||||
rsGRouter->getRoutingMatrixInfo(matrix_info) ;
|
||||
|
||||
//_tst_CW->updateTunnelStatistics(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;
|
||||
|
||||
_tst_CW->updateContent(cache_infos,matrix_info);
|
||||
_tst_CW->updateContent() ;
|
||||
}
|
||||
|
||||
QString GlobalRouterStatistics::getPeerName(const RsPeerId &peer_id)
|
||||
@ -275,9 +117,14 @@ GlobalRouterStatisticsWidget::GlobalRouterStatisticsWidget(QWidget *parent)
|
||||
maxHeight = 0 ;
|
||||
}
|
||||
|
||||
void GlobalRouterStatisticsWidget::updateContent(const std::vector<RsGRouter::GRouterRoutingCacheInfo>& cache_infos,
|
||||
const RsGRouter::GRouterRoutingMatrixInfo& matrix_info)
|
||||
void GlobalRouterStatisticsWidget::updateContent()
|
||||
{
|
||||
std::vector<RsGRouter::GRouterRoutingCacheInfo> cache_infos ;
|
||||
RsGRouter::GRouterRoutingMatrixInfo matrix_info ;
|
||||
|
||||
rsGRouter->getRoutingCacheInfo(cache_infos) ;
|
||||
rsGRouter->getRoutingMatrixInfo(matrix_info) ;
|
||||
|
||||
// What do we need to draw?
|
||||
//
|
||||
// Routing matrix
|
||||
@ -309,23 +156,6 @@ void GlobalRouterStatisticsWidget::updateContent(const std::vector<RsGRouter::GR
|
||||
// draw...
|
||||
int ox=5,oy=5 ;
|
||||
|
||||
// TRHistogram(search_reqs_info).draw(&painter,ox,oy,tr("Search requests repartition") + ":") ;
|
||||
//
|
||||
// painter.setPen(QColor::fromRgb(70,70,70)) ;
|
||||
// painter.drawLine(0,oy,maxWidth,oy) ;
|
||||
// oy += celly ;
|
||||
//
|
||||
// TRHistogram(tunnel_reqs_info).draw(&painter,ox,oy,tr("Tunnel requests repartition") + ":") ;
|
||||
//
|
||||
// // now give information about turtle traffic.
|
||||
// //
|
||||
// TurtleTrafficStatisticsInfo info ;
|
||||
// rsTurtle->getTrafficStatistics(info) ;
|
||||
//
|
||||
// painter.setPen(QColor::fromRgb(70,70,70)) ;
|
||||
// painter.drawLine(0,oy,maxWidth,oy) ;
|
||||
// oy += celly ;
|
||||
|
||||
painter.drawText(ox,oy+celly,tr("Pending packets")+":" + QString::number(cache_infos.size())) ; oy += celly*2 ;
|
||||
|
||||
for(uint32_t i=0;i<cache_infos.size();++i)
|
||||
@ -354,15 +184,6 @@ void GlobalRouterStatisticsWidget::updateContent(const std::vector<RsGRouter::GR
|
||||
}
|
||||
oy += celly ;
|
||||
|
||||
//painter.drawText(ox+2*cellx,oy+celly,tr("Tunnel requests Up")+"\t: " + speedString(info.tr_up_Bps) ) ; oy += celly ;
|
||||
//painter.drawText(ox+2*cellx,oy+celly,tr("Tunnel requests Dn")+"\t: " + speedString(info.tr_dn_Bps) ) ; oy += celly ;
|
||||
//painter.drawText(ox+2*cellx,oy+celly,tr("Incoming file data")+"\t: " + speedString(info.data_dn_Bps) ) ; oy += celly ;
|
||||
//painter.drawText(ox+2*cellx,oy+celly,tr("Outgoing file data")+"\t: " + speedString(info.data_up_Bps) ) ; oy += celly ;
|
||||
//painter.drawText(ox+2*cellx,oy+celly,tr("Forwarded data ")+"\t: " + speedString(info.unknown_updn_Bps) ) ; oy += celly ;
|
||||
|
||||
//for(uint i=0;i<info.forward_probabilities.size();++i)
|
||||
// prob_string += QString::number(info.forward_probabilities[i],'g',2) + " (" + QString::number(i) + ") " ;
|
||||
|
||||
QString prob_string ;
|
||||
|
||||
painter.drawText(ox+0*cellx,oy+celly,tr("Routing matrix (")) ;
|
||||
@ -424,6 +245,6 @@ void GlobalRouterStatisticsWidget::resizeEvent(QResizeEvent *event)
|
||||
maxHeight = TaskGraphRect.height() ;
|
||||
|
||||
QWidget::resizeEvent(event);
|
||||
update();
|
||||
updateContent();
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class GlobalRouterStatisticsWidget: public QWidget
|
||||
virtual void paintEvent(QPaintEvent *event) ;
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
|
||||
void updateContent(const std::vector<RsGRouter::GRouterRoutingCacheInfo>& cache_infos, const RsGRouter::GRouterRoutingMatrixInfo& matrix_info);
|
||||
void updateContent() ;
|
||||
private:
|
||||
static QString speedString(float f) ;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user