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
7255a8d0
Commit
7255a8d0
authored
Jul 26, 2016
by
Don Gagne
Committed by
GitHub
Jul 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3856 from DonLakeFlyer/GridLineDirection
Survey: Adjust grid line direction after polygon clip
parents
fa07aef6
492ff35c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
28 deletions
+32
-28
ComplexMissionItem.cc
src/MissionManager/ComplexMissionItem.cc
+31
-4
ComplexMissionItem.h
src/MissionManager/ComplexMissionItem.h
+1
-0
ComplexMissionItemTest.cc
src/MissionManager/ComplexMissionItemTest.cc
+0
-24
No files found.
src/MissionManager/ComplexMissionItem.cc
View file @
7255a8d0
...
...
@@ -449,6 +449,24 @@ void ComplexMissionItem::_intersectLinesWithPolygon(const QList<QLineF>& lineLis
}
}
/// Adjust the line segments such that they are all going the same direction with respect to going from P1->P2
void
ComplexMissionItem
::
_adjustLineDirection
(
const
QList
<
QLineF
>&
lineList
,
QList
<
QLineF
>&
resultLines
)
{
for
(
int
i
=
0
;
i
<
lineList
.
count
();
i
++
)
{
const
QLineF
&
line
=
lineList
[
i
];
QLineF
adjustedLine
;
if
(
line
.
angle
()
>
180.0
)
{
adjustedLine
.
setP1
(
line
.
p2
());
adjustedLine
.
setP2
(
line
.
p1
());
}
else
{
adjustedLine
=
line
;
}
resultLines
+=
adjustedLine
;
}
}
void
ComplexMissionItem
::
_gridGenerator
(
const
QList
<
QPointF
>&
polygonPoints
,
QList
<
QPointF
>&
gridPoints
)
{
double
gridAngle
=
_gridAngleFact
.
rawValue
().
toDouble
();
...
...
@@ -488,15 +506,24 @@ void ComplexMissionItem::_gridGenerator(const QList<QPointF>& polygonPoints, QL
float
yBottom
=
largeBoundRect
.
bottomRight
().
y
()
+
100.0
;
lineList
+=
QLineF
(
_rotatePoint
(
QPointF
(
x
,
yTop
),
center
,
gridAngle
),
_rotatePoint
(
QPointF
(
x
,
yBottom
),
center
,
gridAngle
));
qCDebug
(
ComplexMissionItemLog
)
<<
"line
"
<<
lineList
.
last
().
x1
()
<<
lineList
.
last
().
y1
()
<<
lineList
.
last
().
x2
()
<<
lineList
.
last
().
y2
()
;
qCDebug
(
ComplexMissionItemLog
)
<<
"line
("
<<
lineList
.
last
().
x1
()
<<
", "
<<
lineList
.
last
().
y1
()
<<
")-("
<<
lineList
.
last
().
x2
()
<<
", "
<<
lineList
.
last
().
y2
()
<<
")"
;
x
+=
gridSpacing
;
}
// Now intesect the lines with the smaller bounding rect
// Now intersect the lines with the polygon
QList
<
QLineF
>
intersectLines
;
#if 1
_intersectLinesWithPolygon
(
lineList
,
polygon
,
intersectLines
);
#else
// This is handy for debugging grid problems, not for release
intersectLines
=
lineList
;
#endif
// Make sure all lines are going to same direction. Polygon intersection leads to line which
// can be in varied directions depending on the order of the intesecting sides.
QList
<
QLineF
>
resultLines
;
//_intersectLinesWithRect(lineList, smallBoundRect, resultLines);
_intersectLinesWithPolygon
(
lineList
,
polygon
,
resultLines
);
_adjustLineDirection
(
intersectLines
,
resultLines
);
// Turn into a path
for
(
int
i
=
0
;
i
<
resultLines
.
count
();
i
++
)
{
...
...
src/MissionManager/ComplexMissionItem.h
View file @
7255a8d0
...
...
@@ -117,6 +117,7 @@ private:
QPointF
_rotatePoint
(
const
QPointF
&
point
,
const
QPointF
&
origin
,
double
angle
);
void
_intersectLinesWithRect
(
const
QList
<
QLineF
>&
lineList
,
const
QRectF
&
boundRect
,
QList
<
QLineF
>&
resultLines
);
void
_intersectLinesWithPolygon
(
const
QList
<
QLineF
>&
lineList
,
const
QPolygonF
&
polygon
,
QList
<
QLineF
>&
resultLines
);
void
_adjustLineDirection
(
const
QList
<
QLineF
>&
lineList
,
QList
<
QLineF
>&
resultLines
);
int
_sequenceNumber
;
bool
_dirty
;
...
...
src/MissionManager/ComplexMissionItemTest.cc
View file @
7255a8d0
...
...
@@ -137,30 +137,6 @@ void ComplexMissionItemTest::_testAddPolygonCoordinate(void)
for
(
int
i
=
0
;
i
<
polyList
.
count
();
i
++
)
{
QCOMPARE
(
polyList
[
i
].
value
<
QGeoCoordinate
>
(),
_polyPoints
[
i
]);
}
_complexItem
->
setDirty
(
false
);
_multiSpy
->
clearAllSignals
();
// Forth call to addPolygonCoordinate should trigger:
// polygonPathChanged
// dirtyChanged
// Grid is generated again on polygon change which triggers:
// lastSequenceNumberChanged - number of internal mission items changes
// gridPointsChanged - grid points show up for the first time
// exitCoordinateChanged - grid generates new exit coordinate
// Note: Given the data set the entry coordinate stays the same
_complexItem
->
addPolygonCoordinate
(
_polyPoints
[
3
]);
QVERIFY
(
_multiSpy
->
checkOnlySignalByMask
(
polygonPathChangedMask
|
lastSequenceNumberChangedMask
|
gridPointsChangedMask
|
exitCoordinateChangedMask
|
dirtyChangedMask
));
seqNum
=
_multiSpy
->
pullIntFromSignalIndex
(
lastSequenceNumberChangedIndex
);
QVERIFY
(
seqNum
>
0
);
polyList
=
_complexItem
->
polygonPath
();
QCOMPARE
(
polyList
.
count
(),
4
);
for
(
int
i
=
0
;
i
<
polyList
.
count
();
i
++
)
{
QCOMPARE
(
polyList
[
i
].
value
<
QGeoCoordinate
>
(),
_polyPoints
[
i
]);
}
}
void
ComplexMissionItemTest
::
_testClearPolygon
(
void
)
...
...
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