Commit 55966675 authored by Don Gagne's avatar Don Gagne

Make HIL Dock Widget a normal widget

parent bcc8a2ab
......@@ -168,6 +168,7 @@ FORMS += \
src/ui/MainWindow.ui \
src/ui/mavlink/QGCMAVLinkMessageSender.ui \
src/ui/MAVLinkSettingsWidget.ui \
src/ui/MultiVehicleDockWidget.ui \
src/ui/QGCCommConfiguration.ui \
src/ui/QGCDataPlot2D.ui \
src/ui/QGCLinkConfiguration.ui \
......@@ -265,6 +266,7 @@ HEADERS += \
src/ui/mavlink/QGCMAVLinkMessageSender.h \
src/ui/MAVLinkDecoder.h \
src/ui/MAVLinkSettingsWidget.h \
src/ui/MultiVehicleDockWidget.h \
src/ui/QGCCommConfiguration.h \
src/ui/QGCDataPlot2D.h \
src/ui/QGCLinkConfiguration.h \
......@@ -308,6 +310,7 @@ HEADERS += \
src/comm/QGCJSBSimLink.h \
src/comm/QGCXPlaneLink.h \
src/ui/CameraView.h \
src/ui/HILDockWidget.h \
src/ui/QGCHilConfiguration.h \
src/ui/QGCHilFlightGearConfiguration.h \
src/ui/QGCHilJSBSimConfiguration.h \
......@@ -370,6 +373,7 @@ SOURCES += \
src/ui/mavlink/QGCMAVLinkMessageSender.cc \
src/ui/MAVLinkDecoder.cc \
src/ui/MAVLinkSettingsWidget.cc \
src/ui/MultiVehicleDockWidget.cc \
src/ui/QGCCommConfiguration.cc \
src/ui/QGCDataPlot2D.cc \
src/ui/QGCLinkConfiguration.cc \
......@@ -412,6 +416,7 @@ SOURCES += \
src/comm/QGCJSBSimLink.cc \
src/comm/QGCXPlaneLink.cc \
src/ui/CameraView.cc \
src/ui/HILDockWidget.cc \
src/ui/QGCHilConfiguration.cc \
src/ui/QGCHilFlightGearConfiguration.cc \
src/ui/QGCHilJSBSimConfiguration.cc \
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
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,
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/>.
======================================================================*/
#include "HILDockWidget.h"
#include "QGCHilConfiguration.h"
HILDockWidget::HILDockWidget(QWidget *parent)
: MultiVehicleDockWidget(parent)
{
init();
}
HILDockWidget::~HILDockWidget()
{
}
QWidget* HILDockWidget::_newVehicleWidget(Vehicle* vehicle, QWidget* parent)
{
return new QGCHilConfiguration(vehicle, parent);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
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,
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/>.
======================================================================*/
#ifndef HILDockWidget_H
#define HILDockWidget_H
#include "MultiVehicleDockWidget.h"
class HILDockWidget : public MultiVehicleDockWidget
{
Q_OBJECT
public:
explicit HILDockWidget(QWidget *parent = 0);
~HILDockWidget();
protected:
// Override from MultiVehicleDockWidget
virtual QWidget* _newVehicleWidget(Vehicle* vehicle, QWidget* parent);
};
#endif
......@@ -33,20 +33,13 @@ This file is part of the QGROUNDCONTROL project
#include <QTimer>
#include <QHostInfo>
#include <QSplashScreen>
#ifndef __mobile__
#include <QGCHilLink.h>
#include <QGCHilConfiguration.h>
#include <QGCHilFlightGearConfiguration.h>
#endif
#include <QQuickView>
#include <QDesktopWidget>
#include <QScreen>
#include <QDesktopServices>
#include "QGC.h"
#ifndef __ios__
#include "SerialLink.h"
#endif
#include "MAVLinkProtocol.h"
#include "MainWindow.h"
#include "GAudioOutput.h"
......@@ -71,6 +64,15 @@ This file is part of the QGROUNDCONTROL project
#include "CustomCommandWidget.h"
#include "HomePositionManager.h"
#include "MissionEditor.h"
#include "LogCompressor.h"
#ifndef __mobile__
#include "HILDockWidget.h"
#endif
#ifndef __ios__
#include "SerialLink.h"
#endif
#ifdef UNITTEST_BUILD
#include "QmlControls/QmlTestWidget.h"
......@@ -80,7 +82,6 @@ This file is part of the QGROUNDCONTROL project
#include "Q3DWidgetFactory.h"
#endif
#include "LogCompressor.h"
/// The key under which the Main Window settings are saved
const char* MAIN_SETTINGS_GROUP = "QGC_MAINWINDOW";
......@@ -92,6 +93,7 @@ const char* MainWindow::_uasStatusDetailsDockWidgetName = "UAS_STATUS_DETAILS_DO
const char* MainWindow::_mapViewDockWidgetName = "MAP_VIEW_DOCKWIDGET";
const char* MainWindow::_pfdDockWidgetName = "PRIMARY_FLIGHT_DISPLAY_DOCKWIDGET";
const char* MainWindow::_uasInfoViewDockWidgetName = "UAS_INFO_INFOVIEW_DOCKWIDGET";
const char* MainWindow::_hilDockWidgetName = "HIL_DOCKWIDGET";
static MainWindow* _instance = NULL; ///< @brief MainWindow singleton
......@@ -163,7 +165,7 @@ MainWindow::MainWindow(QSplashScreen* splashScreen)
#ifdef UNITTEST_BUILD
QAction* qmlTestAction = new QAction("Test QML palette and controls", NULL);
connect(qmlTestAction, &QAction::triggered, this, &MainWindow::_showQmlTestWidget);
_ui.menuTools->addAction(qmlTestAction);
_ui.menuWidgets->addAction(qmlTestAction);
#endif
// Load QML Toolbar
......@@ -267,14 +269,12 @@ MainWindow::MainWindow(QSplashScreen* splashScreen)
_ui.actionPlan->setShortcut(QApplication::translate("MainWindow", "Meta+2", 0));
_ui.actionFlight->setShortcut(QApplication::translate("MainWindow", "Meta+3", 0));
_ui.actionAnalyze->setShortcut(QApplication::translate("MainWindow", "Meta+4", 0));
_ui.actionSimulationView->setShortcut(QApplication::translate("MainWindow", "Meta+5", 0));
_ui.actionFullscreen->setShortcut(QApplication::translate("MainWindow", "Meta+Return", 0));
#else
_ui.actionSetup->setShortcut(QApplication::translate("MainWindow", "Ctrl+1", 0));
_ui.actionPlan->setShortcut(QApplication::translate("MainWindow", "Ctrl+2", 0));
_ui.actionFlight->setShortcut(QApplication::translate("MainWindow", "Ctrl+3", 0));
_ui.actionAnalyze->setShortcut(QApplication::translate("MainWindow", "Ctrl+4", 0));
_ui.actionSimulationView->setShortcut(QApplication::translate("MainWindow", "Ctrl+5", 0));
_ui.actionFullscreen->setShortcut(QApplication::translate("MainWindow", "Ctrl+Return", 0));
#endif
......@@ -341,7 +341,7 @@ void MainWindow::_createDockWidget(const QString& title, const QString& name, Qt
action->setCheckable(true);
action->setData(name);
connect(action, &QAction::triggered, this, &MainWindow::_showDockWidgetAction);
_ui.menuTools->addAction(action);
_ui.menuWidgets->addAction(action);
// Create widget
QGCDockWidget* dockWidget = new QGCDockWidget(title, action, this);
......@@ -391,6 +391,7 @@ void MainWindow::_buildCommonWidgets(void)
{ _mapViewDockWidgetName, "Map view", Qt::RightDockWidgetArea },
{ _pfdDockWidgetName, "Primary Flight Display", Qt::RightDockWidgetArea },
{ _uasInfoViewDockWidgetName, "Info View", Qt::LeftDockWidgetArea },
{ _hilDockWidgetName, "HIL Config", Qt::LeftDockWidgetArea },
};
static const size_t cDockWidgetInfo = sizeof(rgDockWidgetInfo) / sizeof(rgDockWidgetInfo[0]);
......@@ -482,6 +483,8 @@ void MainWindow::_createInnerDockWidget(const QString& widgetName)
widget = new UASInfoWidget(this);
} else if (widgetName == _pfdDockWidgetName) {
widget = new FlightDisplayWidget(this);
} else if (widgetName == _hilDockWidgetName) {
widget = new HILDockWidget(this);
} else if (widgetName == _uasInfoViewDockWidgetName) {
QGCTabbedInfoView* pInfoView = new QGCTabbedInfoView(this);
pInfoView->addSource(mavlinkDecoder);
......@@ -498,48 +501,6 @@ void MainWindow::_createInnerDockWidget(const QString& widgetName)
}
}
#ifndef __mobile__
void MainWindow::_showHILConfigurationWidgets(void)
{
Vehicle* vehicle = MultiVehicleManager::instance()->activeVehicle();
if (!vehicle) {
return;
}
UAS* mav = vehicle->uas();
Q_ASSERT(mav);
int uasId = mav->getUASID();
if (!_mapUasId2HilDockWidget.contains(uasId)) {
// Create QDockWidget
QGCDockWidget* dockWidget = new QGCDockWidget(tr("HIL Config %1").arg(uasId), NULL, this);
Q_CHECK_PTR(dockWidget);
dockWidget->setObjectName(tr("HIL_CONFIG_%1").arg(uasId));
dockWidget->setVisible (false);
// Create inner widget and set it
QWidget* widget = new QGCHilConfiguration(mav, dockWidget);
widget->setParent(dockWidget);
dockWidget->setWidget(widget);
_mapUasId2HilDockWidget[uasId] = dockWidget;
addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
}
if (_currentView == VIEW_SIMULATION) {
// HIL dock widgets only show up on simulation view
foreach (QDockWidget* dockWidget, _mapUasId2HilDockWidget) {
dockWidget->setVisible(true);
}
}
}
#endif
void MainWindow::fullScreenActionItemCallback(bool)
{
_ui.actionNormal->setChecked(false);
......@@ -650,7 +611,6 @@ void MainWindow::connectCommonActions()
QActionGroup* perspectives = new QActionGroup(_ui.menuPerspectives);
perspectives->addAction(_ui.actionAnalyze);
perspectives->addAction(_ui.actionFlight);
perspectives->addAction(_ui.actionSimulationView);
perspectives->addAction(_ui.actionPlan);
perspectives->addAction(_ui.actionSetup);
perspectives->setExclusive(true);
......@@ -666,11 +626,6 @@ void MainWindow::connectCommonActions()
_ui.actionFlight->setChecked(true);
_ui.actionFlight->activate(QAction::Trigger);
}
if (_currentView == VIEW_SIMULATION)
{
_ui.actionSimulationView->setChecked(true);
_ui.actionSimulationView->activate(QAction::Trigger);
}
if (_currentView == VIEW_MISSIONEDITOR)
{
_ui.actionPlan->setChecked(true);
......@@ -687,11 +642,9 @@ void MainWindow::connectCommonActions()
// Connect internal actions
connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleAdded, this, &MainWindow::_vehicleAdded);
connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleRemoved, this, &MainWindow::_vehicleRemoved);
// Views actions
connect(_ui.actionFlight, SIGNAL(triggered()), this, SLOT(loadFlightView()));
connect(_ui.actionSimulationView, SIGNAL(triggered()), this, SLOT(loadSimulationView()));
connect(_ui.actionAnalyze, SIGNAL(triggered()), this, SLOT(loadAnalyzeView()));
connect(_ui.actionPlan, SIGNAL(triggered()), this, SLOT(loadPlanView()));
......@@ -763,11 +716,6 @@ void MainWindow::_vehicleAdded(Vehicle* vehicle)
{
connect(vehicle->uas(), SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)), this, SIGNAL(valueChanged(int,QString,QString,QVariant,quint64)));
// HIL
#ifndef __mobile__
_showHILConfigurationWidgets();
#endif
if (!linechartWidget)
{
linechartWidget = new Linecharts(this);
......@@ -781,22 +729,9 @@ void MainWindow::_vehicleAdded(Vehicle* vehicle)
}
}
void MainWindow::_vehicleRemoved(Vehicle* vehicle)
{
int vehicleId = vehicle->id();
if (_mapUasId2HilDockWidget.contains(vehicleId)) {
_mapUasId2HilDockWidget[vehicleId]->deleteLater();
_mapUasId2HilDockWidget.remove(vehicleId);
}
}
/// Stores the state of the toolbar, status bar and widgets associated with the current view
void MainWindow::_storeCurrentViewState(void)
{
// HIL dock widgets are dynamic and are not part of the saved state
_hideAllHilDockWidgets();
#ifndef __mobile__
// Save list of visible widgets
bool firstWidget = true;
......@@ -845,12 +780,6 @@ void MainWindow::_loadCurrentViewState(void)
centerView = _missionEditorView;
break;
case VIEW_SIMULATION:
_buildSimView();
centerView = _simView;
defaultWidgets = "WAYPOINT_LIST_DOCKWIDGET,PARAMETER_INTERFACE_DOCKWIDGET,PRIMARY_FLIGHT_DISPLAY_DOCKWIDGET";
break;
default:
Q_ASSERT(false);
break;
......@@ -893,30 +822,16 @@ void MainWindow::_loadCurrentViewState(void)
restoreState(settings.value(_getWindowStateKey()).toByteArray());
}
// HIL dock widget are dynamic and don't take part in the saved window state, so this
// need to happen after we restore state
#ifndef __mobile__
_showHILConfigurationWidgets();
#endif
// There is a bug in Qt where a Canvas element inside a QQuickWidget does not
// receive update requests. Here we emit a signal for them to get repainted.
emit repaintCanvas();
}
void MainWindow::_hideAllHilDockWidgets(void)
{
foreach(QDockWidget* dockWidget, _mapUasId2HilDockWidget) {
dockWidget->setVisible(false);
}
}
void MainWindow::_hideAllDockWidgets(void)
{
foreach(QDockWidget* dockWidget, _mapName2DockWidget) {
dockWidget->setVisible(false);
}
_hideAllHilDockWidgets();
}
void MainWindow::_showDockWidgetAction(bool show)
......@@ -971,17 +886,6 @@ void MainWindow::loadFlightView()
}
}
void MainWindow::loadSimulationView()
{
if (_currentView != VIEW_SIMULATION)
{
_storeCurrentViewState();
_currentView = VIEW_SIMULATION;
_ui.actionSimulationView->setChecked(true);
_loadCurrentViewState();
}
}
/// @brief Hides the spash screen if it is currently being shown
void MainWindow::hideSplashScreen(void)
{
......
......@@ -124,7 +124,6 @@ public slots:
void loadSetupView();
void loadFlightView();
void loadSimulationView();
void loadAnalyzeView();
void loadPlanView();
......@@ -193,7 +192,7 @@ protected:
VIEW_ANALYZE, // Engineering/Analyze view mode. Used for analyzing data and modifying onboard parameters
VIEW_UNUSED3, // Unused (don't remove, or it will screw up saved settigns indices)
VIEW_FLIGHT, // Flight/Fly/Operate view mode. Used for 1st-person observation of the vehicle.
VIEW_SIMULATION, // HIL Simulation view. Useful overview of the entire system when doing hardware-in-the-loop simulations.
VIEW_UNUSED4, // Unused (don't remove, or it will screw up saved settigns indices)
VIEW_SETUP, // Setup view. Used for initializing the system for operation.
VIEW_UNUSED1, // Unused (don't remove, or it will screw up saved settigns indices)
VIEW_UNUSED2, // Unused (don't remove, or it will screw up saved settigns indices)
......@@ -261,7 +260,6 @@ private slots:
private slots:
void _vehicleAdded(Vehicle* vehicle);
void _vehicleRemoved(Vehicle* vehicle);
private:
/// Constructor is private since all creation should be through MainWindow::_create
......@@ -279,8 +277,6 @@ private:
QPointer<QWidget> _missionEditorView;
// Dock widget names
static const char* _uasControlDockWidgetName;
static const char* _uasListDockWidgetName;
static const char* _mavlinkDockWidgetName;
static const char* _customCommandWidgetName;
static const char* _filesDockWidgetName;
......@@ -288,9 +284,9 @@ private:
static const char* _mapViewDockWidgetName;
static const char* _pfdDockWidgetName;
static const char* _uasInfoViewDockWidgetName;
static const char* _hilDockWidgetName;
QMap<QString, QDockWidget*> _mapName2DockWidget;
QMap<int, QDockWidget*> _mapUasId2HilDockWidget;
QMap<QDockWidget*, QAction*> _mapDockWidget2Action;
void _buildPlanView(void);
......@@ -307,12 +303,8 @@ private:
void _createDockWidget(const QString& title, const QString& name, Qt::DockWidgetArea area, QWidget* innerWidget);
void _createInnerDockWidget(const QString& widgetName);
void _buildCommonWidgets(void);
void _hideAllHilDockWidgets(void);
void _hideAllDockWidgets(void);
void _showDockWidget(const QString &name, bool show);
#ifndef __mobile__
void _showHILConfigurationWidgets(void);
#endif
bool _autoReconnect;
bool _lowPowerMode; ///< If enabled, QGC reduces the update rates of all widgets
......
......@@ -87,24 +87,14 @@
<addaction name="separator"/>
<addaction name="actionStatusBar"/>
</widget>
<widget class="QMenu" name="menuAdvanced">
<widget class="QMenu" name="menuWidgets">
<property name="title">
<string>Advanced</string>
<string>Widgets</string>
</property>
<widget class="QMenu" name="menuTools">
<property name="title">
<string>Tool Widgets</string>
</property>
<addaction name="separator"/>
</widget>
<addaction name="actionSimulationView"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="menuTools"/>
</widget>
<addaction name="menuMGround"/>
<addaction name="menuPerspectives"/>
<addaction name="menuAdvanced"/>
<addaction name="menuWidgets"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
......@@ -226,14 +216,6 @@
<string>Advanced Mode</string>
</property>
</action>
<action name="actionSimulationView">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>HIL Simulation</string>
</property>
</action>
<action name="actionStatusBar">
<property name="checkable">
<bool>true</bool>
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
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,
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/>.
======================================================================*/
#include "MultiVehicleDockWidget.h"
#include "ui_MultiVehicleDockWidget.h"
#include "MultiVehicleManager.h"
MultiVehicleDockWidget::MultiVehicleDockWidget(QWidget *parent)
: QWidget(parent)
, _ui(new Ui::MultiVehicleDockWidget)
{
_ui->setupUi(this);
connect(MultiVehicleManager::instance(), &MultiVehicleManager::activeVehicleChanged, this, &MultiVehicleDockWidget::_activeVehicleChanged);
connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleAdded, this, &MultiVehicleDockWidget::_vehicleAdded);
connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleRemoved, this, &MultiVehicleDockWidget::_vehicleRemoved);
}
void MultiVehicleDockWidget::init(void)
{
if (MultiVehicleManager::instance()->activeVehicle()) {
_vehicleAdded(MultiVehicleManager::instance()->activeVehicle());
_activeVehicleChanged(MultiVehicleManager::instance()->activeVehicle());
}
}
MultiVehicleDockWidget::~MultiVehicleDockWidget()
{
delete _ui;
}
void MultiVehicleDockWidget::_vehicleRemoved(Vehicle* vehicle)
{
int id = vehicle->id();
if (_vehicleWidgets.contains(id)) {
_vehicleWidgets[id]->deleteLater();
_vehicleWidgets.remove(id);
}
}
void MultiVehicleDockWidget::_vehicleAdded(Vehicle* vehicle)
{
int id = vehicle->id();
if (!_vehicleWidgets.contains(id)) {
QWidget* vehicleWidget = _newVehicleWidget(vehicle, _ui->stackedWidget);
_vehicleWidgets[id] = vehicleWidget;
_ui->stackedWidget->addWidget(vehicleWidget);
}
}
void MultiVehicleDockWidget::_activeVehicleChanged(Vehicle* vehicle)
{
if (vehicle) {
int id = vehicle->id();
if (!_vehicleWidgets.contains(id)) {
_vehicleAdded(vehicle);
}
QWidget* vehicleWidget = _vehicleWidgets[id];
_ui->stackedWidget->setCurrentWidget(vehicleWidget);
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
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,
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/>.
======================================================================*/
#ifndef MultiVehicleDockWidget_H
#define MultiVehicleDockWidget_H
#include <QWidget>
#include <QMap>
#include "Vehicle.h"
namespace Ui
{
class MultiVehicleDockWidget;
}
/// Provides a base class for a dock widget which automatically handles
/// Vehicles coming and going. It does this by using a stacked widget which
/// holds individual Vehicle specific widgets.
class MultiVehicleDockWidget : public QWidget
{
Q_OBJECT
public:
explicit MultiVehicleDockWidget(QWidget *parent = 0);
~MultiVehicleDockWidget();
/// Must be called in the derived class contructor to initialize the base class
void init(void);
protected:
/// Derived class must implement this to create the QWidget for the
/// specified Vehicle.
virtual QWidget* _newVehicleWidget(Vehicle* vehicle, QWidget* parent) = 0;
private slots:
void _vehicleAdded(Vehicle* vehicle);
void _vehicleRemoved(Vehicle* vehicle);
void _activeVehicleChanged(Vehicle* vehicle);
private:
QMap<int, QWidget*> _vehicleWidgets;
Ui::MultiVehicleDockWidget* _ui;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MultiVehicleDockWidget</class>
<widget class="QWidget" name="MultiVehicleDockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="stackedWidget"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
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,
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/>.
======================================================================*/
#include <QSettings>
#include "QGCHilConfiguration.h"
......@@ -7,10 +30,10 @@
#include "QGCHilJSBSimConfiguration.h"
#include "QGCHilXPlaneConfiguration.h"
QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) :
QWidget(parent),
mav(mav),
ui(new Ui::QGCHilConfiguration)
QGCHilConfiguration::QGCHilConfiguration(Vehicle* vehicle, QWidget *parent)
: QWidget(parent)
, _vehicle(vehicle)
, ui(new Ui::QGCHilConfiguration)
{
ui->setupUi(this);
......@@ -29,8 +52,6 @@ QGCHilConfiguration::QGCHilConfiguration(UAS *mav, QWidget *parent) :
}
settings.endGroup();
connect(mav, SIGNAL(destroyed()), this, SLOT(deleteLater()));
}
void QGCHilConfiguration::receiveStatusMessage(const QString& message)
......@@ -65,11 +86,11 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
if(1 == index)
{
// Ensure the sim exists and is disabled
mav->enableHilFlightGear(false, "", true, this);
QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(mav, this);
_vehicle->uas()->enableHilFlightGear(false, "", true, this);
QGCHilFlightGearConfiguration* hfgconf = new QGCHilFlightGearConfiguration(_vehicle->uas(), this);
hfgconf->show();
ui->simulatorConfigurationLayout->addWidget(hfgconf);
QGCFlightGearLink* fg = dynamic_cast<QGCFlightGearLink*>(mav->getHILSimulation());
QGCFlightGearLink* fg = dynamic_cast<QGCFlightGearLink*>(_vehicle->uas()->getHILSimulation());
if (fg)
{
connect(fg, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
......@@ -79,13 +100,13 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
else if (2 == index || 3 == index)
{
// Ensure the sim exists and is disabled
mav->enableHilXPlane(false);
QGCHilXPlaneConfiguration* hxpconf = new QGCHilXPlaneConfiguration(mav->getHILSimulation(), this);
_vehicle->uas()->enableHilXPlane(false);
QGCHilXPlaneConfiguration* hxpconf = new QGCHilXPlaneConfiguration(_vehicle->uas()->getHILSimulation(), this);
hxpconf->show();
ui->simulatorConfigurationLayout->addWidget(hxpconf);
// Select correct version of XPlane
QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(mav->getHILSimulation());
QGCXPlaneLink* xplane = dynamic_cast<QGCXPlaneLink*>(_vehicle->uas()->getHILSimulation());
if (xplane)
{
xplane->setVersion((index == 2) ? 10 : 9);
......@@ -95,11 +116,11 @@ void QGCHilConfiguration::on_simComboBox_currentIndexChanged(int index)
else if (4)
{
// Ensure the sim exists and is disabled
mav->enableHilJSBSim(false, "");
QGCHilJSBSimConfiguration* hfgconf = new QGCHilJSBSimConfiguration(mav, this);
_vehicle->uas()->enableHilJSBSim(false, "");
QGCHilJSBSimConfiguration* hfgconf = new QGCHilJSBSimConfiguration(_vehicle->uas(), this);
hfgconf->show();
ui->simulatorConfigurationLayout->addWidget(hfgconf);
QGCJSBSimLink* jsb = dynamic_cast<QGCJSBSimLink*>(mav->getHILSimulation());
QGCJSBSimLink* jsb = dynamic_cast<QGCJSBSimLink*>(_vehicle->uas()->getHILSimulation());
if (jsb)
{
connect(jsb, SIGNAL(statusMessage(QString)), ui->statusLabel, SLOT(setText(QString)));
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
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,
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/>.
======================================================================*/
#ifndef QGCHILCONFIGURATION_H
#define QGCHILCONFIGURATION_H
#include <QWidget>
#include "QGCHilLink.h"
#include "UAS.h"
#include "Vehicle.h"
namespace Ui {
class QGCHilConfiguration;
......@@ -15,7 +37,7 @@ class QGCHilConfiguration : public QWidget
Q_OBJECT
public:
QGCHilConfiguration(UAS* mav, QWidget *parent = 0);
QGCHilConfiguration(Vehicle* vehicle, QWidget *parent = 0);
~QGCHilConfiguration();
public slots:
......@@ -23,13 +45,12 @@ public slots:
void receiveStatusMessage(const QString& message);
void setVersion(QString version);
protected:
UAS* mav;
private slots:
void on_simComboBox_currentIndexChanged(int index);
private:
Vehicle* _vehicle;
Ui::QGCHilConfiguration *ui;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment