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

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

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

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

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

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

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

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

Lorenz Meier's avatar
Lorenz Meier committed
58 59 60 61 62
        // Select correct version of XPlane
        QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(mav->getHILSimulation());
        if (xplane)
        {
            xplane->setVersion((index == 2) ? 10 : 9);
63
            connect(xplane, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
Lorenz Meier's avatar
Lorenz Meier committed
64
        }
65
    }
66 67 68 69 70 71 72 73 74 75 76 77 78
    else if (4)
    {
        // Ensure the sim exists and is disabled
        mav->enableHilJSBSim(false, "");
        QGCHilJSBSimConfiguration* hfgconf = new QGCHilJSBSimConfiguration(mav, this);
        hfgconf->show();
        ui->simulatorConfigurationLayout->addWidget(hfgconf);
        QGCJSBSimLink* jsb = dynamic_cast<QGCJSBSimLink*>(mav->getHILSimulation());
        if (jsb)
        {
            connect(jsb, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
        }
    }
79
}