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
9 * @addtogroup DialPlugin Dial Plugin
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
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>
43 class DialGadgetWidget
: public QGraphicsView
{
47 DialGadgetWidget(QWidget
*parent
= 0);
49 void enableOpenGL(bool flag
);
50 void enableSmoothUpdates(bool flag
)
54 void setDialFile(QString dfn
, QString bg
, QString fg
, QString n1
, QString n2
, QString n3
,
55 QString n1Move
, QString n2Move
, QString n3Move
);
57 // setNeedle1 and setNeedle2 use a timer to simulate
59 void setNeedle1(double value
);
60 void setNeedle2(double value
);
61 void setNeedle3(double value
);
62 void setN1Min(double value
)
66 void setN1Max(double value
)
70 void setN1Factor(double value
)
74 void setN2Min(double value
)
78 void setN2Max(double value
)
82 void setN2Factor(double value
)
86 void setN3Min(double value
)
90 void setN3Max(double value
)
94 void setN3Factor(double 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
);
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
110 void paintEvent(QPaintEvent
*event
);
111 void resizeEvent(QResizeEvent
*event
);
115 void rotateNeedles();
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
;
129 bool n2enabled
; // Simple flag to skip rendering if the
130 bool fgenabled
; // layer does not exist.
133 // Settings concerning move of the dials
154 // The Value and target variables
155 // are expressed in degrees
156 double needle1Target
;
158 double needle2Target
;
160 double needle3Target
;
163 // Name of the fields to read when an update is received:
182 #endif /* DIALGADGETWIDGET_H_ */