1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-14 21:23:52 +01:00
LibrePilot/ground/src/plugins/lineardial/lineardialgadgetwidget.h
edouard c5e540b1ff OP-60 : new options for linear dial: number of decimal places and factor (+ bug fixes)
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1025 ebee16cc-31ac-478f-84a7-5cbb03baadba
2010-07-04 22:00:50 +00:00

122 lines
3.5 KiB
C++

/**
******************************************************************************
*
* @file lineardialgadgetwidget.h
* @author Edouard Lafargue Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup lineardialplugin
* @{
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LINEARDIALGADGETWIDGET_H_
#define LINEARDIALGADGETWIDGET_H_
#include "lineardialgadgetconfiguration.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavobject.h"
#include <QGraphicsView>
#include <QtSvg/QSvgRenderer>
#include <QtSvg/QGraphicsSvgItem>
#include <QFile>
#include <QTimer>
class LineardialGadgetWidget : public QGraphicsView
{
Q_OBJECT
public:
LineardialGadgetWidget(QWidget *parent = 0);
~LineardialGadgetWidget();
void setDialFile(QString dfn);
void paint();
void setRange(double min, double max) { minValue=min; maxValue=max;}
void setGreenRange(double min, double max) {greenMin=min; greenMax=max;}
void setYellowRange(double min, double max) {yellowMin=min; yellowMax=max;}
void setRedRange(double min, double max) {redMin=min; redMax=max;}
void connectInput(QString obj, QString field);
void setIndex(double val);
void setDialFont(QString fontProps);
void setFactor (double val) { factor = val;}
void setDecimalPlaces(int val) { places = val;}
public slots:
void updateIndex(UAVObject *object1);
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
private:
private slots:
void moveIndex();
private:
QSvgRenderer *m_renderer;
QGraphicsSvgItem *background;
QGraphicsSvgItem *foreground;
QGraphicsSvgItem *index;
QGraphicsSvgItem *green;
QGraphicsSvgItem *yellow;
QGraphicsSvgItem *red;
QGraphicsSvgItem *fieldSymbol;
QGraphicsTextItem *fieldName;
QGraphicsTextItem *fieldValue;
// Simple flag to skip rendering if the
bool fgenabled; // layer does not exist.
bool verticalDial; // True if the dials scales vertically.
qreal startX; // Where we should draw the bargraph
qreal startY; // green/yellow/red zones.
qreal bargraphSize;
qreal indexHeight;
qreal indexWidth;
double minValue;
double maxValue;
double greenMin;
double greenMax;
double yellowMin;
double yellowMax;
double redMin;
double redMax;
double factor;
int places;
// The Value and target variables
// are expressed in degrees
double indexTarget;
double indexValue;
// Rotation timer
QTimer dialTimer;
// Name of the fields to read when an update is received:
UAVDataObject* obj1;
QString field1;
};
#endif /* LINEARDIALGADGETWIDGET_H_ */