Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
e5b570c5
Commit
e5b570c5
authored
Dec 07, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp, QVariant compile error
parent
6485d280
Changes
49
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
2587 additions
and
2079 deletions
+2587
-2079
FactGroup.cc
src/FactSystem/FactGroup.cc
+1
-1
FactGroup.h
src/FactSystem/FactGroup.h
+1
-1
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+4
-4
FactMetaData.h
src/FactSystem/FactMetaData.h
+1
-1
JsonHelper.cc
src/JsonHelper.cc
+463
-430
JsonHelper.h
src/JsonHelper.h
+187
-158
AreaData.cc
src/MeasurementComplexItem/AreaData.cc
+40
-0
AreaData.h
src/MeasurementComplexItem/AreaData.h
+5
-0
CircularGenerator.cpp
src/MeasurementComplexItem/CircularGenerator.cpp
+51
-3
CircularGenerator.h
src/MeasurementComplexItem/CircularGenerator.h
+12
-3
GeneratorBase.h
src/MeasurementComplexItem/GeneratorBase.h
+5
-0
LinearGenerator.cpp
src/MeasurementComplexItem/LinearGenerator.cpp
+46
-0
LinearGenerator.h
src/MeasurementComplexItem/LinearGenerator.h
+11
-0
MeasurementComplexItem.cc
src/MeasurementComplexItem/MeasurementComplexItem.cc
+55
-4
MeasurementComplexItem.h
src/MeasurementComplexItem/MeasurementComplexItem.h
+2
-1
CorridorScanComplexItem.cc
src/MissionManager/CorridorScanComplexItem.cc
+1
-1
CorridorScanComplexItem.h
src/MissionManager/CorridorScanComplexItem.h
+1
-1
FWLandingPatternTest.cc
src/MissionManager/FWLandingPatternTest.cc
+1
-1
FixedWingLandingComplexItem.cc
src/MissionManager/FixedWingLandingComplexItem.cc
+1
-1
FixedWingLandingComplexItem.h
src/MissionManager/FixedWingLandingComplexItem.h
+1
-1
GeoFenceController.cc
src/MissionManager/GeoFenceController.cc
+4
-4
LandingComplexItemTest.h
src/MissionManager/LandingComplexItemTest.h
+1
-1
MissionCommandList.cc
src/MissionManager/MissionCommandList.cc
+1
-1
MissionController.cc
src/MissionManager/MissionController.cc
+4
-4
MissionItem.cc
src/MissionManager/MissionItem.cc
+4
-4
MissionItemTest.cc
src/MissionManager/MissionItemTest.cc
+12
-12
MissionSettingsItem.cc
src/MissionManager/MissionSettingsItem.cc
+1
-1
MissionSettingsItem.h
src/MissionManager/MissionSettingsItem.h
+1
-1
RallyPointController.cc
src/MissionManager/RallyPointController.cc
+1
-1
SimpleMissionItem.cc
src/MissionManager/SimpleMissionItem.cc
+1
-1
SimpleMissionItem.h
src/MissionManager/SimpleMissionItem.h
+1
-1
StructureScanComplexItem.cc
src/MissionManager/StructureScanComplexItem.cc
+1
-1
StructureScanComplexItem.h
src/MissionManager/StructureScanComplexItem.h
+1
-1
StructureScanComplexItemTest.cc
src/MissionManager/StructureScanComplexItemTest.cc
+1
-1
SurveyComplexItem.cc
src/MissionManager/SurveyComplexItem.cc
+1470
-1263
SurveyComplexItem.h
src/MissionManager/SurveyComplexItem.h
+166
-143
TransectStyleComplexItem.cc
src/MissionManager/TransectStyleComplexItem.cc
+2
-2
TransectStyleComplexItem.h
src/MissionManager/TransectStyleComplexItem.h
+1
-1
TransectStyleComplexItemTest.h
src/MissionManager/TransectStyleComplexItemTest.h
+1
-1
VTOLLandingComplexItem.cc
src/MissionManager/VTOLLandingComplexItem.cc
+1
-1
VTOLLandingComplexItem.h
src/MissionManager/VTOLLandingComplexItem.h
+1
-1
VisualMissionItem.h
src/MissionManager/VisualMissionItem.h
+1
-1
QGeoCodeReplyQGC.cpp
src/QtLocationPlugin/QGeoCodeReplyQGC.cpp
+4
-4
TerrainQuery.cc
src/Terrain/TerrainQuery.cc
+5
-5
TerrainTile.cc
src/TerrainTile.cc
+4
-4
CompInfoParam.cc
src/Vehicle/CompInfoParam.cc
+1
-1
CompInfoVersion.cc
src/Vehicle/CompInfoVersion.cc
+1
-1
FirmwareUpgradeController.cc
src/VehicleSetup/FirmwareUpgradeController.cc
+4
-4
QGCSerialPortInfo.cc
src/comm/QGCSerialPortInfo.cc
+2
-2
No files found.
src/FactSystem/FactGroup.cc
View file @
e5b570c5
...
...
@@ -37,7 +37,7 @@ FactGroup::FactGroup(int updateRateMsecs, QObject* parent, bool ignoreCamelCase)
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
}
void
FactGroup
::
_loadFromJsonArray
(
const
QJson
Array
jsonArray
)
void
FactGroup
::
_loadFromJsonArray
(
const
QJson
Object
jsonArray
)
{
QMap
<
QString
,
QString
>
defineMap
;
_nameToFactMetaDataMap
=
FactMetaData
::
createMapFromJsonArray
(
jsonArray
,
defineMap
,
this
);
...
...
src/FactSystem/FactGroup.h
View file @
e5b570c5
...
...
@@ -64,7 +64,7 @@ protected slots:
protected:
void
_addFact
(
Fact
*
fact
,
const
QString
&
name
);
void
_addFactGroup
(
FactGroup
*
factGroup
,
const
QString
&
name
);
void
_loadFromJsonArray
(
const
QJson
Array
jsonArray
);
void
_loadFromJsonArray
(
const
QJson
Object
jsonArray
);
void
_setTelemetryAvailable
(
bool
telemetryAvailable
);
int
_updateRateMSecs
;
///< Update rate for Fact::valueChanged signals, 0: immediate update
...
...
src/FactSystem/FactMetaData.cc
View file @
e5b570c5
...
...
@@ -1448,7 +1448,7 @@ QMap<QString, FactMetaData*> FactMetaData::createMapFromJsonFile(const QString&
return
metaDataMap
;
}
QJson
Array
factArray
;
QJson
Object
factArray
;
QMap
<
QString
/* define name */
,
QString
/* define value */
>
defineMap
;
QList
<
JsonHelper
::
KeyValidateInfo
>
keyInfoList
=
{
...
...
@@ -1466,7 +1466,7 @@ QMap<QString, FactMetaData*> FactMetaData::createMapFromJsonFile(const QString&
return
createMapFromJsonArray
(
factArray
,
defineMap
,
metaDataParent
);
}
QMap
<
QString
,
FactMetaData
*>
FactMetaData
::
createMapFromJsonArray
(
const
QJson
Array
jsonArray
,
QMap
<
QString
,
QString
>&
defineMap
,
QObject
*
metaDataParent
)
QMap
<
QString
,
FactMetaData
*>
FactMetaData
::
createMapFromJsonArray
(
const
QJson
Object
jsonArray
,
QMap
<
QString
,
QString
>&
defineMap
,
QObject
*
metaDataParent
)
{
QMap
<
QString
,
FactMetaData
*>
metaDataMap
;
for
(
int
i
=
0
;
i
<
jsonArray
.
count
();
i
++
)
{
...
...
@@ -1554,7 +1554,7 @@ bool FactMetaData::_parseValuesArray(const QJsonObject& jsonObject, QStringList&
{
_enumValuesArrayValueJsonKey
,
QJsonValue
::
Double
,
true
},
};
const
QJson
Array
&
rgValueDescription
=
jsonObject
[
_enumValuesArrayJsonKey
].
toArray
();
const
QJson
Object
&
rgValueDescription
=
jsonObject
[
_enumValuesArrayJsonKey
].
toArray
();
for
(
int
i
=
0
;
i
<
rgValueDescription
.
count
();
i
++
)
{
if
(
rgValueDescription
[
i
].
type
()
!=
QJsonValue
::
Object
)
{
errorString
=
QStringLiteral
(
"Value at index %1 in
\"
values
\"
array is not an object."
).
arg
(
i
);
...
...
@@ -1589,7 +1589,7 @@ bool FactMetaData::_parseBitmaskArray(const QJsonObject& jsonObject, QStringList
{
_enumBitmaskArrayIndexJsonKey
,
QJsonValue
::
Double
,
true
},
};
const
QJson
Array
&
rgValueDescription
=
jsonObject
[
_enumBitmaskArrayJsonKey
].
toArray
();
const
QJson
Object
&
rgValueDescription
=
jsonObject
[
_enumBitmaskArrayJsonKey
].
toArray
();
for
(
int
i
=
0
;
i
<
rgValueDescription
.
count
();
i
++
)
{
if
(
rgValueDescription
[
i
].
type
()
!=
QJsonValue
::
Object
)
{
errorString
=
QStringLiteral
(
"Value at index %1 in
\"
values
\"
array is not an object."
).
arg
(
i
);
...
...
src/FactSystem/FactMetaData.h
View file @
e5b570c5
...
...
@@ -57,7 +57,7 @@ public:
typedef
QMap
<
QString
,
QString
>
DefineMap_t
;
static
QMap
<
QString
,
FactMetaData
*>
createMapFromJsonFile
(
const
QString
&
jsonFilename
,
QObject
*
metaDataParent
);
static
QMap
<
QString
,
FactMetaData
*>
createMapFromJsonArray
(
const
QJson
Array
jsonArray
,
DefineMap_t
&
defineMap
,
QObject
*
metaDataParent
);
static
QMap
<
QString
,
FactMetaData
*>
createMapFromJsonArray
(
const
QJson
Object
jsonArray
,
DefineMap_t
&
defineMap
,
QObject
*
metaDataParent
);
static
FactMetaData
*
createFromJsonObject
(
const
QJsonObject
&
json
,
QMap
<
QString
,
QString
>&
defineMap
,
QObject
*
metaDataParent
);
...
...
src/JsonHelper.cc
View file @
e5b570c5
This diff is collapsed.
Click to expand it.
src/JsonHelper.h
View file @
e5b570c5
This diff is collapsed.
Click to expand it.
src/MeasurementComplexItem/AreaData.cc
View file @
e5b570c5
...
...
@@ -4,12 +4,17 @@
#include "geometry/SafeArea.h"
#include "geometry/snake.h"
#include "JsonHelper.h"
#include "QGCApplication.h"
#include "QGCLoggingCategory.h"
#include "QGCQGeoCoordinate.h"
QGC_LOGGING_CATEGORY
(
AreaDataLog
,
"AreaDataLog"
)
const
char
*
originJsonKey
=
"Origin"
;
const
char
*
areaListJsonKey
=
"AreaList"
;
const
char
*
initializedJsonKey
=
"Initialized"
;
AreaData
::
AreaData
(
QObject
*
parent
)
:
QObject
(
parent
)
{}
AreaData
::~
AreaData
()
{}
...
...
@@ -270,6 +275,41 @@ bool AreaData::operator!=(const AreaData &other) const {
return
!
(
*
this
==
other
);
}
bool
AreaData
::
load
(
const
QJsonObject
&
obj
,
QString
&
guiErrorString
)
{
qWarning
()
<<
"AreaData::load impl. missing"
;
return
true
;
}
bool
AreaData
::
save
(
QJsonObject
&
obj
)
const
{
// QJsonObject temp;
// QJsonValue jsonOrigin;
// JsonHelper::saveGeoCoordinate(_origin, true, jsonOrigin);
// temp[originJsonKey] = jsonOrigin;
// temp[initializedJsonKey] = _initialized;
// QJsonObject jsonAreaList;
// for (int i = 0; i < _areaList.count(); ++i) {
// auto const &qobj = _areaList[i];
// auto const &area = qobject_cast<const GeoArea *>(qobj);
// QJsonObject jsonArea;
// if (area->saveToJson(jsonArea)) {
// QJsonObject jsonObj;
// jsonObj[area->objectName()] = jsonArea;
// jsonAreaList.append(jsonObj);
// } else {
// qDebug(AreaListLog) << "save(): not able to save area: "
// << area->objectName();
// _processError(tr("Not able to save area: ") + area->objectName());
// return false;
// }
// }
// temp[areaListJsonKey] = jsonAreaList;
// obj = std::move(temp);
return
true
;
}
void
AreaData
::
_setOrigin
(
const
QGeoCoordinate
&
origin
)
{
if
(
this
->
_origin
!=
origin
)
{
this
->
_origin
=
origin
;
...
...
src/MeasurementComplexItem/AreaData.h
View file @
e5b570c5
#pragma once
#include <QGeoCoordinate>
#include <QJsonObject>
#include <QObject>
#include <QString>
#include "QmlObjectListModel.h"
...
...
@@ -72,6 +74,9 @@ public:
bool
operator
==
(
const
AreaData
&
other
)
const
;
bool
operator
!=
(
const
AreaData
&
other
)
const
;
bool
load
(
const
QJsonObject
&
obj
,
QString
&
guiErrorString
);
bool
save
(
QJsonObject
&
obj
)
const
;
QString
errorString
()
const
;
// Contains a message about the last error.
bool
showErrorMessages
()
const
;
...
...
src/MeasurementComplexItem/CircularGenerator.cpp
View file @
e5b570c5
#include "CircularGenerator.h"
#include "JsonHelper.h"
#include "QGCLoggingCategory.h"
#include "SettingsFact.h"
...
...
@@ -29,9 +30,7 @@ const char *CircularGenerator::settingsGroup = "CircularGenerator";
const
char
*
CircularGenerator
::
distanceName
=
"TransectDistance"
;
const
char
*
CircularGenerator
::
deltaAlphaName
=
"DeltaAlpha"
;
const
char
*
CircularGenerator
::
minLengthName
=
"MinLength"
;
const
char
*
CircularGenerator
::
refPointLatitudeName
=
"ReferencePointLat"
;
const
char
*
CircularGenerator
::
refPointLongitudeName
=
"ReferencePointLong"
;
const
char
*
CircularGenerator
::
refPointAltitudeName
=
"ReferencePointAlt"
;
const
char
*
CircularGenerator
::
refPointName
=
"ReferencePoint"
;
CircularGenerator
::
CircularGenerator
(
QObject
*
parent
)
:
CircularGenerator
(
nullptr
,
parent
)
{}
...
...
@@ -184,6 +183,55 @@ void CircularGenerator::setReference(const QGeoCoordinate &reference) {
}
}
bool
CircularGenerator
::
save
(
QJsonObject
&
obj
)
const
{
// QJsonObject temp;
// bool ok = false;
// auto variant = _distance.rawValue();
// auto val = variant.toDouble(ok);
// if (!ok) {
// qCDebug(CircularGeneratorLog)
// << "save(): not able to save distance. Not a double: "
// << variant.typeName();
// return false;
// } else {
// temp[distanceName] = val;
// }
// variant = _deltaAlpha.rawValue();
// val = variant.toDouble(ok);
// if (!ok) {
// qCDebug(CircularGeneratorLog)
// << "save(): not able to save deltaAlpha. Not a double: "
// << variant.typeName();
// return false;
// } else {
// temp[deltaAlphaName] = val;
// }
// variant = _minLength.rawValue();
// val = variant.toDouble(ok);
// if (!ok) {
// qCDebug(CircularGeneratorLog)
// << "save(): not able to save minLength. Not a double: "
// << variant.typeName();
// return false;
// } else {
// temp[minLengthName] = val;
// }
// QJsonObject jsonReference;
// JsonHelper::saveGeoCoordinate(_reference, true, jsonReference);
// temp[refPointName] = jsonReference;
// obj = std::move(temp);
return
true
;
}
bool
CircularGenerator
::
load
(
const
QJsonObject
&
obj
,
QString
&
guiErrorMessage
)
{
qWarning
()
<<
"CircularGenerator::load() impl. missing"
;
return
true
;
}
void
CircularGenerator
::
resetReferenceIfInvalid
()
{
if
(
!
this
->
_reference
.
isValid
())
{
resetReference
();
...
...
src/MeasurementComplexItem/CircularGenerator.h
View file @
e5b570c5
...
...
@@ -35,13 +35,22 @@ public:
void
setReference
(
const
QGeoCoordinate
&
reference
);
//!
//! \brief save Saves the generator.
//! \param obj Json object for saveing.
//! \return Returns true on success, false either.
//!
//! Saves distance, alpha and minLength.
//! \note This methode does not save the data.
//!
virtual
bool
save
(
QJsonObject
&
obj
)
const
override
;
virtual
bool
load
(
const
QJsonObject
&
obj
,
QString
&
guiErrorMessage
)
override
;
static
const
char
*
settingsGroup
;
static
const
char
*
distanceName
;
static
const
char
*
deltaAlphaName
;
static
const
char
*
minLengthName
;
static
const
char
*
refPointLongitudeName
;
static
const
char
*
refPointLatitudeName
;
static
const
char
*
refPointAltitudeName
;
static
const
char
*
refPointName
;
signals:
void
referenceChanged
();
...
...
src/MeasurementComplexItem/GeneratorBase.h
View file @
e5b570c5
#pragma once
#include <QJsonObject>
#include <QObject>
#include <QString>
#include <functional>
#include <memory>
...
...
@@ -27,6 +29,9 @@ public:
virtual
QString
editorQml
()
=
0
;
virtual
QString
mapVisualQml
()
=
0
;
virtual
bool
save
(
QJsonObject
&
obj
)
const
=
0
;
virtual
bool
load
(
const
QJsonObject
&
obj
,
QString
&
guiErrorMessage
)
=
0
;
virtual
QString
name
()
=
0
;
virtual
QString
abbreviation
()
=
0
;
...
...
src/MeasurementComplexItem/LinearGenerator.cpp
View file @
e5b570c5
...
...
@@ -149,6 +149,52 @@ bool LinearGenerator::get(Generator &generator) {
}
}
bool
LinearGenerator
::
save
(
QJsonObject
&
obj
)
const
{
// QJsonObject temp;
// bool ok = false;
// auto variant = _distance.rawValue();
// auto val = variant.toDouble(ok);
// if (!ok) {
// qCDebug(LinearGeneratorLog)
// << "save(): not able to save distance. Not a double: "
// << variant.typeName();
// return false;
// } else {
// temp[distanceName] = val;
// }
// variant = _alpha.rawValue();
// val = variant.toDouble(ok);
// if (!ok) {
// qCDebug(LinearGeneratorLog)
// << "save(): not able to save alpha. Not a double: "
// << variant.typeName();
// return false;
// } else {
// temp[alphaName] = val;
// }
// variant = _minLength.rawValue();
// val = variant.toDouble(ok);
// if (!ok) {
// qCDebug(LinearGeneratorLog)
// << "save(): not able to save minLength. Not a double: "
// << variant.typeName();
// return false;
// } else {
// temp[minLengthName] = val;
// }
// obj = std::move(temp);
return
true
;
}
bool
LinearGenerator
::
load
(
const
QJsonObject
&
obj
,
QString
&
guiErrorString
)
{
qWarning
()
<<
"LinearGenerator::load() impl. missing"
;
return
true
;
}
Fact
*
LinearGenerator
::
distance
()
{
return
&
_distance
;
}
Fact
*
LinearGenerator
::
alpha
()
{
return
&
_alpha
;
}
...
...
src/MeasurementComplexItem/LinearGenerator.h
View file @
e5b570c5
...
...
@@ -27,6 +27,17 @@ public:
virtual
bool
get
(
Generator
&
generator
)
override
;
//!
//! \brief save Saves the generator.
//! \param obj Json object for saveing.
//! \return Returns true on success, false either.
//!
//! Saves distance, alpha and minLength.
//! \note This methode does not save the data.
//!
virtual
bool
save
(
QJsonObject
&
obj
)
const
override
;
virtual
bool
load
(
const
QJsonObject
&
obj
,
QString
&
guiErrorString
)
override
;
Fact
*
distance
();
Fact
*
alpha
();
Fact
*
minLength
();
...
...
src/MeasurementComplexItem/MeasurementComplexItem.cc
View file @
e5b570c5
...
...
@@ -33,6 +33,10 @@ const char *MeasurementComplexItem::jsonComplexItemTypeValue =
const
char
*
MeasurementComplexItem
::
variantName
=
"Variant"
;
const
char
*
MeasurementComplexItem
::
altitudeName
=
"Altitude"
;
const
QString
MeasurementComplexItem
::
name
(
tr
(
"Measurement"
));
const
char
*
areaDataName
=
"AreaDataName"
;
const
char
*
variantNamesName
=
"VariantNames"
;
const
char
*
generatorsName
=
"Generators"
;
const
char
*
variantsName
=
"Variants"
;
MeasurementComplexItem
::
MeasurementComplexItem
(
PlanMasterController
*
masterController
,
bool
flyView
,
...
...
@@ -208,10 +212,7 @@ QString MeasurementComplexItem::mapVisualQML() const {
return
QStringLiteral
(
"MeasurementItemMapVisual.qml"
);
}
void
MeasurementComplexItem
::
save
(
QJsonArray
&
planItems
)
{
qWarning
()
<<
"MeasurementComplexItem::save(): area data save missing."
;
qWarning
()
<<
"MeasurementComplexItem::save(): mission item save missing."
;
void
MeasurementComplexItem
::
save
(
QJsonObject
&
planItems
)
{
if
(
idle
())
{
QJsonObject
saveObject
;
...
...
@@ -221,10 +222,60 @@ void MeasurementComplexItem::save(QJsonArray &planItems) {
saveObject
[
ComplexMissionItem
::
jsonComplexItemTypeKey
]
=
jsonComplexItemTypeValue
;
// Variant and altitude.
saveObject
[
variantName
]
=
double
(
_variant
.
rawValue
().
toUInt
());
saveObject
[
altitudeName
]
=
double
(
_altitude
.
rawValue
().
toUInt
());
// Variant names.
QJsonObject
jsonVariantNames
;
for
(
auto
const
&
name
:
_variantNames
)
{
jsonVariantNames
.
append
(
name
);
}
saveObject
[
variantNamesName
]
=
jsonVariantNames
;
// AreaData.
// QJsonObject jsonAreaData;
// if (!_pAreaData->save(jsonAreaData)) {
// qCDebug(MeasurementComplexItemLog)
// << "save(): not able to save area data";
// return;
// }
// saveObject[areaDataName] = jsonAreaData;
// Generators.
// QJsonArray generatorArray;
// for (int i = 0; i < _generatorList.size(); ++i) {
// auto const gen = _generatorList[i];
// auto const &name = _generatorNameList[i];
// QJsonObject innerObj;
// if (!gen->save(innerObj)) {
// qCDebug(MeasurementComplexItemLog)
// << "save(): not able to save generator: " << name;
// return;
// } else {
// QJsonObject outerObj;
// outerObj[name] = innerObj;
// generatorArray.append(outerObj);
// }
// }
// saveObject[generatorsName] = generatorArray;
// Route Variants
QJsonObject
variantsArray
;
for
(
auto
const
&
route
:
_variantVector
)
{
QJsonValue
variant
;
if
(
!
(
route
.
size
()
==
0
))
{
JsonHelper
::
saveGeoCoordinateArray
(
route
,
true
,
variant
);
}
else
{
JsonHelper
::
saveGeoCoordinateArray
(
_route
,
true
,
variant
);
}
variantsArray
.
append
(
variant
);
}
saveObject
[
variantsName
]
=
variantsArray
;
planItems
.
append
(
saveObject
);
}
else
{
qCDebug
(
MeasurementComplexItemLog
)
<<
"save(): called while not idle."
;
}
}
...
...
src/MeasurementComplexItem/MeasurementComplexItem.h
View file @
e5b570c5
#pragma once
#include <QFutureWatcher>
#include <QJsonArray>
#include <QVector>
#include <memory>
...
...
@@ -84,7 +85,7 @@ public:
virtual
void
setDirty
(
bool
dirty
)
override
final
;
virtual
void
setCoordinate
(
const
QGeoCoordinate
&
coordinate
)
override
final
;
virtual
void
setSequenceNumber
(
int
sequenceNumber
)
override
final
;
virtual
void
save
(
QJson
Array
&
missionItems
)
override
final
;
virtual
void
save
(
QJson
Object
&
missionItems
)
override
final
;
virtual
double
amslEntryAlt
(
void
)
const
override
final
;
virtual
double
amslExitAlt
(
void
)
const
override
final
;
virtual
double
minAMSLAltitude
(
void
)
const
override
final
;
...
...
src/MissionManager/CorridorScanComplexItem.cc
View file @
e5b570c5
...
...
@@ -61,7 +61,7 @@ CorridorScanComplexItem::CorridorScanComplexItem(PlanMasterController* masterCon
setDirty
(
false
);
}
void
CorridorScanComplexItem
::
save
(
QJson
Array
&
planItems
)
void
CorridorScanComplexItem
::
save
(
QJson
Object
&
planItems
)
{
QJsonObject
saveObject
;
...
...
src/MissionManager/CorridorScanComplexItem.h
View file @
e5b570c5
...
...
@@ -37,7 +37,7 @@ public:
// Overrides from TransectStyleComplexItem
QString
patternName
(
void
)
const
final
{
return
name
;
}
void
save
(
QJson
Array
&
planItems
)
final
;
void
save
(
QJson
Object
&
planItems
)
final
;
bool
specifiesCoordinate
(
void
)
const
final
;
double
timeBetweenShots
(
void
)
final
;
...
...
src/MissionManager/FWLandingPatternTest.cc
View file @
e5b570c5
...
...
@@ -81,7 +81,7 @@ void FWLandingPatternTest::_testDirty(void)
void
FWLandingPatternTest
::
_testSaveLoad
(
void
)
{
QJson
Array
items
;
QJson
Object
items
;
_fwItem
->
save
(
items
);
...
...
src/MissionManager/FixedWingLandingComplexItem.cc
View file @
e5b570c5
...
...
@@ -60,7 +60,7 @@ FixedWingLandingComplexItem::FixedWingLandingComplexItem(PlanMasterController* m
setDirty
(
false
);
}
void
FixedWingLandingComplexItem
::
save
(
QJson
Array
&
missionItems
)
void
FixedWingLandingComplexItem
::
save
(
QJson
Object
&
missionItems
)
{
QJsonObject
saveObject
=
_save
();
...
...
src/MissionManager/FixedWingLandingComplexItem.h
View file @
e5b570c5
...
...
@@ -44,7 +44,7 @@ public:
QString
mapVisualQML
(
void
)
const
final
{
return
QStringLiteral
(
"FWLandingPatternMapVisual.qml"
);
}
// Overrides from VisualMissionItem
void
save
(
QJson
Array
&
missionItems
)
final
;
void
save
(
QJson
Object
&
missionItems
)
final
;
static
const
QString
name
;
...
...
src/MissionManager/GeoFenceController.cc
View file @
e5b570c5
...
...
@@ -152,7 +152,7 @@ bool GeoFenceController::load(const QJsonObject& json, QString& errorString)
return
false
;
}
QJson
Array
jsonPolygonArray
=
json
[
_jsonPolygonsKey
].
toArray
();
QJson
Object
jsonPolygonArray
=
json
[
_jsonPolygonsKey
].
toArray
();
for
(
const
QJsonValue
jsonPolygonValue
:
jsonPolygonArray
)
{
if
(
jsonPolygonValue
.
type
()
!=
QJsonValue
::
Object
)
{
errorString
=
tr
(
"GeoFence polygon not stored as object"
);
...
...
@@ -166,7 +166,7 @@ bool GeoFenceController::load(const QJsonObject& json, QString& errorString)
_polygons
.
append
(
fencePolygon
);
}
QJson
Array
jsonCircleArray
=
json
[
_jsonCirclesKey
].
toArray
();
QJson
Object
jsonCircleArray
=
json
[
_jsonCirclesKey
].
toArray
();
for
(
const
QJsonValue
jsonCircleValue
:
jsonCircleArray
)
{
if
(
jsonCircleValue
.
type
()
!=
QJsonValue
::
Object
)
{
errorString
=
tr
(
"GeoFence circle not stored as object"
);
...
...
@@ -200,7 +200,7 @@ void GeoFenceController::save(QJsonObject& json)
{
json
[
JsonHelper
::
jsonVersionKey
]
=
_jsonCurrentVersion
;
QJson
Array
jsonPolygonArray
;
QJson
Object
jsonPolygonArray
;
for
(
int
i
=
0
;
i
<
_polygons
.
count
();
i
++
)
{
QJsonObject
jsonPolygon
;
QGCFencePolygon
*
fencePolygon
=
_polygons
.
value
<
QGCFencePolygon
*>
(
i
);
...
...
@@ -209,7 +209,7 @@ void GeoFenceController::save(QJsonObject& json)
}
json
[
_jsonPolygonsKey
]
=
jsonPolygonArray
;
QJson
Array
jsonCircleArray
;
QJson
Object
jsonCircleArray
;
for
(
int
i
=
0
;
i
<
_circles
.
count
();
i
++
)
{
QJsonObject
jsonCircle
;
QGCFenceCircle
*
fenceCircle
=
_circles
.
value
<
QGCFenceCircle
*>
(
i
);
...
...
src/MissionManager/LandingComplexItemTest.h
View file @
e5b570c5
...
...
@@ -82,7 +82,7 @@ public:
QString
mapVisualQML
(
void
)
const
final
{
return
QStringLiteral
(
"FWLandingPatternMapVisual.qml"
);
}
// Overrides from VisualMissionItem
void
save
(
QJson
Array
&
/*missionItems*/
)
{
};
void
save
(
QJson
Object
&
/*missionItems*/
)
{
};
static
const
QString
name
;
...
...
src/MissionManager/MissionCommandList.cc
View file @
e5b570c5
...
...
@@ -55,7 +55,7 @@ void MissionCommandList::_loadMavCmdInfoJson(const QString& jsonFilename, bool b
}
// Iterate over MissionCommandUIInfo objects
QJson
Array
jsonArray
=
jsonValue
.
toArray
();
QJson
Object
jsonArray
=
jsonValue
.
toArray
();
for
(
QJsonValue
info
:
jsonArray
)
{
if
(
!
info
.
isObject
())
{
qWarning
()
<<
jsonFilename
<<
"mavCmdArray should contain objects"
;
...
...
src/MissionManager/MissionController.cc
View file @
e5b570c5
...
...
@@ -744,7 +744,7 @@ bool MissionController::_loadJsonMissionFileV1(const QJsonObject &json,
// Read complex items
QList
<
SurveyComplexItem
*>
surveyItems
;
QJson
Array
complexArray
(
json
[
_jsonComplexItemsKey
].
toArray
());
QJson
Object
complexArray
(
json
[
_jsonComplexItemsKey
].
toArray
());
qCDebug
(
MissionControllerLog
)
<<
"Json load: complex item count"
<<
complexArray
.
count
();
for
(
int
i
=
0
;
i
<
complexArray
.
count
();
i
++
)
{
...
...
@@ -771,7 +771,7 @@ bool MissionController::_loadJsonMissionFileV1(const QJsonObject &json,
int
nextSimpleItemIndex
=
0
;
int
nextComplexItemIndex
=
0
;
int
nextSequenceNumber
=
1
;
// Start with 1 since home is in 0
QJson
Array
itemArray
(
json
[
_jsonItemsKey
].
toArray
());
QJson
Object
itemArray
(
json
[
_jsonItemsKey
].
toArray
());
MissionSettingsItem
*
settingsItem
=
_addMissionSettings
(
visualItems
);
if
(
json
.
contains
(
_jsonPlannedHomePositionKey
))
{
...
...
@@ -932,7 +932,7 @@ bool MissionController::_loadJsonMissionFileV2(const QJsonObject &json,
// Read mission items
int
nextSequenceNumber
=
1
;
// Start with 1 since home is in 0
const
QJson
Array
rgMissionItems
(
json
[
_jsonItemsKey
].
toArray
());
const
QJson
Object
rgMissionItems
(
json
[
_jsonItemsKey
].
toArray
());
for
(
int
i
=
0
;
i
<
rgMissionItems
.
count
();
i
++
)
{
// Convert to QJsonObject
const
QJsonValue
&
itemValue
=
rgMissionItems
[
i
];
...
...
@@ -1335,7 +1335,7 @@ void MissionController::save(QJsonObject &json) {
// Save the visual items
QJson
Array
rgJsonMissionItems
;
QJson
Object
rgJsonMissionItems
;
for
(
int
i
=
0
;
i
<
_visualItems
->
count
();
i
++
)
{
VisualMissionItem
*
visualItem
=
qobject_cast
<
VisualMissionItem
*>
(
_visualItems
->
get
(
i
));
...
...
src/MissionManager/MissionItem.cc
View file @
e5b570c5
...
...
@@ -147,7 +147,7 @@ void MissionItem::save(QJsonObject &json) const {
json
[
_jsonAutoContinueKey
]
=
autoContinue
();
json
[
_jsonDoJumpIdKey
]
=
_sequenceNumber
;
QJson
Array
rgParams
=
{
param1
(),
param2
(),
param3
(),
param4
(),
QJson
Object
rgParams
=
{
param1
(),
param2
(),
param3
(),
param4
(),
param5
(),
param6
(),
param7
()};
json
[
_jsonParamsKey
]
=
rgParams
;
}
...
...
@@ -206,7 +206,7 @@ bool MissionItem::_convertJsonV1ToV2(const QJsonObject &json,
VisualMissionItem
::
jsonTypeSimpleItemValue
;
}
QJson
Array
rgParams
=
{
QJson
Object
rgParams
=
{
json
[
_jsonParam1Key
].
toDouble
(),
json
[
_jsonParam2Key
].
toDouble
(),
json
[
_jsonParam3Key
].
toDouble
(),
json
[
_jsonParam4Key
].
toDouble
()};
v2Json
[
_jsonParamsKey
]
=
rgParams
;
...
...
@@ -241,7 +241,7 @@ bool MissionItem::_convertJsonV2ToV3(QJsonObject &json, QString &errorString) {
return
false
;
}
QJson
Array
rgParam
=
json
[
_jsonParamsKey
].
toArray
();
QJson
Object
rgParam
=
json
[
_jsonParamsKey
].
toArray
();
rgParam
.
append
(
coordinate
.
latitude
());
rgParam
.
append
(
coordinate
.
longitude
());
rgParam
.
append
(
coordinate
.
altitude
());
...
...
@@ -283,7 +283,7 @@ bool MissionItem::load(const QJsonObject &json, int sequenceNumber,
return
false
;
}
QJson
Array
rgParams
=
convertedJson
[
_jsonParamsKey
].
toArray
();
QJson
Object
rgParams
=
convertedJson
[
_jsonParamsKey
].
toArray
();
if
(
rgParams
.
count
()
!=
7
)
{
errorString
=
tr
(
"%1 key must contains 7 values"
).
arg
(
_jsonParamsKey
);
return
false
;
...
...
src/MissionManager/MissionItemTest.cc
View file @
e5b570c5
...
...
@@ -342,7 +342,7 @@ void MissionItemTest::_testLoadFromJsonV2(void)
QVERIFY
(
!
errorString
.
isEmpty
());
qDebug
()
<<
errorString
;
QJson
Array
badCoordinateArray
;
QJson
Object
badCoordinateArray
;
badCoordinateArray
<<
-
10.0
<<
-
20.0
;
badObject
=
jsonObject
;
badObject
.
remove
(
"coordinate"
);
...
...
@@ -351,7 +351,7 @@ void MissionItemTest::_testLoadFromJsonV2(void)
QVERIFY
(
!
errorString
.
isEmpty
());
qDebug
()
<<
errorString
;
QJson
Array
badCoordinateArray_second
;
QJson
Object
badCoordinateArray_second
;
badCoordinateArray_second
<<
-
10.0
<<
-
20.0
<<
true
;
badObject
=
jsonObject
;
badObject
.
remove
(
"coordinate"
);
...
...
@@ -360,9 +360,9 @@ void MissionItemTest::_testLoadFromJsonV2(void)
QVERIFY
(
!
errorString
.
isEmpty
());
qDebug
()
<<
errorString
;
QJson
Array
badCoordinateArray2
;
QJson
Object
badCoordinateArray2
;
badCoordinateArray2
<<
1
<<
2
;
QJson
Array
badCoordinateArray_third
;
QJson
Object
badCoordinateArray_third
;
badCoordinateArray_third
<<
-
10.0
<<
-
20.0
<<
badCoordinateArray2
;
badObject
=
jsonObject
;
badObject
.
remove
(
"coordinate"
);
...
...
@@ -412,7 +412,7 @@ void MissionItemTest::_testLoadFromJsonV3(void)
// Incorrect param count
badObject
=
jsonObject
;
QJson
Array
rgParam
=
badObject
[
MissionItem
::
_jsonParamsKey
].
toArray
();
QJson
Object
rgParam
=
badObject
[
MissionItem
::
_jsonParamsKey
].
toArray
();
rgParam
.
removeFirst
();
badObject
[
MissionItem
::
_jsonParamsKey
]
=
rgParam
;
QCOMPARE
(
missionItem
.
load
(
badObject
,
_seq
,
errorString
),
false
);
...
...
@@ -450,7 +450,7 @@ void MissionItemTest::_testSimpleLoadFromJson(void)
SimpleMissionItem
simpleMissionItem
(
_masterController
,
false
/* flyView */
,
false
/* forLoad */
,
nullptr
);
QString
errorString
;
QJson
Array
coordinateArray
;
QJson
Object
coordinateArray
;
QJsonObject
jsonObject
;
coordinateArray
<<
-
10.0
<<
-
20.0
<<-
30.0
;
...
...
@@ -460,7 +460,7 @@ void MissionItemTest::_testSimpleLoadFromJson(void)
jsonObject
.
insert
(
VisualMissionItem
::
jsonTypeKey
,
VisualMissionItem
::
jsonTypeSimpleItemValue
);
jsonObject
.
insert
(
MissionItem
::
_jsonCoordinateKey
,
coordinateArray
);
QJson
Array
rgParams
=
{
10
,
20
,
30
,
40
};
QJson
Object
rgParams
=
{
10
,
20
,
30
,
40
};
jsonObject
.
insert
(
MissionItem
::
_jsonParamsKey
,
rgParams
);
QVERIFY
(
simpleMissionItem
.
load
(
jsonObject
,
_seq
,
errorString
));
...
...
@@ -489,7 +489,7 @@ void MissionItemTest::_testSaveToJson(void)
QJsonObject
MissionItemTest
::
_createV1Json
(
void
)
{
QJsonObject
jsonObject
;
QJson
Array
coordinateArray
;
QJson
Object
coordinateArray
;
coordinateArray
<<
-
10.0
<<
-
20.0
<<-
30.0
;
jsonObject
.
insert
(
MissionItem
::
_jsonAutoContinueKey
,
true
);
...
...
@@ -508,7 +508,7 @@ QJsonObject MissionItemTest::_createV1Json(void)
QJsonObject
MissionItemTest
::
_createV2Json
(
void
)
{
QJsonObject
jsonObject
;
QJson
Array
coordinateArray
;
QJson
Object
coordinateArray
;
coordinateArray
<<
-
10.0
<<
-
20.0
<<-
30.0
;
jsonObject
.
insert
(
MissionItem
::
_jsonAutoContinueKey
,
true
);
...
...
@@ -517,7 +517,7 @@ QJsonObject MissionItemTest::_createV2Json(void)
jsonObject
.
insert
(
VisualMissionItem
::
jsonTypeKey
,
VisualMissionItem
::
jsonTypeSimpleItemValue
);
jsonObject
.
insert
(
MissionItem
::
_jsonCoordinateKey
,
coordinateArray
);
QJson
Array
rgParams
=
{
10
,
20
,
30
,
40
};
QJson
Object
rgParams
=
{
10
,
20
,
30
,
40
};
jsonObject
.
insert
(
MissionItem
::
_jsonParamsKey
,
rgParams
);
return
jsonObject
;
...
...
@@ -533,10 +533,10 @@ QJsonObject MissionItemTest::_createV3Json(bool allNaNs)
jsonObject
.
insert
(
VisualMissionItem
::
jsonTypeKey
,
VisualMissionItem
::
jsonTypeSimpleItemValue
);
if
(
allNaNs
)
{
QJson
Array
rgParams
=
{
NAN
,
NAN
,
NAN
,
NAN
,
NAN
,
NAN
,
NAN
};