From e678bc34944e2ebd8a66afe5759b3a9d138f4d9b Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 5 Sep 2020 09:44:03 -0700 Subject: [PATCH] Store terrain follow flight speed in Plan file to prevent recalcs on load (#9056) --- .../TransectStyleComplexItem.cc | 23 ++++++++++++------- src/MissionManager/TransectStyleComplexItem.h | 3 ++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/MissionManager/TransectStyleComplexItem.cc b/src/MissionManager/TransectStyleComplexItem.cc index 454ea09b9..da8e119fc 100644 --- a/src/MissionManager/TransectStyleComplexItem.cc +++ b/src/MissionManager/TransectStyleComplexItem.cc @@ -36,7 +36,8 @@ const char* TransectStyleComplexItem::_jsonTransectStyleComplexItemKey = "Tra const char* TransectStyleComplexItem::_jsonCameraCalcKey = "CameraCalc"; const char* TransectStyleComplexItem::_jsonVisualTransectPointsKey = "VisualTransectPoints"; const char* TransectStyleComplexItem::_jsonItemsKey = "Items"; -const char* TransectStyleComplexItem::_jsonFollowTerrainKey = "FollowTerrain"; +const char* TransectStyleComplexItem::_jsonTerrainFollowKey = "FollowTerrain"; +const char* TransectStyleComplexItem::_jsonTerrainFlightSpeed = "TerrainFlightSpeed"; const char* TransectStyleComplexItem::_jsonCameraShotsKey = "CameraShots"; TransectStyleComplexItem::TransectStyleComplexItem(PlanMasterController* masterController, bool flyView, QString settingsGroup, QObject* parent) @@ -149,13 +150,14 @@ void TransectStyleComplexItem::_save(QJsonObject& complexObject) innerObject[cameraTriggerInTurnAroundName] = _cameraTriggerInTurnAroundFact.rawValue().toBool(); innerObject[hoverAndCaptureName] = _hoverAndCaptureFact.rawValue().toBool(); innerObject[refly90DegreesName] = _refly90DegreesFact.rawValue().toBool(); - innerObject[_jsonFollowTerrainKey] = _followTerrain; + innerObject[_jsonTerrainFollowKey] = _followTerrain; innerObject[_jsonCameraShotsKey] = _cameraShots; if (_followTerrain) { - innerObject[terrainAdjustToleranceName] = _terrainAdjustToleranceFact.rawValue().toDouble(); - innerObject[terrainAdjustMaxClimbRateName] = _terrainAdjustMaxClimbRateFact.rawValue().toDouble(); - innerObject[terrainAdjustMaxDescentRateName] = _terrainAdjustMaxDescentRateFact.rawValue().toDouble(); + innerObject[terrainAdjustToleranceName] = _terrainAdjustToleranceFact.rawValue().toDouble(); + innerObject[terrainAdjustMaxClimbRateName] = _terrainAdjustMaxClimbRateFact.rawValue().toDouble(); + innerObject[terrainAdjustMaxDescentRateName] = _terrainAdjustMaxDescentRateFact.rawValue().toDouble(); + innerObject[_jsonTerrainFlightSpeed] = _vehicleSpeed; } QJsonObject cameraCalcObject; @@ -222,8 +224,8 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, bool forP { _jsonCameraCalcKey, QJsonValue::Object, true }, { _jsonVisualTransectPointsKey, QJsonValue::Array, !forPresets }, { _jsonItemsKey, QJsonValue::Array, !forPresets }, - { _jsonFollowTerrainKey, QJsonValue::Bool, true }, - { _jsonCameraShotsKey, QJsonValue::Double, false }, // Not required since it was missing from initial implementation + { _jsonTerrainFollowKey, QJsonValue::Bool, true }, + { _jsonCameraShotsKey, QJsonValue::Double, false }, // Not required since it was missing from initial implementation }; if (!JsonHelper::validateKeys(innerObject, innerKeyInfoList, errorString)) { return false; @@ -262,7 +264,7 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, bool forP _cameraTriggerInTurnAroundFact.setRawValue (innerObject[cameraTriggerInTurnAroundName].toBool()); _hoverAndCaptureFact.setRawValue (innerObject[hoverAndCaptureName].toBool()); _refly90DegreesFact.setRawValue (innerObject[refly90DegreesName].toBool()); - _followTerrain = innerObject[_jsonFollowTerrainKey].toBool(); + _followTerrain = innerObject[_jsonTerrainFollowKey].toBool(); // These two keys where not included in initial implementation so they are optional. Without them the values will be // incorrect when loaded though. @@ -275,6 +277,7 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, bool forP { terrainAdjustToleranceName, QJsonValue::Double, true }, { terrainAdjustMaxClimbRateName, QJsonValue::Double, true }, { terrainAdjustMaxDescentRateName, QJsonValue::Double, true }, + { _jsonTerrainFlightSpeed, QJsonValue::Double, false }, // Not required since it was missing from initial implementation }; if (!JsonHelper::validateKeys(innerObject, followTerrainKeyInfoList, errorString)) { return false; @@ -283,6 +286,9 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, bool forP _terrainAdjustToleranceFact.setRawValue (innerObject[terrainAdjustToleranceName].toDouble()); _terrainAdjustMaxClimbRateFact.setRawValue (innerObject[terrainAdjustMaxClimbRateName].toDouble()); _terrainAdjustMaxDescentRateFact.setRawValue (innerObject[terrainAdjustMaxDescentRateName].toDouble()); + if (innerObject.contains(_jsonTerrainFlightSpeed)) { + _vehicleSpeed = innerObject[_jsonTerrainFlightSpeed].toDouble(); + } if (!forPresets) { // We have to grovel through mission items to determine min/max alt @@ -622,6 +628,7 @@ TransectStyleComplexItem::ReadyForSaveState TransectStyleComplexItem::readyForSa terrainReady = true; } bool polygonNotReady = !_surveyAreaPolygon.isValid(); + qDebug() << polygonNotReady << _wizardMode << terrainReady; return (polygonNotReady || _wizardMode) ? NotReadyForSaveData : (terrainReady ? ReadyForSave : NotReadyForSaveTerrain); diff --git a/src/MissionManager/TransectStyleComplexItem.h b/src/MissionManager/TransectStyleComplexItem.h index 988215156..0709e7663 100644 --- a/src/MissionManager/TransectStyleComplexItem.h +++ b/src/MissionManager/TransectStyleComplexItem.h @@ -208,7 +208,8 @@ protected: static const char* _jsonTransectStyleComplexItemKey; static const char* _jsonVisualTransectPointsKey; static const char* _jsonItemsKey; - static const char* _jsonFollowTerrainKey; + static const char* _jsonTerrainFollowKey; + static const char* _jsonTerrainFlightSpeed; static const char* _jsonCameraShotsKey; static const int _terrainQueryTimeoutMsecs= 1000; -- 2.22.0