QGCUnconnectedInfoWidget.cc 1.1 KB
Newer Older
1
#include "QGCUnconnectedInfoWidget.h"
2 3 4 5
#include "LinkInterface.h"
#include "LinkManager.h"
#include "MAVLinkSimulationLink.h"
#include "MainWindow.h"
6 7 8 9 10 11 12 13
#include "ui_QGCUnconnectedInfoWidget.h"

QGCUnconnectedInfoWidget::QGCUnconnectedInfoWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::QGCUnconnectedInfoWidget)
{
    ui->setupUi(this);

14 15
    connect(ui->simulationButton, SIGNAL(clicked()), this, SLOT(simulate()));
    connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(addLink()));
16 17 18 19 20 21
}

QGCUnconnectedInfoWidget::~QGCUnconnectedInfoWidget()
{
    delete ui;
}
22 23 24 25 26 27 28 29

/**
 * @brief Starts the system simulation
 */
void QGCUnconnectedInfoWidget::simulate()
{
    // Try to get reference to MAVLinkSimulationlink
    QList<LinkInterface*> links = LinkManager::instance()->getLinks();
30
    foreach(LinkInterface* link, links) {
31
        MAVLinkSimulationLink* sim = dynamic_cast<MAVLinkSimulationLink*>(link);
32
        if (sim) {
33 34 35 36 37 38 39 40 41 42 43 44
            sim->connectLink();
        }
    }
}

/**
 * @return Opens a "Connect new Link" popup
 */
void QGCUnconnectedInfoWidget::addLink()
{
    MainWindow::instance()->addLink();
}