Skip to content
MainWindow.cc 35.2 KiB
Newer Older
pixhawk's avatar
pixhawk committed
/*=====================================================================

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

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

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

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

    QGROUNDCONTROL is distributed in the hope that it will be useful,
pixhawk's avatar
pixhawk committed
    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
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
pixhawk's avatar
pixhawk committed

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

/**
 * @file
 *   @brief Implementation of class MainWindow
 *   @author Lorenz Meier <mail@qgroundcontrol.org>
pixhawk's avatar
pixhawk committed
 */

#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
#include "GAudioOutput.h"
#ifdef QGC_OSG_ENABLED
#include "Q3DWidgetFactory.h"
pixhawk's avatar
pixhawk committed

lm's avatar
lm committed
// FIXME Move
#include "PxQuadMAV.h"
#include "SlugsMAV.h"

pixhawk's avatar
pixhawk committed

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

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

    buildWidgets();

    connectWidgets();

    arrangeCenterStack();

    configureWindowName();
pixhawk's avatar
pixhawk committed

    // Add status bar
    //setStatusBar(createStatusBar());
pixhawk's avatar
pixhawk committed

    // Set the application style (not the same as a style sheet)
    // Set the style to Plastique
    qApp->setStyle("plastique");
pixhawk's avatar
pixhawk committed
    // Set style sheet as last step
    reloadStylesheet();


    // Create actions
    connectActions();

    // Load widgets and show application windowa
    loadWidgets();

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

pixhawk's avatar
pixhawk committed
MainWindow::~MainWindow()
pixhawk's avatar
pixhawk committed
{
    delete statusBar;
    statusBar = NULL;
}

pixhawk's avatar
pixhawk committed
    //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");
pixhawk's avatar
pixhawk committed
    //FIXME: memory of acceptList2 will never be freed again
    QStringList* acceptList2 = new QStringList();
    acceptList2->append("Battery");
    acceptList2->append("Pressure");
pixhawk's avatar
pixhawk committed
    //TODO:  move protocol outside UI
    mavlink     = new MAVLinkProtocol();
pixhawk's avatar
pixhawk committed
    // Center widgets
    linechartWidget   = new Linecharts(this);
    hudWidget         = new HUD(320, 240, this);
pixhawk's avatar
pixhawk committed
    mapWidget         = new MapWidget(this);
    protocolWidget    = new XMLCommProtocolWidget(this);
    dataplotWidget    = new QGCDataPlot2D(this);
    _3DWidget         = Q3DWidgetFactory::get("PIXHAWK");
#ifdef QGC_OSGEARTH_ENABLED
    _3DMapWidget = Q3DWidgetFactory::get("MAP3D");
#endif

pixhawk's avatar
pixhawk committed
    // Dock widgets
    controlDockWidget = new QDockWidget(tr("Control"), this);
    controlDockWidget->setWidget( new UASControlWidget(this) );
pixhawk's avatar
pixhawk committed
    listDockWidget = new QDockWidget(tr("Unmanned Systems"), this);
    listDockWidget->setWidget( new UASListWidget(this) );
pixhawk's avatar
pixhawk committed
    waypointsDockWidget = new QDockWidget(tr("Waypoint List"), this);
    waypointsDockWidget->setWidget( new WaypointList(this, NULL) );
pixhawk's avatar
pixhawk committed
    infoDockWidget = new QDockWidget(tr("Status Details"), this);
    infoDockWidget->setWidget( new UASInfoWidget(this) );
pixhawk's avatar
pixhawk committed
    detectionDockWidget = new QDockWidget(tr("Object Recognition"), this);
    detectionDockWidget->setWidget( new ObjectDetectionView("images/patterns", this) );
pixhawk's avatar
pixhawk committed
    debugConsoleDockWidget = new QDockWidget(tr("Communication Console"), this);
    debugConsoleDockWidget->setWidget( new DebugConsole(this) );
pixhawk's avatar
pixhawk committed
    parametersDockWidget = new QDockWidget(tr("Onboard Parameters"), this);
    parametersDockWidget->setWidget( new ParameterInterface(this) );
pixhawk's avatar
pixhawk committed
    watchdogControlDockWidget = new QDockWidget(tr("Process Control"), this);
    watchdogControlDockWidget->setWidget( new WatchdogControl(this) );
pixhawk's avatar
pixhawk committed
    hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this);
    hsiDockWidget->setWidget( new HSIDisplay(this) );
pixhawk's avatar
pixhawk committed
    headDown1DockWidget = new QDockWidget(tr("Primary Flight Display"), this);
    headDown1DockWidget->setWidget( new HDDisplay(acceptList, this) );
pixhawk's avatar
pixhawk committed
    headDown2DockWidget = new QDockWidget(tr("Payload Status"), this);
    headDown2DockWidget->setWidget( new HDDisplay(acceptList2, this) );
pixhawk's avatar
pixhawk committed
    rcViewDockWidget = new QDockWidget(tr("Radio Control"), this);
    rcViewDockWidget->setWidget( new QGCRemoteControlView(this) );
    headUpDockWidget = new QDockWidget(tr("Control Indicator"), this);
    headUpDockWidget->setWidget( new HUD(320, 240, this));

pixhawk's avatar
pixhawk committed
    // Dialogue widgets
    //FIXME: free memory in destructor
    joystick    = new JoystickInput();
pixhawk's avatar
pixhawk committed
/**
 * Connect all signals and slots of the main window widgets
 */
pixhawk's avatar
pixhawk committed
    if (linechartWidget)
    {
        connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)),
                linechartWidget, SLOT(addSystem(UASInterface*)));
Loading
Loading full blame...