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
96ac6aeb
Commit
96ac6aeb
authored
Dec 15, 2020
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MeasurementComplexItem loading done.
parent
f778e405
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
4 deletions
+52
-4
MeasurementComplexItem.cc
src/MeasurementComplexItem/MeasurementComplexItem.cc
+52
-4
No files found.
src/MeasurementComplexItem/MeasurementComplexItem.cc
View file @
96ac6aeb
#
include
"MeasurementComplexItem.h"
#include "MeasurementComplexItem.h"
#include "CircularGenerator.h"
#include "CircularGenerator.h"
#include "LinearGenerator.h"
#include "LinearGenerator.h"
...
@@ -39,7 +39,7 @@ const char *areaDataKey = "AreaData";
...
@@ -39,7 +39,7 @@ const char *areaDataKey = "AreaData";
const
char
*
variantNamesKey
=
"VariantNames"
;
const
char
*
variantNamesKey
=
"VariantNames"
;
const
char
*
generatorsKey
=
"Generators"
;
const
char
*
generatorsKey
=
"Generators"
;
const
char
*
variantsKey
=
"Variants"
;
const
char
*
variantsKey
=
"Variants"
;
const
char
*
generatorIndexKey
=
"
g
eneratorIndex"
;
const
char
*
generatorIndexKey
=
"
G
eneratorIndex"
;
}
// namespace
}
// namespace
MeasurementComplexItem
::
MeasurementComplexItem
(
MeasurementComplexItem
::
MeasurementComplexItem
(
...
@@ -367,6 +367,54 @@ bool MeasurementComplexItem::load(const QJsonObject &complexObject,
...
@@ -367,6 +367,54 @@ bool MeasurementComplexItem::load(const QJsonObject &complexObject,
}
else
{
}
else
{
_variantVector
.
swap
(
variantVector
);
_variantVector
.
swap
(
variantVector
);
qCritical
()
<<
"add variant names and set variant"
;
qCritical
()
<<
"add variant names and set variant"
;
// load variant names
bool
variantNamesLoaded
=
true
;
if
(
complexObject
.
contains
(
variantNamesKey
)
&&
complexObject
[
variantNamesKey
].
isArray
())
{
QStringList
variantNames
;
for
(
const
auto
&
name
:
complexObject
[
variantNamesKey
])
{
if
(
name
.
isString
())
{
variantNames
.
append
(
name
.
toString
());
}
else
{
variantNamesLoaded
=
false
;
break
;
}
}
if
(
variantNames
.
size
()
!=
_variantVector
.
size
())
{
variantNamesLoaded
=
false
;
}
if
(
variantNamesLoaded
)
{
_variantNames
.
swap
(
variantNames
);
emit
variantNamesChanged
();
}
}
else
{
qCWarning
(
MeasurementComplexItemLog
)
<<
"Not able to load variant names. variantNamesKey missing or wrong "
"type"
;
if
(
complexObject
.
contains
(
variantNamesKey
))
{
qCWarning
(
MeasurementComplexItemLog
)
<<
"variantNamesKey type: "
<<
complexObject
[
variantNamesKey
].
type
();
}
}
// create std. variant names if loading failed
if
(
!
variantNamesLoaded
)
{
qCWarning
(
MeasurementComplexItemLog
)
<<
"Creating std. variant names."
;
this
->
_variantNames
.
clear
();
for
(
std
::
size_t
i
=
1
;
i
<=
std
::
size_t
(
this
->
_variantVector
.
size
());
++
i
)
{
this
->
_variantNames
.
append
(
QString
::
number
(
i
));
}
emit
variantNamesChanged
();
}
_changeVariant
();
stopEditing
(
stopEditing
(
false
/*doUpdate*/
);
// does noting if editing was already stopped
false
/*doUpdate*/
);
// does noting if editing was already stopped
}
}
...
@@ -448,7 +496,7 @@ void MeasurementComplexItem::save(QJsonArray &planItems) {
...
@@ -448,7 +496,7 @@ void MeasurementComplexItem::save(QJsonArray &planItems) {
saveObject
[
generatorsKey
]
=
generatorArray
;
saveObject
[
generatorsKey
]
=
generatorArray
;
// generator index
// generator index
saveObject
[
generatorIndex
]
=
generatorIndex
();
saveObject
[
generatorIndex
Key
]
=
generatorIndex
();
// Route Variants
// Route Variants
QJsonArray
variantsArray
;
QJsonArray
variantsArray
;
...
@@ -752,7 +800,7 @@ void MeasurementComplexItem::_changeVariant() {
...
@@ -752,7 +800,7 @@ void MeasurementComplexItem::_changeVariant() {
if
(
idle
())
{
if
(
idle
())
{
auto
variant
=
this
->
_variant
.
rawValue
().
toUInt
();
auto
variant
=
this
->
_variant
.
rawValue
().
toUInt
();
// Find old variant
and run. Old run
corresponts with empty list.
// Find old variant
. Old variant
corresponts with empty list.
std
::
size_t
old_variant
=
std
::
numeric_limits
<
std
::
size_t
>::
max
();
std
::
size_t
old_variant
=
std
::
numeric_limits
<
std
::
size_t
>::
max
();
for
(
std
::
size_t
i
=
0
;
i
<
std
::
size_t
(
this
->
_variantVector
.
size
());
++
i
)
{
for
(
std
::
size_t
i
=
0
;
i
<
std
::
size_t
(
this
->
_variantVector
.
size
());
++
i
)
{
const
auto
&
variantCoordinates
=
this
->
_variantVector
.
at
(
i
);
const
auto
&
variantCoordinates
=
this
->
_variantVector
.
at
(
i
);
...
...
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