FrameTypeConfig.cc 2.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2013 Michael Carpenter (malcom2073@gmail.com)

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL 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.

    QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief Airframe type configuration widget source.
 *
 *   @author Michael Carpenter <malcom2073@gmail.com>
 *
 */

32 33 34
#include "FrameTypeConfig.h"


35
FrameTypeConfig::FrameTypeConfig(QWidget *parent) : AP2ConfigWidget(parent)
36 37
{
    ui.setupUi(this);
38 39 40 41 42 43

    //Disable until we get a FRAME parameter.
    ui.xRadioButton->setEnabled(false);
    ui.vRadioButton->setEnabled(false);
    ui.plusRadioButton->setEnabled(false);

44 45 46
    connect(ui.plusRadioButton,SIGNAL(clicked()),this,SLOT(plusFrameSelected()));
    connect(ui.xRadioButton,SIGNAL(clicked()),this,SLOT(xFrameSelected()));
    connect(ui.vRadioButton,SIGNAL(clicked()),this,SLOT(vFrameSelected()));
47
    initConnections();
48 49 50 51 52
}

FrameTypeConfig::~FrameTypeConfig()
{
}
53
void FrameTypeConfig::parameterChanged(int uas, int component, QString parameterName, QVariant value)
54
{
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
    if (parameterName == "FRAME")
    {
        ui.xRadioButton->setEnabled(true);
        ui.vRadioButton->setEnabled(true);
        ui.plusRadioButton->setEnabled(true);
        if (value.toInt() == 0)
        {
            ui.plusRadioButton->setChecked(true);
        }
        else if (value.toInt() == 1)
        {
            ui.xRadioButton->setChecked(true);
        }
        else if (value.toInt() == 2)
        {
            ui.vRadioButton->setChecked(true);
        }
    }
}
74

75 76
void FrameTypeConfig::xFrameSelected()
{
77
    if (!m_uas)
78
    {
79 80
        showNullMAVErrorMessageBox();
        return;
81
    }
82
    m_uas->getParamManager()->setParameter(1,"FRAME",QVariant(1));
83 84 85 86
}

void FrameTypeConfig::plusFrameSelected()
{
87
    if (!m_uas)
88
    {
89 90
        showNullMAVErrorMessageBox();
        return;
91
    }
92
    m_uas->getParamManager()->setParameter(1,"FRAME",QVariant(0));
93 94 95 96
}

void FrameTypeConfig::vFrameSelected()
{
97
    if (!m_uas)
98
    {
99 100
        showNullMAVErrorMessageBox();
        return;
101
    }
102
    m_uas->getParamManager()->setParameter(1,"FRAME",QVariant(2));
103
}