AdvancedParamConfig.cc 2.16 KB
Newer Older
1 2 3
#include "AdvancedParamConfig.h"


4
AdvancedParamConfig::AdvancedParamConfig(QWidget *parent) : AP2ConfigWidget(parent)
5 6
{
    ui.setupUi(this);
7
    initConnections();
8 9 10 11 12
}

AdvancedParamConfig::~AdvancedParamConfig()
{
}
13 14
void AdvancedParamConfig::addRange(QString title,QString description,QString param,double min,double max)
{
15 16 17
    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)));
18
    m_paramToWidgetMap[param] = widget;
19 20 21 22 23 24 25
    widget->setupDouble(title + "(" + param + ")",description,0,min,max);
    ui.verticalLayout->addWidget(widget);
    widget->show();
}

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

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