sync repo
[mardrone] / mardrone / gauges / gauge.cpp
1 #include "gauge.h"
2 #include "qgraphicswidget.h"
3 #include "QGraphicsItem"
4 #include <QPainter>
5 #include <QDebug>
6
7 Gauge::Gauge(QGraphicsItem *parent) :
8     QGraphicsWidget(parent)
9 {
10     m_textSize=20;
11     m_tickMinor=0;
12     m_scale=1.0;
13     m_tickLength=10;
14     m_highPosition=0;
15     m_lowPosition=180;
16     m_lineWidth=1;
17     m_backColor=QColor("black");
18     m_needleImage=NULL;
19 }
20 #if 1
21 void Gauge::paint(QPainter *painter,
22                            const QStyleOptionGraphicsItem *option,
23                            QWidget *widget)
24  {
25 //     qDebug() << "Gauge::paint";
26      painter->setBrush(Qt::blue);
27      painter->drawRoundedRect(QRectF(0.0,0.0, size().width(),size().height()), 5,5);
28  }
29 #endif
30 void Gauge::setValue(float val_)
31 {
32     m_value=val_;
33     update(boundingRect()); // Value updated, schedule redtaw
34 };
35
36 void Gauge::propChanged()
37 {
38     update(boundingRect()); // Value updated, schedule redtaw
39 }
40
41
42 bool Gauge::testOption(QString a){
43     return m_options.contains(a);
44
45 };
46 float Gauge::value()
47 {
48     return m_value;
49 };
50 void Gauge::setValue2(float val_)
51 {
52     m_value2=val_;
53     update(boundingRect()); // Value updated, schedule redtaw
54 };
55 float Gauge::value2()
56 {
57     return m_value2;
58 };
59
60
61 QRectF Gauge::boundingRect() const
62     {
63 //        qDebug() << "GaugeBand::boundingRect()" << size().width() << size().height();
64         return QRectF(0.0,0.0,size().width(),size().height());
65     }