void VoipStatisticsWidget::updateVoipStatistics(const std::map<std::string, std::list<RsVoipPongResult> >& info, double maxRTT, double minTS, double maxTS) { //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 ; double refTS = time(NULL); //painter.setPen(QColor::fromRgb(70,70,70)) ; //painter.drawLine(0,oy,maxWidth,oy) ; //oy += celly ; //painter.setPen(QColor::fromRgb(0,0,0)) ; // round up RTT to nearest double roundedRTT = maxRTT; if (maxRTT < 0.15) { roundedRTT = 0.2; } else if (maxRTT < 0.4) { roundedRTT = 0.5; } else if (maxRTT < 0.8) { roundedRTT = 1.0; } else if (maxRTT < 1.8) { roundedRTT = 2.0; } else if (maxRTT < 4.5) { roundedRTT = 5.0; } VoipLagPlot(info, refTS, roundedRTT, minTS, maxTS).draw(&painter,ox,oy,QObject::tr("Round Trip Time:")) ; // update the pixmap pixmap = tmppixmap; maxHeight = oy; // + PLOT_HEIGHT * 2; }
void ctkExampleDicomAppLogic::onCreateSecondaryCapture() { const QPixmap* pixmap = ui.PlaceHolderForImage->pixmap(); if(pixmap!=NULL) { QStringList preferredProtocols; preferredProtocols.append("file:"); QString outputlocation = getHostInterface()->getOutputLocation(preferredProtocols); QString templatefilename = QDir(outputlocation).absolutePath(); if(templatefilename.isEmpty()==false) templatefilename.append('/'); templatefilename.append("ctkdahscXXXXXX.jpg"); QTemporaryFile *tempfile = new QTemporaryFile(templatefilename,this->AppWidget); if(tempfile->open()) { QString filename = QFileInfo(tempfile->fileName()).absoluteFilePath(); qDebug() << "Created file: " << filename; tempfile->close(); QPixmap tmppixmap(*pixmap); QPainter painter(&tmppixmap); painter.setPen(Qt::white); painter.setFont(QFont("Arial", 15)); painter.drawText(tmppixmap.rect(),Qt::AlignBottom|Qt::AlignLeft,"Secondary capture by ctkExampleDicomApp"); //painter.drawText(rect(), Qt::AlignCenter, "Qt"); tmppixmap.save(tempfile->fileName(), "JPEG"); qDebug() << "Created Uuid: " << getHostInterface()->generateUID(); ctkDicomAppHosting::AvailableData resultData; ctkDicomAvailableDataHelper::addToAvailableData(resultData, objectLocatorCache(), tempfile->fileName()); bool success = publishData(resultData, true); if(!success) { qCritical() << "Failed to publish data"; } qDebug() << " publishData returned: " << success; } else qDebug() << "Creating temporary file failed."; } }
void OutQueueStatisticsWidget::updateStatistics(OutQueueStatistics& stats) { static const int cellx = 6 ; static const int celly = 10+4 ; QPixmap tmppixmap(maxWidth, maxHeight); tmppixmap.fill(Qt::transparent); 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 ; painter.setPen(QColor::fromRgb(70,70,70)) ; //painter.drawLine(0,oy,maxWidth,oy) ; //oy += celly ; QString by_priority_string,by_service_string ; for(int i=1;i<stats.per_priority_item_count.size();++i) by_priority_string += QString::number(stats.per_priority_item_count[i]) + " (" + QString::number(i) + ") " ; for(std::map<uint16_t,uint32_t>::const_iterator it(stats.per_service_item_count.begin());it!=stats.per_service_item_count.end();++it) by_service_string += QString::number(it->second) + " (" + serviceName(it->first) + ") " ; painter.drawText(ox,oy+celly,tr("Outqueue statistics")+":") ; oy += celly*2 ; painter.drawText(ox+2*cellx,oy+celly,tr("By priority: ") + by_priority_string); oy += celly ; painter.drawText(ox+2*cellx,oy+celly,tr("By service : ") + by_service_string); oy += celly ; oy += celly ; // update the pixmap // pixmap = tmppixmap; maxHeight = oy ; }
void GlobalRouterStatisticsWidget::updateContent() { RsGRouter::GRouterRoutingMatrixInfo matrix_info ; rsGRouter->getRoutingMatrixInfo(matrix_info) ; float size = QFontMetricsF(font()).height() ; float fact = size/14.0 ; // What do we need to draw? // // Routing matrix // Key [][][][][][][][][][] // // -> each [] shows a square (one per friend node) that is the routing probabilities for all connected friends // computed using the "computeRoutingProbabilitites()" method. // // Own key ids // key service id description // // Data items // Msg id Local origin Destination Time Status // QPixmap tmppixmap(maxWidth, maxHeight); tmppixmap.fill(Qt::transparent); setFixedHeight(maxHeight); QPainter painter(&tmppixmap); painter.initFrom(this); painter.setPen(QColor::fromRgb(0,0,0)) ; QFont times_f(font());//"Times") ; QFont monospace_f("Monospace") ; monospace_f.setStyleHint(QFont::TypeWriter) ; monospace_f.setPointSize(font().pointSize()) ; QFontMetricsF fm_monospace(monospace_f) ; QFontMetricsF fm_times(times_f) ; static const int cellx = fm_monospace.width(QString(" ")) ; static const int celly = fm_monospace.height() ; maxHeight = 500*fact ; // std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; // draw... int ox=5*fact,oy=5*fact ; painter.setFont(times_f) ; painter.drawText(ox,oy+celly,tr("Managed keys")+":" + QString::number(matrix_info.published_keys.size())) ; oy += celly*2 ; painter.setFont(monospace_f) ; for(std::map<Sha1CheckSum,RsGRouter::GRouterPublishedKeyInfo>::const_iterator it(matrix_info.published_keys.begin());it!=matrix_info.published_keys.end();++it) { QString packet_string ; packet_string += QString::fromStdString(it->second.authentication_key.toStdString()) ; packet_string += tr(" : Service ID =")+" "+QString::number(it->second.service_id,16) ; packet_string += " \""+QString::fromUtf8(it->second.description_string.c_str()) + "\"" ; painter.drawText(ox+2*cellx,oy+celly,packet_string ) ; oy += celly ; } oy += celly ; std::map<QString, std::vector<QString> > tos ; // Now draw the matrix QString prob_string ; painter.setFont(times_f) ; QString Q = tr("Routing matrix (") ; painter.drawText(ox+0*cellx,oy+fm_times.height(),Q) ; // draw scale for(int i=0;i<100*fact;++i) { painter.setPen(colorScale(i/100.0/fact)) ; painter.drawLine(ox+fm_times.width(Q)+i,oy+fm_times.height()*0.5,ox+fm_times.width(Q)+i,oy+fm_times.height()) ; } painter.setPen(QColor::fromRgb(0,0,0)) ; painter.drawText(ox+fm_times.width(Q) + 102*fact,oy+celly,")") ; oy += celly ; oy += celly ; //print friends in the same order their prob is shown QString FO = tr("Friend Order ("); RsPeerDetails peer_ssl_details; for(uint32_t i=0;i<matrix_info.friend_ids.size();++i){ rsPeers->getPeerDetails(matrix_info.friend_ids[i], peer_ssl_details); QString fn = QString::fromUtf8(peer_ssl_details.name.c_str()); FO+=fn; FO+=" "; } FO+=")"; painter.drawText(ox+0*cellx,oy+fm_times.height(),FO) ; oy += celly ; oy += celly ; static const int MaxKeySize = 20*fact ; painter.setFont(monospace_f) ; for(std::map<GRouterKeyId,std::vector<float> >::const_iterator it(matrix_info.per_friend_probabilities.begin());it!=matrix_info.per_friend_probabilities.end();++it) { bool is_null = true ; for(uint32_t i=0;i<matrix_info.friend_ids.size();++i) if(it->second[i] > 0.0) is_null = false ; if(!is_null) { QString ids = QString::fromStdString(it->first.toStdString())+" : " ; painter.drawText(ox+2*cellx,oy+celly,ids) ; for(uint32_t i=0;i<matrix_info.friend_ids.size();++i) painter.fillRect(ox+i*cellx+fm_monospace.width(ids),oy,cellx,celly,colorScale(it->second[i])) ; oy += celly ; } } 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, 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 ; }