diff --git a/QGCApplication.pro b/QGCApplication.pro index d51b14217c3beb825d71daa8122f724db3a7bdc5..a9647133b6f1ff2d941db7e5fd1999298d606cad 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -166,6 +166,7 @@ FORMS += \ src/ui/LogReplayLinkConfigurationWidget.ui \ src/ui/MainWindow.ui \ src/ui/MAVLinkSettingsWidget.ui \ + src/ui/MockLinkConfiguration.ui \ src/ui/QGCCommConfiguration.ui \ src/ui/QGCLinkConfiguration.ui \ src/ui/QGCMapRCToParamDialog.ui \ @@ -257,6 +258,7 @@ HEADERS += \ src/ui/MainWindow.h \ src/ui/MAVLinkDecoder.h \ src/ui/MAVLinkSettingsWidget.h \ + src/ui/MockLinkConfiguration.h \ src/ui/QGCCommConfiguration.h \ src/ui/QGCLinkConfiguration.h \ src/ui/QGCMapRCToParamDialog.h \ @@ -368,6 +370,7 @@ SOURCES += \ src/ui/MainWindow.cc \ src/ui/MAVLinkDecoder.cc \ src/ui/MAVLinkSettingsWidget.cc \ + src/ui/MockLinkConfiguration.cc \ src/ui/QGCCommConfiguration.cc \ src/ui/QGCLinkConfiguration.cc \ src/ui/QGCMapRCToParamDialog.cpp \ diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml index 10c6fb7a606f7aed0dc04954bde60b847fab6535..c7bb64bb380e0b1afb96e5d4045e840993d03a27 100644 --- a/src/MissionEditor/MissionEditor.qml +++ b/src/MissionEditor/MissionEditor.qml @@ -206,7 +206,9 @@ QGCView { onDragActiveChanged: { if (!drag.active) { var point = Qt.point(itemEditor.x + (itemEditor.width / 2), itemEditor.y + (itemEditor.height / 2)) - itemEditor.missionItem.coordinate = editorMap.toCoordinate(point) + var coordinate = editorMap.toCoordinate(point) + coordinate.altitude = itemEditor.missionItem.coordinate.altitude + itemEditor.missionItem.coordinate = coordinate } } } diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index e3e6fba534f69b96fce5f10ccd8da912a7ba4106..c9370a7ee349fb938dbbdf4441e89159a4c76ff0 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -378,6 +378,8 @@ void QGCApplication::_initCommon(void) } else if (settings.allKeys().count()) { // Settings version key is missing and there are settings. This is an upgrade scenario. settingsUpgraded = true; + } else { + settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION); } if (settingsUpgraded) { diff --git a/src/VehicleSetup/SetupView.qml b/src/VehicleSetup/SetupView.qml index cc039b6bd6544f0206a07b0a949212751b90a8ba..5744217859a228d0d5584512ece2c337fa97dde6 100644 --- a/src/VehicleSetup/SetupView.qml +++ b/src/VehicleSetup/SetupView.qml @@ -53,7 +53,11 @@ Item { function showSummaryPanel() { if (_fullParameterVehicleAvailable) { - panelLoader.source = "VehicleSummary.qml"; + if (multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length == 0) { + panelLoader.sourceComponent = noComponentsVehicleSummaryComponent + } else { + panelLoader.source = "VehicleSummary.qml"; + } } else if (multiVehicleManager.parameterReadyVehicleAvailable) { panelLoader.sourceComponent = missingParametersVehicleSummaryComponent } else { @@ -115,7 +119,7 @@ Item { } Component { - id: disconnectedVehicleSummaryComponent + id: noComponentsVehicleSummaryComponent Rectangle { color: qgcPal.windowShade @@ -127,17 +131,33 @@ Item { horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap font.pixelSize: ScreenTools.mediumFontPixelSize - text: "Welcome to QGroundControl. " + - "QGroundControl supports any mavlink enabled vehicle. " + - "If you are using the PX4 Flight Stack, you also get full support for setting up and calibrating your vehicle. "+ - "Otherwise you will only get support for flying a vehicle which has been setup and calibrated using other means. " + - "Use the Connect button above to connect to your vehicle." + text: "QGroundControl does not currently support setup of your vehicle type. " + + "If your vehicle is already configured you can still Fly." onLinkActivated: Qt.openUrlExternally(link) } } } + Component { + id: disconnectedVehicleSummaryComponent + + Rectangle { + color: qgcPal.windowShade + + QGCLabel { + anchors.margins: _defaultTextWidth * 2 + anchors.fill: parent + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + font.pixelSize: ScreenTools.largeFontPixelSize + text: "Click Connect on the top right to Fly. Click Firmware on the left to upgrade your vehicle." + + onLinkActivated: Qt.openUrlExternally(link) + } + } + } Component { id: missingParametersVehicleSummaryComponent @@ -218,6 +238,7 @@ Item { width: _buttonWidth imageResource: "/qmlimages/VehicleSummaryIcon.png" setupIndicator: false + checked: true exclusiveGroup: setupButtonGroup text: "SUMMARY" diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index 793d3f3222df1406f9a2740f6a93b0fdc96c077a..967d1ff7553cbaad1d4906bf9a93cd22350b02c4 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -438,7 +438,7 @@ void LinkManager::loadLinkConfigurationList() // Debug buids always add MockLink automatically #ifdef QT_DEBUG - MockConfiguration* pMock = new MockConfiguration("Mock Link"); + MockConfiguration* pMock = new MockConfiguration("Mock Link PX4"); pMock->setDynamic(true); addLinkConfiguration(pMock); linksChanged = true; diff --git a/src/comm/MockLink.cc b/src/comm/MockLink.cc index a425891370a2a22393ff303a15a39e9c8ebd5b01..9a62d9debb942bdb050b8138dd61be60e790bc45 100644 --- a/src/comm/MockLink.cc +++ b/src/comm/MockLink.cc @@ -71,6 +71,8 @@ float MockLink::_vehicleLatitude = 47.633033f; float MockLink::_vehicleLongitude = -122.08794f; float MockLink::_vehicleAltitude = 2.5f; +const char* MockConfiguration::_firmwareTypeKey = "FirmwareType"; + MockLink::MockLink(MockConfiguration* config) : _missionItemHandler(this) , _name("MockLink") @@ -85,6 +87,10 @@ MockLink::MockLink(MockConfiguration* config) , _fileServer(NULL) { _config = config; + if (_config) { + _autopilotType = config->firmwareType(); + } + union px4_custom_mode px4_cm; px4_cm.data = 0; @@ -740,3 +746,51 @@ void MockLink::_sendGpsRawInt(void) 8); // satellite count respondWithMavlinkMessage(msg); } + +MockConfiguration::MockConfiguration(const QString& name) + : LinkConfiguration(name) + , _firmwareType(MAV_AUTOPILOT_PX4) +{ + +} + +MockConfiguration::MockConfiguration(MockConfiguration* source) + : LinkConfiguration(source) +{ + _firmwareType = source->_firmwareType; +} + +void MockConfiguration::copyFrom(LinkConfiguration *source) +{ + LinkConfiguration::copyFrom(source); + MockConfiguration* usource = dynamic_cast(source); + Q_ASSERT(usource != NULL); + _firmwareType = usource->_firmwareType; +} + +void MockConfiguration::saveSettings(QSettings& settings, const QString& root) +{ + settings.beginGroup(root); + settings.setValue(_firmwareTypeKey, (int)_firmwareType); + settings.sync(); + settings.endGroup(); +} + +void MockConfiguration::loadSettings(QSettings& settings, const QString& root) +{ + settings.beginGroup(root); + _firmwareType = (MAV_AUTOPILOT)settings.value(_firmwareTypeKey, (int)MAV_AUTOPILOT_PX4).toInt(); + settings.endGroup(); +} + +void MockConfiguration::updateSettings() +{ + if (_link) { + MockLink* ulink = dynamic_cast(_link); + if (ulink) { + // Restart connect not supported + Q_ASSERT(false); + //ulink->_restartConnection(); + } + } +} diff --git a/src/comm/MockLink.h b/src/comm/MockLink.h index 790291833c79625710c3a2ba7609f27e941af6c5..9da4fe7b4c7bf28f887a0e4c67f922d34d81f152 100644 --- a/src/comm/MockLink.h +++ b/src/comm/MockLink.h @@ -35,22 +35,26 @@ Q_DECLARE_LOGGING_CATEGORY(MockLinkLog) Q_DECLARE_LOGGING_CATEGORY(MockLinkVerboseLog) -/// @file -/// @brief Mock implementation of a Link. -/// -/// @author Don Gagne - class MockConfiguration : public LinkConfiguration { public: + MockConfiguration(const QString& name); + MockConfiguration(MockConfiguration* source); + + MAV_AUTOPILOT firmwareType(void) { return _firmwareType; } + void setFirmwareType(MAV_AUTOPILOT firmwareType) { _firmwareType = firmwareType; } + + // Overrides from LinkConfiguration + int type(void) { return LinkConfiguration::TypeMock; } + void copyFrom(LinkConfiguration* source); + void loadSettings(QSettings& settings, const QString& root); + void saveSettings(QSettings& settings, const QString& root); + void updateSettings(void); + +private: + MAV_AUTOPILOT _firmwareType; - MockConfiguration(const QString& name) : LinkConfiguration(name) {} - MockConfiguration(MockConfiguration* source) : LinkConfiguration(source) {} - int type() { return LinkConfiguration::TypeMock; } - void copyFrom(LinkConfiguration* source) { LinkConfiguration::copyFrom(source); } - void loadSettings(QSettings& settings, const QString& root) { Q_UNUSED(settings); Q_UNUSED(root); } - void saveSettings(QSettings& settings, const QString& root) { Q_UNUSED(settings); Q_UNUSED(root); } - void updateSettings() {} + static const char* _firmwareTypeKey; }; class MockLink : public LinkInterface diff --git a/src/ui/MockLinkConfiguration.cc b/src/ui/MockLinkConfiguration.cc new file mode 100644 index 0000000000000000000000000000000000000000..c6b3e477ceb91620d9f87445f1758c85e0614a57 --- /dev/null +++ b/src/ui/MockLinkConfiguration.cc @@ -0,0 +1,75 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +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 . + +======================================================================*/ + +#include "MockLinkConfiguration.h" +#include "ui_MockLinkConfiguration.h" + +MockLinkConfiguration::MockLinkConfiguration(MockConfiguration *config, QWidget *parent) + : QWidget(parent) + , _ui(new Ui::MockLinkConfiguration) + , _config(config) +{ + _ui->setupUi(this); + + switch (config->firmwareType()) { + case MAV_AUTOPILOT_PX4: + _ui->px4Radio->setChecked(true); + break; + case MAV_AUTOPILOT_ARDUPILOTMEGA: + _ui->apmRadio->setChecked(true); + break; + default: + _ui->genericRadio->setChecked(true); + break; + } + + connect(_ui->px4Radio, &QRadioButton::clicked, this, &MockLinkConfiguration::_px4RadioClicked); + connect(_ui->apmRadio, &QRadioButton::clicked, this, &MockLinkConfiguration::_apmRadioClicked); + connect(_ui->genericRadio, &QRadioButton::clicked, this, &MockLinkConfiguration::_genericRadioClicked); +} + +MockLinkConfiguration::~MockLinkConfiguration() +{ + delete _ui; +} + +void MockLinkConfiguration::_px4RadioClicked(bool checked) +{ + if (checked) { + _config->setFirmwareType(MAV_AUTOPILOT_PX4); + } +} + +void MockLinkConfiguration::_apmRadioClicked(bool checked) +{ + if (checked) { + _config->setFirmwareType(MAV_AUTOPILOT_ARDUPILOTMEGA); + } +} + +void MockLinkConfiguration::_genericRadioClicked(bool checked) +{ + if (checked) { + _config->setFirmwareType(MAV_AUTOPILOT_GENERIC); + } +} diff --git a/src/ui/MockLinkConfiguration.h b/src/ui/MockLinkConfiguration.h new file mode 100644 index 0000000000000000000000000000000000000000..34feb999f39f8493d14f5c6cf5578e004b7f3948 --- /dev/null +++ b/src/ui/MockLinkConfiguration.h @@ -0,0 +1,53 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +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 . + +======================================================================*/ + +#ifndef MockLinkConfiguration_H +#define MockLinkConfiguration_H + +#include + +#include "MockLink.h" + +namespace Ui +{ +class MockLinkConfiguration; +} + +class MockLinkConfiguration : public QWidget +{ + Q_OBJECT +public: + explicit MockLinkConfiguration(MockConfiguration *config, QWidget *parent = 0); + ~MockLinkConfiguration(); + +private slots: + void _px4RadioClicked(bool checked); + void _apmRadioClicked(bool checked); + void _genericRadioClicked(bool checked); + +private: + Ui::MockLinkConfiguration* _ui; + MockConfiguration* _config; +}; + +#endif // MockLinkConfiguration_H diff --git a/src/ui/MockLinkConfiguration.ui b/src/ui/MockLinkConfiguration.ui new file mode 100644 index 0000000000000000000000000000000000000000..d54fbb091abbf227b45934cb6427718f0f3629eb --- /dev/null +++ b/src/ui/MockLinkConfiguration.ui @@ -0,0 +1,42 @@ + + + MockLinkConfiguration + + + + 0 + 0 + 187 + 116 + + + + Form + + + + + + PX4 Firmware + + + + + + + APM Firmware + + + + + + + Generic Firmware + + + + + + + + diff --git a/src/ui/QGCCommConfiguration.cc b/src/ui/QGCCommConfiguration.cc index bc32198e44d9ab6850c117c5fc77af84ba4e0049..53f167f2fb7e46b71c53381f1b0ac9bb7a2bc0cf 100644 --- a/src/ui/QGCCommConfiguration.cc +++ b/src/ui/QGCCommConfiguration.cc @@ -36,6 +36,7 @@ This file is part of the QGROUNDCONTROL project #endif #include "QGCUDPLinkConfiguration.h" #include "QGCTCPLinkConfiguration.h" +#include "MockLinkConfiguration.h" #include "LogReplayLinkConfigurationWidget.h" #include "QGCCommConfiguration.h" #include "ui_QGCCommConfiguration.h" @@ -151,7 +152,8 @@ void QGCCommConfiguration::_loadTypeConfigWidget(int type) break; #ifdef QT_DEBUG case LinkConfiguration::TypeMock: { - _ui->linkScrollArea->setWidget(NULL); + QWidget* conf = new MockLinkConfiguration((MockConfiguration*)_config, this); + _ui->linkScrollArea->setWidget(conf); _ui->linkGroupBox->setTitle(tr("Mock Link")); _ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeMock)); }