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
8250ef7b
Commit
8250ef7b
authored
Dec 10, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
measurement complex item loading almost finished
parent
1eccaa0c
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
280 additions
and
60 deletions
+280
-60
AreaData.cc
src/MeasurementComplexItem/AreaData.cc
+8
-5
CircularGenerator.cpp
src/MeasurementComplexItem/CircularGenerator.cpp
+18
-4
GeneratorBase.cc
src/MeasurementComplexItem/GeneratorBase.cc
+19
-1
GeneratorBase.h
src/MeasurementComplexItem/GeneratorBase.h
+9
-7
LinearGenerator.cpp
src/MeasurementComplexItem/LinearGenerator.cpp
+17
-3
MeasurementComplexItem.cc
src/MeasurementComplexItem/MeasurementComplexItem.cc
+196
-31
MeasurementComplexItem.h
src/MeasurementComplexItem/MeasurementComplexItem.h
+10
-5
call_once.h
src/MeasurementComplexItem/call_once.h
+3
-4
No files found.
src/MeasurementComplexItem/AreaData.cc
View file @
8250ef7b
...
...
@@ -304,14 +304,16 @@ bool AreaData::load(const QJsonObject &obj, QString &errorString) {
if
(
JsonHelper
::
validateKeys
(
obj
,
keyInfo
,
e
))
{
this
->
clear
();
// iterate over json array
for
(
const
auto
&
jsonArea
:
obj
[
areaListKey
].
toArray
())
{
for
(
const
auto
valueRef
:
obj
[
areaListKey
].
toArray
())
{
const
auto
jsonArea
=
valueRef
.
toObject
();
// check if area type key is present
QList
<
JsonHelper
::
KeyValidateInfo
>
areaInfo
=
{
{
GeoArea
::
areaTypeKey
,
QJsonValue
::
String
,
true
},
};
if
(
!
JsonHelper
::
validateKeys
(
jsonArea
,
areaInfo
,
e
))
{
// load MeasurementArea
if
(
jsonArea
[
GeoArea
::
areaTypeKey
]
==
MeasurementArea
::
name
)
{
if
(
jsonArea
[
GeoArea
::
areaTypeKey
].
toString
()
==
MeasurementArea
::
name
)
{
auto
area
=
getGeoArea
<
MeasurementArea
*>
(
_areaList
);
if
(
area
==
nullptr
)
{
auto
area
=
new
MeasurementArea
(
this
);
...
...
@@ -330,7 +332,8 @@ bool AreaData::load(const QJsonObject &obj, QString &errorString) {
}
}
// load SafeArea
else
if
(
jsonArea
[
GeoArea
::
areaTypeKey
]
==
SafeArea
::
name
)
{
else
if
(
jsonArea
[
GeoArea
::
areaTypeKey
].
toString
()
==
SafeArea
::
name
)
{
auto
area
=
getGeoArea
<
SafeArea
*>
(
_areaList
);
if
(
area
==
nullptr
)
{
auto
area
=
new
SafeArea
(
this
);
...
...
@@ -352,7 +355,7 @@ bool AreaData::load(const QJsonObject &obj, QString &errorString) {
else
{
returnValue
=
false
;
errorString
.
append
(
tr
(
"Unknown area type: "
)
+
jsonArea
[
GeoArea
::
areaTypeKey
]);
jsonArea
[
GeoArea
::
areaTypeKey
]
.
toString
()
);
}
}
// GeoArea::areaTypeKey missing
...
...
@@ -397,7 +400,7 @@ bool AreaData::save(QJsonObject &obj) {
QJsonObject
temp
;
QJsonValue
jsonOrigin
;
JsonHelper
::
saveGeoCoordinate
(
_origin
,
tru
e
,
jsonOrigin
);
JsonHelper
::
saveGeoCoordinate
(
_origin
,
fals
e
,
jsonOrigin
);
temp
[
originKey
]
=
jsonOrigin
;
temp
[
initializedKey
]
=
_initialized
;
...
...
src/MeasurementComplexItem/CircularGenerator.cpp
View file @
8250ef7b
...
...
@@ -19,12 +19,20 @@ template <> inline auto get<0>(const IntPoint &p) { return p.X; }
template
<>
inline
auto
get
<
1
>
(
const
IntPoint
&
p
)
{
return
p
.
Y
;
}
namespace
routing
{
namespace
{
const
QString
generatorType
=
"CircularGenerator"
;
GeneratorBase
*
creator
(
QObject
*
parent
)
{
return
new
CircularGenerator
(
parent
);
}
const
char
*
distanceKey
=
"TransectDistance"
;
const
char
*
deltaAlphaKey
=
"DeltaAlpha"
;
const
char
*
minLengthKey
=
"MinLength"
;
const
char
*
referenceKey
=
"ReferencePoint"
;
}
// namespace
REGISTER_GENERATOR
(
generatorType
,
creator
)
bool
circularTransects
(
const
snake
::
FPoint
&
reference
,
...
...
@@ -34,10 +42,6 @@ bool circularTransects(const snake::FPoint &reference,
snake
::
Length
minLength
,
snake
::
Transects
&
transects
);
const
char
*
CircularGenerator
::
settingsGroup
=
"CircularGenerator"
;
const
char
*
distanceKey
=
"TransectDistance"
;
const
char
*
deltaAlphaKey
=
"DeltaAlpha"
;
const
char
*
minLengthKey
=
"MinLength"
;
const
char
*
referenceKey
=
"ReferencePoint"
;
CircularGenerator
::
CircularGenerator
(
QObject
*
parent
)
:
CircularGenerator
(
nullptr
,
parent
)
{}
...
...
@@ -192,6 +196,8 @@ void CircularGenerator::setReference(const QGeoCoordinate &reference) {
bool
CircularGenerator
::
save
(
QJsonObject
&
obj
)
const
{
QJsonObject
temp
;
GeneratorBase
::
save
(
temp
);
bool
ok
=
false
;
auto
variant
=
_distance
.
rawValue
();
auto
val
=
variant
.
toDouble
(
&
ok
);
...
...
@@ -237,6 +243,14 @@ bool CircularGenerator::save(QJsonObject &obj) const {
bool
CircularGenerator
::
load
(
const
QJsonObject
&
obj
,
QString
&
errorString
)
{
bool
returnValue
=
true
;
{
QString
e
;
if
(
!
GeneratorBase
::
load
(
obj
,
e
))
{
returnValue
=
false
;
errorString
.
append
(
e
);
}
}
// load distance
{
QString
e
;
...
...
src/MeasurementComplexItem/GeneratorBase.cc
View file @
8250ef7b
...
...
@@ -5,6 +5,7 @@
namespace
routing
{
const
char
*
GeneratorBase
::
typeKey
=
"GeneratorType"
;
const
char
*
GeneratorBase
::
nameKey
=
"Name"
;
GeneratorBase
::
GeneratorBase
(
QObject
*
parent
)
:
GeneratorBase
(
nullptr
,
parent
)
{}
...
...
@@ -16,7 +17,24 @@ GeneratorBase::GeneratorBase(GeneratorBase::Data d, QObject *parent)
GeneratorBase
::~
GeneratorBase
()
{}
QString
GeneratorBase
::
name
()
{
return
_name
;
}
bool
GeneratorBase
::
save
(
QJsonObject
&
obj
)
const
{
obj
[
typeKey
]
=
type
();
obj
[
name
]
=
name
();
return
true
;
}
bool
GeneratorBase
::
load
(
const
QJsonObject
&
obj
,
QString
&
errorString
)
{
if
(
obj
.
contains
[
nameKey
]
&&
obj
[
nameKey
].
isString
())
{
setName
(
obj
[
nameKey
].
toString
());
return
true
;
}
else
{
errorString
.
append
(
tr
(
"Not able to load generator name. Leaving name unchanged."
));
return
false
;
}
}
QString
GeneratorBase
::
name
()
const
{
return
_name
;
}
void
GeneratorBase
::
setName
(
const
QString
&
name
)
{
if
(
_name
!=
name
)
{
...
...
src/MeasurementComplexItem/GeneratorBase.h
View file @
8250ef7b
...
...
@@ -27,16 +27,17 @@ public:
Q_PROPERTY
(
QString
mapVisualQml
READ
mapVisualQml
CONSTANT
)
Q_PROPERTY
(
QString
name
READ
name
WRITE
setName
NOTIFY
nameChanged
)
virtual
QString
editorQml
()
=
0
;
virtual
QString
mapVisualQml
()
=
0
;
virtual
QString
editorQml
()
const
=
0
;
virtual
QString
mapVisualQml
()
const
=
0
;
virtual
bool
save
(
QJsonObject
&
obj
)
const
=
0
;
virtual
bool
load
(
const
QJsonObject
&
obj
,
QString
&
errorString
)
=
0
;
virtual
bool
save
(
QJsonObject
&
obj
)
const
;
// must be called if overridden
virtual
bool
load
(
const
QJsonObject
&
obj
,
QString
&
errorString
);
// must be called if overridden
QString
name
();
QString
name
()
const
;
void
setName
(
const
QString
&
name
);
virtual
QString
abbreviation
()
=
0
;
virtual
QString
type
()
=
0
;
virtual
QString
abbreviation
()
const
=
0
;
virtual
QString
type
()
const
=
0
;
virtual
bool
get
(
Generator
&
generator
)
=
0
;
...
...
@@ -44,6 +45,7 @@ public:
void
setData
(
Data
d
);
static
const
char
*
typeKey
;
static
const
char
*
nameKey
;
signals:
void
generatorChanged
();
...
...
src/MeasurementComplexItem/LinearGenerator.cpp
View file @
8250ef7b
...
...
@@ -12,10 +12,17 @@
#include "nemo_interface/SnakeTile.h"
namespace
routing
{
namespace
{
const
QString
generatorType
=
"LinearGenerator"
;
GeneratorBase
*
creator
(
QObject
*
parent
)
{
return
new
LinearGenerator
(
parent
);
}
const
char
*
distanceKey
=
"TransectDistance"
;
const
char
*
alphaKey
=
"Alpha"
;
const
char
*
minLengthKey
=
"MinLength"
;
}
// namespace
REGISTER_GENERATOR
(
generatorType
,
creator
)
QGC_LOGGING_CATEGORY
(
LinearGeneratorLog
,
"LinearGeneratorLog"
)
...
...
@@ -25,9 +32,6 @@ bool linearTransects(const snake::FPolygon &polygon,
snake
::
Length
minLength
,
snake
::
Transects
&
transects
);
const
char
*
LinearGenerator
::
settingsGroup
=
"LinearGenerator"
;
const
char
*
distanceKey
=
"TransectDistance"
;
const
char
*
alphaKey
=
"Alpha"
;
const
char
*
minLengthKey
=
"MinLength"
;
LinearGenerator
::
LinearGenerator
(
QObject
*
parent
)
:
LinearGenerator
(
nullptr
,
parent
)
{}
...
...
@@ -159,6 +163,8 @@ bool LinearGenerator::get(Generator &generator) {
bool
LinearGenerator
::
save
(
QJsonObject
&
obj
)
const
{
QJsonObject
temp
;
GeneratorBase
::
save
(
temp
);
bool
ok
=
false
;
auto
variant
=
_distance
.
rawValue
();
auto
val
=
variant
.
toDouble
(
&
ok
);
...
...
@@ -200,6 +206,14 @@ bool LinearGenerator::save(QJsonObject &obj) const {
bool
LinearGenerator
::
load
(
const
QJsonObject
&
obj
,
QString
&
errorString
)
{
bool
returnValue
=
true
;
{
QString
e
;
if
(
!
GeneratorBase
::
load
(
obj
,
e
))
{
returnValue
=
false
;
errorString
.
append
(
e
);
}
}
// load distance
{
QString
e
;
...
...
src/MeasurementComplexItem/MeasurementComplexItem.cc
View file @
8250ef7b
This diff is collapsed.
Click to expand it.
src/MeasurementComplexItem/MeasurementComplexItem.h
View file @
8250ef7b
...
...
@@ -101,9 +101,12 @@ public:
Q_INVOKABLE
bool
switchToGenerator
(
const
QString
&
name
);
Q_INVOKABLE
bool
switchToGenerator
(
int
index
);
Q_INVOKABLE
void
resetGenerators
();
QStringList
generatorNameList
();
QStringList
generatorNameList
()
const
;
routing
::
GeneratorBase
*
generator
();
int
generatorIndex
();
const
routing
::
GeneratorBase
*
generator
()
const
;
routing
::
GeneratorBase
*
generator
(
int
index
);
const
routing
::
GeneratorBase
*
generator
(
int
index
)
const
;
int
generatorIndex
()
const
;
// Editing.
//!
...
...
@@ -119,7 +122,11 @@ public:
//! Stops area editing. Will reset area data to the state before
//! editingStart() if it is invalid. Triggers a route update.
//!
Q_INVOKABLE
void
stopEditing
();
//! \param doUpdate No route update will be triggered if false, route update
//! will eventually be triggered if true. \return Returns true if a route
//! update was triggered, false either.
//!
Q_INVOKABLE
bool
stopEditing
(
bool
doUpdate
=
true
);
//!
//! \brief abortEditing Aborts area editing.
//!
...
...
@@ -143,8 +150,6 @@ public:
bool
followTerrain
()
const
;
static
const
char
*
settingsGroup
;
static
const
char
*
variantName
;
static
const
char
*
altitudeName
;
static
const
char
*
jsonComplexItemTypeValue
;
static
const
QString
name
;
...
...
src/MeasurementComplexItem/call_once.h
View file @
8250ef7b
...
...
@@ -38,10 +38,9 @@ inline static void qCallOnce(Function func, QBasicAtomicInt &flag) {
}
template
<
class
Function
>
inline
static
void
qCallOncePerThread
(
Function
func
)
{
using
namespace
CallOnce
;
if
(
!
once_flag
()
->
hasLocalData
())
{
once_flag
()
->
setLocalData
(
new
QAtomicInt
(
CO_Request
));
qCallOnce
(
func
,
*
once_flag
()
->
localData
());
if
(
!
CallOnce
::
once_flag
()
->
hasLocalData
())
{
CallOnce
::
once_flag
()
->
setLocalData
(
new
QAtomicInt
(
CallOnce
::
CO_Request
));
qCallOnce
(
func
,
*
CallOnce
::
once_flag
()
->
localData
());
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment