void TurtleRouterStatisticsWidget::updateTunnelStatistics(const std::vector<std::vector<std::string> >& /*hashes_info*/, const std::vector<std::vector<std::string> >& /*tunnels_info*/, const std::vector<TurtleRequestDisplayInfo >& search_reqs_info, const std::vector<TurtleRequestDisplayInfo >& tunnel_reqs_info, const RsTurtle *turtle) { static const int cellx = 6 ; static const int celly = 10+4 ; QPixmap tmppixmap(maxWidth, maxHeight); tmppixmap.fill(this, 0, 0); setFixedHeight(maxHeight); QPainter painter(&tmppixmap); painter.initFrom(this); maxHeight = 500 ; // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; // 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 ; turtle->getTrafficStatistics(info) ; painter.setPen(QColor::fromRgb(70,70,70)) ; painter.drawLine(0,oy,maxWidth,oy) ; oy += celly ; painter.drawText(ox,oy+celly,tr("Turtle router traffic")+":") ; oy += celly*2 ; 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 ; QString prob_string ; for(uint i=0;i<info.forward_probabilities.size();++i) prob_string += QString::number(info.forward_probabilities[i],'g',2) + " (" + QString::number(i) + ") " ; painter.drawText(ox+2*cellx,oy+celly,tr("TR Forward probabilities")+"\t: " + prob_string ) ; oy += celly ; oy += celly ; // update the pixmap // pixmap = tmppixmap; maxHeight = oy ; }
void TurtleRouterStatisticsWidget::updateTunnelStatistics(const std::vector<std::vector<std::string> >& /*hashes_info*/, const std::vector<std::vector<std::string> >& /*tunnels_info*/, const std::vector<TurtleRequestDisplayInfo >& search_reqs_info, const std::vector<TurtleRequestDisplayInfo >& tunnel_reqs_info) { QPixmap tmppixmap(maxWidth, maxHeight); tmppixmap.fill(Qt::transparent); setFixedHeight(maxHeight); QPainter painter(&tmppixmap); painter.initFrom(this); // extracts the height of the fonts in pixels. This is used to callibrate the size of the objects to draw. float fontHeight = QFontMetricsF(font()).height(); float fact = fontHeight/14.0; maxHeight = 500*fact ; int cellx = 6*fact ; int celly = (10+4)*fact ; // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; // draw... int ox=5*fact,oy=5*fact ; TRHistogram(search_reqs_info).draw(&painter,ox,oy,tr("Search requests repartition") + ":",fontHeight) ; 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") + ":",fontHeight) ; // 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("Turtle router traffic")+":") ; oy += celly*2 ; 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("Tunnel requests Up")+"\t: " + speedString(info.tr_up_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 ; QString prob_string ; for(uint i=0;i<info.forward_probabilities.size();++i) prob_string += QString::number(info.forward_probabilities[i],'g',2) + " (" + QString::number(i) + ") " ; painter.drawText(ox+2*cellx,oy+celly,tr("TR Forward probabilities")+"\t: " + prob_string ) ; oy += celly ; oy += celly ; // update the pixmap // pixmap = tmppixmap; maxHeight = oy ; }