mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-25 17:21:05 -04:00
draw bottom legend after data curves in RSGraphWidget
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8255 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0e16733ce0
commit
fd992161e1
2 changed files with 21 additions and 13 deletions
|
@ -310,12 +310,15 @@ void RSGraphWidget::paintEvent(QPaintEvent *)
|
||||||
_painter->drawRect(_rec);
|
_painter->drawRect(_rec);
|
||||||
|
|
||||||
/* Paint the scale */
|
/* Paint the scale */
|
||||||
paintScale();
|
paintScale1();
|
||||||
/* Plot the rsDHT/allDHT data */
|
/* Plot the rsDHT/allDHT data */
|
||||||
paintData();
|
paintData();
|
||||||
/* Paint the rsDHT/allDHT totals */
|
/* Paint the rsDHT/allDHT totals */
|
||||||
paintTotals();
|
paintTotals();
|
||||||
|
|
||||||
|
// part of the scale that needs to write over the data curves.
|
||||||
|
paintScale2();
|
||||||
|
|
||||||
if(_flags & RSGRAPH_FLAGS_SHOW_LEGEND)
|
if(_flags & RSGRAPH_FLAGS_SHOW_LEGEND)
|
||||||
paintLegend() ;
|
paintLegend() ;
|
||||||
|
|
||||||
|
@ -504,7 +507,7 @@ QString RSGraphWidget::totalToStr(qreal total)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Paints the scale on the graph. */
|
/** Paints the scale on the graph. */
|
||||||
void RSGraphWidget::paintScale()
|
void RSGraphWidget::paintScale1()
|
||||||
{
|
{
|
||||||
int top = _rec.y();
|
int top = _rec.y();
|
||||||
int bottom = _rec.height();
|
int bottom = _rec.height();
|
||||||
|
@ -535,21 +538,25 @@ void RSGraphWidget::paintScale()
|
||||||
|
|
||||||
/* Draw vertical separator */
|
/* Draw vertical separator */
|
||||||
_painter->drawLine(SCALE_WIDTH, top, SCALE_WIDTH, bottom);
|
_painter->drawLine(SCALE_WIDTH, top, SCALE_WIDTH, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
// draw time below the graph
|
void RSGraphWidget::paintScale2()
|
||||||
|
{
|
||||||
|
// draw time below the graph
|
||||||
|
|
||||||
static const int npix = 100 ;
|
int bottom = _rec.height();
|
||||||
|
static const int npix = 100 ;
|
||||||
|
|
||||||
for(int i=_rec.width();i>SCALE_WIDTH;i-=npix)
|
for(int i=_rec.width();i>SCALE_WIDTH;i-=npix)
|
||||||
{
|
{
|
||||||
pos = bottom - FONT_SIZE;
|
qreal pos = bottom - FONT_SIZE;
|
||||||
|
|
||||||
int seconds = (_rec.width()-i)/_time_scale ; // pixels / (pixels per second) => seconds
|
int seconds = (_rec.width()-i)/_time_scale ; // pixels / (pixels per second) => seconds
|
||||||
QString text = QString::number(seconds)+ " secs";
|
QString text = QString::number(seconds)+ " secs";
|
||||||
|
|
||||||
_painter->setPen(SCALE_COLOR);
|
_painter->setPen(SCALE_COLOR);
|
||||||
_painter->drawText(QPointF(i, _rec.height()-0.5*FONT_SIZE), text);
|
_painter->drawText(QPointF(i, _rec.height()-0.5*FONT_SIZE), text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RSGraphWidget::wheelEvent(QWheelEvent *e)
|
void RSGraphWidget::wheelEvent(QWheelEvent *e)
|
||||||
|
|
|
@ -172,7 +172,8 @@ class RSGraphWidget: public QFrame
|
||||||
/** Paints the scale in the graph. */
|
/** Paints the scale in the graph. */
|
||||||
void paintLegend();
|
void paintLegend();
|
||||||
/** Paints the scale in the graph. */
|
/** Paints the scale in the graph. */
|
||||||
void paintScale();
|
void paintScale1();
|
||||||
|
void paintScale2();
|
||||||
|
|
||||||
QColor getColor(int i) ;
|
QColor getColor(int i) ;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue