CompassConfig.cc 4.71 KB
Newer Older
1 2 3
#include "CompassConfig.h"


4
CompassConfig::CompassConfig(QWidget *parent) : AP2ConfigWidget(parent)
5 6
{
    ui.setupUi(this);
7 8 9 10 11 12 13 14
    ui.autoDecCheckBox->setEnabled(false);
    ui.enableCheckBox->setEnabled(false);
    ui.orientationComboBox->setEnabled(false);
    ui.declinationLineEdit->setEnabled(false);
    connect(ui.enableCheckBox,SIGNAL(clicked(bool)),this,SLOT(enableClicked(bool)));
    connect(ui.autoDecCheckBox,SIGNAL(clicked(bool)),this,SLOT(autoDecClicked(bool)));
    connect(ui.orientationComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(orientationComboChanged(int)));

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    ui.orientationComboBox->addItem("ROTATION_NONE");
    ui.orientationComboBox->addItem("ROTATION_YAW_45");
    ui.orientationComboBox->addItem("ROTATION_YAW_90");
    ui.orientationComboBox->addItem("ROTATION_YAW_135");
    ui.orientationComboBox->addItem("ROTATION_YAW_180");
    ui.orientationComboBox->addItem("ROTATION_YAW_225");
    ui.orientationComboBox->addItem("ROTATION_YAW_270");
    ui.orientationComboBox->addItem("ROTATION_YAW_315");
    ui.orientationComboBox->addItem("ROTATION_ROLL_180");
    ui.orientationComboBox->addItem("ROTATION_ROLL_180_YAW_45");
    ui.orientationComboBox->addItem("ROTATION_ROLL_180_YAW_90");
    ui.orientationComboBox->addItem("ROTATION_ROLL_180_YAW_135");
    ui.orientationComboBox->addItem("ROTATION_PITCH_180");
    ui.orientationComboBox->addItem("ROTATION_ROLL_180_YAW_225");
    ui.orientationComboBox->addItem("ROTATION_ROLL_180_YAW_270");
    ui.orientationComboBox->addItem("ROTATION_ROLL_180_YAW_315");
    ui.orientationComboBox->addItem("ROTATION_ROLL_90");
    ui.orientationComboBox->addItem("ROTATION_ROLL_90_YAW_45");
    ui.orientationComboBox->addItem("ROTATION_ROLL_90_YAW_90");
    ui.orientationComboBox->addItem("ROTATION_ROLL_90_YAW_135");
    ui.orientationComboBox->addItem("ROTATION_ROLL_270");
    ui.orientationComboBox->addItem("ROTATION_ROLL_270_YAW_45");
    ui.orientationComboBox->addItem("ROTATION_ROLL_270_YAW_90");
    ui.orientationComboBox->addItem("ROTATION_ROLL_270_YAW_135");
    ui.orientationComboBox->addItem("ROTATION_PITCH_90");
    ui.orientationComboBox->addItem("ROTATION_PITCH_270");
    ui.orientationComboBox->addItem("ROTATION_MAX");
42
}
43 44 45
CompassConfig::~CompassConfig()
{
}
46 47 48 49 50 51 52 53 54
void CompassConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
    if (parameterName == "MAG_ENABLE")
    {
        if (value.toInt() == 0)
        {
            ui.enableCheckBox->setChecked(false);
            ui.autoDecCheckBox->setEnabled(false);
            ui.declinationLineEdit->setEnabled(false);
55
            ui.orientationComboBox->setEnabled(false);
56 57 58 59 60 61
        }
        else
        {
            ui.enableCheckBox->setChecked(true);
            ui.autoDecCheckBox->setEnabled(true);
            ui.declinationLineEdit->setEnabled(true);
62
            ui.orientationComboBox->setEnabled(true);
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
        }
        ui.enableCheckBox->setEnabled(true);
    }
    else if (parameterName == "COMPASS_AUTODEC")
    {
        if (value.toInt() == 0)
        {
            ui.autoDecCheckBox->setChecked(false);
        }
        else
        {
            ui.autoDecCheckBox->setChecked(true);
        }
    }
    else if (parameterName == "COMPASS_DEC")
    {
        ui.declinationLineEdit->setText(QString::number(value.toDouble()));
    }
81 82 83 84 85 86
    else if (parameterName == "COMPASS_ORIENT")
    {
        disconnect(ui.orientationComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(orientationComboChanged(int)));
        ui.orientationComboBox->setCurrentIndex(value.toInt());
        connect(ui.orientationComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(orientationComboChanged(int)));
    }
87 88 89 90 91 92 93 94
}

void CompassConfig::enableClicked(bool enabled)
{
    if (m_uas)
    {
        if (enabled)
        {
95
            m_uas->getParamManager()->setParameter(1,"MAG_ENABLE",QVariant(1));
96 97 98 99 100 101 102 103
            ui.autoDecCheckBox->setEnabled(true);
            if (!ui.autoDecCheckBox->isChecked())
            {
                ui.declinationLineEdit->setEnabled(true);
            }
        }
        else
        {
104
            m_uas->getParamManager()->setParameter(1,"MAG_ENABLE",QVariant(0));
105 106 107 108 109 110 111 112 113 114 115 116
            ui.autoDecCheckBox->setEnabled(false);
            ui.declinationLineEdit->setEnabled(false);
        }
    }
}

void CompassConfig::autoDecClicked(bool enabled)
{
    if (m_uas)
    {
        if (enabled)
        {
117
            m_uas->getParamManager()->setParameter(1,"COMPASS_AUTODEC",QVariant(1));
118 119 120
        }
        else
        {
121
            m_uas->getParamManager()->setParameter(1,"COMPASS_AUTODEC",QVariant(0));
122 123 124 125 126 127
        }
    }
}

void CompassConfig::orientationComboChanged(int index)
{
128 129 130 131 132 133
    //COMPASS_ORIENT
    if (!m_uas)
    {
        return;
    }
    m_uas->getParamManager()->setParameter(1,"COMPASS_ORIENT",index);
134 135

}