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
65ebabe4
Unverified
Commit
65ebabe4
authored
May 20, 2018
by
Don Gagne
Committed by
GitHub
May 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6469 from DonLakeFlyer/SurveyEntry
Survey: Rotate survey entry
parents
0f630c06
fb467b4a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
44 deletions
+44
-44
SurveyComplexItem.cc
src/MissionManager/SurveyComplexItem.cc
+24
-16
SurveyComplexItem.h
src/MissionManager/SurveyComplexItem.h
+10
-8
SurveyComplexItemTest.cc
src/MissionManager/SurveyComplexItemTest.cc
+6
-13
SurveyItemEditor.qml
src/PlanView/SurveyItemEditor.qml
+4
-7
No files found.
src/MissionManager/SurveyComplexItem.cc
View file @
65ebabe4
...
...
@@ -29,14 +29,14 @@ const char* SurveyComplexItem::gridAngleName = "GridAngle";
const
char
*
SurveyComplexItem
::
gridEntryLocationName
=
"GridEntryLocation"
;
const
char
*
SurveyComplexItem
::
_jsonGridAngleKey
=
"angle"
;
const
char
*
SurveyComplexItem
::
_json
GridEntryLocationKey
=
"entryLocation"
;
const
char
*
SurveyComplexItem
::
_json
EntryPointKey
=
"entryLocation"
;
const
char
*
SurveyComplexItem
::
_jsonV3GridObjectKey
=
"grid"
;
const
char
*
SurveyComplexItem
::
_jsonV3GridAltitudeKey
=
"altitude"
;
const
char
*
SurveyComplexItem
::
_jsonV3GridAltitudeRelativeKey
=
"relativeAltitude"
;
const
char
*
SurveyComplexItem
::
_jsonV3GridAngleKey
=
"angle"
;
const
char
*
SurveyComplexItem
::
_jsonV3GridSpacingKey
=
"spacing"
;
const
char
*
SurveyComplexItem
::
_jsonV3
GridEntryLocationKey
=
"entryLocation"
;
const
char
*
SurveyComplexItem
::
_jsonV3
EntryPointKey
=
"entryLocation"
;
const
char
*
SurveyComplexItem
::
_jsonV3TurnaroundDistKey
=
"turnAroundDistance"
;
const
char
*
SurveyComplexItem
::
_jsonV3CameraTriggerDistanceKey
=
"cameraTriggerDistance"
;
const
char
*
SurveyComplexItem
::
_jsonV3CameraTriggerInTurnaroundKey
=
"cameraTriggerInTurnaround"
;
...
...
@@ -62,7 +62,7 @@ SurveyComplexItem::SurveyComplexItem(Vehicle* vehicle, bool flyView, QObject* pa
:
TransectStyleComplexItem
(
vehicle
,
flyView
,
settingsGroup
,
parent
)
,
_metaDataMap
(
FactMetaData
::
createMapFromJsonFile
(
QStringLiteral
(
":/json/Survey.SettingsGroup.json"
),
this
))
,
_gridAngleFact
(
settingsGroup
,
_metaDataMap
[
gridAngleName
])
,
_
gridEntryLocationFact
(
settingsGroup
,
_metaDataMap
[
gridEntryLocationName
]
)
,
_
entryPoint
(
EntryLocationTopLeft
)
{
_editorQml
=
"qrc:/qml/SurveyItemEditor.qml"
;
...
...
@@ -79,11 +79,9 @@ SurveyComplexItem::SurveyComplexItem(Vehicle* vehicle, bool flyView, QObject* pa
}
connect
(
&
_gridAngleFact
,
&
Fact
::
valueChanged
,
this
,
&
SurveyComplexItem
::
_setDirty
);
connect
(
&
_gridEntryLocationFact
,
&
Fact
::
valueChanged
,
this
,
&
SurveyComplexItem
::
_setDirty
);
connect
(
this
,
&
SurveyComplexItem
::
refly90DegreesChanged
,
this
,
&
SurveyComplexItem
::
_setDirty
);
connect
(
&
_gridAngleFact
,
&
Fact
::
valueChanged
,
this
,
&
SurveyComplexItem
::
_rebuildTransects
);
connect
(
&
_gridEntryLocationFact
,
&
Fact
::
valueChanged
,
this
,
&
SurveyComplexItem
::
_rebuildTransects
);
connect
(
this
,
&
SurveyComplexItem
::
refly90DegreesChanged
,
this
,
&
SurveyComplexItem
::
_rebuildTransects
);
// FIXME: Shouldn't these be in TransectStyleComplexItem? They are also in CorridorScanComplexItem constructur
...
...
@@ -101,7 +99,7 @@ void SurveyComplexItem::save(QJsonArray& planItems)
saveObject
[
VisualMissionItem
::
jsonTypeKey
]
=
VisualMissionItem
::
jsonTypeComplexItemValue
;
saveObject
[
ComplexMissionItem
::
jsonComplexItemTypeKey
]
=
jsonComplexItemTypeValue
;
saveObject
[
_jsonGridAngleKey
]
=
_gridAngleFact
.
rawValue
().
toDouble
();
saveObject
[
_json
GridEntryLocationKey
]
=
_gridEntryLocationFact
.
rawValue
().
toInt
()
;
saveObject
[
_json
EntryPointKey
]
=
_entryPoint
;
// Polygon shape
_surveyAreaPolygon
.
saveToJson
(
saveObject
);
...
...
@@ -154,7 +152,7 @@ bool SurveyComplexItem::_loadV4(const QJsonObject& complexObject, int sequenceNu
QList
<
JsonHelper
::
KeyValidateInfo
>
keyInfoList
=
{
{
VisualMissionItem
::
jsonTypeKey
,
QJsonValue
::
String
,
true
},
{
ComplexMissionItem
::
jsonComplexItemTypeKey
,
QJsonValue
::
String
,
true
},
{
_json
GridEntryLocation
Key
,
QJsonValue
::
Double
,
true
},
{
_json
EntryPoint
Key
,
QJsonValue
::
Double
,
true
},
{
_jsonGridAngleKey
,
QJsonValue
::
Double
,
true
},
};
if
(
!
JsonHelper
::
validateKeys
(
complexObject
,
keyInfoList
,
errorString
))
{
...
...
@@ -183,7 +181,7 @@ bool SurveyComplexItem::_loadV4(const QJsonObject& complexObject, int sequenceNu
}
_gridAngleFact
.
setRawValue
(
complexObject
[
_jsonGridAngleKey
].
toDouble
());
_
gridEntryLocationFact
.
setRawValue
(
complexObject
[
_jsonGridEntryLocationKey
].
toInt
()
);
_
entryPoint
=
complexObject
[
_jsonEntryPointKey
].
toInt
(
);
_ignoreRecalc
=
false
;
...
...
@@ -234,7 +232,7 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu
{
_jsonV3GridAltitudeRelativeKey
,
QJsonValue
::
Bool
,
true
},
{
_jsonV3GridAngleKey
,
QJsonValue
::
Double
,
true
},
{
_jsonV3GridSpacingKey
,
QJsonValue
::
Double
,
true
},
{
_json
V3GridEntryLocation
Key
,
QJsonValue
::
Double
,
false
},
{
_json
EntryPoint
Key
,
QJsonValue
::
Double
,
false
},
{
_jsonV3TurnaroundDistKey
,
QJsonValue
::
Double
,
true
},
};
QJsonObject
gridObject
=
complexObject
[
_jsonV3GridObjectKey
].
toObject
();
...
...
@@ -246,10 +244,10 @@ bool SurveyComplexItem::_loadV3(const QJsonObject& complexObject, int sequenceNu
_gridAngleFact
.
setRawValue
(
gridObject
[
_jsonV3GridAngleKey
].
toDouble
());
_turnAroundDistanceFact
.
setRawValue
(
gridObject
[
_jsonV3TurnaroundDistKey
].
toDouble
());
if
(
gridObject
.
contains
(
_json
V3GridEntryLocation
Key
))
{
_
gridEntryLocationFact
.
setRawValue
(
gridObject
[
_jsonV3GridEntryLocationKey
].
toDouble
()
);
if
(
gridObject
.
contains
(
_json
EntryPoint
Key
))
{
_
entryPoint
=
gridObject
[
_jsonEntryPointKey
].
toDouble
(
);
}
else
{
_
gridEntryLocationFact
.
setRawValue
(
_gridEntryLocationFact
.
rawDefaultValue
())
;
_
entryPoint
=
EntryLocationTopRight
;
}
_cameraCalc
.
distanceToSurface
()
->
setRawValue
(
gridObject
[
_jsonV3GridAltitudeKey
].
toDouble
());
...
...
@@ -408,14 +406,13 @@ void SurveyComplexItem::_adjustTransectsToEntryPointLocation(QList<QList<QGeoCoo
return
;
}
int
entryLocation
=
_gridEntryLocationFact
.
rawValue
().
toInt
();
bool
reversePoints
=
false
;
bool
reverseTransects
=
false
;
if
(
entryLocation
==
EntryLocationBottomLeft
||
entryLocation
==
EntryLocationBottomRight
)
{
if
(
_entryPoint
==
EntryLocationBottomLeft
||
_entryPoint
==
EntryLocationBottomRight
)
{
reversePoints
=
true
;
}
if
(
entryLocation
==
EntryLocationTopRight
||
entryLocation
==
EntryLocationBottomRight
)
{
if
(
_entryPoint
==
EntryLocationTopRight
||
_entryPoint
==
EntryLocationBottomRight
)
{
reverseTransects
=
true
;
}
...
...
@@ -428,7 +425,7 @@ void SurveyComplexItem::_adjustTransectsToEntryPointLocation(QList<QList<QGeoCoo
_reverseTransectOrder
(
transects
);
}
qCDebug
(
SurveyComplexItemLog
)
<<
"_adjustTransectsToEntryPointLocation Modified entry point:entryLocation"
<<
transects
.
first
().
first
()
<<
entryLocation
;
qCDebug
(
SurveyComplexItemLog
)
<<
"_adjustTransectsToEntryPointLocation Modified entry point:entryLocation"
<<
transects
.
first
().
first
()
<<
_entryPoint
;
}
#if 0
...
...
@@ -1401,4 +1398,15 @@ void SurveyComplexItem::_appendLoadedMissionItems(QList<MissionItem*>& items, QO
}
}
void
SurveyComplexItem
::
rotateEntryPoint
(
void
)
{
if
(
_entryPoint
==
EntryLocationLast
)
{
_entryPoint
=
EntryLocationFirst
;
}
else
{
_entryPoint
++
;
}
_rebuildTransects
();
setDirty
(
true
);
}
src/MissionManager/SurveyComplexItem.h
View file @
65ebabe4
...
...
@@ -23,11 +23,11 @@ class SurveyComplexItem : public TransectStyleComplexItem
public:
SurveyComplexItem
(
Vehicle
*
vehicle
,
bool
flyView
,
QObject
*
parent
);
Q_PROPERTY
(
Fact
*
gridAngle
READ
gridAngle
CONSTANT
)
Q_PROPERTY
(
Fact
*
gridEntryLocation
READ
gridEntryLocation
CONSTANT
)
Q_PROPERTY
(
Fact
*
gridAngle
READ
gridAngle
CONSTANT
)
Fact
*
gridAngle
(
void
)
{
return
&
_gridAngleFact
;
}
Fact
*
gridEntryLocation
(
void
)
{
return
&
_gridEntryLocationFact
;
}
Fact
*
gridAngle
(
void
)
{
return
&
_gridAngleFact
;
}
Q_INVOKABLE
void
rotateEntryPoint
(
void
);
// Overrides from ComplexMissionItem
bool
load
(
const
QJsonObject
&
complexObject
,
int
sequenceNumber
,
QString
&
errorString
)
final
;
...
...
@@ -47,10 +47,12 @@ public:
// Must match json spec for GridEntryLocation
enum
EntryLocation
{
EntryLocationTopLeft
,
EntryLocationFirst
,
EntryLocationTopLeft
=
EntryLocationFirst
,
EntryLocationTopRight
,
EntryLocationBottomLeft
,
EntryLocationBottomRight
,
EntryLocationLast
=
EntryLocationBottomRight
};
static
const
char
*
jsonComplexItemTypeValue
;
...
...
@@ -106,17 +108,17 @@ private:
QMap
<
QString
,
FactMetaData
*>
_metaDataMap
;
SettingsFact
_gridAngleFact
;
SettingsFact
_gridEntryLocationFac
t
;
int
_entryPoin
t
;
static
const
char
*
_jsonGridAngleKey
;
static
const
char
*
_json
GridEntryLocation
Key
;
static
const
char
*
_json
EntryPoint
Key
;
static
const
char
*
_jsonV3GridObjectKey
;
static
const
char
*
_jsonV3GridAltitudeKey
;
static
const
char
*
_jsonV3GridAltitudeRelativeKey
;
static
const
char
*
_jsonV3GridAngleKey
;
static
const
char
*
_jsonV3GridSpacingKey
;
static
const
char
*
_jsonV3
GridEntryLocation
Key
;
static
const
char
*
_jsonV3
EntryPoint
Key
;
static
const
char
*
_jsonV3TurnaroundDistKey
;
static
const
char
*
_jsonV3CameraTriggerDistanceKey
;
static
const
char
*
_jsonV3CameraTriggerInTurnaroundKey
;
...
...
src/MissionManager/SurveyComplexItemTest.cc
View file @
65ebabe4
...
...
@@ -66,12 +66,11 @@ void SurveyComplexItemTest::_testDirty(void)
_surveyItem
->
setDirty
(
false
);
QVERIFY
(
!
_surveyItem
->
dirty
());
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
surveyDirtyChangedMask
));
QVERIFY
(
!
_multiSpy
->
pullBoolFromSignalIndex
(
surveyDirtyChangedIndex
));
_multiSpy
->
clearAllSignals
();
// These facts should set dirty when changed
QList
<
Fact
*>
rgFacts
;
rgFacts
<<
_surveyItem
->
gridAngle
()
<<
_surveyItem
->
gridEntryLocation
()
;
rgFacts
<<
_surveyItem
->
gridAngle
();
foreach
(
Fact
*
fact
,
rgFacts
)
{
qDebug
()
<<
fact
->
name
();
QVERIFY
(
!
_surveyItem
->
dirty
());
...
...
@@ -138,21 +137,15 @@ void SurveyComplexItemTest::_testEntryLocation(void)
for
(
double
gridAngle
=-
360.0
;
gridAngle
<=
360.0
;
gridAngle
++
)
{
_surveyItem
->
gridAngle
()
->
setRawValue
(
gridAngle
);
QList
<
QGeoCoordinate
>
rgSeenEntryCoords
;
QList
<
int
>
rgEntryLocation
;
rgEntryLocation
<<
SurveyComplexItem
::
EntryLocationTopLeft
<<
SurveyComplexItem
::
EntryLocationTopRight
<<
SurveyComplexItem
::
EntryLocationBottomLeft
<<
SurveyComplexItem
::
EntryLocationBottomRight
;
// Validate that each entry location is unique
for
(
int
i
=
0
;
i
<
rgEntryLocation
.
count
();
i
++
)
{
int
entryLocation
=
rgEntryLocation
[
i
];
_surveyItem
->
gridEntryLocation
()
->
setRawValue
(
entryLocation
);
QList
<
QGeoCoordinate
>
rgSeenEntryCoords
;
for
(
int
rotateCount
=
0
;
rotateCount
<
3
;
rotateCount
++
)
{
_surveyItem
->
rotateEntryPoint
();
QVERIFY
(
!
rgSeenEntryCoords
.
contains
(
_surveyItem
->
coordinate
()));
rgSeenEntryCoords
<<
_surveyItem
->
coordinate
();
}
_surveyItem
->
rotateEntryPoint
();
// Rotate back for first entry point
rgSeenEntryCoords
.
clear
();
}
}
...
...
src/PlanView/SurveyItemEditor.qml
View file @
65ebabe4
...
...
@@ -97,13 +97,10 @@ Rectangle {
Layout.fillWidth
:
true
}
QGCLabel
{
text
:
qsTr
(
"
Entry
"
)
}
FactComboBox
{
fact
:
missionItem
.
gridEntryLocation
indexModel
:
false
Layout.fillWidth
:
true
QGCButton
{
Layout.columnSpan
:
2
text
:
qsTr
(
"
Rotate Entry Point
"
)
onClicked
:
missionItem
.
rotateEntryPoint
();
}
FactCheckBox
{
...
...
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