CompassConfig.cc 4.74 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
    initConnections();
43
}
44 45 46
CompassConfig::~CompassConfig()
{
}
47 48 49 50 51 52 53 54 55
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);
56
            ui.orientationComboBox->setEnabled(false);
57 58 59 60 61 62
        }
        else
        {
            ui.enableCheckBox->setChecked(true);
            ui.autoDecCheckBox->setEnabled(true);
            ui.declinationLineEdit->setEnabled(true);
63
            ui.orientationComboBox->setEnabled(true);
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
        }
        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()));
    }
82 83 84 85 86 87
    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)));
    }
88 89 90 91 92 93 94 95
}

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

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

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

}