Newer
Older
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
#include <QSettings>
Lorenz Meier
committed
#include "QGCHilConfiguration.h"
#include "ui_QGCHilConfiguration.h"
Lorenz Meier
committed
#include "QGCHilJSBSimConfiguration.h"
QGCHilConfiguration::QGCHilConfiguration(Vehicle* vehicle, QWidget *parent)
: QWidget(parent)
, _vehicle(vehicle)
, ui(new Ui::QGCHilConfiguration)
Lorenz Meier
committed
{
ui->setupUi(this);
// XXX its quite wrong that this is implicitely a factory
// class, but this is something to clean up for later.
QSettings settings;
settings.beginGroup("QGC_HILCONFIG");
int i = settings.value("SIMULATOR_INDEX", -1).toInt();
Lorenz Meier
committed
// ui->simComboBox->blockSignals(true);
ui->simComboBox->setCurrentIndex(i);
Lorenz Meier
committed
// ui->simComboBox->blockSignals(false);
}
settings.endGroup();
Lorenz Meier
committed
}
void QGCHilConfiguration::receiveStatusMessage(const QString& message)
{
ui->statusLabel->setText(message);
}
QGCHilConfiguration::~QGCHilConfiguration()
{
QSettings settings;
settings.beginGroup("QGC_HILCONFIG");
settings.setValue("SIMULATOR_INDEX", ui->simComboBox->currentIndex());
settings.endGroup();
Lorenz Meier
committed
void QGCHilConfiguration::setVersion(QString version)
{
Don Gagne
committed
Q_UNUSED(version);
Lorenz Meier
committed
}
void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
Lorenz Meier
committed
{
//clean up
QLayoutItem *child;
while ((child = ui->simulatorConfigurationLayout->takeAt(0)) != 0)
{
delete child->widget();
delete child;
Lorenz Meier
committed
{
_vehicle->uas()->enableHilFlightGear(false, "", true, this);
QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(_vehicle, this);
ui->simulatorConfigurationLayout->addWidget(hfgconf);
QGCFlightGearLink* fg = dynamic_cast<QGCFlightGearLink*>(_vehicle->uas()->getHILSimulation());
if (fg)
{
connect(fg, &QGCFlightGearLink::statusMessage, ui->statusLabel, &QLabel::setText);
Lorenz Meier
committed
}
Lorenz Meier
committed
else if (2 == index || 3 == index)
Lorenz Meier
committed
{
_vehicle->uas()->enableHilXPlane(false);
QGCHilXPlaneConfiguration* hxpconf = new QGCHilXPlaneConfiguration(_vehicle->uas()->getHILSimulation(), this);
ui->simulatorConfigurationLayout->addWidget(hxpconf);
Lorenz Meier
committed
QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(_vehicle->uas()->getHILSimulation());
if (xplane)
{
xplane->setVersion((index == 2) ? 10 : 9);
connect(xplane, &QGCXPlaneLink::statusMessage, ui->statusLabel, &QLabel::setText);
// Disabling JSB Sim since its not well maintained,
// but as refactoring is pending we're not ditching the code yet
// else if (4)
// {
// // Ensure the sim exists and is disabled
// _vehicle->uas()->enableHilJSBSim(false, "");
// QGCHilJSBSimConfiguration* hfgconf = new QGCHilJSBSimConfiguration(_vehicle, this);
// hfgconf->show();
// ui->simulatorConfigurationLayout->addWidget(hfgconf);
// QGCJSBSimLink* jsb = dynamic_cast<QGCJSBSimLink*>(_vehicle->uas()->getHILSimulation());
// if (jsb)
// {
// connect(jsb, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
// }
// }