MainWindow.cc 35.2 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2
/*=====================================================================

3
QGroundControl Open Source Ground Control Station
pixhawk's avatar
pixhawk committed
4

5
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
pixhawk's avatar
pixhawk committed
6

7
This file is part of the QGROUNDCONTROL project
pixhawk's avatar
pixhawk committed
8

9
    QGROUNDCONTROL is free software: you can redistribute it and/or modify
pixhawk's avatar
pixhawk committed
10 11 12 13
    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.

14
    QGROUNDCONTROL is distributed in the hope that it will be useful,
pixhawk's avatar
pixhawk committed
15 16 17 18 19
    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
20
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
pixhawk's avatar
pixhawk committed
21 22 23 24 25

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

/**
 * @file
26
 *   @brief Implementation of class MainWindow
27
 *   @author Lorenz Meier <mail@qgroundcontrol.org>
pixhawk's avatar
pixhawk committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
 */

#include <QSettings>
#include <QDockWidget>
#include <QNetworkInterface>
#include <QMessageBox>
#include <QDebug>
#include <QTimer>
#include <QHostInfo>

#include "MG.h"
#include "MAVLinkSimulationLink.h"
#include "SerialLink.h"
#include "UDPLink.h"
#include "MAVLinkProtocol.h"
#include "CommConfigurationWindow.h"
#include "WaypointList.h"
#include "MainWindow.h"
#include "JoystickWidget.h"
pixhawk's avatar
pixhawk committed
47
#include "GAudioOutput.h"
48

49
#ifdef QGC_OSG_ENABLED
50
#include "Q3DWidgetFactory.h"
51
#endif
pixhawk's avatar
pixhawk committed
52

lm's avatar
lm committed
53 54 55 56
// FIXME Move
#include "PxQuadMAV.h"
#include "SlugsMAV.h"

pixhawk's avatar
pixhawk committed
57 58 59 60 61 62 63 64 65 66

#include "LogCompressor.h"

/**
* Create new mainwindow. The constructor instantiates all parts of the user
* interface. It does NOT show the mainwindow. To display it, call the show()
* method.
*
* @see QMainWindow::show()
**/
67
MainWindow::MainWindow(QWidget *parent) :
pixhawk's avatar
pixhawk committed
68 69
        QMainWindow(parent),
        settings()
pixhawk's avatar
pixhawk committed
70
{
71 72 73
    this->hide();
    this->setVisible(false);

pixhawk's avatar
pixhawk committed
74 75 76
    // Setup user interface
    ui.setupUi(this);

77 78 79 80 81 82 83
    buildWidgets();

    connectWidgets();

    arrangeCenterStack();

    configureWindowName();
pixhawk's avatar
pixhawk committed
84 85

    // Add status bar
86
    //setStatusBar(createStatusBar());
pixhawk's avatar
pixhawk committed
87 88 89 90

    // Set the application style (not the same as a style sheet)
    // Set the style to Plastique
    qApp->setStyle("plastique");
91

pixhawk's avatar
pixhawk committed
92 93 94 95
    // Set style sheet as last step
    reloadStylesheet();


96 97 98
    // Create actions
    connectActions();

99
    // Load widgets and show application windowa
100 101 102 103
    loadWidgets();

    // Adjust the size
    adjustSize();
pixhawk's avatar
pixhawk committed
104 105
}

pixhawk's avatar
pixhawk committed
106
MainWindow::~MainWindow()
pixhawk's avatar
pixhawk committed
107 108 109 110 111
{
    delete statusBar;
    statusBar = NULL;
}

112 113 114

void MainWindow::buildWidgets()
{
pixhawk's avatar
pixhawk committed
115 116 117 118 119 120 121 122
    //FIXME: memory of acceptList will never be freed again
    QStringList* acceptList = new QStringList();
    acceptList->append("roll IMU");
    acceptList->append("pitch IMU");
    acceptList->append("yaw IMU");
    acceptList->append("rollspeed IMU");
    acceptList->append("pitchspeed IMU");
    acceptList->append("yawspeed IMU");
123

pixhawk's avatar
pixhawk committed
124 125 126 127
    //FIXME: memory of acceptList2 will never be freed again
    QStringList* acceptList2 = new QStringList();
    acceptList2->append("Battery");
    acceptList2->append("Pressure");
128

pixhawk's avatar
pixhawk committed
129 130
    //TODO:  move protocol outside UI
    mavlink     = new MAVLinkProtocol();
131

pixhawk's avatar
pixhawk committed
132 133
    // Center widgets
    linechartWidget   = new Linecharts(this);
134
    hudWidget         = new HUD(320, 240, this);
pixhawk's avatar
pixhawk committed
135 136 137
    mapWidget         = new MapWidget(this);
    protocolWidget    = new XMLCommProtocolWidget(this);
    dataplotWidget    = new QGCDataPlot2D(this);
138
    #ifdef QGC_OSG_ENABLED
139
    _3DWidget         = Q3DWidgetFactory::get("PIXHAWK");
140
    #endif
141

142 143 144 145
#ifdef QGC_OSGEARTH_ENABLED
    _3DMapWidget = Q3DWidgetFactory::get("MAP3D");
#endif

pixhawk's avatar
pixhawk committed
146 147 148
    // Dock widgets
    controlDockWidget = new QDockWidget(tr("Control"), this);
    controlDockWidget->setWidget( new UASControlWidget(this) );
149

pixhawk's avatar
pixhawk committed
150 151
    listDockWidget = new QDockWidget(tr("Unmanned Systems"), this);
    listDockWidget->setWidget( new UASListWidget(this) );
152

pixhawk's avatar
pixhawk committed
153 154
    waypointsDockWidget = new QDockWidget(tr("Waypoint List"), this);
    waypointsDockWidget->setWidget( new WaypointList(this, NULL) );
155

pixhawk's avatar
pixhawk committed
156 157
    infoDockWidget = new QDockWidget(tr("Status Details"), this);
    infoDockWidget->setWidget( new UASInfoWidget(this) );
158

pixhawk's avatar
pixhawk committed
159 160
    detectionDockWidget = new QDockWidget(tr("Object Recognition"), this);
    detectionDockWidget->setWidget( new ObjectDetectionView("images/patterns", this) );
161

pixhawk's avatar
pixhawk committed
162 163
    debugConsoleDockWidget = new QDockWidget(tr("Communication Console"), this);
    debugConsoleDockWidget->setWidget( new DebugConsole(this) );
164

pixhawk's avatar
pixhawk committed
165 166
    parametersDockWidget = new QDockWidget(tr("Onboard Parameters"), this);
    parametersDockWidget->setWidget( new ParameterInterface(this) );
167

pixhawk's avatar
pixhawk committed
168 169
    watchdogControlDockWidget = new QDockWidget(tr("Process Control"), this);
    watchdogControlDockWidget->setWidget( new WatchdogControl(this) );
170

pixhawk's avatar
pixhawk committed
171 172
    hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this);
    hsiDockWidget->setWidget( new HSIDisplay(this) );
173

pixhawk's avatar
pixhawk committed
174 175
    headDown1DockWidget = new QDockWidget(tr("Primary Flight Display"), this);
    headDown1DockWidget->setWidget( new HDDisplay(acceptList, this) );
176

pixhawk's avatar
pixhawk committed
177 178
    headDown2DockWidget = new QDockWidget(tr("Payload Status"), this);
    headDown2DockWidget->setWidget( new HDDisplay(acceptList2, this) );
179

pixhawk's avatar
pixhawk committed
180 181
    rcViewDockWidget = new QDockWidget(tr("Radio Control"), this);
    rcViewDockWidget->setWidget( new QGCRemoteControlView(this) );
182

183 184 185
    headUpDockWidget = new QDockWidget(tr("Control Indicator"), this);
    headUpDockWidget->setWidget( new HUD(320, 240, this));

pixhawk's avatar
pixhawk committed
186 187 188
    // Dialogue widgets
    //FIXME: free memory in destructor
    joystick    = new JoystickInput();
189

190 191
}

pixhawk's avatar
pixhawk committed
192 193 194
/**
 * Connect all signals and slots of the main window widgets
 */
195 196
void MainWindow::connectWidgets()
{
pixhawk's avatar
pixhawk committed
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
    if (linechartWidget)
    {
        connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
                linechartWidget, SLOT(addSystem(UASInterface*)));
        connect(UASManager::instance(), SIGNAL(activeUASSet(int)),
                linechartWidget, SLOT(selectSystem(int)));
        connect(linechartWidget, SIGNAL(logfileWritten(QString)),
                this, SLOT(loadDataView(QString)));
    }
    if (infoDockWidget && infoDockWidget->widget())
    {
        connect(mavlink, SIGNAL(receiveLossChanged(int, float)),
                infoDockWidget->widget(), SLOT(updateSendLoss(int, float)));
    }
    if (mapWidget && waypointsDockWidget->widget())
    {
        // clear path create on the map
        connect(waypointsDockWidget->widget(), SIGNAL(clearPathclicked()), mapWidget, SLOT(clearPath()));
        // add Waypoint widget in the WaypointList widget when mouse clicked
        connect(mapWidget, SIGNAL(captureMapCoordinateClick(QPointF)), waypointsDockWidget->widget(), SLOT(addWaypointMouse(QPointF)));
        // it notifies that a waypoint global goes to do create
218 219
        //connect(mapWidget, SIGNAL(createGlobalWP(bool, QPointF)), waypointsDockWidget->widget(), SLOT(setIsWPGlobal(bool, QPointF)));
        //connect(mapWidget, SIGNAL(sendGeometryEndDrag(QPointF,int)), waypointsDockWidget->widget(), SLOT(waypointGlobalChanged(QPointF,int)) );
220 221 222 223

        // it notifies that a waypoint global goes to do create and a map graphic too
        connect(waypointsDockWidget->widget(), SIGNAL(createWaypointAtMap(QPointF)), mapWidget, SLOT(createWaypointGraphAtMap(QPointF)));
        // it notifies that a waypoint global change its position by spinBox on Widget WaypointView
224
        //connect(waypointsDockWidget->widget(), SIGNAL(changePositionWPGlobalBySpinBox(int,float,float)), mapWidget, SLOT(changeGlobalWaypointPositionBySpinBox(int,float,float)));
pixhawk's avatar
pixhawk committed
225
    }
226 227
}

228 229
void MainWindow::arrangeCenterStack()
{
230

pixhawk's avatar
pixhawk committed
231 232 233 234 235
    QStackedWidget *centerStack = new QStackedWidget(this);
    if (!centerStack) return;
    if (linechartWidget) centerStack->addWidget(linechartWidget);
    if (protocolWidget) centerStack->addWidget(protocolWidget);
    if (mapWidget) centerStack->addWidget(mapWidget);
236
    #ifdef QGC_OSG_ENABLED
237
    if (_3DWidget) centerStack->addWidget(_3DWidget);
238 239
#endif
    #ifdef QGC_OSGEARTH_ENABLED
240
    if (_3DMapWidget) centerStack->addWidget(_3DMapWidget);
241
    #endif
pixhawk's avatar
pixhawk committed
242 243
    if (hudWidget) centerStack->addWidget(hudWidget);
    if (dataplotWidget) centerStack->addWidget(dataplotWidget);
244

pixhawk's avatar
pixhawk committed
245
    setCentralWidget(centerStack);
246 247
}

248 249
void MainWindow::configureWindowName()
{
pixhawk's avatar
pixhawk committed
250 251 252
    QList<QHostAddress> hostAddresses = QNetworkInterface::allAddresses();
    QString windowname = qApp->applicationName() + " " + qApp->applicationVersion();
    bool prevAddr = false;
253

pixhawk's avatar
pixhawk committed
254
    windowname.append(" (" + QHostInfo::localHostName() + ": ");
255

pixhawk's avatar
pixhawk committed
256 257 258 259 260 261 262 263 264 265
    for (int i = 0; i < hostAddresses.size(); i++)
    {
        // Exclude loopback IPv4 and all IPv6 addresses
        if (hostAddresses.at(i) != QHostAddress("127.0.0.1") && !hostAddresses.at(i).toString().contains(":"))
        {
            if(prevAddr) windowname.append("/");
            windowname.append(hostAddresses.at(i).toString());
            prevAddr = true;
        }
    }
266

pixhawk's avatar
pixhawk committed
267
    windowname.append(")");
268

pixhawk's avatar
pixhawk committed
269
    setWindowTitle(windowname);
270 271

#ifndef Q_WS_MAC
pixhawk's avatar
pixhawk committed
272
    //qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png"));
273 274 275
#endif
}

pixhawk's avatar
pixhawk committed
276
QStatusBar* MainWindow::createStatusBar()
pixhawk's avatar
pixhawk committed
277 278 279 280 281 282 283 284
{
    QStatusBar* bar = new QStatusBar();
    /* Add status fields and messages */
    /* Enable resize grip in the bottom right corner */
    bar->setSizeGripEnabled(true);
    return bar;
}

pixhawk's avatar
pixhawk committed
285
void MainWindow::startVideoCapture()
pixhawk's avatar
pixhawk committed
286 287 288 289 290 291 292 293 294 295 296
{
    QString format = "bmp";
    QString initialPath = QDir::currentPath() + tr("/untitled.") + format;

    QString screenFileName = QFileDialog::getSaveFileName(this, tr("Save As"),
                                                          initialPath,
                                                          tr("%1 Files (*.%2);;All Files (*)")
                                                          .arg(format.toUpper())
                                                          .arg(format));
    delete videoTimer;
    videoTimer = new QTimer(this);
297 298 299
    //videoTimer->setInterval(40);
    //connect(videoTimer, SIGNAL(timeout()), this, SLOT(saveScreen()));
    //videoTimer->stop();
pixhawk's avatar
pixhawk committed
300 301
}

pixhawk's avatar
pixhawk committed
302
void MainWindow::stopVideoCapture()
pixhawk's avatar
pixhawk committed
303 304 305 306 307 308
{
    videoTimer->stop();

    // TODO Convert raw images to PNG
}

pixhawk's avatar
pixhawk committed
309
void MainWindow::saveScreen()
pixhawk's avatar
pixhawk committed
310 311 312 313 314 315 316 317 318 319
{
    QPixmap window = QPixmap::grabWindow(this->winId());
    QString format = "bmp";

    if (!screenFileName.isEmpty())
    {
        window.save(screenFileName, format.toAscii());
    }
}

320 321 322 323 324 325
/**
 * Reload the style sheet from disk. The function tries to load "qgroundcontrol.css" from the application
 * directory (which by default does not exist). If it fails, it will load the bundled default CSS
 * from memory.
 * To customize the application, just create a qgroundcontrol.css file in the application directory
 */
pixhawk's avatar
pixhawk committed
326
void MainWindow::reloadStylesheet()
pixhawk's avatar
pixhawk committed
327 328
{
    // Load style sheet
329 330 331 332 333
    QFile* styleSheet = new QFile(QCoreApplication::applicationDirPath() + "/qgroundcontrol.css");
    if (!styleSheet->exists())
    {
        styleSheet = new QFile(":/images/style-mission.css");
    }
334 335
    if (styleSheet->open(QIODevice::ReadOnly | QIODevice::Text))
    {
336 337
        QString style = QString(styleSheet->readAll());
        style.replace("ICONDIR", QCoreApplication::applicationDirPath()+ "/images/");
pixhawk's avatar
pixhawk committed
338
        qApp->setStyleSheet(style);
339 340 341
    }
    else
    {
342
        qDebug() << "Style not set:" << styleSheet->fileName() << "opened: " << styleSheet->isOpen();
pixhawk's avatar
pixhawk committed
343
    }
344
    delete styleSheet;
pixhawk's avatar
pixhawk committed
345 346
}

pixhawk's avatar
pixhawk committed
347
void MainWindow::showStatusMessage(const QString& status, int timeout)
pixhawk's avatar
pixhawk committed
348
{
349
    //statusBar->showMessage(status, timeout);
pixhawk's avatar
pixhawk committed
350 351
}

352
void MainWindow::showStatusMessage(const QString& status)
pixhawk's avatar
pixhawk committed
353
{
354
    //statusBar->showMessage(status, 5);
pixhawk's avatar
pixhawk committed
355 356 357 358 359 360
}

/**
* @brief Create all actions associated to the main window
*
**/
pixhawk's avatar
pixhawk committed
361
void MainWindow::connectActions()
pixhawk's avatar
pixhawk committed
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
{
    // Connect actions from ui
    connect(ui.actionAdd_Link, SIGNAL(triggered()), this, SLOT(addLink()));

    // Connect internal actions
    connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(UASCreated(UASInterface*)));

    // Connect user interface controls
    connect(ui.actionLiftoff, SIGNAL(triggered()), UASManager::instance(), SLOT(launchActiveUAS()));
    connect(ui.actionLand, SIGNAL(triggered()), UASManager::instance(), SLOT(returnActiveUAS()));
    connect(ui.actionEmergency_Land, SIGNAL(triggered()), UASManager::instance(), SLOT(stopActiveUAS()));
    connect(ui.actionEmergency_Kill, SIGNAL(triggered()), UASManager::instance(), SLOT(killActiveUAS()));

    connect(ui.actionConfiguration, SIGNAL(triggered()), UASManager::instance(), SLOT(configureActiveUAS()));

    // User interface actions
    connect(ui.actionPilotView, SIGNAL(triggered()), this, SLOT(loadPilotView()));
    connect(ui.actionEngineerView, SIGNAL(triggered()), this, SLOT(loadEngineerView()));
    connect(ui.actionOperatorView, SIGNAL(triggered()), this, SLOT(loadOperatorView()));
381
    connect(ui.action3DView, SIGNAL(triggered()), this, SLOT(load3DView()));
382
    connect(ui.action3DMapView, SIGNAL(triggered()), this, SLOT(load3DMapView()));
383
    connect(ui.actionShow_full_view, SIGNAL(triggered()), this, SLOT(loadAllView()));
384
    connect(ui.actionShow_MAVLink_view, SIGNAL(triggered()), this, SLOT(loadMAVLinkView()));
385
    connect(ui.actionShow_data_analysis_view, SIGNAL(triggered()), this, SLOT(loadDataView()));
pixhawk's avatar
pixhawk committed
386
    connect(ui.actionStyleConfig, SIGNAL(triggered()), this, SLOT(reloadStylesheet()));
387
    connect(ui.actionGlobalOperatorView, SIGNAL(triggered()), this, SLOT(loadGlobalOperatorView()));
388 389 390 391
    connect(ui.actionOnline_documentation, SIGNAL(triggered()), this, SLOT(showHelp()));
    connect(ui.actionCredits_Developers, SIGNAL(triggered()), this, SLOT(showCredits()));
    connect(ui.actionProject_Roadmap, SIGNAL(triggered()), this, SLOT(showRoadMap()));

pixhawk's avatar
pixhawk committed
392 393
    // Joystick configuration
    connect(ui.actionJoystickSettings, SIGNAL(triggered()), this, SLOT(configure()));
394 395


pixhawk's avatar
pixhawk committed
396 397
}

398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
void MainWindow::showHelp()
{
    if(!QDesktopServices::openUrl(QUrl("http://qgroundcontrol.org/user_guide")))
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);
        msgBox.setText("Could not open help in browser");
        msgBox.setInformativeText("To get to the online help, please open http://qgroundcontrol.org/user_guide in a browser.");
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.setDefaultButton(QMessageBox::Ok);
        msgBox.exec();
    }
}

void MainWindow::showCredits()
{
    if(!QDesktopServices::openUrl(QUrl("http://qgroundcontrol.org/credits")))
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);
        msgBox.setText("Could not open credits in browser");
        msgBox.setInformativeText("To get to the online help, please open http://qgroundcontrol.org/credits in a browser.");
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.setDefaultButton(QMessageBox::Ok);
        msgBox.exec();
    }
}

void MainWindow::showRoadMap()
{
    if(!QDesktopServices::openUrl(QUrl("http://qgroundcontrol.org/roadmap")))
    {
        QMessageBox msgBox;
        msgBox.setIcon(QMessageBox::Critical);
        msgBox.setText("Could not open roadmap in browser");
        msgBox.setInformativeText("To get to the online help, please open http://qgroundcontrol.org/roadmap in a browser.");
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.setDefaultButton(QMessageBox::Ok);
        msgBox.exec();
    }
}

pixhawk's avatar
pixhawk committed
440
void MainWindow::configure()
pixhawk's avatar
pixhawk committed
441 442 443 444
{
    joystickWidget = new JoystickWidget(joystick, this);
}

pixhawk's avatar
pixhawk committed
445
void MainWindow::addLink()
pixhawk's avatar
pixhawk committed
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
{
    SerialLink* link = new SerialLink();
    // TODO This should be only done in the dialog itself

    LinkManager::instance()->addProtocol(link, mavlink);

    CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this);

    ui.menuNetwork->addAction(commWidget->getAction());

    commWidget->show();

    // TODO Implement the link removal!
}

pixhawk's avatar
pixhawk committed
461 462
void MainWindow::addLink(LinkInterface *link)
{
463
    LinkManager::instance()->addProtocol(link, mavlink);
pixhawk's avatar
pixhawk committed
464 465 466 467 468 469 470
    CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this);
    ui.menuNetwork->addAction(commWidget->getAction());

    // Special case for simulationlink
    MAVLinkSimulationLink* sim = dynamic_cast<MAVLinkSimulationLink*>(link);
    if (sim)
    {
471
        //connect(sim, SIGNAL(valueChanged(int,QString,double,quint64)), linechart, SLOT(appendData(int,QString,double,quint64)));
pixhawk's avatar
pixhawk committed
472 473 474 475
        connect(ui.actionSimulate, SIGNAL(triggered(bool)), sim, SLOT(connectLink(bool)));
    }
}

pixhawk's avatar
pixhawk committed
476
void MainWindow::UASCreated(UASInterface* uas)
pixhawk's avatar
pixhawk committed
477 478 479
{
    // Connect the UAS to the full user interface

480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
    if (uas != NULL)
    {
        QIcon icon;
        // Set matching icon
        switch (uas->getSystemType())
        {
        case 0:
            icon = QIcon(":/images/mavs/generic.svg");
            break;
        case 1:
            icon = QIcon(":/images/mavs/fixed-wing.svg");
            break;
        case 2:
            icon = QIcon(":/images/mavs/quadrotor.svg");
            break;
        case 3:
            icon = QIcon(":/images/mavs/coaxial.svg");
            break;
        case 4:
            icon = QIcon(":/images/mavs/helicopter.svg");
            break;
        case 5:
            icon = QIcon(":/images/mavs/groundstation.svg");
            break;
        default:
            icon = QIcon(":/images/mavs/unknown.svg");
            break;
        }

        ui.menuConnected_Systems->addAction(icon, tr("Select %1 for control").arg(uas->getUASName()), uas, SLOT(setSelected()));

        // FIXME Should be not inside the mainwindow
512 513
        if (debugConsoleDockWidget)
        {
pixhawk's avatar
pixhawk committed
514 515 516 517 518 519
            DebugConsole *debugConsole = dynamic_cast<DebugConsole*>(debugConsoleDockWidget->widget());
            if (debugConsole)
            {
                connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)),
                        debugConsole, SLOT(receiveTextMessage(int,int,int,QString)));
            }
520
        }
521 522

        // Health / System status indicator
523 524
        if (infoDockWidget)
        {
pixhawk's avatar
pixhawk committed
525 526 527 528 529
            UASInfoWidget *infoWidget = dynamic_cast<UASInfoWidget*>(infoDockWidget->widget());
            if (infoWidget)
            {
                infoWidget->addUAS(uas);
            }
530
        }
531 532

        // UAS List
533 534
        if (listDockWidget)
        {
pixhawk's avatar
pixhawk committed
535 536 537 538 539
            UASListWidget *listWidget = dynamic_cast<UASListWidget*>(listDockWidget->widget());
            if (listWidget)
            {
                listWidget->addUAS(uas);
            }
540
        }
541 542 543 544 545 546 547 548 549 550 551 552 553

        // Camera view
        //camera->addUAS(uas);

        // Revalidate UI
        // TODO Stylesheet reloading should in theory not be necessary
        reloadStylesheet();

        // Check which type this UAS is of
        PxQuadMAV* mav = dynamic_cast<PxQuadMAV*>(uas);
        if (mav) loadPixhawkView();
        SlugsMAV* mav2 = dynamic_cast<SlugsMAV*>(uas);
        if (mav2) loadSlugsView();
lm's avatar
lm committed
554

555
    }
pixhawk's avatar
pixhawk committed
556 557
}

558 559 560
/**
 * Clears the current view completely
 */
pixhawk's avatar
pixhawk committed
561
void MainWindow::clearView()
pixhawk's avatar
pixhawk committed
562 563
{ 
    // Halt HUD
564 565 566 567 568 569 570 571 572
    if (hudWidget) hudWidget->stop();
    // Disable linechart
    if (linechartWidget) linechartWidget->setActive(false);
    // Halt HDDs
    if (headDown1DockWidget)
    {
        HDDisplay* hddWidget = dynamic_cast<HDDisplay*>( headDown1DockWidget->widget() );
        if (hddWidget) hddWidget->stop();
    }
pixhawk's avatar
pixhawk committed
573
    if (headDown2DockWidget)
574 575 576 577 578 579 580 581 582 583
    {
        HDDisplay* hddWidget = dynamic_cast<HDDisplay*>( headDown2DockWidget->widget() );
        if (hddWidget) hddWidget->stop();
    }
    // Halt HSI
    if (hsiDockWidget)
    {
        HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
        if (hsi) hsi->stop();
    }
pixhawk's avatar
pixhawk committed
584

585 586
    // Remove all dock widgets from main window
    QObjectList childList( this->children() );
pixhawk's avatar
pixhawk committed
587

588 589 590
    QObjectList::iterator i;
    QDockWidget* dockWidget;
    for (i = childList.begin(); i != childList.end(); ++i)
pixhawk's avatar
pixhawk committed
591
    {
592 593
        dockWidget = dynamic_cast<QDockWidget*>(*i);
        if (dockWidget)
pixhawk's avatar
pixhawk committed
594
        {
595 596 597 598 599
            // Remove dock widget from main window
            this->removeDockWidget(dockWidget);
            // Deletion of dockWidget would also delete all child
            // widgets of dockWidget
            // Is there a way to unset a widget from QDockWidget?
pixhawk's avatar
pixhawk committed
600 601 602 603
        }
    }
}

lm's avatar
lm committed
604 605 606 607 608 609
void MainWindow::loadSlugsView()
{
    clearView();
    // Engineer view, used in EMAV2009

    // LINE CHART
610 611 612 613 614 615 616 617 618
    if (linechartWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
            linechartWidget->setActive(true);
            centerStack->setCurrentWidget(linechartWidget);
        }
    }
lm's avatar
lm committed
619 620

    // UAS CONTROL
621 622 623 624 625
    if (controlDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
        controlDockWidget->show();
    }
lm's avatar
lm committed
626 627

    // UAS LIST
628 629 630 631 632
    if (listDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
        listDockWidget->show();
    }
lm's avatar
lm committed
633 634

    // UAS STATUS
635 636 637 638 639
    if (infoDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget);
        infoDockWidget->show();
    }
lm's avatar
lm committed
640 641

    // HORIZONTAL SITUATION INDICATOR
642 643 644 645 646 647 648 649 650 651
    if (hsiDockWidget)
    {
        HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
        if (hsi)
        {
            hsi->start();
            addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
            hsiDockWidget->show();
        }
    }
lm's avatar
lm committed
652 653

    // WAYPOINT LIST
654 655 656 657 658
    if (waypointsDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
        waypointsDockWidget->show();
    }
lm's avatar
lm committed
659 660

    // DEBUG CONSOLE
661 662 663 664 665
    if (debugConsoleDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, debugConsoleDockWidget);
        debugConsoleDockWidget->show();
    }
lm's avatar
lm committed
666 667

    // ONBOARD PARAMETERS
668 669 670 671 672
    if (parametersDockWidget)
    {
        addDockWidget(Qt::RightDockWidgetArea, parametersDockWidget);
        parametersDockWidget->show();
    }
lm's avatar
lm committed
673 674 675 676 677 678 679 680 681

    this->show();
}

void MainWindow::loadPixhawkView()
{
    clearView();
    // Engineer view, used in EMAV2009

682
#ifdef QGC_OSG_ENABLED
683
    // 3D map
684
    if (_3DWidget)
685 686 687 688
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
689
            //map3DWidget->setActive(true);
690
            centerStack->setCurrentWidget(_3DWidget);
691 692
        }
    }
693
#endif
lm's avatar
lm committed
694 695

    // UAS CONTROL
696 697 698 699 700
    if (controlDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
        controlDockWidget->show();
    }
lm's avatar
lm committed
701

702 703 704 705 706 707 708 709 710 711 712 713
    // HORIZONTAL SITUATION INDICATOR
    if (hsiDockWidget)
    {
        HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
        if (hsi)
        {
            hsi->start();
            addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
            hsiDockWidget->show();
        }
    }

lm's avatar
lm committed
714
    // UAS LIST
715 716 717 718 719
    if (listDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
        listDockWidget->show();
    }
lm's avatar
lm committed
720 721

    // UAS STATUS
722 723 724 725 726
    if (infoDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget);
        infoDockWidget->show();
    }
lm's avatar
lm committed
727 728

    // WAYPOINT LIST
729 730 731 732 733
    if (waypointsDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
        waypointsDockWidget->show();
    }
lm's avatar
lm committed
734 735

    // DEBUG CONSOLE
736 737 738 739 740
    if (debugConsoleDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, debugConsoleDockWidget);
        debugConsoleDockWidget->show();
    }
lm's avatar
lm committed
741 742

    // ONBOARD PARAMETERS
743 744 745 746 747
    if (parametersDockWidget)
    {
        addDockWidget(Qt::RightDockWidgetArea, parametersDockWidget);
        parametersDockWidget->show();
    }
lm's avatar
lm committed
748 749 750 751

    this->show();
}

752 753 754
void MainWindow::loadDataView()
{
    clearView();
755 756 757 758 759 760 761 762

    // DATAPLOT
    if (dataplotWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
            centerStack->setCurrentWidget(dataplotWidget);
    }
763 764
}

765 766 767
void MainWindow::loadDataView(QString fileName)
{
    clearView();
pixhawk's avatar
pixhawk committed
768

769 770 771 772 773 774 775 776 777 778
    // DATAPLOT
    if (dataplotWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
            centerStack->setCurrentWidget(dataplotWidget);
            dataplotWidget->loadFile(fileName);
        }
    }
779 780
}

pixhawk's avatar
pixhawk committed
781
void MainWindow::loadPilotView()
pixhawk's avatar
pixhawk committed
782 783 784 785
{
    clearView();

    // HEAD UP DISPLAY
786 787 788 789 790 791 792 793 794
    if (hudWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
            centerStack->setCurrentWidget(hudWidget);
            hudWidget->start();
        }
    }
pixhawk's avatar
pixhawk committed
795 796

    //connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), pfd, SLOT(setActiveUAS(UASInterface*)));
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817
    if (headDown1DockWidget)
    {
        HDDisplay *hdd = dynamic_cast<HDDisplay*>(headDown1DockWidget->widget());
        if (hdd)
        {
            addDockWidget(Qt::RightDockWidgetArea, headDown1DockWidget);
            headDown1DockWidget->show();
            hdd->start();
        }
        
    }
    if (headDown2DockWidget)
    {
        HDDisplay *hdd = dynamic_cast<HDDisplay*>(headDown2DockWidget->widget());
        if (hdd)
        {
            addDockWidget(Qt::RightDockWidgetArea, headDown2DockWidget);
            headDown2DockWidget->show();
            hdd->start();
        }
    }
pixhawk's avatar
pixhawk committed
818

pixhawk's avatar
pixhawk committed
819 820 821
    this->show();
}

pixhawk's avatar
pixhawk committed
822
void MainWindow::loadOperatorView()
pixhawk's avatar
pixhawk committed
823 824 825
{
    clearView();

826
    // MAP
827 828 829 830 831 832 833 834
    if (mapWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
            centerStack->setCurrentWidget(mapWidget);
        }
    }
pixhawk's avatar
pixhawk committed
835 836

    // UAS CONTROL
837 838 839 840 841
    if (controlDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
        controlDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
842 843

    // UAS LIST
844 845 846 847 848
    if (listDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
        listDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
849 850

    // UAS STATUS
851 852 853 854 855
    if (infoDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget);
        infoDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
856 857

    // WAYPOINT LIST
858 859 860 861 862
    if (waypointsDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
        waypointsDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
863

lm's avatar
lm committed
864
    // HORIZONTAL SITUATION INDICATOR
865 866 867 868 869 870 871 872 873 874
    if (hsiDockWidget)
    {
        HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
        if (hsi)
        {
            addDockWidget(Qt::BottomDockWidgetArea, hsiDockWidget);
            hsiDockWidget->show();
            hsi->start();
        }
    }
pixhawk's avatar
pixhawk committed
875 876

    // OBJECT DETECTION
877 878 879 880 881
    if (detectionDockWidget)
    {
        addDockWidget(Qt::RightDockWidgetArea, detectionDockWidget);
        detectionDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
882

pixhawk's avatar
pixhawk committed
883
    // PROCESS CONTROL
884 885 886 887 888 889
    if (watchdogControlDockWidget)
    {
        addDockWidget(Qt::RightDockWidgetArea, watchdogControlDockWidget);
        watchdogControlDockWidget->show();
    }

pixhawk's avatar
pixhawk committed
890 891 892
    this->show();
}

893 894 895 896 897
void MainWindow::loadGlobalOperatorView()
{
    clearView();

    // MAP
898 899 900 901 902 903 904 905
    if (mapWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
            centerStack->setCurrentWidget(mapWidget);
        }
    }
906 907

    // UAS CONTROL
908 909 910 911 912
    if (controlDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
        controlDockWidget->show();
    }
913 914

    // UAS LIST
915 916 917 918 919
    if (listDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
        listDockWidget->show();
    }
920 921

    // UAS STATUS
922 923 924 925 926
    if (infoDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget);
        infoDockWidget->show();
    }
927 928

    // WAYPOINT LIST
929 930 931 932 933
    if (waypointsDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
        waypointsDockWidget->show();
    }
934

935 936 937 938 939 940 941 942 943 944 945
//    // HORIZONTAL SITUATION INDICATOR
//    if (hsiDockWidget)
//    {
//        HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
//        if (hsi)
//        {
//            addDockWidget(Qt::BottomDockWidgetArea, hsiDockWidget);
//            hsiDockWidget->show();
//            hsi->start();
//        }
//    }
946 947

    // PROCESS CONTROL
948 949 950 951 952
    if (watchdogControlDockWidget)
    {
        addDockWidget(Qt::RightDockWidgetArea, watchdogControlDockWidget);
        watchdogControlDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
953

954 955 956 957 958 959
    // HEAD UP DISPLAY
    if (headUpDockWidget)
    {
        addDockWidget(Qt::RightDockWidgetArea, headUpDockWidget);
        // FIXME Replace with default ->show() call
        HUD* hud = dynamic_cast<HUD*>(headUpDockWidget->widget());
pixhawk's avatar
pixhawk committed
960

961 962 963 964 965 966
        if (hud)
        {
            headUpDockWidget->show();
            hud->start();
        }
    }
pixhawk's avatar
pixhawk committed
967 968 969

}

970 971
void MainWindow::load3DMapView()
{
972
        #ifdef QGC_OSGEARTH_ENABLED
973 974 975
            clearView();

            // 3D map
976
            if (_3DMapWidget)
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
            {
                QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
                if (centerStack)
                {
                    //map3DWidget->setActive(true);
                    centerStack->setCurrentWidget(_3DMapWidget);
                }
            }

            // UAS CONTROL
            if (controlDockWidget)
            {
                addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
                controlDockWidget->show();
            }

            // UAS LIST
            if (listDockWidget)
            {
                addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
                listDockWidget->show();
            }

            // WAYPOINT LIST
            if (waypointsDockWidget)
            {
                addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
                waypointsDockWidget->show();
            }

            // HORIZONTAL SITUATION INDICATOR
            if (hsiDockWidget)
            {
                HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
                if (hsi)
                {
                    hsi->start();
                    addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
                    hsiDockWidget->show();
                }
            }
#endif
            this->show();

        }


1024
void MainWindow::load3DView()
pixhawk's avatar
pixhawk committed
1025
{
1026
        #ifdef QGC_OSG_ENABLED
1027
            clearView();
pixhawk's avatar
pixhawk committed
1028

1029
            // 3D map
1030
            if (_3DWidget)
1031 1032 1033 1034 1035
            {
                QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
                if (centerStack)
                {
                    //map3DWidget->setActive(true);
1036
                    centerStack->setCurrentWidget(_3DWidget);
1037 1038
                }
            }
pixhawk's avatar
pixhawk committed
1039

1040 1041 1042 1043 1044 1045
            // UAS CONTROL
            if (controlDockWidget)
            {
                addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
                controlDockWidget->show();
            }
pixhawk's avatar
pixhawk committed
1046

1047 1048 1049 1050 1051 1052
            // UAS LIST
            if (listDockWidget)
            {
                addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
                listDockWidget->show();
            }
1053

1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
            // WAYPOINT LIST
            if (waypointsDockWidget)
            {
                addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
                waypointsDockWidget->show();
            }

            // HORIZONTAL SITUATION INDICATOR
            if (hsiDockWidget)
            {
                HSIDisplay* hsi = dynamic_cast<HSIDisplay*>( hsiDockWidget->widget() );
                if (hsi)
                {
                    hsi->start();
                    addDockWidget(Qt::LeftDockWidgetArea, hsiDockWidget);
                    hsiDockWidget->show();
                }
            }
1072
#endif
1073
            this->show();
1074

1075
        }
pixhawk's avatar
pixhawk committed
1076

pixhawk's avatar
pixhawk committed
1077
void MainWindow::loadEngineerView()
pixhawk's avatar
pixhawk committed
1078 1079 1080 1081 1082
{
    clearView();
    // Engineer view, used in EMAV2009

    // LINE CHART
1083 1084 1085 1086 1087 1088 1089 1090 1091
    if (linechartWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
            linechartWidget->setActive(true);
            centerStack->setCurrentWidget(linechartWidget);
        }
    }
pixhawk's avatar
pixhawk committed
1092 1093

    // UAS CONTROL
1094 1095 1096 1097 1098
    if (controlDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
        controlDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
1099 1100

    // UAS LIST
1101 1102 1103 1104 1105
    if (listDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
        listDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
1106 1107

    // UAS STATUS
1108 1109 1110 1111 1112
    if (infoDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget);
        infoDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
1113

lm's avatar
lm committed
1114
    // WAYPOINT LIST
1115 1116 1117 1118 1119
    if (waypointsDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
        waypointsDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
1120 1121

    // DEBUG CONSOLE
1122 1123 1124 1125 1126
    if (debugConsoleDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, debugConsoleDockWidget);
        debugConsoleDockWidget->show();
    }
pixhawk's avatar
pixhawk committed
1127

lm's avatar
lm committed
1128
    // ONBOARD PARAMETERS
1129 1130 1131 1132 1133
    if (parametersDockWidget)
    {
        addDockWidget(Qt::RightDockWidgetArea, parametersDockWidget);
        parametersDockWidget->show();
    }
lm's avatar
lm committed
1134

1135 1136 1137 1138 1139 1140 1141
    // RADIO CONTROL VIEW
    if (rcViewDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, rcViewDockWidget);
        rcViewDockWidget->show();
    }

pixhawk's avatar
pixhawk committed
1142 1143 1144
    this->show();
}

1145 1146 1147
void MainWindow::loadMAVLinkView()
{
    clearView();
1148 1149 1150 1151 1152 1153 1154 1155 1156 1157

    if (protocolWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
            centerStack->setCurrentWidget(protocolWidget);
        }
    }

1158
    this->show();
1159 1160
}

1161 1162
void MainWindow::loadAllView()
{
1163 1164
    clearView();

1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185
    if (headDown1DockWidget)
    {
        HDDisplay *hdd = dynamic_cast<HDDisplay*>(headDown1DockWidget->widget());
        if (hdd)
        {
            addDockWidget(Qt::RightDockWidgetArea, headDown1DockWidget);
            headDown1DockWidget->show();
            hdd->start();
        }
        
    }
    if (headDown2DockWidget)
    {
        HDDisplay *hdd = dynamic_cast<HDDisplay*>(headDown2DockWidget->widget());
        if (hdd)
        {
            addDockWidget(Qt::RightDockWidgetArea, headDown2DockWidget);
            headDown2DockWidget->show();
            hdd->start();
        }
    }
1186 1187

    // UAS CONTROL
1188 1189 1190 1191 1192
    if (controlDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, controlDockWidget);
        controlDockWidget->show();
    }
1193 1194

    // UAS LIST
1195 1196 1197 1198 1199
    if (listDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, listDockWidget);
        listDockWidget->show();
    }
1200 1201

    // UAS STATUS
1202 1203 1204 1205 1206
    if (infoDockWidget)
    {
        addDockWidget(Qt::LeftDockWidgetArea, infoDockWidget);
        infoDockWidget->show();
    }
1207 1208

    // WAYPOINT LIST
1209 1210 1211 1212 1213
    if (waypointsDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, waypointsDockWidget);
        waypointsDockWidget->show();
    }
1214 1215

    // DEBUG CONSOLE
1216 1217 1218 1219 1220
    if (debugConsoleDockWidget)
    {
        addDockWidget(Qt::BottomDockWidgetArea, debugConsoleDockWidget);
        debugConsoleDockWidget->show();
    }
1221 1222

    // OBJECT DETECTION
1223 1224
    if (detectionDockWidget)
    {
pixhawk's avatar
pixhawk committed
1225 1226
        addDockWidget(Qt::RightDockWidgetArea, detectionDockWidget);
        detectionDockWidget->show();
1227
    }
1228 1229

    // LINE CHART
1230 1231 1232 1233 1234 1235 1236 1237 1238
    if (linechartWidget)
    {
        QStackedWidget *centerStack = dynamic_cast<QStackedWidget*>(centralWidget());
        if (centerStack)
        {
            linechartWidget->setActive(true);
            centerStack->setCurrentWidget(linechartWidget);
        }
    }
1239 1240

    // ONBOARD PARAMETERS
1241 1242 1243 1244 1245
    if (parametersDockWidget)
    {
        addDockWidget(Qt::RightDockWidgetArea, parametersDockWidget);
        parametersDockWidget->show();
    }
1246 1247

    this->show();
1248 1249
}

pixhawk's avatar
pixhawk committed
1250
void MainWindow::loadWidgets()
pixhawk's avatar
pixhawk committed
1251
{
1252 1253
    //loadOperatorView();
    loadEngineerView();
pixhawk's avatar
pixhawk committed
1254 1255
    //loadPilotView();
}