Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 KeyOz 1
#include <qpainter.h>
2
#include <qwt_dial_needle.h>
3
#include "cSpeedMeter.h"
4
 
5
cSpeedMeter::cSpeedMeter(QWidget *parent): QwtDial(parent), d_label("m/s")
6
{
7
    setWrapping(false);
8
    setReadOnly(true);
9
 
10
    setOrigin(125.0);
11
    setScaleArc(0.0, 270.0);
12
    scaleDraw()->setSpacing(8);
13
 
14
    QwtDialSimpleNeedle *needle = new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130));
15
    setNeedle(needle);
16
 
17
    setScaleOptions(ScaleTicks | ScaleLabel);
18
    setScaleTicks(0, 4, 8);
19
}
20
 
21
void cSpeedMeter::setLabel(const QString &label)
22
{
23
    d_label = label;
24
    update();
25
}
26
 
27
QString cSpeedMeter::label() const
28
{
29
    return d_label;
30
}
31
 
32
void cSpeedMeter::drawScaleContents(QPainter *painter, const QPoint &center, int radius) const
33
{
34
    QRect rect(0, 0, 2 * radius, 2 * radius - 10);
35
    rect.moveCenter(center);
36
 
37
    const QColor color =
38
 
39
    palette().color(QPalette::Text);
40
    painter->setPen(color);
41
 
42
    const int flags = Qt::AlignBottom | Qt::AlignHCenter;
43
    painter->drawText(rect, flags, d_label);
44
}