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
fc2260ab
Commit
fc2260ab
authored
Oct 05, 2019
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New editing tools support
parent
d18a914e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
363 additions
and
144 deletions
+363
-144
QGCMapPolygon.cc
src/MissionManager/QGCMapPolygon.cc
+39
-0
QGCMapPolygon.h
src/MissionManager/QGCMapPolygon.h
+14
-4
QGCMapPolygonVisuals.qml
src/MissionManager/QGCMapPolygonVisuals.qml
+310
-140
No files found.
src/MissionManager/QGCMapPolygon.cc
View file @
fc2260ab
...
...
@@ -29,6 +29,7 @@ QGCMapPolygon::QGCMapPolygon(QObject* parent)
,
_centerDrag
(
false
)
,
_ignoreCenterUpdates
(
false
)
,
_interactive
(
false
)
,
_resetActive
(
false
)
{
_init
();
}
...
...
@@ -39,6 +40,7 @@ QGCMapPolygon::QGCMapPolygon(const QGCMapPolygon& other, QObject* parent)
,
_centerDrag
(
false
)
,
_ignoreCenterUpdates
(
false
)
,
_interactive
(
false
)
,
_resetActive
(
false
)
{
*
this
=
other
;
...
...
@@ -265,11 +267,14 @@ void QGCMapPolygon::appendVertices(const QList<QGeoCoordinate>& coordinates)
{
QList
<
QObject
*>
objects
;
_beginResetIfNotActive
();
for
(
const
QGeoCoordinate
&
coordinate
:
coordinates
)
{
objects
.
append
(
new
QGCQGeoCoordinate
(
coordinate
,
this
));
_polygonPath
.
append
(
QVariant
::
fromValue
(
coordinate
));
}
_polygonModel
.
append
(
objects
);
_endResetIfNotActive
();
emit
pathChanged
();
}
...
...
@@ -448,8 +453,10 @@ void QGCMapPolygon::offset(double distance)
}
// Update internals
_beginResetIfNotActive
();
clear
();
appendVertices
(
rgNewPolygon
);
_endResetIfNotActive
();
}
bool
QGCMapPolygon
::
loadKMLOrSHPFile
(
const
QString
&
file
)
...
...
@@ -461,8 +468,10 @@ bool QGCMapPolygon::loadKMLOrSHPFile(const QString& file)
return
false
;
}
_beginResetIfNotActive
();
clear
();
appendVertices
(
rgCoords
);
_endResetIfNotActive
();
return
true
;
}
...
...
@@ -509,7 +518,37 @@ void QGCMapPolygon::verifyClockwiseWinding(void)
rgReversed
.
prepend
(
varCoord
.
value
<
QGeoCoordinate
>
());
}
_beginResetIfNotActive
();
clear
();
appendVertices
(
rgReversed
);
_endResetIfNotActive
();
}
}
void
QGCMapPolygon
::
beginReset
(
void
)
{
_resetActive
=
true
;
_polygonModel
.
beginReset
();
}
void
QGCMapPolygon
::
endReset
(
void
)
{
_resetActive
=
false
;
_polygonModel
.
endReset
();
emit
pathChanged
();
emit
centerChanged
(
_center
);
}
void
QGCMapPolygon
::
_beginResetIfNotActive
(
void
)
{
if
(
!
_resetActive
)
{
beginReset
();
}
}
void
QGCMapPolygon
::
_endResetIfNotActive
(
void
)
{
if
(
!
_resetActive
)
{
endReset
();
}
}
src/MissionManager/QGCMapPolygon.h
View file @
fc2260ab
...
...
@@ -36,6 +36,8 @@ public:
Q_PROPERTY
(
QGeoCoordinate
center
READ
center
WRITE
setCenter
NOTIFY
centerChanged
)
Q_PROPERTY
(
bool
centerDrag
READ
centerDrag
WRITE
setCenterDrag
NOTIFY
centerDragChanged
)
Q_PROPERTY
(
bool
interactive
READ
interactive
WRITE
setInteractive
NOTIFY
interactiveChanged
)
Q_PROPERTY
(
bool
isValid
READ
isValid
NOTIFY
countChanged
)
Q_PROPERTY
(
bool
empty
READ
empty
NOTIFY
countChanged
)
Q_INVOKABLE
void
clear
(
void
);
Q_INVOKABLE
void
appendVertex
(
const
QGeoCoordinate
&
coordinate
);
...
...
@@ -69,6 +71,9 @@ public:
/// Adjust polygon winding order to be clockwise (if needed)
Q_INVOKABLE
void
verifyClockwiseWinding
(
void
);
Q_INVOKABLE
void
beginReset
(
void
);
Q_INVOKABLE
void
endReset
(
void
);
/// Saves the polygon to the json object.
/// @param json Json object to save to
void
saveToJson
(
QJsonObject
&
json
);
...
...
@@ -94,6 +99,8 @@ public:
QGeoCoordinate
center
(
void
)
const
{
return
_center
;
}
bool
centerDrag
(
void
)
const
{
return
_centerDrag
;
}
bool
interactive
(
void
)
const
{
return
_interactive
;
}
bool
isValid
(
void
)
const
{
return
_polygonModel
.
count
()
>=
3
;
}
bool
empty
(
void
)
const
{
return
_polygonModel
.
count
()
==
0
;
}
QVariantList
path
(
void
)
const
{
return
_polygonPath
;
}
QmlObjectListModel
*
qmlPathModel
(
void
)
{
return
&
_polygonModel
;
}
...
...
@@ -122,10 +129,12 @@ private slots:
void
_updateCenter
(
void
);
private:
void
_init
(
void
);
QPolygonF
_toPolygonF
(
void
)
const
;
QGeoCoordinate
_coordFromPointF
(
const
QPointF
&
point
)
const
;
QPointF
_pointFFromCoord
(
const
QGeoCoordinate
&
coordinate
)
const
;
void
_init
(
void
);
QPolygonF
_toPolygonF
(
void
)
const
;
QGeoCoordinate
_coordFromPointF
(
const
QPointF
&
point
)
const
;
QPointF
_pointFFromCoord
(
const
QGeoCoordinate
&
coordinate
)
const
;
void
_beginResetIfNotActive
(
void
);
void
_endResetIfNotActive
(
void
);
QVariantList
_polygonPath
;
QmlObjectListModel
_polygonModel
;
...
...
@@ -134,6 +143,7 @@ private:
bool
_centerDrag
;
bool
_ignoreCenterUpdates
;
bool
_interactive
;
bool
_resetActive
;
};
#endif
src/MissionManager/QGCMapPolygonVisuals.qml
View file @
fc2260ab
This diff is collapsed.
Click to expand it.
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