StandardParamConfig.cc 2.17 KB
Newer Older
1
#include "StandardParamConfig.h"
2 3 4 5
#include "ParamWidget.h"
StandardParamConfig::StandardParamConfig(QWidget *parent) : AP2ConfigWidget(parent)
{
    ui.setupUi(this);
6
    initConnections();
7 8 9 10 11 12
}
StandardParamConfig::~StandardParamConfig()
{
}
void StandardParamConfig::addRange(QString title,QString description,QString param,double min,double max)
{
13 14 15
    ParamWidget *widget = new ParamWidget(param,ui.scrollAreaWidgetContents);
    connect(widget,SIGNAL(doubleValueChanged(QString,double)),this,SLOT(doubleValueChanged(QString,double)));
    connect(widget,SIGNAL(intValueChanged(QString,int)),this,SLOT(intValueChanged(QString,int)));
16 17 18 19
    paramToWidgetMap[param] = widget;
    widget->setupDouble(title + "(" + param + ")",description,0,min,max);
    ui.verticalLayout->addWidget(widget);
    widget->show();
20 21
}

22 23
void StandardParamConfig::addCombo(QString title,QString description,QString param,QList<QPair<int,QString> > valuelist)
{
24 25 26
    ParamWidget *widget = new ParamWidget(param,ui.scrollAreaWidgetContents);
    connect(widget,SIGNAL(doubleValueChanged(QString,double)),this,SLOT(doubleValueChanged(QString,double)));
    connect(widget,SIGNAL(intValueChanged(QString,int)),this,SLOT(intValueChanged(QString,int)));
27 28 29 30 31 32
    paramToWidgetMap[param] = widget;
    widget->setupCombo(title + "(" + param + ")",description,valuelist);
    ui.verticalLayout->addWidget(widget);
    widget->show();
}
void StandardParamConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
33
{
34 35
    if (paramToWidgetMap.contains(parameterName))
    {
36 37 38 39 40 41 42 43
        if (value.type() == QVariant::Double)
        {
            paramToWidgetMap[parameterName]->setValue(value.toDouble());
        }
        else
        {
            paramToWidgetMap[parameterName]->setValue(value.toInt());
        }
44
    }
45
}
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
void StandardParamConfig::doubleValueChanged(QString param,double value)
{
    if (!m_uas)
    {
        this->showNullMAVErrorMessageBox();
    }
    m_uas->getParamManager()->setParameter(1,param,value);
}

void StandardParamConfig::intValueChanged(QString param,int value)
{
    if (!m_uas)
    {
        this->showNullMAVErrorMessageBox();
    }
    m_uas->getParamManager()->setParameter(1,param,value);
}