Commit 32da19df authored by Don Gagne's avatar Don Gagne

Merge pull request #1952 from DonLakeFlyer/HILWidget

Make HIL Dock Widget a normal widget
parents fbd56334 bfab2a89
......@@ -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 \
......
......@@ -16,6 +16,7 @@
#if defined _MSC_VER && defined QGC_SPEECH_ENABLED
// Documentation: http://msdn.microsoft.com/en-us/library/ee125082%28v=VS.85%29.aspx
#include <basetyps.h>
#include <sapi.h>
#endif
......
/*=====================================================================
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
This diff is collapsed.
......@@ -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