Browse Source

Merge pull request #1140 from DonLakeFlyer/SafetyConfig

Safety config starting point
QGC4.4
Don Gagne 10 years ago
parent
commit
6b1383fe81
  1. 7
      qgroundcontrol.pro
  2. 5
      qgroundcontrol.qrc
  3. 4
      src/AutoPilotPlugins/PX4/AirframeComponent.cc
  4. 2
      src/AutoPilotPlugins/PX4/AirframeComponent.h
  5. 4
      src/AutoPilotPlugins/PX4/FlightModesComponent.cc
  6. 2
      src/AutoPilotPlugins/PX4/FlightModesComponent.h
  7. 13
      src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
  8. 4
      src/AutoPilotPlugins/PX4/PX4Component.cc
  9. 3
      src/AutoPilotPlugins/PX4/PX4Component.h
  10. 4
      src/AutoPilotPlugins/PX4/RadioComponent.cc
  11. 2
      src/AutoPilotPlugins/PX4/RadioComponent.h
  12. 156
      src/AutoPilotPlugins/PX4/SafetyComponent.cc
  13. 60
      src/AutoPilotPlugins/PX4/SafetyComponent.h
  14. 17
      src/AutoPilotPlugins/PX4/SafetyComponent.qml
  15. 4
      src/AutoPilotPlugins/PX4/SensorsComponent.cc
  16. 2
      src/AutoPilotPlugins/PX4/SensorsComponent.h
  17. 49
      src/QGCQmlWidgetHolder.cpp
  18. 59
      src/QGCQmlWidgetHolder.h
  19. 32
      src/QGCQmlWidgetHolder.ui
  20. 16
      src/VehicleSetup/SetupView.cc
  21. 9
      src/VehicleSetup/VehicleComponent.cc
  22. 15
      src/VehicleSetup/VehicleComponent.h

7
qgroundcontrol.pro

@ -341,7 +341,8 @@ FORMS += \ @@ -341,7 +341,8 @@ FORMS += \
src/ui/px4_configuration/QGCPX4SensorCalibration.ui \
src/ui/px4_configuration/PX4RCCalibration.ui \
src/ui/px4_configuration/PX4FirmwareUpgrade.ui \
src/ui/QGCUASFileView.ui
src/ui/QGCUASFileView.ui \
src/QGCQmlWidgetHolder.ui \
HEADERS += \
src/MG.h \
@ -493,6 +494,7 @@ HEADERS += \ @@ -493,6 +494,7 @@ HEADERS += \
src/audio/QGCAudioWorker.h \
src/QGCQuickWidget.h \
src/QGCPalette.h \
src/QGCQmlWidgetHolder.h \
SOURCES += \
src/main.cc \
@ -633,6 +635,7 @@ SOURCES += \ @@ -633,6 +635,7 @@ SOURCES += \
src/audio/QGCAudioWorker.cpp \
src/QGCQuickWidget.cc \
src/QGCPalette.cc \
src/QGCQmlWidgetHolder.cpp \
#
# Unit Test specific configuration goes here
@ -725,6 +728,7 @@ HEADERS+= \ @@ -725,6 +728,7 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/FlightModeConfig.h \
src/AutoPilotPlugins/PX4/AirframeComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponent.h \
src/AutoPilotPlugins/PX4/SafetyComponent.h \
src/AutoPilotPlugins/PX4/PX4ParameterFacts.h \
src/VehicleSetup/SetupWidgetHolder.h \
@ -743,6 +747,7 @@ SOURCES += \ @@ -743,6 +747,7 @@ SOURCES += \
src/AutoPilotPlugins/PX4/FlightModeConfig.cc \
src/AutoPilotPlugins/PX4/AirframeComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponent.cc \
src/AutoPilotPlugins/PX4/SafetyComponent.cc \
src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc \
src/VehicleSetup/SetupWidgetHolder.cc \

5
qgroundcontrol.qrc

@ -239,10 +239,11 @@ @@ -239,10 +239,11 @@
<file alias="test.qml">src/test.qml</file>
<file alias="QGroundControl/FactControls/qmldir">qml/QGroundControl/FactControls/qmldir</file>
<file alias="QGroundControl/FactControls/SetupButton.qml">qml/QGroundControl/FactControls/SetupButton.qml</file>
<file alias="SetupViewConnected.qml">src/VehicleSetup/SetupViewConnected.qml</file>
<file alias="SetupViewDisconnected.qml">src/VehicleSetup/SetupViewDisconnected.qml</file>
<file alias="octo_x.png">files/images/px4/airframes/octo_x.png</file>
<file alias="px4fmu_2.x.png">files/images/px4/boards/px4fmu_2.x.png</file>
<file alias="SetupViewConnected.qml">src/VehicleSetup/SetupViewConnected.qml</file>
<file alias="SetupViewDisconnected.qml">src/VehicleSetup/SetupViewDisconnected.qml</file>
<file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
</qresource>
<qresource prefix="/AutoPilotPlugins/PX4">
<file alias="ParameterFactMetaData.xml">src/AutoPilotPlugins/PX4/ParameterFactMetaData.xml</file>

4
src/AutoPilotPlugins/PX4/AirframeComponent.cc

@ -62,8 +62,8 @@ static const struct mavType mavTypeInfo[] = { @@ -62,8 +62,8 @@ static const struct mavType mavTypeInfo[] = {
};
static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]);
AirframeComponent::AirframeComponent(UASInterface* uas, QObject* parent) :
PX4Component(uas, parent),
AirframeComponent::AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Airframe"))
{
// Validate that our mavTypeInfo array hasn't gotten out of sync

2
src/AutoPilotPlugins/PX4/AirframeComponent.h

@ -35,7 +35,7 @@ class AirframeComponent : public PX4Component @@ -35,7 +35,7 @@ class AirframeComponent : public PX4Component
Q_OBJECT
public:
AirframeComponent(UASInterface* uas, QObject* parent = NULL);
AirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;

4
src/AutoPilotPlugins/PX4/FlightModesComponent.cc

@ -45,8 +45,8 @@ static const SwitchListItem switchList[] = { @@ -45,8 +45,8 @@ static const SwitchListItem switchList[] = {
};
static const size_t cSwitchList = sizeof(switchList) / sizeof(switchList[0]);
FlightModesComponent::FlightModesComponent(UASInterface* uas, QObject* parent) :
PX4Component(uas, parent),
FlightModesComponent::FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Flight Modes"))
{
}

2
src/AutoPilotPlugins/PX4/FlightModesComponent.h

@ -35,7 +35,7 @@ class FlightModesComponent : public PX4Component @@ -35,7 +35,7 @@ class FlightModesComponent : public PX4Component
Q_OBJECT
public:
FlightModesComponent(UASInterface* uas, QObject* parent = NULL);
FlightModesComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;

13
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc

@ -26,6 +26,7 @@ @@ -26,6 +26,7 @@
#include "RadioComponent.h"
#include "SensorsComponent.h"
#include "FlightModesComponent.h"
#include "SafetyComponent.h"
#include "AutoPilotPluginManager.h"
#include "UASManager.h"
#include "QGCUASParamManagerInterface.h"
@ -196,19 +197,23 @@ const QVariantList& PX4AutoPilotPlugin::components(void) @@ -196,19 +197,23 @@ const QVariantList& PX4AutoPilotPlugin::components(void)
Q_ASSERT(_uas);
component = new AirframeComponent(_uas);
component = new AirframeComponent(_uas, this);
Q_CHECK_PTR(component);
_components.append(QVariant::fromValue(component));
component = new RadioComponent(_uas);
component = new RadioComponent(_uas, this);
Q_CHECK_PTR(component);
_components.append(QVariant::fromValue(component));
component = new FlightModesComponent(_uas);
component = new FlightModesComponent(_uas, this);
Q_CHECK_PTR(component);
_components.append(QVariant::fromValue(component));
component = new SensorsComponent(_uas);
component = new SensorsComponent(_uas, this);
Q_CHECK_PTR(component);
_components.append(QVariant::fromValue(component));
component = new SafetyComponent(_uas, this);
Q_CHECK_PTR(component);
_components.append(QVariant::fromValue(component));
}

4
src/AutoPilotPlugins/PX4/PX4Component.cc

@ -26,8 +26,8 @@ @@ -26,8 +26,8 @@
#include "PX4Component.h"
PX4Component::PX4Component(UASInterface* uas, QObject* parent) :
VehicleComponent(uas, parent)
PX4Component::PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
VehicleComponent(uas, autopilot, parent)
{
bool fSuccess = connect(_paramMgr, SIGNAL(parameterUpdated(int, QString, QVariant)), this, SLOT(_parameterUpdated(int, QString, QVariant)));
Q_ASSERT(fSuccess);

3
src/AutoPilotPlugins/PX4/PX4Component.h

@ -35,7 +35,7 @@ class PX4Component : public VehicleComponent @@ -35,7 +35,7 @@ class PX4Component : public VehicleComponent
Q_OBJECT
public:
PX4Component(UASInterface* uas, QObject* parent = NULL);
PX4Component(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
/// @brief Returns an array of parameter names for which a change should cause the setupCompleteChanged
/// signal to be emitted. Last element is signalled by NULL. Must be implemented by upper level class.
@ -45,7 +45,6 @@ private slots: @@ -45,7 +45,6 @@ private slots:
/// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal
/// setupCompleteChanged at appropriate times.
void _parameterUpdated(int compId, QString paramName, QVariant value);
};
#endif

4
src/AutoPilotPlugins/PX4/RadioComponent.cc

@ -31,8 +31,8 @@ @@ -31,8 +31,8 @@
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "RC_MAP_MODE_SW", NULL };
RadioComponent::RadioComponent(UASInterface* uas, QObject* parent) :
PX4Component(uas, parent),
RadioComponent::RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Radio"))
{
}

2
src/AutoPilotPlugins/PX4/RadioComponent.h

@ -36,7 +36,7 @@ class RadioComponent : public PX4Component @@ -36,7 +36,7 @@ class RadioComponent : public PX4Component
Q_OBJECT
public:
RadioComponent(UASInterface* uas, QObject* parent = NULL);
RadioComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;

156
src/AutoPilotPlugins/PX4/SafetyComponent.cc

@ -0,0 +1,156 @@ @@ -0,0 +1,156 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "SafetyComponent.h"
#include "PX4RCCalibration.h"
#include "VehicleComponentSummaryItem.h"
#include "QGCQmlWidgetHolder.h"
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { NULL };
SafetyComponent::SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Safety"))
{
}
QString SafetyComponent::name(void) const
{
return _name;
}
QString SafetyComponent::description(void) const
{
return tr("The Safety Component is used to setup triggers for Return to Land as well as the settings for Return to Land itself.");
}
QString SafetyComponent::icon(void) const
{
return ":/files/images/px4/menu/remote.png";
}
bool SafetyComponent::requiresSetup(void) const
{
return false;
}
bool SafetyComponent::setupComplete(void) const
{
// FIXME: What aboout invalid settings?
return true;
}
QString SafetyComponent::setupStateDescription(void) const
{
const char* stateDescription;
if (requiresSetup()) {
stateDescription = "Requires setup";
} else {
stateDescription = "Setup complete";
}
return QString(stateDescription);
}
const char** SafetyComponent::setupCompleteChangedTriggerList(void) const
{
return triggerParams;
}
QStringList SafetyComponent::paramFilterList(void) const
{
QStringList list;
return list;
}
QWidget* SafetyComponent::setupWidget(void) const
{
QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder();
Q_CHECK_PTR(holder);
holder->setAutoPilot(_autopilot);
holder->setSource(QUrl::fromUserInput("qrc:/qml/SafetyComponent.qml"));
return holder;
}
const QVariantList& SafetyComponent::summaryItems(void)
{
// FIXME: No summary items yet
#if 0
if (!_summaryItems.count()) {
QString name;
QString state;
// FIXME: Need to pull receiver type from RSSI value
name = "Receiver type:";
state = "n/a";
VehicleComponentSummaryItem* item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
static const char* stickParams[] = { "RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE" };
QString summary("Chan ");
bool allSticksMapped = true;
for (size_t i=0; i<sizeof(stickParams)/sizeof(stickParams[0]); i++) {
QVariant value;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), stickParams[i], value)) {
if (value.toInt() == 0) {
allSticksMapped = false;
break;
} else {
if (i != 0) {
summary += ",";
}
summary += value.toString();
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
summary += "?";
}
}
if (!allSticksMapped) {
summary = "Not mapped";
}
name = "Ail, Ele, Rud, Throt:";
state = summary;
item = new VehicleComponentSummaryItem(name, state, this);
_summaryItems.append(QVariant::fromValue(item));
}
#endif
return _summaryItems;
}

60
src/AutoPilotPlugins/PX4/SafetyComponent.h

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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 SafetyComponent_H
#define SafetyComponent_H
#include "PX4Component.h"
/// @file
/// @brief The Radio VehicleComponent is used to calibrate the trasmitter and assign function mapping
/// to channels.
/// @author Don Gagne <don@thegagnes.com>
class SafetyComponent : public PX4Component
{
Q_OBJECT
public:
SafetyComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
virtual QString name(void) const;
virtual QString description(void) const;
virtual QString icon(void) const;
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual const QVariantList& summaryItems(void);
private:
const QString _name;
QVariantList _summaryItems;
};
#endif

17
src/AutoPilotPlugins/PX4/SafetyComponent.qml

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.FactSystem 1.0
Rectangle {
QGCPalette { id: palette; colorGroup: QGCPalette.Active }
width: 400
height: 400
color: palette.window
Column {
Label { text: "Work in Progress"; color: palette.windowText }
Label { text: autopilot.parameters["RTL_RETURN_ALT"].value; color: palette.windowText }
}
}

4
src/AutoPilotPlugins/PX4/SensorsComponent.cc

@ -36,8 +36,8 @@ static const char* triggerParams[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS @@ -36,8 +36,8 @@ static const char* triggerParams[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS
/// @brief Used to translate from parameter name to user string
static const char* triggerSensors[] = { "Compass", "Gyro", "Acceleromter", "Airspeed", NULL };
SensorsComponent::SensorsComponent(UASInterface* uas, QObject* parent) :
PX4Component(uas, parent),
SensorsComponent::SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
PX4Component(uas, autopilot, parent),
_name(tr("Sensors"))
{
}

2
src/AutoPilotPlugins/PX4/SensorsComponent.h

@ -35,7 +35,7 @@ class SensorsComponent : public PX4Component @@ -35,7 +35,7 @@ class SensorsComponent : public PX4Component
Q_OBJECT
public:
SensorsComponent(UASInterface* uas, QObject* parent = NULL);
SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;

49
src/QGCQmlWidgetHolder.cpp

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include "QGCQmlWidgetHolder.h"
QGCQmlWidgetHolder::QGCQmlWidgetHolder(QWidget *parent) :
QWidget(parent)
{
_ui.setupUi(this);
}
QGCQmlWidgetHolder::~QGCQmlWidgetHolder()
{
}
void QGCQmlWidgetHolder::setAutoPilot(AutoPilotPlugin* autoPilot)
{
_ui.qmlWidget->rootContext()->setContextProperty("autopilot", autoPilot);
}
void QGCQmlWidgetHolder::setSource(const QUrl& qmlUrl)
{
_ui.qmlWidget->setSource(qmlUrl);
_ui.qmlWidget->setMinimumSize(_ui.qmlWidget->rootObject()->width(), _ui.qmlWidget->rootObject()->height());
}

59
src/QGCQmlWidgetHolder.h

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 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 QGCQmlWidgetHolder_h
#define QGCQmlWidgetHolder_h
/// @file
/// @author Don Gagne <don@thegagnes.com>
#include <QWidget>
#include "ui_QGCQmlWidgetHolder.h"
#include "AutoPilotPlugin.h"
namespace Ui {
class QGCQmlWidgetHolder;
}
/// This is used to create widgets which are implemented in QML.
class QGCQmlWidgetHolder : public QWidget
{
Q_OBJECT
public:
explicit QGCQmlWidgetHolder(QWidget *parent = 0);
~QGCQmlWidgetHolder();
/// Sets the UAS into the widget which in turn will load facts into the context
void setAutoPilot(AutoPilotPlugin* autoPilot);
/// Sets the QML into the control
void setSource(const QUrl& qmlUrl);
private:
Ui::QGCQmlWidgetHolder _ui;
};
#endif

32
src/QGCQmlWidgetHolder.ui

@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCQmlWidgetHolder</class>
<widget class="QWidget" name="QGCQmlWidgetHolder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGCQuickWidget" name="qmlWidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QGCQuickWidget</class>
<extends>QQuickWidget</extends>
<header>QGCQuickWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

16
src/VehicleSetup/SetupView.cc

@ -142,13 +142,15 @@ void SetupView::_setupButtonClicked(const QVariant& component) @@ -142,13 +142,15 @@ void SetupView::_setupButtonClicked(const QVariant& component)
VehicleComponent* vehicle = qobject_cast<VehicleComponent*>(component.value<QObject*>());
Q_ASSERT(vehicle);
SetupWidgetHolder* dialog = new SetupWidgetHolder(MainWindow::instance());
dialog->setModal(true);
dialog->setWindowTitle(vehicle->name());
SetupWidgetHolder dialog(MainWindow::instance());
dialog.setModal(true);
dialog.setWindowTitle(vehicle->name());
QWidget* setupWidget = vehicle->setupWidget();
qDebug() << setupWidget->minimumSize();
dialog->resize(setupWidget->minimumSize());
dialog->setInnerWidget(setupWidget);
dialog->exec();
dialog.resize(setupWidget->minimumSize());
dialog.setInnerWidget(setupWidget);
dialog.exec();
delete setupWidget;
}

9
src/VehicleSetup/VehicleComponent.cc

@ -25,13 +25,18 @@ @@ -25,13 +25,18 @@
/// @author Don Gagne <don@thegagnes.com>
#include "VehicleComponent.h"
#include "AutoPilotPlugin.h"
VehicleComponent::VehicleComponent(UASInterface* uas, QObject* parent) :
VehicleComponent::VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) :
QObject(parent),
_uas(uas),
_paramMgr(_uas->getParamManager())
_autopilot(autopilot)
{
Q_ASSERT(uas);
Q_ASSERT(autopilot);
_paramMgr = _uas->getParamManager();
Q_ASSERT(_paramMgr);
}
VehicleComponent::~VehicleComponent()

15
src/VehicleSetup/VehicleComponent.h

@ -21,6 +21,9 @@ @@ -21,6 +21,9 @@
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef VEHICLECOMPONENT_H
#define VEHICLECOMPONENT_H
@ -30,11 +33,10 @@ @@ -30,11 +33,10 @@
#include "UASInterface.h"
/// @file
/// @brief Vehicle Component class. A vehicle component is an object which
/// abstracts the physical portion of a vehicle into a set of
/// configurable values and user interface.
/// @author Don Gagne <don@thegagnes.com>
class AutoPilotPlugin;
/// A vehicle component is an object which abstracts the physical portion of a vehicle into a set of
/// configurable values and user interface.
class VehicleComponent : public QObject
{
@ -50,7 +52,7 @@ class VehicleComponent : public QObject @@ -50,7 +52,7 @@ class VehicleComponent : public QObject
Q_PROPERTY(QVariantList summaryItems READ summaryItems CONSTANT);
public:
VehicleComponent(UASInterface* uas, QObject* parent = NULL);
VehicleComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL);
~VehicleComponent();
virtual QString name(void) const = 0;
@ -70,6 +72,7 @@ signals: @@ -70,6 +72,7 @@ signals:
protected:
UASInterface* _uas;
AutoPilotPlugin* _autopilot;
QGCUASParamManagerInterface* _paramMgr;
};

Loading…
Cancel
Save