QGCHilConfiguration.cc 1.9 KB
Newer Older
1 2 3
#include "QGCHilConfiguration.h"
#include "ui_QGCHilConfiguration.h"

4 5 6 7
#include "QGCHilFlightGearConfiguration.h"
#include "QGCHilXPlaneConfiguration.h"

QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) :
8
    QWidget(parent),
9
    mav(mav),
10 11 12 13 14
    ui(new Ui::QGCHilConfiguration)
{
    ui->setupUi(this);
}

15 16 17 18 19
void QGCHilConfiguration::receiveStatusMessage(const QString& message)
{
    ui->statusLabel->setText(message);
}

20 21 22 23 24 25
QGCHilConfiguration::~QGCHilConfiguration()
{
    delete ui;
}

void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
26
{
27 28 29 30 31 32 33 34
    //clean up
    QLayoutItem *child;
    while ((child = ui->simulatorConfigurationLayout->takeAt(0)) != 0)
    {
      delete child->widget();
      delete child;
    }

35
    if(1 == index)
36
    {
Lorenz Meier's avatar
Lorenz Meier committed
37 38
        // Ensure the sim exists and is disabled
        mav->enableHilFlightGear(false, "");
39 40
        QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(mav, this);
        hfgconf->show();
41 42 43 44 45 46
        ui->simulatorConfigurationLayout->addWidget(hfgconf);
        QGCFlightGearLink* fg = dynamic_cast<QGCFlightGearLink*>(mav->getHILSimulation());
        if (fg)
        {
            connect(fg, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
        }
47

48
    }
49
    else if(2 == index || 3 == index)
50
    {
Lorenz Meier's avatar
Lorenz Meier committed
51 52
        // Ensure the sim exists and is disabled
        mav->enableHilXPlane(false);
53 54
        QGCHilXPlaneConfiguration* hxpconf = new QGCHilXPlaneConfiguration(mav->getHILSimulation(), this);
        hxpconf->show();
55
        ui->simulatorConfigurationLayout->addWidget(hxpconf);
56

Lorenz Meier's avatar
Lorenz Meier committed
57 58 59 60 61
        // Select correct version of XPlane
        QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(mav->getHILSimulation());
        if (xplane)
        {
            xplane->setVersion((index == 2) ? 10 : 9);
62
            connect(xplane, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
Lorenz Meier's avatar
Lorenz Meier committed
63
        }
64
    }
65
}