2010-04-19 06:38:03 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file airspeedgadgetwidget.h
|
|
|
|
* @author David "Buzz" Carlson Copyright (C) 2010.
|
|
|
|
* @brief
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
* @defgroup airspeed
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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 AIRSPEEDGADGETWIDGET_H_
|
|
|
|
#define AIRSPEEDGADGETWIDGET_H_
|
|
|
|
|
2010-05-02 14:07:00 +00:00
|
|
|
#include "airspeedgadgetconfiguration.h"
|
2010-05-27 13:51:30 +00:00
|
|
|
#include "extensionsystem/pluginmanager.h"
|
|
|
|
#include "uavobjects/uavobjectmanager.h"
|
2010-05-19 16:07:11 +00:00
|
|
|
#include "uavobjects/uavobject.h"
|
2010-04-19 06:38:03 +00:00
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QtSvg/QSvgRenderer>
|
|
|
|
#include <QtSvg/QGraphicsSvgItem>
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
class AirspeedGadgetWidget : public QGraphicsView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
AirspeedGadgetWidget(QWidget *parent = 0);
|
|
|
|
~AirspeedGadgetWidget();
|
2010-05-02 14:07:00 +00:00
|
|
|
void setDialFile(QString dfn, QString bg, QString fg, QString n1, QString n2);
|
2010-04-19 06:38:03 +00:00
|
|
|
void paint();
|
2010-05-02 14:07:00 +00:00
|
|
|
// setNeedle1 and setNeedle2 use a timer to simulate
|
|
|
|
// needle inertia
|
|
|
|
void setNeedle1(double value);
|
|
|
|
void setNeedle2(double value);
|
|
|
|
void setN1Min(double value) {n1MinValue = value;}
|
|
|
|
void setN1Max(double value) {n1MaxValue = value;}
|
2010-05-28 09:04:03 +00:00
|
|
|
void setN2Min(double value) {n2MinValue = value;}
|
2010-05-02 14:07:00 +00:00
|
|
|
void setN2Max(double value) {n2MaxValue = value;}
|
2010-05-03 05:59:41 +00:00
|
|
|
// Sets up needle/UAVObject connections:
|
|
|
|
void connectNeedles(QString object1, QString field1,
|
|
|
|
QString object2, QString field2);
|
2010-04-19 06:38:03 +00:00
|
|
|
|
2010-05-27 13:51:30 +00:00
|
|
|
public slots:
|
|
|
|
void updateNeedle1(UAVObject *object1); // Called by the UAVObject
|
|
|
|
void updateNeedle2(UAVObject *object2); // Called by the UAVObject
|
|
|
|
|
2010-04-19 06:38:03 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *event);
|
2010-04-27 14:04:06 +00:00
|
|
|
void resizeEvent(QResizeEvent *event);
|
2010-04-19 06:38:03 +00:00
|
|
|
|
2010-05-27 13:51:30 +00:00
|
|
|
|
2010-04-19 06:38:03 +00:00
|
|
|
private slots:
|
2010-05-02 14:07:00 +00:00
|
|
|
// Test function
|
2010-04-19 06:38:03 +00:00
|
|
|
void testRotate();
|
2010-05-02 14:07:00 +00:00
|
|
|
void rotateNeedles();
|
2010-04-19 06:38:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QSvgRenderer *m_renderer;
|
|
|
|
QGraphicsSvgItem *m_background;
|
|
|
|
QGraphicsSvgItem *m_foreground;
|
2010-05-02 14:07:00 +00:00
|
|
|
QGraphicsSvgItem *m_needle1;
|
|
|
|
QGraphicsSvgItem *m_needle2;
|
2010-05-03 05:59:41 +00:00
|
|
|
|
|
|
|
bool n2enabled; // Simple flag to skip rendering if the
|
|
|
|
bool fgenabled; // layer does not exist.
|
|
|
|
|
2010-05-02 14:07:00 +00:00
|
|
|
double n1MinValue;
|
|
|
|
double n1MaxValue;
|
|
|
|
double n2MinValue;
|
|
|
|
double n2MaxValue;
|
|
|
|
|
2010-05-03 05:59:41 +00:00
|
|
|
// The Value and target variables
|
|
|
|
// are expressed in degrees
|
2010-05-02 14:07:00 +00:00
|
|
|
double needle1Target;
|
|
|
|
double needle1Value;
|
|
|
|
double needle2Target;
|
|
|
|
double needle2Value;
|
|
|
|
|
2010-05-27 09:47:42 +00:00
|
|
|
// Name of the fields to read when an update is received:
|
2010-05-27 13:51:30 +00:00
|
|
|
UAVDataObject* obj1;
|
|
|
|
UAVDataObject* obj2;
|
2010-05-27 09:47:42 +00:00
|
|
|
QString field1;
|
|
|
|
QString field2;
|
|
|
|
|
2010-05-02 14:07:00 +00:00
|
|
|
// Rotation timer
|
|
|
|
QTimer dialTimer;
|
2010-04-19 06:38:03 +00:00
|
|
|
|
|
|
|
// Test variables
|
2010-05-27 09:47:42 +00:00
|
|
|
#if 0
|
2010-04-19 06:38:03 +00:00
|
|
|
int testSpeed;
|
|
|
|
QTimer m_testTimer;
|
|
|
|
// End test variables
|
2010-05-27 09:47:42 +00:00
|
|
|
#endif
|
2010-04-19 06:38:03 +00:00
|
|
|
};
|
|
|
|
#endif /* AIRSPEEDGADGETWIDGET_H_ */
|