Commit e13234e0 authored by DonLakeFlyer's avatar DonLakeFlyer

Fix load/save bugs

parent dd1ea23a
...@@ -29,7 +29,6 @@ const char* CorridorScanComplexItem::jsonComplexItemTypeValue = "CorridorScan"; ...@@ -29,7 +29,6 @@ const char* CorridorScanComplexItem::jsonComplexItemTypeValue = "CorridorScan";
CorridorScanComplexItem::CorridorScanComplexItem(Vehicle* vehicle, QObject* parent) CorridorScanComplexItem::CorridorScanComplexItem(Vehicle* vehicle, QObject* parent)
: TransectStyleComplexItem (vehicle, settingsGroup, parent) : TransectStyleComplexItem (vehicle, settingsGroup, parent)
, _ignoreRecalc (false)
, _entryPoint (0) , _entryPoint (0)
, _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CorridorScan.SettingsGroup.json"), this)) , _metaDataMap (FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/CorridorScan.SettingsGroup.json"), this))
, _corridorWidthFact (settingsGroup, _metaDataMap[corridorWidthName]) , _corridorWidthFact (settingsGroup, _metaDataMap[corridorWidthName])
......
...@@ -69,8 +69,7 @@ private: ...@@ -69,8 +69,7 @@ private:
QGCMapPolyline _corridorPolyline; QGCMapPolyline _corridorPolyline;
QList<QList<QGeoCoordinate>> _transectSegments; ///< Internal transect segments including grid exit, turnaround and internal camera points QList<QList<QGeoCoordinate>> _transectSegments; ///< Internal transect segments including grid exit, turnaround and internal camera points
bool _ignoreRecalc; int _entryPoint;
int _entryPoint;
QMap<QString, FactMetaData*> _metaDataMap; QMap<QString, FactMetaData*> _metaDataMap;
SettingsFact _corridorWidthFact; SettingsFact _corridorWidthFact;
......
...@@ -32,7 +32,7 @@ const char* TransectStyleComplexItem::terrainAdjustMaxDescentRateName = "Ter ...@@ -32,7 +32,7 @@ const char* TransectStyleComplexItem::terrainAdjustMaxDescentRateName = "Ter
const char* TransectStyleComplexItem::_jsonTransectStyleComplexItemKey = "TransectStyleComplexItem"; const char* TransectStyleComplexItem::_jsonTransectStyleComplexItemKey = "TransectStyleComplexItem";
const char* TransectStyleComplexItem::_jsonCameraCalcKey = "CameraCalc"; const char* TransectStyleComplexItem::_jsonCameraCalcKey = "CameraCalc";
const char* TransectStyleComplexItem::_jsonTransectPointsKey = "TransectPoints"; const char* TransectStyleComplexItem::_jsonVisualTransectPointsKey = "VisualTransectPoints";
const char* TransectStyleComplexItem::_jsonItemsKey = "Items"; const char* TransectStyleComplexItem::_jsonItemsKey = "Items";
const char* TransectStyleComplexItem::_jsonFollowTerrainKey = "FollowTerrain"; const char* TransectStyleComplexItem::_jsonFollowTerrainKey = "FollowTerrain";
...@@ -150,7 +150,7 @@ void TransectStyleComplexItem::_save(QJsonObject& complexObject) ...@@ -150,7 +150,7 @@ void TransectStyleComplexItem::_save(QJsonObject& complexObject)
// Save transects polyline // Save transects polyline
JsonHelper::saveGeoCoordinateArray(_visualTransectPoints, false /* writeAltitude */, transectPointsJson); JsonHelper::saveGeoCoordinateArray(_visualTransectPoints, false /* writeAltitude */, transectPointsJson);
innerObject[_jsonTransectPointsKey] = transectPointsJson; innerObject[_jsonVisualTransectPointsKey] = transectPointsJson;
// Save the interal mission items // Save the interal mission items
QJsonArray missionItemsJsonArray; QJsonArray missionItemsJsonArray;
...@@ -205,7 +205,7 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, QString& ...@@ -205,7 +205,7 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, QString&
{ hoverAndCaptureName, QJsonValue::Bool, true }, { hoverAndCaptureName, QJsonValue::Bool, true },
{ refly90DegreesName, QJsonValue::Bool, true }, { refly90DegreesName, QJsonValue::Bool, true },
{ _jsonCameraCalcKey, QJsonValue::Object, true }, { _jsonCameraCalcKey, QJsonValue::Object, true },
{ _jsonTransectPointsKey, QJsonValue::Array, true }, { _jsonVisualTransectPointsKey, QJsonValue::Array, true },
{ _jsonItemsKey, QJsonValue::Array, true }, { _jsonItemsKey, QJsonValue::Array, true },
{ _jsonFollowTerrainKey, QJsonValue::Bool, true }, { _jsonFollowTerrainKey, QJsonValue::Bool, true },
}; };
...@@ -213,13 +213,12 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, QString& ...@@ -213,13 +213,12 @@ bool TransectStyleComplexItem::_load(const QJsonObject& complexObject, QString&
return false; return false;
} }
#if 0 // Load visual transect points
// FIXME if (!JsonHelper::loadGeoCoordinateArray(innerObject[_jsonVisualTransectPointsKey], false /* altitudeRequired */, _visualTransectPoints, errorString)) {
// Load transect points
if (!JsonHelper::loadGeoCoordinateArray(innerObject[_jsonTransectPointsKey], false /* altitudeRequired */, _transectPoints, errorString)) {
return false; return false;
} }
#endif _coordinate = _visualTransectPoints.count() ? _visualTransectPoints.first().value<QGeoCoordinate>() : QGeoCoordinate();
_exitCoordinate = _visualTransectPoints.count() ? _visualTransectPoints.last().value<QGeoCoordinate>() : QGeoCoordinate();
// Load generated mission items // Load generated mission items
_loadedMissionItemsParent = new QObject(this); _loadedMissionItemsParent = new QObject(this);
...@@ -339,6 +338,10 @@ bool TransectStyleComplexItem::hoverAndCaptureAllowed(void) const ...@@ -339,6 +338,10 @@ bool TransectStyleComplexItem::hoverAndCaptureAllowed(void) const
void TransectStyleComplexItem::_rebuildTransects(void) void TransectStyleComplexItem::_rebuildTransects(void)
{ {
if (_ignoreRecalc) {
return;
}
_rebuildTransectsPhase1(); _rebuildTransectsPhase1();
_queryTransectsPathHeightInfo(); _queryTransectsPathHeightInfo();
...@@ -352,6 +355,11 @@ void TransectStyleComplexItem::_rebuildTransects(void) ...@@ -352,6 +355,11 @@ void TransectStyleComplexItem::_rebuildTransects(void)
} }
emit visualTransectPointsChanged(); emit visualTransectPointsChanged();
_coordinate = _visualTransectPoints.count() ? _visualTransectPoints.first().value<QGeoCoordinate>() : QGeoCoordinate();
_exitCoordinate = _visualTransectPoints.count() ? _visualTransectPoints.last().value<QGeoCoordinate>() : QGeoCoordinate();
emit coordinateChanged(_coordinate);
emit exitCoordinateChanged(_exitCoordinate);
_rebuildTransectsPhase2(); _rebuildTransectsPhase2();
emit lastSequenceNumberChanged(lastSequenceNumber()); emit lastSequenceNumberChanged(lastSequenceNumber());
...@@ -654,20 +662,26 @@ void TransectStyleComplexItem::setFollowTerrain(bool followTerrain) ...@@ -654,20 +662,26 @@ void TransectStyleComplexItem::setFollowTerrain(bool followTerrain)
int TransectStyleComplexItem::lastSequenceNumber(void) const int TransectStyleComplexItem::lastSequenceNumber(void) const
{ {
int itemCount = 0; if (_loadedMissionItems.count()) {
// We have stored mission items, just use those
return _sequenceNumber + _loadedMissionItems.count() - 1;
} else {
// We have to determine from transects
int itemCount = 0;
foreach (const QList<CoordInfo_t>& rgCoordInfo, _transects) { foreach (const QList<CoordInfo_t>& rgCoordInfo, _transects) {
itemCount += rgCoordInfo.count(); itemCount += rgCoordInfo.count();
} }
if (_cameraTriggerInTurnAroundFact.rawValue().toBool()) { if (_cameraTriggerInTurnAroundFact.rawValue().toBool()) {
// Only one camera start and on camera stop // Only one camera start and on camera stop
itemCount += 2; itemCount += 2;
} else { } else {
// Each transect will have a camera start and stop in it // Each transect will have a camera start and stop in it
itemCount += _transects.count() * 2; itemCount += _transects.count() * 2;
} }
return _sequenceNumber + itemCount - 1; return _sequenceNumber + itemCount - 1;
}
} }
...@@ -192,7 +192,7 @@ protected: ...@@ -192,7 +192,7 @@ protected:
static const char* _jsonCameraCalcKey; static const char* _jsonCameraCalcKey;
static const char* _jsonTransectStyleComplexItemKey; static const char* _jsonTransectStyleComplexItemKey;
static const char* _jsonTransectPointsKey; static const char* _jsonVisualTransectPointsKey;
static const char* _jsonItemsKey; static const char* _jsonItemsKey;
static const char* _jsonFollowTerrainKey; static const char* _jsonFollowTerrainKey;
......
...@@ -134,7 +134,7 @@ Rectangle { ...@@ -134,7 +134,7 @@ Rectangle {
SectionHeader { SectionHeader {
id: terrainHeader id: terrainHeader
text: qsTr("Terrain") text: qsTr("Terrain")
checked: false checked: missionItem.followTerrain
} }
ColumnLayout { ColumnLayout {
......
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