mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
only show relevant entries in statistics graphs
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8254 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
819c7b66c5
commit
0e16733ce0
@ -105,12 +105,13 @@ QString RSGraphSource::displayValue(float v) const
|
||||
return QString::number(v,'f',_digits) + " " + unitName() ;
|
||||
}
|
||||
|
||||
void RSGraphSource::getCurrentValues(std::vector<float>& vals) const
|
||||
void RSGraphSource::getCurrentValues(std::vector<QPointF>& vals) const
|
||||
{
|
||||
std::map<std::string,std::list<std::pair<qint64,float> > >::const_iterator it = _points.begin();
|
||||
qint64 now = getTime() ;
|
||||
|
||||
for(it = _points.begin();it!=_points.end();++it)
|
||||
vals.push_back(it->second.back().second) ;
|
||||
vals.push_back(QPointF( (now - it->second.back().first)/1000.0f,it->second.back().second)) ;
|
||||
}
|
||||
|
||||
QString RSGraphSource::legend(int i,float v) const
|
||||
@ -565,23 +566,29 @@ void RSGraphWidget::paintLegend()
|
||||
{
|
||||
int bottom = _rec.height();
|
||||
|
||||
std::vector<float> vals ;
|
||||
std::vector<QPointF> vals ;
|
||||
_source->getCurrentValues(vals) ;
|
||||
int j=0;
|
||||
|
||||
for(uint i=0;i<vals.size();++i)
|
||||
if( _masked_entries.find(_source->displayName(i).toStdString()) == _masked_entries.end() )
|
||||
{
|
||||
qreal paintStep = 4+FONT_SIZE;
|
||||
qreal pos = 20+i*paintStep;
|
||||
QString text = _source->legend(i,vals[i]) ;
|
||||
{
|
||||
if( _rec.width() - (vals[i].x()-0)*_time_scale < SCALE_WIDTH )
|
||||
continue ;
|
||||
|
||||
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);
|
||||
qreal paintStep = 4+FONT_SIZE;
|
||||
qreal pos = 20+j*paintStep;
|
||||
QString text = _source->legend(i,vals[i].y()) ;
|
||||
|
||||
_painter->setPen(SCALE_COLOR);
|
||||
_painter->drawText(QPointF(SCALE_WIDTH + 40,pos + 0.5*FONT_SIZE), text) ;
|
||||
}
|
||||
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) ;
|
||||
|
||||
++j ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
virtual QString displayValue(float v) const ;
|
||||
|
||||
// return the vector of last values up to date
|
||||
virtual void getCurrentValues(std::vector<float>& vals) const ;
|
||||
virtual void getCurrentValues(std::vector<QPointF>& vals) const ;
|
||||
|
||||
// returns what to display in the legend. Derive this to show additional info.
|
||||
virtual QString legend(int i,float v) const ;
|
||||
|
Loading…
Reference in New Issue
Block a user