OP-1900 have path_progress updated correctly for leg_remaining and error_below end...
[librepilot.git] / ground / openpilotgcs / src / plugins / dial / dialgadgetwidget.h
blob4bfddd747e1a6e5fc0c98c8972472a85b23d68d6
1 /**
2 ******************************************************************************
4 * @file dialgadgetwidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @see The GNU Public License (GPL) Version 3
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup DialPlugin Dial Plugin
10 * @{
11 * @brief Plots flight information rotary style dials
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef DIALGADGETWIDGET_H_
30 #define DIALGADGETWIDGET_H_
32 #include "dialgadgetconfiguration.h"
33 #include "extensionsystem/pluginmanager.h"
34 #include "uavobjectmanager.h"
35 #include "uavobject.h"
36 #include <QGraphicsView>
37 #include <QtSvg/QSvgRenderer>
38 #include <QtSvg/QGraphicsSvgItem>
40 #include <QFile>
41 #include <QTimer>
43 class DialGadgetWidget : public QGraphicsView {
44 Q_OBJECT
46 public:
47 DialGadgetWidget(QWidget *parent = 0);
48 ~DialGadgetWidget();
49 void enableOpenGL(bool flag);
50 void enableSmoothUpdates(bool flag)
52 beSmooth = flag;
54 void setDialFile(QString dfn, QString bg, QString fg, QString n1, QString n2, QString n3,
55 QString n1Move, QString n2Move, QString n3Move);
56 void paint();
57 // setNeedle1 and setNeedle2 use a timer to simulate
58 // needle inertia
59 void setNeedle1(double value);
60 void setNeedle2(double value);
61 void setNeedle3(double value);
62 void setN1Min(double value)
64 n1MinValue = value;
66 void setN1Max(double value)
68 n1MaxValue = value;
70 void setN1Factor(double value)
72 n1Factor = value;
74 void setN2Min(double value)
76 n2MinValue = value;
78 void setN2Max(double value)
80 n2MaxValue = value;
82 void setN2Factor(double value)
84 n2Factor = value;
86 void setN3Min(double value)
88 n3MinValue = value;
90 void setN3Max(double value)
92 n3MaxValue = value;
94 void setN3Factor(double value)
96 n3Factor = value;
98 // Sets up needle/UAVObject connections:
99 void connectNeedles(QString object1, QString field1,
100 QString object2, QString field2,
101 QString object3, QString field3);
102 void setDialFont(QString fontProps);
104 public slots:
105 void updateNeedle1(UAVObject *object1); // Called by the UAVObject
106 void updateNeedle2(UAVObject *object2); // Called by the UAVObject
107 void updateNeedle3(UAVObject *object3); // Called by the UAVObject
109 protected:
110 void paintEvent(QPaintEvent *event);
111 void resizeEvent(QResizeEvent *event);
114 private slots:
115 void rotateNeedles();
117 private:
118 QSvgRenderer *m_renderer;
119 QGraphicsSvgItem *m_background;
120 QGraphicsSvgItem *m_foreground;
121 QGraphicsSvgItem *m_needle1;
122 QGraphicsSvgItem *m_needle2;
123 QGraphicsSvgItem *m_needle3;
124 QGraphicsTextItem *m_text1;
125 QGraphicsTextItem *m_text2;
126 QGraphicsTextItem *m_text3;
128 bool n3enabled;
129 bool n2enabled; // Simple flag to skip rendering if the
130 bool fgenabled; // layer does not exist.
131 bool dialError;
133 // Settings concerning move of the dials
134 bool rotateN1;
135 bool rotateN2;
136 bool rotateN3;
137 bool horizN1;
138 bool horizN2;
139 bool horizN3;
140 bool vertN1;
141 bool vertN2;
142 bool vertN3;
144 double n1MinValue;
145 double n1MaxValue;
146 double n1Factor;
147 double n2MinValue;
148 double n2MaxValue;
149 double n2Factor;
150 double n3MinValue;
151 double n3MaxValue;
152 double n3Factor;
154 // The Value and target variables
155 // are expressed in degrees
156 double needle1Target;
157 double needle1Value;
158 double needle2Target;
159 double needle2Value;
160 double needle3Target;
161 double needle3Value;
163 // Name of the fields to read when an update is received:
164 UAVDataObject *obj1;
165 UAVDataObject *obj2;
166 UAVDataObject *obj3;
167 QString field1;
168 QString subfield1;
169 bool haveSubField1;
170 QString field2;
171 QString subfield2;
172 bool haveSubField2;
173 QString field3;
174 QString subfield3;
175 bool haveSubField3;
177 // Rotation timer
178 QTimer dialTimer;
180 bool beSmooth;
182 #endif /* DIALGADGETWIDGET_H_ */