MainWindow.cc 26.4 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"
pixhawk's avatar
pixhawk committed
48

lm's avatar
lm committed
49 50 51 52
// FIXME Move
#include "PxQuadMAV.h"
#include "SlugsMAV.h"

pixhawk's avatar
pixhawk committed
53 54 55 56 57 58 59 60 61 62

#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()
**/
63 64 65
MainWindow::MainWindow(QWidget *parent) :
  QMainWindow(parent),
  settings()
pixhawk's avatar
pixhawk committed
66
{
67 68 69
    this->hide();
    this->setVisible(false);

pixhawk's avatar
pixhawk committed
70 71 72
    // Setup user interface
    ui.setupUi(this);

73 74 75 76 77 78 79
    buildWidgets();

    connectWidgets();

    arrangeCenterStack();

    configureWindowName();
pixhawk's avatar
pixhawk committed
80 81 82 83 84 85 86

    // Add status bar
    setStatusBar(createStatusBar());

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

pixhawk's avatar
pixhawk committed
88 89 90 91
    // Set style sheet as last step
    reloadStylesheet();


92 93 94
    // Create actions
    connectActions();

95
    // Load widgets and show application windowa
96 97 98 99
    loadWidgets();

    // Adjust the size
    adjustSize();
100

101 102 103 104
   // clear path create on the map
    connect(waypoints, SIGNAL(clearPathclicked()), map, SLOT(clearPath()));
    // add Waypoint widget in the WaypointList widget when mouse clicked
    connect(map, SIGNAL(captureMapCoordinateClick(QPointF)), waypoints, SLOT(addWaypointMouse(QPointF)));
105
    // it notifies that a waypoint global goes to do create
106 107
    connect(map, SIGNAL(createGlobalWP(bool,QPointF)), waypoints, SLOT(setIsWPGlobal(bool, QPointF)));
     // it notifies that a waypoint global goes to do create
108
    connect(map, SIGNAL(sendGeometryEndDrag(QPointF,int)), waypoints, SLOT(waypointGlobalChanged(QPointF,int)) );
109 110
     // it notifies that a waypoint global goes to do create and a map graphic too
    connect(waypoints, SIGNAL(createWaypointAtMap(QPointF)), map, SLOT(createWaypointGraphAtMap(QPointF)));
111

pixhawk's avatar
pixhawk committed
112 113
}

pixhawk's avatar
pixhawk committed
114
MainWindow::~MainWindow()
pixhawk's avatar
pixhawk committed
115 116 117 118 119
{
    delete statusBar;
    statusBar = NULL;
}

120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152

void MainWindow::buildWidgets()
{
  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");

  QStringList* acceptList2 = new QStringList();
  acceptList2->append("Battery");
  acceptList2->append("Pressure");


  mavlink     = new MAVLinkProtocol();
  linechart   = new Linecharts(this);
  control     = new UASControlWidget(this);
  list        = new UASListWidget(this);
  waypoints   = new WaypointList(this, NULL);
  info        = new UASInfoWidget(this);
  detection   = new ObjectDetectionView("patterns", this);
  hud         = new HUD(640, 480, this);
  debugConsole= new DebugConsole(this);
  map         = new MapWidget(this);
  protocol    = new XMLCommProtocolWidget(this);
  parameters  = new ParameterInterface(this);
  watchdogControl = new WatchdogControl(this);
  hsi         = new HSIDisplay(this);
  headDown1   = new HDDisplay(acceptList, this);
  headDown2   = new HDDisplay(acceptList2, this);
  joystick    = new JoystickInput();
153
  dataplot    = new QGCDataPlot2D();
154 155
}

156 157
void MainWindow::connectWidgets()
{
158 159
  connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), linechart, SLOT(addSystem(UASInterface*)));
  connect(UASManager::instance(), SIGNAL(activeUASSet(int)), linechart, SLOT(selectSystem(int)));
160
  connect(linechart, SIGNAL(logfileWritten(QString)), this, SLOT(loadDataView(QString)));
161
  connect(mavlink, SIGNAL(receiveLossChanged(int, float)), info, SLOT(updateSendLoss(int, float)));
162 163 164 165




166 167
}

168 169
void MainWindow::arrangeCenterStack()
{
170 171 172 173 174 175 176

  centerStack = new QStackedWidget(this);

  centerStack->addWidget(linechart);
  centerStack->addWidget(protocol);
  centerStack->addWidget(map);
  centerStack->addWidget(hud);
177
  centerStack->addWidget(dataplot);
178
  centerStack->addWidget(hsi);
179 180 181 182

  setCentralWidget(centerStack);
}

183 184
void MainWindow::configureWindowName()
{
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
  QList<QHostAddress> hostAddresses = QNetworkInterface::allAddresses();
  QString windowname = qApp->applicationName() + " " + qApp->applicationVersion();
  bool prevAddr = false;

  windowname.append(" (" + QHostInfo::localHostName() + ": ");

  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;
      }
  }

  windowname.append(")");

  setWindowTitle(windowname);

#ifndef Q_WS_MAC
  //qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png"));
#endif
}

pixhawk's avatar
pixhawk committed
211
QStatusBar* MainWindow::createStatusBar()
pixhawk's avatar
pixhawk committed
212 213 214 215 216 217 218 219
{
    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
220
void MainWindow::startVideoCapture()
pixhawk's avatar
pixhawk committed
221 222 223 224 225 226 227 228 229 230 231
{
    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);
232 233 234
    //videoTimer->setInterval(40);
    //connect(videoTimer, SIGNAL(timeout()), this, SLOT(saveScreen()));
    //videoTimer->stop();
pixhawk's avatar
pixhawk committed
235 236
}

pixhawk's avatar
pixhawk committed
237
void MainWindow::stopVideoCapture()
pixhawk's avatar
pixhawk committed
238 239 240 241 242 243
{
    videoTimer->stop();

    // TODO Convert raw images to PNG
}

pixhawk's avatar
pixhawk committed
244
void MainWindow::saveScreen()
pixhawk's avatar
pixhawk committed
245 246 247 248 249 250 251 252 253 254
{
    QPixmap window = QPixmap::grabWindow(this->winId());
    QString format = "bmp";

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

255 256 257 258 259 260
/**
 * 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
261
void MainWindow::reloadStylesheet()
pixhawk's avatar
pixhawk committed
262 263
{
    // Load style sheet
264 265 266 267 268
    QFile* styleSheet = new QFile(QCoreApplication::applicationDirPath() + "/qgroundcontrol.css");
    if (!styleSheet->exists())
    {
        styleSheet = new QFile(":/images/style-mission.css");
    }
269 270
    if (styleSheet->open(QIODevice::ReadOnly | QIODevice::Text))
    {
271 272
        QString style = QString(styleSheet->readAll());
        style.replace("ICONDIR", QCoreApplication::applicationDirPath()+ "/images/");
pixhawk's avatar
pixhawk committed
273
        qApp->setStyleSheet(style);
274 275 276
    }
    else
    {
277
        qDebug() << "Style not set:" << styleSheet->fileName() << "opened: " << styleSheet->isOpen();
pixhawk's avatar
pixhawk committed
278
    }
279
    delete styleSheet;
pixhawk's avatar
pixhawk committed
280 281
}

pixhawk's avatar
pixhawk committed
282
void MainWindow::showStatusMessage(const QString& status, int timeout)
pixhawk's avatar
pixhawk committed
283 284 285 286
{
    statusBar->showMessage(status, timeout);
}

287
void MainWindow::showStatusMessage(const QString& status)
pixhawk's avatar
pixhawk committed
288
{
289
    statusBar->showMessage(status, 5);
pixhawk's avatar
pixhawk committed
290 291 292 293 294 295
}

/**
* @brief Create all actions associated to the main window
*
**/
pixhawk's avatar
pixhawk committed
296
void MainWindow::connectActions()
pixhawk's avatar
pixhawk committed
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
{
    // 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()));
    connect(ui.actionSettingsView, SIGNAL(triggered()), this, SLOT(loadSettingsView()));
317
    connect(ui.actionShow_full_view, SIGNAL(triggered()), this, SLOT(loadAllView()));
318
    connect(ui.actionShow_MAVLink_view, SIGNAL(triggered()), this, SLOT(loadMAVLinkView()));
319
    connect(ui.actionShow_data_analysis_view, SIGNAL(triggered()), this, SLOT(loadDataView()));
pixhawk's avatar
pixhawk committed
320
    connect(ui.actionStyleConfig, SIGNAL(triggered()), this, SLOT(reloadStylesheet()));
321
    connect(ui.actionGlobalOperatorView, SIGNAL(triggered()), this, SLOT(loadGlobalOperatorView()));
322 323 324 325
    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
326 327
    // Joystick configuration
    connect(ui.actionJoystickSettings, SIGNAL(triggered()), this, SLOT(configure()));
328 329


pixhawk's avatar
pixhawk committed
330 331
}

332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
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
374
void MainWindow::configure()
pixhawk's avatar
pixhawk committed
375 376 377 378
{
    joystickWidget = new JoystickWidget(joystick, this);
}

pixhawk's avatar
pixhawk committed
379
void MainWindow::addLink()
pixhawk's avatar
pixhawk committed
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
{
    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
395 396
void MainWindow::addLink(LinkInterface *link)
{
397
    LinkManager::instance()->addProtocol(link, mavlink);
pixhawk's avatar
pixhawk committed
398 399 400 401 402 403 404
    CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this);
    ui.menuNetwork->addAction(commWidget->getAction());

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

pixhawk's avatar
pixhawk committed
410
void MainWindow::UASCreated(UASInterface* uas)
pixhawk's avatar
pixhawk committed
411 412 413
{
    // Connect the UAS to the full user interface

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 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
    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
        connect(uas, SIGNAL(textMessageReceived(int,int,int,QString)), debugConsole, SLOT(receiveTextMessage(int,int,int,QString)));

        // Health / System status indicator
        info->addUAS(uas);

        // UAS List
        list->addUAS(uas);

        // 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
466

467
    }
pixhawk's avatar
pixhawk committed
468 469
}

470 471 472
/**
 * Clears the current view completely
 */
pixhawk's avatar
pixhawk committed
473
void MainWindow::clearView()
pixhawk's avatar
pixhawk committed
474 475 476
{ 
    // Halt HUD
    hud->stop();
477
    linechart->setActive(false);
pixhawk's avatar
pixhawk committed
478 479
    headDown1->stop();
    headDown2->stop();
lm's avatar
lm committed
480
    hsi->stop();
pixhawk's avatar
pixhawk committed
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500

    // Remove all dock widgets
    QList<QObject*> list = this->children();

    QList<QObject*>::iterator i;
    for (i = list.begin(); i != list.end(); ++i)
    {
        QDockWidget* widget = dynamic_cast<QDockWidget*>(*i);
        if (widget)
        {
            // Hide widgets
            QWidget* childWidget = dynamic_cast<QWidget*>(widget->widget());
            if (childWidget) childWidget->setVisible(false);
            // Remove dock widget
            this->removeDockWidget(widget);
            //delete widget;
        }
    }
}

lm's avatar
lm committed
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
void MainWindow::loadSlugsView()
{
    clearView();
    // Engineer view, used in EMAV2009

    // LINE CHART
    linechart->setActive(true);
    centerStack->setCurrentWidget(linechart);

    // UAS CONTROL
    QDockWidget* container1 = new QDockWidget(tr("Control"), this);
    container1->setWidget(control);
    addDockWidget(Qt::LeftDockWidgetArea, container1);

    // UAS LIST
    QDockWidget* container4 = new QDockWidget(tr("Unmanned Systems"), this);
    container4->setWidget(list);
    addDockWidget(Qt::BottomDockWidgetArea, container4);

    // UAS STATUS
    QDockWidget* container3 = new QDockWidget(tr("Status Details"), this);
    container3->setWidget(info);
    addDockWidget(Qt::LeftDockWidgetArea, container3);

    // HORIZONTAL SITUATION INDICATOR
    QDockWidget* container6 = new QDockWidget(tr("Horizontal Situation Indicator"), this);
    container6->setWidget(hsi);
    hsi->start();
    addDockWidget(Qt::LeftDockWidgetArea, container6);

    // WAYPOINT LIST
    QDockWidget* container5 = new QDockWidget(tr("Waypoint List"), this);
    container5->setWidget(waypoints);
    addDockWidget(Qt::BottomDockWidgetArea, container5);

    // DEBUG CONSOLE
    QDockWidget* container7 = new QDockWidget(tr("Communication Console"), this);
    container7->setWidget(debugConsole);
    addDockWidget(Qt::BottomDockWidgetArea, container7);

    // ONBOARD PARAMETERS
    QDockWidget* containerParams = new QDockWidget(tr("Onboard Parameters"), this);
    containerParams->setWidget(parameters);
    addDockWidget(Qt::RightDockWidgetArea, containerParams);


    this->show();
}

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

    // LINE CHART
    linechart->setActive(true);
    centerStack->setCurrentWidget(linechart);

    // UAS CONTROL
    QDockWidget* container1 = new QDockWidget(tr("Control"), this);
    container1->setWidget(control);
    addDockWidget(Qt::LeftDockWidgetArea, container1);

    // UAS LIST
    QDockWidget* container4 = new QDockWidget(tr("Unmanned Systems"), this);
    container4->setWidget(list);
    addDockWidget(Qt::BottomDockWidgetArea, container4);

    // UAS STATUS
    QDockWidget* container3 = new QDockWidget(tr("Status Details"), this);
    container3->setWidget(info);
    addDockWidget(Qt::LeftDockWidgetArea, container3);

    // WAYPOINT LIST
    QDockWidget* container5 = new QDockWidget(tr("Waypoint List"), this);
    container5->setWidget(waypoints);
    addDockWidget(Qt::BottomDockWidgetArea, container5);

    // DEBUG CONSOLE
    QDockWidget* container7 = new QDockWidget(tr("Communication Console"), this);
    container7->setWidget(debugConsole);
    addDockWidget(Qt::BottomDockWidgetArea, container7);

    // ONBOARD PARAMETERS
    QDockWidget* containerParams = new QDockWidget(tr("Onboard Parameters"), this);
    containerParams->setWidget(parameters);
    addDockWidget(Qt::RightDockWidgetArea, containerParams);


    this->show();
}

593 594 595 596 597 598
void MainWindow::loadDataView()
{
    clearView();
    centerStack->setCurrentWidget(dataplot);
}

599 600 601 602 603 604 605
void MainWindow::loadDataView(QString fileName)
{
    clearView();
    centerStack->setCurrentWidget(dataplot);
    dataplot->loadFile(fileName);
}

pixhawk's avatar
pixhawk committed
606
void MainWindow::loadPilotView()
pixhawk's avatar
pixhawk committed
607 608 609 610 611 612 613 614
{
    clearView();

    // HEAD UP DISPLAY
    centerStack->setCurrentWidget(hud);
    hud->start();

    //connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), pfd, SLOT(setActiveUAS(UASInterface*)));
pixhawk's avatar
pixhawk committed
615
    QDockWidget* container1 = new QDockWidget(tr("Primary Flight Display"), this);
pixhawk's avatar
pixhawk committed
616 617 618
    container1->setWidget(headDown1);
    addDockWidget(Qt::RightDockWidgetArea, container1);

pixhawk's avatar
pixhawk committed
619
    QDockWidget* container2 = new QDockWidget(tr("Payload Status"), this);
pixhawk's avatar
pixhawk committed
620 621
    container2->setWidget(headDown2);
    addDockWidget(Qt::RightDockWidgetArea, container2);
pixhawk's avatar
pixhawk committed
622 623 624 625

    headDown1->start();
    headDown2->start();

pixhawk's avatar
pixhawk committed
626 627 628
    this->show();
}

pixhawk's avatar
pixhawk committed
629
void MainWindow::loadOperatorView()
pixhawk's avatar
pixhawk committed
630 631 632
{
    clearView();

633 634 635 636 637

    centerStack->setCurrentWidget(hsi);
    hsi->start();


pixhawk's avatar
pixhawk committed
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658

    // UAS CONTROL
    QDockWidget* container1 = new QDockWidget(tr("Control"), this);
    container1->setWidget(control);
    addDockWidget(Qt::LeftDockWidgetArea, container1);

    // UAS LIST
    QDockWidget* container4 = new QDockWidget(tr("Unmanned Systems"), this);
    container4->setWidget(list);
    addDockWidget(Qt::BottomDockWidgetArea, container4);

    // UAS STATUS
    QDockWidget* container3 = new QDockWidget(tr("Status Details"), this);
    container3->setWidget(info);
    addDockWidget(Qt::LeftDockWidgetArea, container3);

    // WAYPOINT LIST
    QDockWidget* container5 = new QDockWidget(tr("Waypoint List"), this);
    container5->setWidget(waypoints);
    addDockWidget(Qt::BottomDockWidgetArea, container5);

lm's avatar
lm committed
659
    // HORIZONTAL SITUATION INDICATOR
660 661 662 663
//    QDockWidget* container7 = new QDockWidget(tr("Horizontal Situation Indicator"), this);
//    container7->setWidget(hsi);
//    hsi->start();
//    addDockWidget(Qt::BottomDockWidgetArea, container7);
pixhawk's avatar
pixhawk committed
664 665 666 667 668 669

    // OBJECT DETECTION
    QDockWidget* container6 = new QDockWidget(tr("Object Recognition"), this);
    container6->setWidget(detection);
    addDockWidget(Qt::RightDockWidgetArea, container6);

pixhawk's avatar
pixhawk committed
670 671 672 673
    // PROCESS CONTROL
    QDockWidget* pControl = new QDockWidget(tr("Process Control"), this);
    pControl->setWidget(watchdogControl);
    addDockWidget(Qt::RightDockWidgetArea, pControl);
pixhawk's avatar
pixhawk committed
674 675 676
    this->show();
}

677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
void MainWindow::loadGlobalOperatorView()
{
    clearView();

    // MAP
   centerStack->setCurrentWidget(map);

    // UAS CONTROL
    QDockWidget* container1 = new QDockWidget(tr("Control"), this);
    container1->setWidget(control);
    addDockWidget(Qt::LeftDockWidgetArea, container1);

    // UAS LIST
    QDockWidget* container4 = new QDockWidget(tr("Unmanned Systems"), this);
    container4->setWidget(list);
    addDockWidget(Qt::BottomDockWidgetArea, container4);

    // UAS STATUS
    QDockWidget* container3 = new QDockWidget(tr("Status Details"), this);
    container3->setWidget(info);
    addDockWidget(Qt::LeftDockWidgetArea, container3);

    // WAYPOINT LIST
    QDockWidget* container5 = new QDockWidget(tr("Waypoint List"), this);
    container5->setWidget(waypoints);
    addDockWidget(Qt::BottomDockWidgetArea, container5);

    // // HEAD UP DISPLAY
    QDockWidget* container6 = new QDockWidget(tr("Control Indicator"), this);
    container6->setWidget(hud);
    hud->start();
    addDockWidget(Qt::RightDockWidgetArea, container6);

//    // OBJECT DETECTION
//    QDockWidget* container6 = new QDockWidget(tr("Object Recognition"), this);
//    container6->setWidget(detection);
//    addDockWidget(Qt::RightDockWidgetArea, container6);

    // PROCESS CONTROL
    QDockWidget* pControl = new QDockWidget(tr("Process Control"), this);
    pControl->setWidget(watchdogControl);
    addDockWidget(Qt::BottomDockWidgetArea, pControl);
    this->show();
}
pixhawk's avatar
pixhawk committed
721
void MainWindow::loadSettingsView()
pixhawk's avatar
pixhawk committed
722 723 724 725
{
    clearView();

    // LINE CHART
726
    linechart->setActive(true);
pixhawk's avatar
pixhawk committed
727 728
    centerStack->setCurrentWidget(linechart);

729
    /*
pixhawk's avatar
pixhawk committed
730 731 732
    // COMM XML
    QDockWidget* container1 = new QDockWidget(tr("MAVLink XML to C Code Generator"), this);
    container1->setWidget(protocol);
733
    addDockWidget(Qt::LeftDockWidgetArea, container1);*/
pixhawk's avatar
pixhawk committed
734 735 736 737 738

    // ONBOARD PARAMETERS
    QDockWidget* container6 = new QDockWidget(tr("Onboard Parameters"), this);
    container6->setWidget(parameters);
    addDockWidget(Qt::RightDockWidgetArea, container6);
739
    this->show();
pixhawk's avatar
pixhawk committed
740 741
}

pixhawk's avatar
pixhawk committed
742
void MainWindow::loadEngineerView()
pixhawk's avatar
pixhawk committed
743 744 745 746 747
{
    clearView();
    // Engineer view, used in EMAV2009

    // LINE CHART
748
    linechart->setActive(true);
pixhawk's avatar
pixhawk committed
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765
    centerStack->setCurrentWidget(linechart);

    // UAS CONTROL
    QDockWidget* container1 = new QDockWidget(tr("Control"), this);
    container1->setWidget(control);
    addDockWidget(Qt::LeftDockWidgetArea, container1);

    // UAS LIST
    QDockWidget* container4 = new QDockWidget(tr("Unmanned Systems"), this);
    container4->setWidget(list);
    addDockWidget(Qt::BottomDockWidgetArea, container4);

    // UAS STATUS
    QDockWidget* container3 = new QDockWidget(tr("Status Details"), this);
    container3->setWidget(info);
    addDockWidget(Qt::LeftDockWidgetArea, container3);

lm's avatar
lm committed
766 767 768 769
    // WAYPOINT LIST
    QDockWidget* container5 = new QDockWidget(tr("Waypoint List"), this);
    container5->setWidget(waypoints);
    addDockWidget(Qt::BottomDockWidgetArea, container5);
pixhawk's avatar
pixhawk committed
770 771 772 773 774 775

    // DEBUG CONSOLE
    QDockWidget* container7 = new QDockWidget(tr("Communication Console"), this);
    container7->setWidget(debugConsole);
    addDockWidget(Qt::BottomDockWidgetArea, container7);

lm's avatar
lm committed
776 777 778 779 780 781
    // ONBOARD PARAMETERS
    QDockWidget* containerParams = new QDockWidget(tr("Onboard Parameters"), this);
    containerParams->setWidget(parameters);
    addDockWidget(Qt::RightDockWidgetArea, containerParams);


pixhawk's avatar
pixhawk committed
782 783 784
    this->show();
}

785 786 787 788
void MainWindow::loadMAVLinkView()
{
    clearView();
    centerStack->setCurrentWidget(protocol);
789
    this->show();
790 791
}

792 793
void MainWindow::loadAllView()
{
794 795 796 797 798 799 800 801 802
    clearView();

    QDockWidget* containerPFD = new QDockWidget(tr("Primary Flight Display"), this);
    containerPFD->setWidget(headDown1);
    addDockWidget(Qt::RightDockWidgetArea, containerPFD);

    QDockWidget* containerPayload = new QDockWidget(tr("Payload Status"), this);
    containerPayload->setWidget(headDown2);
    addDockWidget(Qt::RightDockWidgetArea, containerPayload);
803

804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846
    headDown1->start();
    headDown2->start();

    // UAS CONTROL
    QDockWidget* containerControl = new QDockWidget(tr("Control"), this);
    containerControl->setWidget(control);
    addDockWidget(Qt::LeftDockWidgetArea, containerControl);

    // UAS LIST
    QDockWidget* containerUASList = new QDockWidget(tr("Unmanned Systems"), this);
    containerUASList->setWidget(list);
    addDockWidget(Qt::BottomDockWidgetArea, containerUASList);

    // UAS STATUS
    QDockWidget* containerStatus = new QDockWidget(tr("Status Details"), this);
    containerStatus->setWidget(info);
    addDockWidget(Qt::LeftDockWidgetArea, containerStatus);

    // WAYPOINT LIST
    QDockWidget* containerWaypoints = new QDockWidget(tr("Waypoint List"), this);
    containerWaypoints->setWidget(waypoints);
    addDockWidget(Qt::BottomDockWidgetArea, containerWaypoints);

    // DEBUG CONSOLE
    QDockWidget* containerComm = new QDockWidget(tr("Communication Console"), this);
    containerComm->setWidget(debugConsole);
    addDockWidget(Qt::BottomDockWidgetArea, containerComm);

    // OBJECT DETECTION
    QDockWidget* containerObjRec = new QDockWidget(tr("Object Recognition"), this);
    containerObjRec->setWidget(detection);
    addDockWidget(Qt::RightDockWidgetArea, containerObjRec);

    // LINE CHART
    linechart->setActive(true);
    centerStack->setCurrentWidget(linechart);

    // ONBOARD PARAMETERS
    QDockWidget* containerParams = new QDockWidget(tr("Onboard Parameters"), this);
    containerParams->setWidget(parameters);
    addDockWidget(Qt::RightDockWidgetArea, containerParams);

    this->show();
847 848
}

pixhawk's avatar
pixhawk committed
849
void MainWindow::loadWidgets()
pixhawk's avatar
pixhawk committed
850
{
851 852
    //loadOperatorView();
    loadEngineerView();
pixhawk's avatar
pixhawk committed
853 854
    //loadPilotView();
}