Initial import of version 0.3
[gpsdata] / src / compass.h
1 /*
2  *  GPSData for Maemo.
3  *  Copyright (C) 2011 Roman Moravcik
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef COMPASS_H
21 #define COMPASS_H
22
23 #ifdef QT_NO_OPENGL
24 #include <QWidget>
25 #else
26 #include <QGLWidget>
27 #endif
28 #include <QTimer>
29
30 #ifdef QT_NO_OPENGL
31 class Compass : public QWidget
32 #else
33 class Compass : public QGLWidget
34 #endif
35 {
36   Q_OBJECT
37
38 public:
39     enum CompassType
40     {
41         Gps = 0,
42         Sensor = 1
43     };
44
45     Compass(CompassType type);
46     ~Compass();
47
48     void updateWidget(const int azimuth, double calibration);
49     void updateWidget(const int azimuth, bool locked, int speed);
50
51 private slots:
52     void moveTimerEvent();
53
54 private:
55     CompassType m_type;
56     int m_azimuth;
57     int m_compassAzimuth;
58     bool m_locked;
59     int m_gpsSpeed;
60     double m_sensorCalibLevel;
61
62     QColor m_azimuthLabelWarnColor;
63     QColor m_scaleColor;
64     QColor m_windroseNorthColor;
65     QColor m_windroseColor;
66     QColor m_windroseBckColor;
67
68     void paintAzimuth(QPainter &painter, const QRectF &area);
69     void paintCompass(QPainter &painter, const QRectF &area);
70
71     QTimer *m_rotateTimer;
72
73 protected:
74     void paintEvent(QPaintEvent *event);
75 };
76
77 #endif // GCOMPASS_H