2 ******************************************************************************
4 * @file lineardialgadgetwidget.h
5 * @author Edouard Lafargue Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
8 * @addtogroup LinearDialPlugin Linear Dial Plugin
10 * @brief Impliments a gadget that displays linear gauges
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef LINEARDIALGADGETWIDGET_H_
29 #define LINEARDIALGADGETWIDGET_H_
31 #include "lineardialgadgetconfiguration.h"
32 #include "extensionsystem/pluginmanager.h"
33 #include "uavobjectmanager.h"
34 #include "uavobject.h"
35 #include <QGraphicsView>
36 #include <QtSvg/QSvgRenderer>
37 #include <QtSvg/QGraphicsSvgItem>
42 class LineardialGadgetWidget
: public QGraphicsView
{
46 LineardialGadgetWidget(QWidget
*parent
= 0);
47 ~LineardialGadgetWidget();
48 void enableOpenGL(bool flag
);
49 void setDialFile(QString dfn
);
51 void setRange(double min
, double max
)
53 minValue
= min
; maxValue
= max
;
55 void setGreenRange(double min
, double max
)
57 greenMin
= min
; greenMax
= max
;
59 void setYellowRange(double min
, double max
)
61 yellowMin
= min
; yellowMax
= max
;
63 void setRedRange(double min
, double max
)
65 redMin
= min
; redMax
= max
;
67 void connectInput(QString obj
, QString field
);
68 void setIndex(double val
);
69 void setDialFont(QString fontProps
);
70 void setFactor(double val
)
74 void setDecimalPlaces(int val
)
80 void updateIndex(UAVObject
*object1
);
84 void paintEvent(QPaintEvent
*event
);
85 void resizeEvent(QResizeEvent
*event
);
93 QSvgRenderer
*m_renderer
;
94 QGraphicsSvgItem
*background
;
95 QGraphicsSvgItem
*foreground
;
96 QGraphicsSvgItem
*index
;
97 QGraphicsSvgItem
*green
;
98 QGraphicsSvgItem
*yellow
;
99 QGraphicsSvgItem
*red
;
100 QGraphicsSvgItem
*fieldSymbol
;
102 QGraphicsTextItem
*fieldName
;
103 QGraphicsTextItem
*fieldValue
;
105 // Simple flag to skip rendering if the
106 bool fgenabled
; // layer does not exist.
107 bool verticalDial
; // True if the dials scales vertically.
109 qreal startX
; // Where we should draw the bargraph
110 qreal startY
; // green/yellow/red zones.
126 // The Value and target variables
127 // are expressed in degrees
134 // Name of the fields to read when an update is received:
140 #endif /* LINEARDIALGADGETWIDGET_H_ */