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
98071529
Unverified
Commit
98071529
authored
Mar 14, 2018
by
Don Gagne
Committed by
GitHub
Mar 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6213 from DonLakeFlyer/StableMerge
Stable merge
parents
78be63ea
ba0dce20
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
80 additions
and
77 deletions
+80
-77
MissionManager.h
src/MissionManager/MissionManager.h
+0
-4
QGCMapPolygon.cc
src/MissionManager/QGCMapPolygon.cc
+14
-3
QGCMapPolygon.h
src/MissionManager/QGCMapPolygon.h
+1
-0
SurveyMissionItem.cc
src/MissionManager/SurveyMissionItem.cc
+25
-63
SurveyMissionItem.h
src/MissionManager/SurveyMissionItem.h
+0
-1
SurveyItemEditor.qml
src/PlanView/SurveyItemEditor.qml
+1
-0
QmlObjectListModel.cc
src/QmlControls/QmlObjectListModel.cc
+31
-0
QmlObjectListModel.h
src/QmlControls/QmlObjectListModel.h
+8
-6
No files found.
src/MissionManager/MissionManager.h
View file @
98071529
...
...
@@ -38,10 +38,6 @@ public:
/// from mission start to resumeIndex in the generate mission.
void
generateResumeMission
(
int
resumeIndex
);
signals:
void
currentIndexChanged
(
int
currentIndex
);
void
lastCurrentIndexChanged
(
int
lastCurrentIndex
);
private
slots
:
void
_mavlinkMessageReceived
(
const
mavlink_message_t
&
message
);
...
...
src/MissionManager/QGCMapPolygon.cc
View file @
98071529
...
...
@@ -258,6 +258,19 @@ void QGCMapPolygon::appendVertex(const QGeoCoordinate& coordinate)
emit
pathChanged
();
}
void
QGCMapPolygon
::
appendVertices
(
const
QList
<
QGeoCoordinate
>&
coordinates
)
{
QList
<
QObject
*>
objects
;
foreach
(
const
QGeoCoordinate
&
coordinate
,
coordinates
)
{
objects
.
append
(
new
QGCQGeoCoordinate
(
coordinate
,
this
));
_polygonPath
.
append
(
QVariant
::
fromValue
(
coordinate
));
}
_polygonModel
.
append
(
objects
);
emit
pathChanged
();
}
void
QGCMapPolygon
::
_polygonModelDirtyChanged
(
bool
dirty
)
{
if
(
dirty
)
{
...
...
@@ -509,9 +522,7 @@ bool QGCMapPolygon::loadKMLFile(const QString& kmlFile)
}
clear
();
for
(
int
i
=
0
;
i
<
rgCoords
.
count
();
i
++
)
{
appendVertex
(
rgCoords
[
i
]);
}
appendVertices
(
rgCoords
);
return
true
;
}
...
...
src/MissionManager/QGCMapPolygon.h
View file @
98071529
...
...
@@ -40,6 +40,7 @@ public:
Q_INVOKABLE
void
clear
(
void
);
Q_INVOKABLE
void
appendVertex
(
const
QGeoCoordinate
&
coordinate
);
Q_INVOKABLE
void
removeVertex
(
int
vertexIndex
);
Q_INVOKABLE
void
appendVertices
(
const
QList
<
QGeoCoordinate
>&
coordinates
);
/// Adjust the value for the specified coordinate
/// @param vertexIndex Polygon point index to modify (0-based)
...
...
src/MissionManager/SurveyMissionItem.cc
View file @
98071529
...
...
@@ -554,53 +554,6 @@ void SurveyMissionItem::_swapPoints(QList<QPointF>& points, int index1, int inde
points
[
index2
]
=
temp
;
}
QList
<
QPointF
>
SurveyMissionItem
::
_convexPolygon
(
const
QList
<
QPointF
>&
polygon
)
{
// We use the Graham scan algorithem to convert the possibly concave polygon to a convex polygon
// https://en.wikipedia.org/wiki/Graham_scan
QList
<
QPointF
>
workPolygon
(
polygon
);
// First point must be lowest y-coordinate point
for
(
int
i
=
1
;
i
<
workPolygon
.
count
();
i
++
)
{
if
(
workPolygon
[
i
].
y
()
<
workPolygon
[
0
].
y
())
{
_swapPoints
(
workPolygon
,
i
,
0
);
}
}
// Sort the points by angle with first point
for
(
int
i
=
1
;
i
<
workPolygon
.
count
();
i
++
)
{
qreal
angle
=
_dp
(
workPolygon
[
0
],
workPolygon
[
i
]);
for
(
int
j
=
i
+
1
;
j
<
workPolygon
.
count
();
j
++
)
{
if
(
_dp
(
workPolygon
[
0
],
workPolygon
[
j
])
>
angle
)
{
_swapPoints
(
workPolygon
,
i
,
j
);
angle
=
_dp
(
workPolygon
[
0
],
workPolygon
[
j
]);
}
}
}
// Perform the the Graham scan
workPolygon
.
insert
(
0
,
workPolygon
.
last
());
// Sentinel for algo stop
int
convexCount
=
1
;
// Number of points on the convex hull.
for
(
int
i
=
2
;
i
<=
polygon
.
count
();
i
++
)
{
while
(
_ccw
(
workPolygon
[
convexCount
-
1
],
workPolygon
[
convexCount
],
workPolygon
[
i
])
<=
0
)
{
if
(
convexCount
>
1
)
{
convexCount
-=
1
;
}
else
if
(
i
==
polygon
.
count
())
{
break
;
}
else
{
i
++
;
}
}
convexCount
++
;
_swapPoints
(
workPolygon
,
convexCount
,
i
);
}
return
workPolygon
.
mid
(
1
,
convexCount
);
}
/// Returns true if the current grid angle generates north/south oriented transects
bool
SurveyMissionItem
::
_gridAngleIsNorthSouthTransects
()
{
...
...
@@ -695,8 +648,6 @@ void SurveyMissionItem::_generateGrid(void)
qCDebug
(
SurveyMissionItemLog
)
<<
"vertex:x:y"
<<
vertex
<<
polygonPoints
.
last
().
x
()
<<
polygonPoints
.
last
().
y
();
}
polygonPoints
=
_convexPolygon
(
polygonPoints
);
double
coveredArea
=
0.0
;
for
(
int
i
=
0
;
i
<
polygonPoints
.
count
();
i
++
)
{
if
(
i
!=
0
)
{
...
...
@@ -714,8 +665,6 @@ void SurveyMissionItem::_generateGrid(void)
_adjustTransectsToEntryPointLocation
(
_transectSegments
);
_appendGridPointsFromTransects
(
_transectSegments
);
if
(
_refly90Degrees
)
{
QVariantList
reflyPointsGeo
;
transectSegments
.
clear
();
cameraShots
+=
_gridGenerator
(
polygonPoints
,
transectSegments
,
true
/* refly */
);
_convertTransectToGeo
(
transectSegments
,
tangentOrigin
,
_reflyTransectSegments
);
...
...
@@ -844,28 +793,41 @@ void SurveyMissionItem::_intersectLinesWithRect(const QList<QLineF>& lineList, c
void
SurveyMissionItem
::
_intersectLinesWithPolygon
(
const
QList
<
QLineF
>&
lineList
,
const
QPolygonF
&
polygon
,
QList
<
QLineF
>&
resultLines
)
{
resultLines
.
clear
();
for
(
int
i
=
0
;
i
<
lineList
.
count
();
i
++
)
{
int
foundCount
=
0
;
QLineF
intersectLine
;
const
QLineF
&
line
=
lineList
[
i
];
QList
<
QPointF
>
intersections
;
// Intersect the line with all the polygon edges
for
(
int
j
=
0
;
j
<
polygon
.
count
()
-
1
;
j
++
)
{
QPointF
intersectPoint
;
QLineF
polygonLine
=
QLineF
(
polygon
[
j
],
polygon
[
j
+
1
]);
if
(
line
.
intersect
(
polygonLine
,
&
intersectPoint
)
==
QLineF
::
BoundedIntersection
)
{
if
(
foundCount
==
0
)
{
foundCount
++
;
intersectLine
.
setP1
(
intersectPoint
);
}
else
{
foundCount
++
;
intersectLine
.
setP2
(
intersectPoint
);
break
;
}
intersections
.
append
(
intersectPoint
);
}
}
if
(
foundCount
==
2
)
{
resultLines
+=
intersectLine
;
// We now have one or more intersection points all along the same line. Find the two
// which are furthest away from each other to form the transect.
if
(
intersections
.
count
()
>
1
)
{
QPointF
firstPoint
;
QPointF
secondPoint
;
double
currentMaxDistance
=
0
;
for
(
int
i
=
0
;
i
<
intersections
.
count
();
i
++
)
{
for
(
int
j
=
0
;
j
<
intersections
.
count
();
j
++
)
{
QLineF
lineTest
(
intersections
[
i
],
intersections
[
j
]);
\
double
newMaxDistance
=
lineTest
.
length
();
if
(
newMaxDistance
>
currentMaxDistance
)
{
firstPoint
=
intersections
[
i
];
secondPoint
=
intersections
[
j
];
currentMaxDistance
=
newMaxDistance
;
}
}
}
resultLines
+=
QLineF
(
firstPoint
,
secondPoint
);
}
}
}
...
...
src/MissionManager/SurveyMissionItem.h
View file @
98071529
...
...
@@ -217,7 +217,6 @@ private:
qreal
_ccw
(
QPointF
pt1
,
QPointF
pt2
,
QPointF
pt3
);
qreal
_dp
(
QPointF
pt1
,
QPointF
pt2
);
void
_swapPoints
(
QList
<
QPointF
>&
points
,
int
index1
,
int
index2
);
QList
<
QPointF
>
_convexPolygon
(
const
QList
<
QPointF
>&
polygon
);
void
_reverseTransectOrder
(
QList
<
QList
<
QGeoCoordinate
>>&
transects
);
void
_reverseInternalTransectPoints
(
QList
<
QList
<
QGeoCoordinate
>>&
transects
);
void
_adjustTransectsToEntryPointLocation
(
QList
<
QList
<
QGeoCoordinate
>>&
transects
);
...
...
src/PlanView/SurveyItemEditor.qml
View file @
98071529
...
...
@@ -63,6 +63,7 @@ Rectangle {
}
}
}
recalcFromCameraValues
()
}
function
recalcFromCameraValues
()
{
...
...
src/QmlControls/QmlObjectListModel.cc
View file @
98071529
...
...
@@ -172,11 +172,42 @@ void QmlObjectListModel::insert(int i, QObject* object)
setDirty
(
true
);
}
void
QmlObjectListModel
::
insert
(
int
i
,
QList
<
QObject
*>
objects
)
{
if
(
i
<
0
||
i
>
_objectList
.
count
())
{
qWarning
()
<<
"Invalid index index:count"
<<
i
<<
_objectList
.
count
();
}
int
j
=
i
;
foreach
(
QObject
*
object
,
objects
)
{
QQmlEngine
::
setObjectOwnership
(
object
,
QQmlEngine
::
CppOwnership
);
// Look for a dirtyChanged signal on the object
if
(
object
->
metaObject
()
->
indexOfSignal
(
QMetaObject
::
normalizedSignature
(
"dirtyChanged(bool)"
))
!=
-
1
)
{
if
(
!
_skipDirtyFirstItem
||
j
!=
0
)
{
QObject
::
connect
(
object
,
SIGNAL
(
dirtyChanged
(
bool
)),
this
,
SLOT
(
_childDirtyChanged
(
bool
)));
}
}
j
++
;
_objectList
.
insert
(
i
,
object
);
}
insertRows
(
i
,
objects
.
count
());
setDirty
(
true
);
}
void
QmlObjectListModel
::
append
(
QObject
*
object
)
{
insert
(
_objectList
.
count
(),
object
);
}
void
QmlObjectListModel
::
append
(
QList
<
QObject
*>
objects
)
{
insert
(
_objectList
.
count
(),
objects
);
}
QObjectList
QmlObjectListModel
::
swapObjectList
(
const
QObjectList
&
newlist
)
{
QObjectList
oldlist
(
_objectList
);
...
...
src/QmlControls/QmlObjectListModel.h
View file @
98071529
...
...
@@ -37,11 +37,13 @@ public:
void
setDirty
(
bool
dirty
);
void
append
(
QObject
*
object
);
void
append
(
QList
<
QObject
*>
objects
);
QObjectList
swapObjectList
(
const
QObjectList
&
newlist
);
void
clear
(
void
);
QObject
*
removeAt
(
int
i
);
QObject
*
removeOne
(
QObject
*
object
)
{
return
removeAt
(
indexOf
(
object
));
}
void
insert
(
int
i
,
QObject
*
object
);
void
insert
(
int
i
,
QList
<
QObject
*>
objects
);
QObject
*
operator
[](
int
i
);
const
QObject
*
operator
[](
int
i
)
const
;
bool
contains
(
QObject
*
object
)
{
return
_objectList
.
indexOf
(
object
)
!=
-
1
;
}
...
...
@@ -63,12 +65,12 @@ private slots:
private:
// Overrides from QAbstractListModel
virtual
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
virtual
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
;
virtual
QHash
<
int
,
QByteArray
>
roleNames
(
void
)
const
;
virtual
bool
insertRows
(
int
position
,
int
rows
,
const
QModelIndex
&
index
=
QModelIndex
())
;
virtual
bool
removeRows
(
int
position
,
int
rows
,
const
QModelIndex
&
index
=
QModelIndex
())
;
virtual
bool
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
=
Qt
::
EditRole
)
;
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
QHash
<
int
,
QByteArray
>
roleNames
(
void
)
const
override
;
bool
insertRows
(
int
position
,
int
rows
,
const
QModelIndex
&
index
=
QModelIndex
())
override
;
bool
removeRows
(
int
position
,
int
rows
,
const
QModelIndex
&
index
=
QModelIndex
())
override
;
bool
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
=
Qt
::
EditRole
)
override
;
private:
QList
<
QObject
*>
_objectList
;
...
...
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