2010-08-20 23:18:20 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file configtaskwidget.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
|
|
|
* @addtogroup ConfigPlugin Config Plugin
|
|
|
|
* @{
|
|
|
|
* @brief The Configuration Gadget used to update settings in the firmware (task widget)
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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 CONFIGTASKWIDGET_H
|
|
|
|
#define CONFIGTASKWIDGET_H
|
|
|
|
|
2010-09-07 21:31:19 +02:00
|
|
|
|
2010-08-20 23:18:20 +02:00
|
|
|
#include "extensionsystem/pluginmanager.h"
|
2011-01-22 18:38:22 +01:00
|
|
|
#include "uavobjectmanager.h"
|
|
|
|
#include "uavobject.h"
|
2011-06-02 16:08:19 +02:00
|
|
|
#include "uavobjectutilmanager.h"
|
2010-09-07 21:31:19 +02:00
|
|
|
#include <QQueue>
|
2010-08-20 23:18:20 +02:00
|
|
|
#include <QtGui/QWidget>
|
|
|
|
#include <QList>
|
2011-07-26 00:18:41 +02:00
|
|
|
#include <QLabel>
|
|
|
|
#include "smartsavebutton.h"
|
2011-07-26 21:35:38 +02:00
|
|
|
#include "mixercurvewidget.h"
|
|
|
|
#include <QTableWidget>
|
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
#include <QSpinBox>
|
2011-08-02 18:06:17 +02:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
|
2010-08-20 23:18:20 +02:00
|
|
|
class ConfigTaskWidget: public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2012-02-03 21:29:28 +01:00
|
|
|
struct shadow
|
2011-07-26 00:18:41 +02:00
|
|
|
{
|
|
|
|
QWidget * widget;
|
2012-02-02 17:22:40 +01:00
|
|
|
float scale;
|
|
|
|
bool isLimited;
|
|
|
|
};
|
2012-02-03 21:29:28 +01:00
|
|
|
struct objectToWidget
|
2012-02-02 17:22:40 +01:00
|
|
|
{
|
2012-02-03 21:29:28 +01:00
|
|
|
UAVObject * object;
|
|
|
|
UAVObjectField * field;
|
2012-02-02 17:22:40 +01:00
|
|
|
QWidget * widget;
|
2012-02-03 21:29:28 +01:00
|
|
|
int index;
|
2012-02-02 17:22:40 +01:00
|
|
|
float scale;
|
|
|
|
bool isLimited;
|
2012-02-03 21:29:28 +01:00
|
|
|
QList<shadow *> shadowsList;
|
2012-02-02 17:22:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum buttonTypeEnum {none,save_button,apply_button,reload_button,default_button};
|
|
|
|
struct uiRelationAutomation
|
|
|
|
{
|
|
|
|
QString objname;
|
|
|
|
QString fieldname;
|
|
|
|
QString element;
|
2011-08-04 17:58:41 +02:00
|
|
|
int scale;
|
2012-02-02 17:22:40 +01:00
|
|
|
bool ismaster;
|
|
|
|
bool haslimits;
|
|
|
|
buttonTypeEnum buttonType;
|
|
|
|
QList<int> buttonGroup;
|
2011-07-26 00:18:41 +02:00
|
|
|
};
|
|
|
|
|
2010-08-20 23:18:20 +02:00
|
|
|
ConfigTaskWidget(QWidget *parent = 0);
|
|
|
|
~ConfigTaskWidget();
|
2012-02-03 21:29:28 +01:00
|
|
|
|
2010-09-07 21:31:19 +02:00
|
|
|
void saveObjectToSD(UAVObject *obj);
|
2010-08-26 16:23:40 +02:00
|
|
|
UAVObjectManager* getObjectManager();
|
2011-03-28 20:43:15 +02:00
|
|
|
static double listMean(QList<double> list);
|
2012-02-03 21:29:28 +01:00
|
|
|
|
2011-07-26 21:35:38 +02:00
|
|
|
void addUAVObject(QString objectName);
|
|
|
|
void addWidget(QWidget * widget);
|
2012-02-03 21:29:28 +01:00
|
|
|
|
2012-02-02 17:22:40 +01:00
|
|
|
void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget,int index=0,float scale=1,bool isLimited=false,QList<int>* defaultReloadGroups=0);
|
|
|
|
void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget,QString element,float scale,bool isLimited=false,QList<int>* defaultReloadGroups=0);
|
2012-02-03 21:29:28 +01:00
|
|
|
void addUAVObjectToWidgetRelation(QString object, QString field, QWidget *widget, QString index);
|
2012-02-02 17:22:40 +01:00
|
|
|
|
2012-02-03 21:29:28 +01:00
|
|
|
//BUTTONS//
|
2012-02-02 17:22:40 +01:00
|
|
|
void addApplySaveButtons(QPushButton * update,QPushButton * save);
|
|
|
|
void addReloadButton(QPushButton * button,int buttonGroup);
|
|
|
|
void addDefaultButton(QPushButton * button,int buttonGroup);
|
2012-02-03 21:29:28 +01:00
|
|
|
//////////
|
|
|
|
|
2012-02-02 17:22:40 +01:00
|
|
|
void addWidgetToDefaultReloadGroups(QWidget * widget, QList<int> *groups);
|
2012-02-03 21:29:28 +01:00
|
|
|
|
2012-02-02 17:22:40 +01:00
|
|
|
bool addShadowWidget(QWidget * masterWidget, QWidget * shadowWidget,float shadowScale=1,bool shadowIsLimited=false);
|
2012-02-03 21:29:28 +01:00
|
|
|
bool addShadowWidget(QString object,QString field,QWidget * widget,int index=0,float scale=1,bool isLimited=false, QList<int> *defaultReloadGroups=NULL);
|
2012-02-02 17:22:40 +01:00
|
|
|
|
|
|
|
void autoLoadWidgets();
|
2011-08-04 17:58:41 +02:00
|
|
|
|
2011-07-26 21:35:38 +02:00
|
|
|
bool isDirty();
|
2011-08-02 18:06:17 +02:00
|
|
|
void setDirty(bool value);
|
2012-02-03 21:29:28 +01:00
|
|
|
|
2011-09-23 14:48:27 +02:00
|
|
|
bool allObjectsUpdated();
|
2012-02-02 17:22:40 +01:00
|
|
|
|
2011-06-07 16:56:16 +02:00
|
|
|
public slots:
|
|
|
|
void onAutopilotDisconnect();
|
|
|
|
void onAutopilotConnect();
|
2011-09-23 14:48:27 +02:00
|
|
|
void invalidateObjects();
|
2012-02-02 17:22:40 +01:00
|
|
|
void removeObject(UAVObject*);
|
|
|
|
void removeAllObjects();
|
|
|
|
signals:
|
|
|
|
void objectAdded(UAVObject*);
|
|
|
|
void objectRemoved(UAVObject*);
|
2011-03-29 03:29:56 +02:00
|
|
|
private slots:
|
2011-09-23 14:48:27 +02:00
|
|
|
void objectUpdated(UAVObject*);
|
2012-02-02 17:22:40 +01:00
|
|
|
void defaultButtonClicked();
|
|
|
|
void reloadButtonClicked();
|
2010-09-07 21:31:19 +02:00
|
|
|
private:
|
2011-08-23 12:25:28 +02:00
|
|
|
bool isConnected;
|
2011-08-04 17:58:41 +02:00
|
|
|
QStringList objectsList;
|
2011-07-26 00:18:41 +02:00
|
|
|
QList <objectToWidget*> objOfInterest;
|
|
|
|
ExtensionSystem::PluginManager *pm;
|
|
|
|
UAVObjectManager *objManager;
|
|
|
|
smartSaveButton *smartsave;
|
2011-09-23 14:48:27 +02:00
|
|
|
QMap<UAVObject *,bool> objectUpdates;
|
2012-02-02 17:22:40 +01:00
|
|
|
QMap<int,QList<objectToWidget*> *> defaultReloadGroups;
|
2012-02-03 21:29:28 +01:00
|
|
|
QMap<QWidget *,objectToWidget*> shadowsList;
|
2011-07-26 21:35:38 +02:00
|
|
|
bool dirty;
|
2012-02-02 17:22:40 +01:00
|
|
|
bool setFieldFromWidget(QWidget *widget, UAVObjectField *field, int index, float scale);
|
2012-02-05 15:41:23 +01:00
|
|
|
bool setWidgetFromField(QWidget *widget, UAVObjectField *field, int index, float scale, bool hasLimits);
|
2012-02-03 21:29:28 +01:00
|
|
|
QVariant getVariantFromWidget(QWidget *widget, float scale);
|
|
|
|
bool setWidgetFromVariant(QWidget *widget,QVariant value,float scale);
|
2012-02-02 17:22:40 +01:00
|
|
|
void connectWidgetUpdatesToSlot(QWidget *widget, const char *function);
|
2012-02-05 15:41:23 +01:00
|
|
|
void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, float sclale);
|
|
|
|
QString outOfLimitsStyle;
|
2011-07-26 00:18:41 +02:00
|
|
|
protected slots:
|
2011-07-26 21:35:38 +02:00
|
|
|
virtual void disableObjUpdates();
|
|
|
|
virtual void enableObjUpdates();
|
|
|
|
virtual void clearDirty();
|
2011-07-26 00:18:41 +02:00
|
|
|
virtual void widgetsContentsChanged();
|
|
|
|
virtual void populateWidgets();
|
|
|
|
virtual void refreshWidgetsValues();
|
2012-02-03 21:29:28 +01:00
|
|
|
virtual void updateObjectsFromWidgets();
|
2011-07-26 00:18:41 +02:00
|
|
|
protected:
|
|
|
|
virtual void enableControls(bool enable);
|
2012-02-05 15:41:23 +01:00
|
|
|
void checkWidgetsLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, QVariant value, float scale);
|
2010-08-20 23:18:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONFIGTASKWIDGET_H
|