From 2baf67ae565e85dac36af21cee9d40d193ea5cc8 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 11 Dec 2019 10:20:54 +0300 Subject: [PATCH 1/6] Change decimal futzing to bias towards specifically set decimal places value --- src/FactSystem/Fact.cc | 2 +- src/FactSystem/FactMetaData.cc | 35 ++++++++++++++++++----------------- src/FactSystem/FactMetaData.h | 4 ++-- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/FactSystem/Fact.cc b/src/FactSystem/Fact.cc index 391f79b..66794d4 100644 --- a/src/FactSystem/Fact.cc +++ b/src/FactSystem/Fact.cc @@ -519,7 +519,7 @@ int Fact::decimalPlaces(void) const return _metaData->decimalPlaces(); } else { qWarning() << kMissingMetadata << name(); - return FactMetaData::defaultDecimalPlaces; + return FactMetaData::kDefaultDecimalPlaces; } } diff --git a/src/FactSystem/FactMetaData.cc b/src/FactSystem/FactMetaData.cc index 4316a94..2568fda 100644 --- a/src/FactSystem/FactMetaData.cc +++ b/src/FactSystem/FactMetaData.cc @@ -88,7 +88,7 @@ const char* FactMetaData::_qgcRebootRequiredJsonKey = "qgcRebootRequired"; FactMetaData::FactMetaData(QObject* parent) : QObject (parent) , _type (valueTypeInt32) - , _decimalPlaces (unknownDecimalPlaces) + , _decimalPlaces (kUnknownDecimalPlaces) , _rawDefaultValue (0) , _defaultValueAvailable(false) , _rawMax (_maxForType()) @@ -112,7 +112,7 @@ FactMetaData::FactMetaData(QObject* parent) FactMetaData::FactMetaData(ValueType_t type, QObject* parent) : QObject (parent) , _type (type) - , _decimalPlaces (unknownDecimalPlaces) + , _decimalPlaces (kUnknownDecimalPlaces) , _rawDefaultValue (0) , _defaultValueAvailable(false) , _rawMax (_maxForType()) @@ -142,7 +142,7 @@ FactMetaData::FactMetaData(const FactMetaData& other, QObject* parent) FactMetaData::FactMetaData(ValueType_t type, const QString name, QObject* parent) : QObject (parent) , _type (type) - , _decimalPlaces (unknownDecimalPlaces) + , _decimalPlaces (kUnknownDecimalPlaces) , _rawDefaultValue (0) , _defaultValueAvailable(false) , _rawMax (_maxForType()) @@ -1023,8 +1023,8 @@ double FactMetaData::cookedIncrement(void) const int FactMetaData::decimalPlaces(void) const { - int actualDecimalPlaces = defaultDecimalPlaces; - int incrementDecimalPlaces = unknownDecimalPlaces; + int actualDecimalPlaces = kDefaultDecimalPlaces; + int incrementDecimalPlaces = kUnknownDecimalPlaces; // First determine decimal places from increment double increment = _rawTranslator(this->rawIncrement()).toDouble(); @@ -1041,20 +1041,21 @@ int FactMetaData::decimalPlaces(void) const } } - // Correct decimal places is the larger of the two, increment or meta data value - if (incrementDecimalPlaces != unknownDecimalPlaces && _decimalPlaces == unknownDecimalPlaces) { - actualDecimalPlaces = incrementDecimalPlaces; - } else { - // Adjust decimal places for cooked translation - int settingsDecimalPlaces = _decimalPlaces == unknownDecimalPlaces ? defaultDecimalPlaces : _decimalPlaces; - double ctest = _rawTranslator(1.0).toDouble(); - - settingsDecimalPlaces += -log10(ctest); + if (_decimalPlaces == kUnknownDecimalPlaces) { + if (incrementDecimalPlaces != kUnknownDecimalPlaces) { + actualDecimalPlaces = incrementDecimalPlaces; + } else { + // Adjust decimal places for cooked translation + int settingsDecimalPlaces = _decimalPlaces == kUnknownDecimalPlaces ? kDefaultDecimalPlaces : _decimalPlaces; + double ctest = _rawTranslator(1.0).toDouble(); - settingsDecimalPlaces = qMin(25, settingsDecimalPlaces); - settingsDecimalPlaces = qMax(0, settingsDecimalPlaces); + settingsDecimalPlaces += -log10(ctest); - actualDecimalPlaces = qMax(settingsDecimalPlaces, incrementDecimalPlaces); + settingsDecimalPlaces = qMin(25, settingsDecimalPlaces); + settingsDecimalPlaces = qMax(0, settingsDecimalPlaces); + } + } else { + actualDecimalPlaces = _decimalPlaces; } return actualDecimalPlaces; diff --git a/src/FactSystem/FactMetaData.h b/src/FactSystem/FactMetaData.h index 04a7837..a96e1fb 100644 --- a/src/FactSystem/FactMetaData.h +++ b/src/FactSystem/FactMetaData.h @@ -166,8 +166,8 @@ public: /// @returns false: Convertion failed bool clampValue(const QVariant& cookedValue, QVariant& typedValue); - static const int defaultDecimalPlaces = 3; ///< Default value for decimal places if not specified/known - static const int unknownDecimalPlaces = -1; ///< Number of decimal places to specify is not known + static const int kDefaultDecimalPlaces = 3; ///< Default value for decimal places if not specified/known + static const int kUnknownDecimalPlaces = -1; ///< Number of decimal places to specify is not known static ValueType_t stringToType(const QString& typeString, bool& unknownType); static size_t typeToSize(ValueType_t type); From eb13f463deb01c7c409e85d05ddaac0209efaae1 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 11 Dec 2019 10:21:18 +0300 Subject: [PATCH 2/6] Fix ArduPilot VTOL takeoff --- src/FirmwarePlugin/APM/MavCmdInfoCommon.json | 12 +++++++----- src/MissionManager/MavCmdInfoCommon.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/FirmwarePlugin/APM/MavCmdInfoCommon.json b/src/FirmwarePlugin/APM/MavCmdInfoCommon.json index f5db22f..1226035 100644 --- a/src/FirmwarePlugin/APM/MavCmdInfoCommon.json +++ b/src/FirmwarePlugin/APM/MavCmdInfoCommon.json @@ -47,11 +47,13 @@ "specifiesAltitudeOnly": true }, { - "id": 84, - "comment": "MAV_CMD_NAV_VTOL_TAKEOFF", - "specifiesCoordinate": true, - "friendlyEdit": true, - "category": "VTOL" + "id": 84, + "comment": "MAV_CMD_NAV_VTOL_TAKEOFF", + "description": "Takeoff to specified altitude.", + "specifiesCoordinate": false, + "specifiesAltitudeOnly": true, + "friendlyEdit": true, + "category": "VTOL" }, { "id": 85, diff --git a/src/MissionManager/MavCmdInfoCommon.json b/src/MissionManager/MavCmdInfoCommon.json index e3d0178..48a9cb1 100644 --- a/src/MissionManager/MavCmdInfoCommon.json +++ b/src/MissionManager/MavCmdInfoCommon.json @@ -286,7 +286,7 @@ { "id": 84, "rawName": "MAV_CMD_NAV_VTOL_TAKEOFF", - "friendlyName": "VTOL takeoff and transition", + "friendlyName": "VTOL takeoff", "description": "Takeoff in VTOL mode, transition to forward flight and fly to the specified location.", "specifiesCoordinate": true, "friendlyEdit": true, From b3c923aaf3482a3bd00f0c42e4533d3e1b500f9c Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 11 Dec 2019 10:21:34 +0300 Subject: [PATCH 3/6] Can't hide fly through commands --- src/PlanView/MissionItemEditor.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PlanView/MissionItemEditor.qml b/src/PlanView/MissionItemEditor.qml index 870edd6..4b14cdc 100644 --- a/src/PlanView/MissionItemEditor.qml +++ b/src/PlanView/MissionItemEditor.qml @@ -242,7 +242,8 @@ Rectangle { MissionCommandDialog { missionItem: _root.missionItem map: _root.map - flyThroughCommandsAllowed: _missionController.flyThroughCommandsAllowed + // FIXME: Disabling fly through commands doesn't work since you may need to change from an RTL to something else + flyThroughCommandsAllowed: true //_missionController.flyThroughCommandsAllowed } } From fd14f343b9470ed1c979bee2f96cf3822c965176 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 11 Dec 2019 10:21:47 +0300 Subject: [PATCH 4/6] Fix VTOL value --- src/Settings/App.SettingsGroup.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Settings/App.SettingsGroup.json b/src/Settings/App.SettingsGroup.json index 7dabbee..660b453 100644 --- a/src/Settings/App.SettingsGroup.json +++ b/src/Settings/App.SettingsGroup.json @@ -12,7 +12,7 @@ "shortDescription": "Offline editing vehicle type", "type": "uint32", "enumStrings": "Fixed Wing,Multi-Rotor,VTOL,Rover,Sub", - "enumValues": "1,2,19,10,12", + "enumValues": "1,2,20,10,12", "defaultValue": 2 }, { From c3639316dc4d24355fd760897753b04afe8f5e25 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 11 Dec 2019 10:21:57 +0300 Subject: [PATCH 5/6] Show MapScale at correct times --- src/PlanView/PlanView.qml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index 76bfd9f..13f46b6 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -941,10 +941,9 @@ Item { anchors.left: parent.left mapControl: editorMap buttonsOnLeft: true - terrainButtonVisible: true - visible: _toolStripBottom < y && _editingLayer === _layerMission + terrainButtonVisible: _editingLayer === _layerMission + visible: _toolStripBottom < y terrainButtonChecked: waypointValuesDisplay.visible - onTerrainButtonClicked: waypointValuesDisplay.toggleVisible() } From 1e0f27a40c65b6c182c3456dedc2023ec35e9108 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 11 Dec 2019 10:22:04 +0300 Subject: [PATCH 6/6] New constant name --- src/MissionManager/MissionCommandUIInfo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MissionManager/MissionCommandUIInfo.cc b/src/MissionManager/MissionCommandUIInfo.cc index 7fb8e0a..51d48d2 100644 --- a/src/MissionManager/MissionCommandUIInfo.cc +++ b/src/MissionManager/MissionCommandUIInfo.cc @@ -351,7 +351,7 @@ bool MissionCommandUIInfo::loadJsonInfo(const QJsonObject& jsonObject, bool requ MissionCmdParamInfo* paramInfo = new MissionCmdParamInfo(this); paramInfo->_label = paramObject.value(_labelJsonKey).toString(); - paramInfo->_decimalPlaces = paramObject.value(_decimalPlacesJsonKey).toInt(FactMetaData::unknownDecimalPlaces); + paramInfo->_decimalPlaces = paramObject.value(_decimalPlacesJsonKey).toInt(FactMetaData::kUnknownDecimalPlaces); paramInfo->_enumStrings = paramObject.value(_enumStringsJsonKey).toString().split(",", QString::SkipEmptyParts); paramInfo->_param = i; paramInfo->_units = paramObject.value(_unitsJsonKey).toString();