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
81769297
Commit
81769297
authored
Jun 25, 2019
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed wima classes to copy and swap idiom
parent
2b61da4b
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
631 additions
and
582 deletions
+631
-582
QGCMapPolygon.cc
src/MissionManager/QGCMapPolygon.cc
+37
-0
QGCMapPolygon.h
src/MissionManager/QGCMapPolygon.h
+6
-0
QmlObjectListModel.cc
src/QmlControls/QmlObjectListModel.cc
+9
-0
QmlObjectListModel.h
src/QmlControls/QmlObjectListModel.h
+3
-0
WimaArea.cc
src/Wima/WimaArea.cc
+98
-46
WimaArea.h
src/Wima/WimaArea.h
+23
-17
WimaController.cc
src/Wima/WimaController.cc
+223
-304
WimaController.h
src/Wima/WimaController.h
+22
-16
WimaDataContainer.cc
src/Wima/WimaDataContainer.cc
+41
-3
WimaDataContainer.h
src/Wima/WimaDataContainer.h
+17
-6
WimaGOperationArea.cc
src/Wima/WimaGOperationArea.cc
+48
-106
WimaGOperationArea.h
src/Wima/WimaGOperationArea.h
+13
-21
WimaServiceArea.cc
src/Wima/WimaServiceArea.cc
+37
-19
WimaServiceArea.h
src/Wima/WimaServiceArea.h
+12
-6
WimaVCorridor.cc
src/Wima/WimaVCorridor.cc
+32
-29
WimaVCorridor.h
src/Wima/WimaVCorridor.h
+10
-9
No files found.
src/MissionManager/QGCMapPolygon.cc
View file @
81769297
...
@@ -367,6 +367,43 @@ void QGCMapPolygon::setInteractive(bool interactive)
...
@@ -367,6 +367,43 @@ void QGCMapPolygon::setInteractive(bool interactive)
}
}
}
}
void
print
(
const
QGCMapPolygon
&
poly
)
{
QString
message
;
print
(
poly
,
message
);
qWarning
()
<<
message
;
}
void
print
(
const
QGCMapPolygon
&
poly
,
QString
&
outputString
)
{
outputString
.
append
(
QString
(
"Coordinates:
\n
"
));
for
(
int
i
=
0
;
i
<
poly
.
count
();
i
++
)
{
QGeoCoordinate
coordinate
=
poly
.
vertexCoordinate
(
i
);
outputString
.
append
(
QString
(
"%s
\n
"
).
arg
(
coordinate
.
toString
(
QGeoCoordinate
::
Degrees
)));
}
outputString
.
append
(
QString
(
"Dirty: %s
\n
"
).
arg
(
QVariant
(
poly
.
_dirty
).
toString
()));
outputString
.
append
(
QString
(
"Center: %s
\n
"
).
arg
(
poly
.
_center
.
toString
(
QGeoCoordinate
::
Degrees
)));
outputString
.
append
(
QString
(
"Center Drag: %s
\n
"
).
arg
(
QVariant
(
poly
.
_centerDrag
).
toString
()));
outputString
.
append
(
QString
(
"Ignore Center Updates: %s
\n
"
).
arg
(
QVariant
(
poly
.
_centerDrag
).
toString
()));
outputString
.
append
(
QString
(
"Interactive: %s
\n
"
).
arg
(
QVariant
(
poly
.
_interactive
).
toString
()));
}
void
swap
(
QGCMapPolygon
&
poly1
,
QGCMapPolygon
&
poly2
)
{
using
std
::
swap
;
poly1
.
_polygonPath
.
swap
(
poly2
.
_polygonPath
);
swap
(
poly1
.
_polygonModel
,
poly2
.
_polygonModel
);
swap
(
poly1
.
_dirty
,
poly2
.
_dirty
);
swap
(
poly1
.
_center
,
poly2
.
_center
);
swap
(
poly1
.
_centerDrag
,
poly2
.
_centerDrag
);
swap
(
poly1
.
_ignoreCenterUpdates
,
poly2
.
_ignoreCenterUpdates
);
swap
(
poly1
.
_interactive
,
poly2
.
_interactive
);
}
QGeoCoordinate
QGCMapPolygon
::
vertexCoordinate
(
int
vertex
)
const
QGeoCoordinate
QGCMapPolygon
::
vertexCoordinate
(
int
vertex
)
const
{
{
if
(
vertex
>=
0
&&
vertex
<
_polygonPath
.
count
())
{
if
(
vertex
>=
0
&&
vertex
<
_polygonPath
.
count
())
{
...
...
src/MissionManager/QGCMapPolygon.h
View file @
81769297
...
@@ -105,6 +105,12 @@ public:
...
@@ -105,6 +105,12 @@ public:
void
setCenterDrag
(
bool
centerDrag
);
void
setCenterDrag
(
bool
centerDrag
);
void
setInteractive
(
bool
interactive
);
void
setInteractive
(
bool
interactive
);
// Friends
friend
void
swap
(
QGCMapPolygon
&
poly1
,
QGCMapPolygon
&
poly2
);
friend
void
print
(
const
QGCMapPolygon
&
poly
,
QString
&
outputString
);
friend
void
print
(
const
QGCMapPolygon
&
poly
);
// static Variables
static
const
char
*
jsonPolygonKey
;
static
const
char
*
jsonPolygonKey
;
signals:
signals:
...
...
src/QmlControls/QmlObjectListModel.cc
View file @
81769297
...
@@ -268,3 +268,12 @@ void QmlObjectListModel::clearAndDeleteContents()
...
@@ -268,3 +268,12 @@ void QmlObjectListModel::clearAndDeleteContents()
clear
();
clear
();
endResetModel
();
endResetModel
();
}
}
void
swap
(
QmlObjectListModel
&
list1
,
QmlObjectListModel
&
list2
)
{
using
std
::
swap
;
swap
(
list1
.
_objectList
,
list2
.
_objectList
);
swap
(
list1
.
_dirty
,
list2
.
_dirty
);
swap
(
list1
.
_skipDirtyFirstItem
,
list2
.
_skipDirtyFirstItem
);
}
src/QmlControls/QmlObjectListModel.h
View file @
81769297
...
@@ -59,6 +59,9 @@ public:
...
@@ -59,6 +59,9 @@ public:
void
beginReset
()
{
beginResetModel
();
}
void
beginReset
()
{
beginResetModel
();
}
void
endReset
()
{
endResetModel
();
}
void
endReset
()
{
endResetModel
();
}
// Friends
friend
void
swap
(
QmlObjectListModel
&
list1
,
QmlObjectListModel
&
list2
);
signals:
signals:
void
countChanged
(
int
count
);
void
countChanged
(
int
count
);
void
dirtyChanged
(
bool
dirtyChanged
);
void
dirtyChanged
(
bool
dirtyChanged
);
...
...
src/Wima/WimaArea.cc
View file @
81769297
...
@@ -6,42 +6,32 @@ const char* WimaArea::wimaAreaName = "WimaArea";
...
@@ -6,42 +6,32 @@ const char* WimaArea::wimaAreaName = "WimaArea";
const
char
*
WimaArea
::
areaTypeName
=
"AreaType"
;
const
char
*
WimaArea
::
areaTypeName
=
"AreaType"
;
WimaArea
::
WimaArea
()
:
QGCMapPolygon
(
nullptr
)
{
this
->
setObjectName
(
wimaAreaName
);
_maxAltitude
=
30
;
_wimaVehicle
=
new
WimaVehicle
(
this
);
}
WimaArea
::
WimaArea
(
QObject
*
parent
)
:
QGCMapPolygon
(
parent
)
{
this
->
setObjectName
(
wimaAreaName
);
_maxAltitude
=
30
;
_wimaVehicle
=
new
WimaVehicle
(
this
);
}
WimaArea
::
WimaArea
(
const
QGCMapPolygon
&
other
,
QObject
*
parent
)
WimaArea
::
WimaArea
(
QObject
*
parent
)
:
QGCMapPolygon
(
other
,
parent
)
:
QGCMapPolygon
(
parent
)
{
{
this
->
setObjectName
(
wimaAreaName
);
init
(
);
_maxAltitude
=
30
;
_maxAltitude
=
30
;
_wimaVehicle
=
new
WimaVehicle
(
this
);
}
}
WimaArea
::
WimaArea
(
const
WimaArea
&
other
,
QObject
*
parent
)
WimaArea
::
WimaArea
(
const
WimaArea
&
other
,
QObject
*
parent
)
:
WimaArea
(
parent
)
:
QGCMapPolygon
(
other
,
parent
)
{
{
this
->
setObjectName
(
wimaAreaName
);
init
(
);
this
->
setPath
(
other
.
path
());
this
->
setPath
(
other
.
path
());
this
->
setCenter
(
other
.
center
());
this
->
setCenter
(
other
.
center
());
this
->
setCenterDrag
(
other
.
centerDrag
());
this
->
setCenterDrag
(
other
.
centerDrag
());
this
->
setInteractive
(
other
.
interactive
());
this
->
setInteractive
(
other
.
interactive
());
_maxAltitude
=
other
.
maxAltitude
();
_maxAltitude
=
other
.
maxAltitude
();
_wimaVehicle
=
other
.
vehicle
();
}
}
WimaArea
&
WimaArea
::
operator
=
(
WimaArea
other
)
{
swap
(
*
this
,
other
);
// copy-swap-idiom
return
*
this
;
}
void
WimaArea
::
setMaxAltitude
(
double
alt
)
void
WimaArea
::
setMaxAltitude
(
double
alt
)
{
{
...
@@ -51,14 +41,7 @@ void WimaArea::setMaxAltitude(double alt)
...
@@ -51,14 +41,7 @@ void WimaArea::setMaxAltitude(double alt)
}
}
}
}
void
WimaArea
::
setVehicle
(
WimaVehicle
*
vehicle
)
{
if
(
_wimaVehicle
!=
vehicle
){
_wimaVehicle
->
deleteLater
();
_wimaVehicle
=
vehicle
;
emit
vehicleChanged
();
}
}
/*QList<WimaArea *>* WimaArea::splitArea<T>(WimaArea *polygonToSplitt, int numberOfFractions)
/*QList<WimaArea *>* WimaArea::splitArea<T>(WimaArea *polygonToSplitt, int numberOfFractions)
{
{
...
@@ -127,7 +110,7 @@ void WimaArea::join(QList<WimaArea *>* polyList, WimaArea* joinedPoly)
...
@@ -127,7 +110,7 @@ void WimaArea::join(QList<WimaArea *>* polyList, WimaArea* joinedPoly)
return
;
return
;
}
}
void
WimaArea
::
join
(
WimaArea
&
poly1
,
WimaArea
&
poly2
,
WimaArea
&
joinedPoly
)
bool
WimaArea
::
join
(
WimaArea
&
poly1
,
WimaArea
&
poly2
,
WimaArea
&
joinedPoly
)
{
{
if
(
poly1
.
count
()
>=
3
&&
poly2
.
count
()
>=
3
)
{
if
(
poly1
.
count
()
>=
3
&&
poly2
.
count
()
>=
3
)
{
...
@@ -156,7 +139,7 @@ void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly)
...
@@ -156,7 +139,7 @@ void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly)
if
(
crossContainsWalker
==
true
)
{
if
(
crossContainsWalker
==
true
)
{
joinedPoly
.
appendVertices
(
crossPoly
->
coordinateList
());
joinedPoly
.
appendVertices
(
crossPoly
->
coordinateList
());
return
;
return
true
;
}
}
...
@@ -222,22 +205,28 @@ void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly)
...
@@ -222,22 +205,28 @@ void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly)
}
}
if
(
currentVertex
==
startVertex
)
{
if
(
currentVertex
==
startVertex
)
{
return
;
if
(
poly1
.
count
()
==
joinedPoly
.
count
())
{
// is the case if poly1 and poly2 don't intersect
return
false
;
}
else
{
return
true
;
}
}
}
}
}
}
else
{
}
else
{
qWarning
(
"WimaArea::joinPolygons(poly1, poly2): poly->count() < 3"
);
return
false
;
return
;
}
}
}
}
void
WimaArea
::
join
(
WimaArea
&
poly
)
bool
WimaArea
::
join
(
WimaArea
&
poly
)
{
{
WimaArea
joinedArea
;
WimaArea
joinedArea
;
join
(
*
this
,
poly
,
joinedArea
);
if
(
join
(
*
this
,
poly
,
joinedArea
)
)
{
this
->
setPath
(
joinedArea
.
path
());
this
->
setPath
(
joinedArea
.
path
());
return
;
return
true
;
}
else
{
return
false
;
}
}
}
bool
WimaArea
::
isDisjunct
(
QList
<
WimaArea
*>*
polyList
)
bool
WimaArea
::
isDisjunct
(
QList
<
WimaArea
*>*
polyList
)
...
@@ -378,20 +367,18 @@ bool WimaArea::intersects(const QGCMapPolyline& line, const WimaArea& poly, QLis
...
@@ -378,20 +367,18 @@ bool WimaArea::intersects(const QGCMapPolyline& line, const WimaArea& poly, QLis
}
}
}
}
double
WimaArea
::
distInsidePoly
(
const
QGeoCoordinate
&
c1
,
const
QGeoCoordinate
&
c2
,
const
WimaArea
&
poly
)
double
WimaArea
::
distInsidePoly
(
const
QGeoCoordinate
&
c1
,
const
QGeoCoordinate
&
c2
,
WimaArea
poly
)
{
{
WimaArea
bigPoly
(
poly
);
poly
.
offset
(
0.1
);
// hack to compensate for numerical issues, migh be replaced in the future...
bigPoly
.
offset
(
0.1
);
// hack to compensate for numerical issues, migh be replaced in the future...
if
(
poly
.
containsCoordinate
(
c1
)
&&
poly
.
containsCoordinate
(
c2
))
{
if
(
bigPoly
.
containsCoordinate
(
c1
)
&&
bigPoly
.
containsCoordinate
(
c2
))
{
QList
<
QGeoCoordinate
>
intersectionList
;
QList
<
QGeoCoordinate
>
intersectionList
;
QList
<
QPair
<
int
,
int
>>
neighbourlist
;
QList
<
QPair
<
int
,
int
>>
neighbourlist
;
QGCMapPolyline
line
;
QGCMapPolyline
line
;
line
.
appendVertex
(
c1
);
line
.
appendVertex
(
c1
);
line
.
appendVertex
(
c2
);
line
.
appendVertex
(
c2
);
intersects
(
line
,
bigP
oly
,
intersectionList
,
neighbourlist
);
intersects
(
line
,
p
oly
,
intersectionList
,
neighbourlist
);
//if ( intersectionList.size() == (c1InPolyRim || c2InPolyRim ? 2:0) ){
if
(
intersectionList
.
size
()
==
0
){
if
(
intersectionList
.
size
()
==
0
){
return
c1
.
distanceTo
(
c2
);
return
c1
.
distanceTo
(
c2
);
}
else
{
}
else
{
...
@@ -403,8 +390,12 @@ double WimaArea::distInsidePoly(const QGeoCoordinate &c1, const QGeoCoordinate &
...
@@ -403,8 +390,12 @@ double WimaArea::distInsidePoly(const QGeoCoordinate &c1, const QGeoCoordinate &
}
}
}
}
void
WimaArea
::
dijkstraPath
(
const
QGeoCoordinate
&
start
,
const
QGeoCoordinate
&
end
,
const
WimaArea
&
poly
,
QList
<
QGeoCoordinate
>
&
dijkstraPath
)
bool
WimaArea
::
dijkstraPath
(
const
QGeoCoordinate
&
start
,
const
QGeoCoordinate
&
end
,
const
WimaArea
&
poly
,
QList
<
QGeoCoordinate
>
&
dijkstraPath
)
{
{
if
(
isSelfIntersecting
(
poly
)
)
{
return
false
;
}
struct
Node
{
struct
Node
{
QGeoCoordinate
coordinate
;
QGeoCoordinate
coordinate
;
double
distance
=
std
::
numeric_limits
<
qreal
>::
infinity
();
double
distance
=
std
::
numeric_limits
<
qreal
>::
infinity
();
...
@@ -477,7 +468,7 @@ void WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &e
...
@@ -477,7 +468,7 @@ void WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &e
Node
*
Node
=
&
nodeList
.
last
();
Node
*
Node
=
&
nodeList
.
last
();
if
(
Node
->
predecessorNode
==
nullptr
)
{
if
(
Node
->
predecessorNode
==
nullptr
)
{
qWarning
(
"WimaArea::dijkstraPath(): Error, no path found!"
);
qWarning
(
"WimaArea::dijkstraPath(): Error, no path found!"
);
return
;
return
false
;
}
}
while
(
1
)
{
while
(
1
)
{
...
@@ -489,6 +480,40 @@ void WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &e
...
@@ -489,6 +480,40 @@ void WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &e
break
;
break
;
}
}
}
}
return
true
;
}
bool
WimaArea
::
isSelfIntersecting
(
const
WimaArea
&
poly
)
{
int
i
=
0
;
if
(
poly
.
count
()
>
3
)
{
while
(
i
<
poly
.
count
()
-
1
)
{
QGCMapPolyline
refLine
;
refLine
.
appendVertex
(
poly
.
vertexCoordinate
(
i
));
refLine
.
appendVertex
(
poly
.
vertexCoordinate
(
poly
.
nextVertexIndex
(
i
)));
int
j
=
poly
.
nextVertexIndex
(
i
);
while
(
j
<
poly
.
count
())
{
QGeoCoordinate
dummy
;
QGCMapPolyline
iteratorLine
;
iteratorLine
.
appendVertex
(
poly
.
vertexCoordinate
(
j
));
iteratorLine
.
appendVertex
(
poly
.
vertexCoordinate
(
poly
.
nextVertexIndex
(
j
)));
if
(
intersects
(
refLine
,
iteratorLine
,
dummy
)
)
return
true
;
j
++
;
}
i
++
;
}
}
return
false
;
}
bool
WimaArea
::
isSelfIntersecting
()
{
return
isSelfIntersecting
(
*
this
);
}
}
void
WimaArea
::
saveToJson
(
QJsonObject
&
json
)
void
WimaArea
::
saveToJson
(
QJsonObject
&
json
)
...
@@ -515,3 +540,30 @@ bool WimaArea::loadFromJson(const QJsonObject &json, QString& errorString)
...
@@ -515,3 +540,30 @@ bool WimaArea::loadFromJson(const QJsonObject &json, QString& errorString)
}
}
}
}
void
WimaArea
::
init
()
{
this
->
setObjectName
(
wimaAreaName
);
}
void
print
(
const
WimaArea
&
area
)
{
QString
message
;
print
(
area
,
message
);
qWarning
()
<<
message
;
}
void
print
(
const
WimaArea
&
area
,
QString
&
outputString
)
{
outputString
.
append
(
QString
(
"Type: %s"
).
arg
(
area
.
objectName
()));
print
(
static_cast
<
const
QGCMapPolygon
&>
(
area
),
outputString
);
outputString
.
append
(
QString
(
"Maximum Altitude: %.3f"
).
arg
(
area
.
_maxAltitude
));
}
void
swap
(
WimaArea
&
area1
,
WimaArea
&
area2
)
{
using
std
::
swap
;
swap
(
static_cast
<
QGCMapPolygon
&>
(
area1
),
static_cast
<
QGCMapPolygon
&>
(
area2
));
swap
(
area1
.
_maxAltitude
,
area2
.
_maxAltitude
);
}
src/Wima/WimaArea.h
View file @
81769297
...
@@ -15,21 +15,17 @@ class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
...
@@ -15,21 +15,17 @@ class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
{
{
Q_OBJECT
Q_OBJECT
public:
public:
WimaArea
();
WimaArea
(
QObject
*
parent
=
nullptr
);
WimaArea
(
QObject
*
parent
);
WimaArea
(
const
WimaArea
&
other
,
QObject
*
parent
=
nullptr
);
WimaArea
(
const
QGCMapPolygon
&
other
,
QObject
*
parent
);
WimaArea
&
operator
=
(
WimaArea
other
);
WimaArea
(
const
WimaArea
&
other
,
QObject
*
parent
);
Q_PROPERTY
(
double
maxAltitude
READ
maxAltitude
WRITE
setMaxAltitude
NOTIFY
maxAltitudeChanged
)
Q_PROPERTY
(
double
maxAltitude
READ
maxAltitude
WRITE
setMaxAltitude
NOTIFY
maxAltitudeChanged
)
Q_PROPERTY
(
QString
mapVisualQML
READ
mapVisualQML
CONSTANT
)
Q_PROPERTY
(
QString
mapVisualQML
READ
mapVisualQML
CONSTANT
)
Q_PROPERTY
(
QString
editorQML
READ
editorQML
CONSTANT
)
Q_PROPERTY
(
QString
editorQML
READ
editorQML
CONSTANT
)
Q_PROPERTY
(
WimaVehicle
*
vehicle
READ
vehicle
WRITE
setVehicle
NOTIFY
vehicleChanged
)
//Property accessors
//Property accessors
double
maxAltitude
(
void
)
const
{
return
_maxAltitude
;}
double
maxAltitude
(
void
)
const
{
return
_maxAltitude
;}
WimaVehicle
*
vehicle
(
void
)
const
{
return
_wimaVehicle
;}
virtual
QString
mapVisualQML
(
void
)
const
{
return
"WimaAreaMapVisual.qml"
;}
virtual
QString
mapVisualQML
(
void
)
const
{
return
"WimaAreaMapVisual.qml"
;}
virtual
QString
editorQML
(
void
)
const
{
return
"WimaAreaEditor.qml"
;}
virtual
QString
editorQML
(
void
)
const
{
return
"WimaAreaEditor.qml"
;}
...
@@ -39,10 +35,6 @@ public:
...
@@ -39,10 +35,6 @@ public:
void
setVehicle
(
WimaVehicle
*
vehicle
);
void
setVehicle
(
WimaVehicle
*
vehicle
);
// Member Methodes
// Member Methodes
/*template <class T>
QList<T*>* splitArea (WimaArea *polygonToSplitt, int numberOfFractions); // use QScopedPointer to store return value
template <class T>
QList<T*>* splitArea (int numberOfFractions); // use QScopedPointer to store return value*/
//iterates over all vertices in _polygon and returns the index of that one closest to coordinate
//iterates over all vertices in _polygon and returns the index of that one closest to coordinate
int
getClosestVertexIndex
(
const
QGeoCoordinate
&
coordinate
)
const
;
int
getClosestVertexIndex
(
const
QGeoCoordinate
&
coordinate
)
const
;
//iterates over all vertices in _polygon and returns that one closest to coordinate
//iterates over all vertices in _polygon and returns that one closest to coordinate
...
@@ -52,9 +44,9 @@ public:
...
@@ -52,9 +44,9 @@ public:
static
void
join
(
QList
<
WimaArea
*>*
polyList
,
WimaArea
*
joinedPoly
);
// change to & notation
static
void
join
(
QList
<
WimaArea
*>*
polyList
,
WimaArea
*
joinedPoly
);
// change to & notation
/// joins the poly1 and poly2 if possible, joins the polygons to form a simple polygon (no holes)
/// joins the poly1 and poly2 if possible, joins the polygons to form a simple polygon (no holes)
/// see https://en.wikipedia.org/wiki/Simple_polygon
/// see https://en.wikipedia.org/wiki/Simple_polygon
/// @return t
he joined polygon of poly1 and poly2 if possible, poly1
else
/// @return t
rue if polygons have been joined, false
else
static
void
join
(
WimaArea
&
poly1
,
WimaArea
&
poly2
,
WimaArea
&
joinedPoly
);
static
bool
join
(
WimaArea
&
poly1
,
WimaArea
&
poly2
,
WimaArea
&
joinedPoly
);
void
join
(
WimaArea
&
poly
);
bool
join
(
WimaArea
&
poly
);
bool
isDisjunct
(
QList
<
WimaArea
*>*
polyList
);
// change to & notation, if necessary
bool
isDisjunct
(
QList
<
WimaArea
*>*
polyList
);
// change to & notation, if necessary
bool
isDisjunct
(
WimaArea
*
poly1
,
WimaArea
*
poly2
);
// change to & notation, if necessary
bool
isDisjunct
(
WimaArea
*
poly1
,
WimaArea
*
poly2
);
// change to & notation, if necessary
/// calculates the next polygon vertex index
/// calculates the next polygon vertex index
...
@@ -77,13 +69,25 @@ public:
...
@@ -77,13 +69,25 @@ public:
static
bool
intersects
(
const
QGCMapPolyline
&
line
,
const
WimaArea
&
poly
,
QList
<
QGeoCoordinate
>&
intersectionList
,
QList
<
QPair
<
int
,
int
>>&
neighbourlist
);
static
bool
intersects
(
const
QGCMapPolyline
&
line
,
const
WimaArea
&
poly
,
QList
<
QGeoCoordinate
>&
intersectionList
,
QList
<
QPair
<
int
,
int
>>&
neighbourlist
);
/// calculates the distance between to geo coordinates, returns the distance if the path lies within the polygon and inf. else.
/// calculates the distance between to geo coordinates, returns the distance if the path lies within the polygon and inf. else.
/// @return the distance if the path lies within the polygon and inf. else.
/// @return the distance if the path lies within the polygon and inf. else.
static
double
distInsidePoly
(
const
QGeoCoordinate
&
c1
,
const
QGeoCoordinate
&
c2
,
const
WimaArea
&
poly
);
static
double
distInsidePoly
(
const
QGeoCoordinate
&
c1
,
const
QGeoCoordinate
&
c2
,
WimaArea
poly
);
/// calculates the shortes path between two geo coordinates inside a polygon using the Dijkstra Algorithm
/// calculates the shortes path between two geo coordinates inside a polygon using the Dijkstra Algorithm
static
void
dijkstraPath
(
const
QGeoCoordinate
&
c1
,
const
QGeoCoordinate
&
c2
,
const
WimaArea
&
poly
,
QList
<
QGeoCoordinate
>&
dijkstraPath
);
/// @return true if path was found, false else
static
bool
dijkstraPath
(
const
QGeoCoordinate
&
c1
,
const
QGeoCoordinate
&
c2
,
const
WimaArea
&
poly
,
QList
<
QGeoCoordinate
>&
dijkstraPath
);
/// @return true if the polygon is self intersecting
static
bool
isSelfIntersecting
(
const
WimaArea
&
poly
);
bool
isSelfIntersecting
();
void
saveToJson
(
QJsonObject
&
jsonObject
);
void
saveToJson
(
QJsonObject
&
jsonObject
);
bool
loadFromJson
(
const
QJsonObject
&
jsonObject
,
QString
&
errorString
);
bool
loadFromJson
(
const
QJsonObject
&
jsonObject
,
QString
&
errorString
);
// Friends
friend
void
swap
(
WimaArea
&
area1
,
WimaArea
&
area2
);
/// prints the member values of area to the outputString
friend
void
print
(
const
WimaArea
&
area
,
QString
&
outputString
);
/// prints the member values of area to the console
friend
void
print
(
const
WimaArea
&
area
);
// static Members
// static Members
// Accurracy used to compute isDisjunct
// Accurracy used to compute isDisjunct
static
const
double
numericalAccuracy
;
static
const
double
numericalAccuracy
;
...
@@ -98,7 +102,9 @@ signals:
...
@@ -98,7 +102,9 @@ signals:
protected:
protected:
double
_maxAltitude
;
double
_maxAltitude
;
WimaVehicle
*
_wimaVehicle
;
private:
void
init
();
};
};
src/Wima/WimaController.cc
View file @
81769297
This diff is collapsed.
Click to expand it.
src/Wima/WimaController.h
View file @
81769297
...
@@ -31,32 +31,33 @@ public:
...
@@ -31,32 +31,33 @@ public:
Q_PROPERTY
(
PlanMasterController
*
masterController
READ
masterController
WRITE
setMasterController
NOTIFY
masterControllerChanged
)
Q_PROPERTY
(
PlanMasterController
*
masterController
READ
masterController
WRITE
setMasterController
NOTIFY
masterControllerChanged
)
Q_PROPERTY
(
MissionController
*
missionController
READ
missionController
WRITE
setMissionController
NOTIFY
missionControllerChanged
)
Q_PROPERTY
(
MissionController
*
missionController
READ
missionController
WRITE
setMissionController
NOTIFY
missionControllerChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
visualItems
READ
visualItems
NOTIFY
visualItemsChanged
)
Q_PROPERTY
(
const
QmlObjectListModel
*
visualItems
READ
visualItems
NOTIFY
visualItemsChanged
)
Q_PROPERTY
(
int
currentPolygonIndex
READ
currentPolygonIndex
WRITE
setCurrentPolygonIndex
NOTIFY
currentPolygonIndexChanged
)
Q_PROPERTY
(
int
currentPolygonIndex
READ
currentPolygonIndex
WRITE
setCurrentPolygonIndex
NOTIFY
currentPolygonIndexChanged
)
Q_PROPERTY
(
QString
currentFile
READ
currentFile
NOTIFY
currentFileChanged
)
Q_PROPERTY
(
QString
currentFile
READ
currentFile
NOTIFY
currentFileChanged
)
Q_PROPERTY
(
QStringList
loadNameFilters
READ
loadNameFilters
CONSTANT
)
Q_PROPERTY
(
QStringList
loadNameFilters
READ
loadNameFilters
CONSTANT
)
Q_PROPERTY
(
QStringList
saveNameFilters
READ
saveNameFilters
CONSTANT
)
Q_PROPERTY
(
QStringList
saveNameFilters
READ
saveNameFilters
CONSTANT
)
Q_PROPERTY
(
QString
fileExtension
READ
fileExtension
CONSTANT
)
Q_PROPERTY
(
QString
fileExtension
READ
fileExtension
CONSTANT
)
Q_PROPERTY
(
QGeoCoordinate
joinedAreaCenter
READ
joinedAreaCenter
CONSTANT
)
Q_PROPERTY
(
QGeoCoordinate
joinedAreaCenter
READ
joinedAreaCenter
CONSTANT
)
Q_PROPERTY
(
WimaArea
*
joinedArea
READ
joinedArea
NOTIFY
joinedAreaChanged
)
Q_PROPERTY
(
WimaArea
joinedArea
READ
joinedArea
NOTIFY
joinedAreaChanged
)
Q_PROPERTY
(
bool
flyView
READ
flyView
CONSTANT
)
Q_PROPERTY
(
bool
flyView
READ
flyView
CONSTANT
)
Q_PROPERTY
(
WimaDataContainer
*
dataContainer
READ
dataContainer
WRITE
setDataContainer
NOTIFY
dataContainerChanged
)
Q_PROPERTY
(
WimaDataContainer
*
dataContainer
READ
dataContainer
WRITE
setDataContainer
NOTIFY
dataContainerChanged
)
Q_PROPERTY
(
bool
readyForSaveSend
READ
readyForSaveSend
NOTIFY
readyForSaveSendChanged
)
// Property accessors
// Property accessors
PlanMasterController
*
masterController
(
void
)
const
{
return
_masterController
;
}
PlanMasterController
*
masterController
(
void
)
const
{
return
_masterController
;
}
MissionController
*
missionController
(
void
)
const
{
return
_missionController
;
}
MissionController
*
missionController
(
void
)
const
{
return
_missionController
;
}
QmlObjectListModel
*
visualItems
(
void
)
const
;
const
QmlObjectListModel
*
visualItems
(
void
)
const
;
int
currentPolygonIndex
(
void
)
const
{
return
_currentPolygonIndex
;
}
int
currentPolygonIndex
(
void
)
const
{
return
_currentPolygonIndex
;
}
QString
currentFile
(
void
)
const
{
return
_currentFile
;
}
QString
currentFile
(
void
)
const
{
return
_currentFile
;
}
QStringList
loadNameFilters
(
void
)
const
;
QStringList
loadNameFilters
(
void
)
const
;
QStringList
saveNameFilters
(
void
)
const
;
QStringList
saveNameFilters
(
void
)
const
;
QString
fileExtension
(
void
)
const
{
return
wimaFileExtension
;
}
QString
fileExtension
(
void
)
const
{
return
wimaFileExtension
;
}
QGeoCoordinate
joinedAreaCenter
(
void
)
const
;
QGeoCoordinate
joinedAreaCenter
(
void
)
const
;
WimaArea
*
joinedArea
(
void
)
const
;
WimaArea
joinedArea
(
void
)
const
;
WimaDataContainer
*
dataContainer
(
void
)
const
{
return
_container
;
}
WimaDataContainer
*
dataContainer
(
void
)
const
{
return
_container
;
}
bool
flyView
(
void
)
const
{
return
_flyView
;
}
bool
flyView
(
void
)
const
{
return
_flyView
;
}
bool
readyForSaveSend
(
void
)
const
{
return
_readyForSaveSend
;
}
...
@@ -100,6 +101,7 @@ public:
...
@@ -100,6 +101,7 @@ public:
// Member Methodes
// Member Methodes
QJsonDocument
saveToJson
(
FileType
fileType
);
QJsonDocument
saveToJson
(
FileType
fileType
);
void
setReadyForSaveSend
(
bool
ready
);
signals:
signals:
void
masterControllerChanged
(
void
);
void
masterControllerChanged
(
void
);
...
@@ -109,26 +111,30 @@ signals:
...
@@ -109,26 +111,30 @@ signals:
void
currentFileChanged
();
void
currentFileChanged
();
void
joinedAreaChanged
();
void
joinedAreaChanged
();
void
dataContainerChanged
();
void
dataContainerChanged
();
void
readyForSaveSendChanged
(
bool
ready
);
private
slots
:
private
slots
:
void
recalcVehicleCorridor
();
void
recalcPolygonInteractivity
(
int
index
);
void
recalcVehicleMeasurementAreas
();
bool
updateJoinedArea
();
void
recalcAll
();
void
updateContainer
();
void
recalcPolygonInteractivity
(
int
index
);
void
downloadFromContainer
();
void
updateJoinedArea
();
void
setOpArea
(
const
WimaGOperationArea
&
area
);
void
uploadToContainer
();
void
setSerArea
(
const
WimaServiceArea
&
area
);
void
downloadFromContainer
();
void
setCorridor
(
const
WimaVCorridor
&
area
);
void
setJoinedArea
(
const
WimaArea
&
area
);
private:
private:
bool
_flyView
;
bool
_flyView
;
bool
_readyForSaveSend
;
PlanMasterController
*
_masterController
;
PlanMasterController
*
_masterController
;
MissionController
*
_missionController
;
MissionController
*
_missionController
;
int
_currentPolygonIndex
;
int
_currentPolygonIndex
;
QString
_currentFile
;
QString
_currentFile
;
WimaDataContainer
*
_container
;
WimaDataContainer
*
_container
;
QmlObjectListModel
*
_visualItems
;
QmlObjectListModel
_visualItems
;
WimaArea
*
_joinedArea
;
WimaArea
_joinedArea
;
WimaGOperationArea
_opArea
;
WimaServiceArea
_serArea
;
WimaVCorridor
_corridor
;
};
};
src/Wima/WimaDataContainer.cc
View file @
81769297
#include "WimaDataContainer.h"
#include "WimaDataContainer.h"
WimaDataContainer
::
WimaDataContainer
(
QObject
*
parent
)
WimaDataContainer
::
WimaDataContainer
(
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
_visualItems
(
this
)
,
_joinedArea
(
this
)
,
_joinedArea
(
this
)
,
_opArea
(
this
)
,
_serArea
(
this
)
,
_corridor
(
this
)
{
{
}
}
void
WimaDataContainer
::
setJoinedArea
(
const
WimaArea
&
joinedArea
)
{
if
(
_joinedArea
.
path
()
!=
joinedArea
.
path
())
{
_joinedArea
=
joinedArea
;
emit
joinedAreaChanged
(
_joinedArea
);
}
}
void
WimaDataContainer
::
setOpArea
(
const
WimaGOperationArea
&
opArea
)
{
if
(
_opArea
.
path
()
!=
opArea
.
path
())
{
_opArea
=
opArea
;
emit
opAreaChanged
(
_opArea
);
}
}
void
WimaDataContainer
::
setSerArea
(
const
WimaServiceArea
&
serArea
)
{
if
(
_serArea
.
path
()
!=
serArea
.
path
())
{
_serArea
=
serArea
;
emit
serAreaChanged
(
_serArea
);
}
}
void
WimaDataContainer
::
setCorridor
(
const
WimaVCorridor
&
corridor
)
{
if
(
_corridor
.
path
()
!=
corridor
.
path
())
{
_corridor
=
corridor
;
emit
corridorChanged
(
_corridor
);
}
}
src/Wima/WimaDataContainer.h
View file @
81769297
...
@@ -6,6 +6,9 @@
...
@@ -6,6 +6,9 @@
#include "QmlObjectListModel.h"
#include "QmlObjectListModel.h"
#include "WimaArea.h"
#include "WimaArea.h"
#include "WimaGOperationArea.h"
#include "WimaServiceArea.h"
#include "WimaVCorridor.h"
class
WimaDataContainer
:
public
QObject
class
WimaDataContainer
:
public
QObject
{
{
...
@@ -13,21 +16,29 @@ class WimaDataContainer : public QObject
...
@@ -13,21 +16,29 @@ class WimaDataContainer : public QObject
public:
public:
explicit
WimaDataContainer
(
QObject
*
parent
=
nullptr
);
explicit
WimaDataContainer
(
QObject
*
parent
=
nullptr
);
QmlObjectListModel
*
visualItems
(
void
)
{
return
&
_visualItems
;
}
//use setVisualItems to modify list
WimaArea
joinedArea
(
void
)
{
return
_joinedArea
;
}
WimaArea
joinedArea
(
void
)
{
return
_joinedArea
;
}
WimaGOperationArea
opArea
(
void
)
{
return
_opArea
;
}
WimaServiceArea
serArea
(
void
)
{
return
_serArea
;
}
WimaVCorridor
corridor
(
void
)
{
return
_corridor
;
}
void
setJoinedArea
(
const
WimaArea
&
joinedArea
);
void
setJoinedArea
(
const
WimaArea
&
joinedArea
);
void
setVisualItems
(
const
QmlObjectListModel
&
list
);
void
setOpArea
(
const
WimaGOperationArea
&
opArea
);
void
setSerArea
(
const
WimaServiceArea
&
serArea
);
void
setCorridor
(
const
WimaVCorridor
&
corridor
);
signals:
signals:
void
joinedAreaChanged
();
void
joinedAreaChanged
(
const
WimaArea
&
area
);
void
visualItemsChanged
();
void
opAreaChanged
(
const
WimaGOperationArea
&
area
);
void
serAreaChanged
(
const
WimaServiceArea
&
area
);
void
corridorChanged
(
const
WimaVCorridor
&
area
);
public
slots
:
public
slots
:
private:
private:
QmlObjectListModel
_visualItems
;
WimaArea
_joinedArea
;
WimaArea
_joinedArea
;
WimaGOperationArea
_opArea
;
WimaServiceArea
_serArea
;
WimaVCorridor
_corridor
;
};
};
#endif // WIMADATACONTAINER_H
#endif // WIMADATACONTAINER_H
src/Wima/WimaGOperationArea.cc
View file @
81769297
...
@@ -8,69 +8,24 @@ const char* WimaGOperationArea::layerDistanceName = "LayerDistance
...
@@ -8,69 +8,24 @@ const char* WimaGOperationArea::layerDistanceName = "LayerDistance
const
char
*
WimaGOperationArea
::
borderPolygonOffsetName
=
"BorderPolygonOffset"
;
const
char
*
WimaGOperationArea
::
borderPolygonOffsetName
=
"BorderPolygonOffset"
;
const
char
*
WimaGOperationArea
::
wimaGOperationAreaName
=
"Operation Area"
;
const
char
*
WimaGOperationArea
::
wimaGOperationAreaName
=
"Operation Area"
;
WimaGOperationArea
::
WimaGOperationArea
()
:
WimaGOperationArea
(
nullptr
)
{
}
WimaGOperationArea
::
WimaGOperationArea
(
QObject
*
parent
)
WimaGOperationArea
::
WimaGOperationArea
(
QObject
*
parent
)
:
WimaArea
(
parent
)
:
WimaArea
(
parent
)
,
_metaDataMap
(
FactMetaData
::
createMapFromJsonFile
(
QStringLiteral
(
":/json/WimaGOperationArea.SettingsGroup.json"
),
this
/* QObject parent */
))
,
_bottomLayerAltitude
(
settingsGroup
,
_metaDataMap
[
bottomLayerAltitudeName
])
,
_numberOfLayers
(
settingsGroup
,
_metaDataMap
[
numberOfLayersName
])
,
_layerDistance
(
settingsGroup
,
_metaDataMap
[
layerDistanceName
])
,
_borderPolygonOffset
(
settingsGroup
,
_metaDataMap
[
borderPolygonOffsetName
])
,
_borderPolygon
(
new
QGCMapPolygon
(
this
))
{
{
this
->
setObjectName
(
wimaGOperationAreaName
);
init
();
connect
(
this
,
&
WimaGOperationArea
::
pathChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
connect
(
&
_borderPolygonOffset
,
&
SettingsFact
::
rawValueChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
}
}
WimaGOperationArea
::
WimaGOperationArea
(
const
WimaArea
&
other
,
QObject
*
parent
)
WimaGOperationArea
::
WimaGOperationArea
(
const
Wima
GOperation
Area
&
other
,
QObject
*
parent
)
:
WimaArea
(
other
,
parent
)
:
WimaArea
(
other
,
parent
)
,
_metaDataMap
(
FactMetaData
::
createMapFromJsonFile
(
QStringLiteral
(
":/json/WimaGOperationArea.SettingsGroup.json"
),
this
/* QObject parent */
))
,
_bottomLayerAltitude
(
settingsGroup
,
_metaDataMap
[
bottomLayerAltitudeName
])
,
_numberOfLayers
(
settingsGroup
,
_metaDataMap
[
numberOfLayersName
])
,
_layerDistance
(
settingsGroup
,
_metaDataMap
[
layerDistanceName
])
,
_borderPolygonOffset
(
settingsGroup
,
_metaDataMap
[
borderPolygonOffsetName
])
,
_borderPolygon
(
new
QGCMapPolygon
(
this
))
{
{
this
->
setObjectName
(
wimaGOperationAreaName
);
init
();
connect
(
this
,
&
WimaGOperationArea
::
pathChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
connect
(
&
_borderPolygonOffset
,
&
SettingsFact
::
rawValueChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
}
void
WimaGOperationArea
::
addVehicle
(
WimaVehicle
*
vehicle
)
{
if
(
vehicle
!=
nullptr
){
_wimaVehicle
=
vehicle
;
emit
vehicleChanged
();
}
}
}
void
WimaGOperationArea
::
removeVehicle
(
int
vehicleIndex
)
WimaGOperationArea
&
WimaGOperationArea
::
operator
=
(
WimaGOperationArea
other
)
{
{
if
(
vehicleIndex
>=
0
){
swap
(
*
this
,
other
);
_wimaVehicle
=
nullptr
;
emit
vehicleChanged
();
}
}
void
WimaGOperationArea
::
setVehicleCorridor
(
WimaVCorridor
*
corridor
)
return
*
this
;
{
if
(
corridor
!=
nullptr
){
if
(
corridor
!=
_vehicleCorridor
){
_vehicleCorridor
=
corridor
;
emit
vehicleCorridorChanged
(
_vehicleCorridor
);
}
else
{
qWarning
(
"WimaGOperationArea::setVehicleCorridor(): new corridor equals old _vehicleCorridor!"
);
}
}
else
{
qWarning
(
"WimaGOperationArea::setVehicleCorridor(): corridor == nullptr!"
);
}
}
}
void
WimaGOperationArea
::
saveToJson
(
QJsonObject
&
json
)
void
WimaGOperationArea
::
saveToJson
(
QJsonObject
&
json
)
...
@@ -122,77 +77,64 @@ bool WimaGOperationArea::loadFromJson(const QJsonObject &json, QString& errorStr
...
@@ -122,77 +77,64 @@ bool WimaGOperationArea::loadFromJson(const QJsonObject &json, QString& errorStr
}
}
}
}
void
WimaGOperationArea
::
recalcBorderPolygon
(
)
void
print
(
const
WimaGOperationArea
&
area
)
{
{
//qWarning("WimaGOperationArea::recalcBorderPolygon() %f", _borderPolygonOffset.rawValue().toDouble());
QString
message
;
QGCMapPolygon
polyCopy
=
this
->
toQGCPolygon
(
*
this
);
print
(
area
,
message
);
polyCopy
.
offset
(
_borderPolygonOffset
.
rawValue
().
toDouble
());
qWarning
()
<<
message
;
_borderPolygon
.
setPath
(
polyCopy
.
path
());
polyCopy
.
deleteLater
();
emit
borderPolygonChanged
();
}
}
/*void WimaGOperationArea::recalculatesubPolygons(
)
void
print
(
const
WimaGOperationArea
&
area
,
QString
outputStr
)
{
{
int vehicleCount = _vehicleList->count();
print
(
static_cast
<
const
WimaArea
&>
(
area
),
outputStr
);
QScopedPointer<QList<QGCMapPolygon*>> listQGCPoly(this->splitPolygonArea(vehicleCount));
outputStr
.
append
(
QString
(
"Bottom Layer Altitude: %.3f
\n
"
).
arg
(
area
.
_bottomLayerAltitude
.
rawValue
().
toDouble
()));
outputStr
.
append
(
QString
(
"Number of Layers: %i
\n
"
).
arg
(
area
.
_numberOfLayers
.
rawValue
().
toInt
()));
int polyCount = listQGCPoly->size();
outputStr
.
append
(
QString
(
"Layer Distance: %.3f
\n
"
).
arg
(
area
.
_layerDistance
.
rawValue
().
toDouble
()));
_vehiclePolygons->clear();
outputStr
.
append
(
QString
(
"Border Polygon Offset: %.3f
\n
"
).
arg
(
area
.
_borderPolygonOffset
.
rawValue
().
toDouble
()));
for(int i = 0; i < polyCount; i++){
WimaVehicleMeasurementPolygon* subPoly = new WimaVehicleMeasurementPolygon(listQGCPoly->takeAt(i), this);
outputStr
.
append
(
QString
(
"Border Polygon Coordinates
\n
"
).
arg
(
area
.
_borderPolygonOffset
.
rawValue
().
toDouble
()));
_vehiclePolygons->append(subPoly);
for
(
int
i
=
0
;
i
<
area
.
_borderPolygon
.
count
();
i
++
)
{
QGeoCoordinate
coordinate
=
area
.
_borderPolygon
.
vertexCoordinate
(
i
);
outputStr
.
append
(
QString
(
"%s
\n
"
).
arg
(
coordinate
.
toString
(
QGeoCoordinate
::
Degrees
)));
}
}
}
}
void
WimaGOperationArea::removeAllVehicles(
)
void
swap
(
WimaGOperationArea
&
area1
,
WimaGOperationArea
&
area2
)
{
{
int count = _vehicleList->count();
using
std
::
swap
;
if(count > 0){
swap
(
area1
.
_metaDataMap
,
area2
.
_metaDataMap
);
do{
swap
(
area1
.
_bottomLayerAltitude
,
area2
.
_bottomLayerAltitude
);
_vehicleList->removeAt(0);
swap
(
area1
.
_numberOfLayers
,
area2
.
_numberOfLayers
);
count--;
swap
(
area1
.
_layerDistance
,
area2
.
_layerDistance
);
}while(count > 0);
swap
(
area1
.
_borderPolygonOffset
,
area2
.
_borderPolygonOffset
);
swap
(
area1
.
_borderPolygon
,
area2
.
_borderPolygon
);
emit vehicleListChanged();
}
}
}
void
WimaGOperationArea
::
recalcBorderPolygon
()
void WimaGOperationArea::addVehiclePolygon()
{
{
_vehiclePolygons->append(new WimaVehicleMeasurementPolygon(this));
//qWarning("WimaGOperationArea::recalcBorderPolygon() %f", _borderPolygonOffset.rawValue().toDouble());
QGCMapPolygon
polyCopy
=
this
->
toQGCPolygon
(
*
this
);
polyCopy
.
offset
(
_borderPolygonOffset
.
rawValue
().
toDouble
());
_borderPolygon
.
setPath
(
polyCopy
.
path
());
polyCopy
.
deleteLater
();
emit
vehiclePolygons
Changed();
emit
borderPolygon
Changed
();
}
}
void WimaGOperationArea::
removeVehiclePolygon(int polygonIndex
)
void
WimaGOperationArea
::
init
(
)
{
{
if(polygonIndex >= 0 && polygonIndex < _vehiclePolygons->count()){
_vehiclePolygons->removeAt(polygonIndex);
emit vehiclePolygonsChanged();
}else {
qWarning("Index out of bounds!");
}
}
void WimaGOperationArea::removeVehiclePolygon(WimaVehicleMeasurementPolygon *wimaPolygon)
_metaDataMap
=
FactMetaData
::
createMapFromJsonFile
(
QStringLiteral
(
":/json/WimaGOperationArea.SettingsGroup.json"
),
this
/* QObject parent */
);
{
_bottomLayerAltitude
=
SettingsFact
(
settingsGroup
,
_metaDataMap
[
bottomLayerAltitudeName
],
this
/* QObject parent */
);
if(wimaPolygon != nullptr){
_numberOfLayers
=
SettingsFact
(
settingsGroup
,
_metaDataMap
[
numberOfLayersName
],
this
/* QObject parent */
);
QObject* removedPolygon = _vehiclePolygons->removeOne(wimaPolygon);
_layerDistance
=
SettingsFact
(
settingsGroup
,
_metaDataMap
[
layerDistanceName
],
this
/* QObject parent */
);
if(removedPolygon){
_borderPolygonOffset
=
SettingsFact
(
settingsGroup
,
_metaDataMap
[
borderPolygonOffsetName
],
this
/* QObject parent */
);
emit vehiclePolygonsChanged();
_borderPolygon
=
new
QGCMapPolygon
(
this
);
}else {
qWarning("Polygon not inside polygon list.");
}
}else {
qWarning("Not a valid Polygon.");
}
}*/
this
->
setObjectName
(
wimaGOperationAreaName
);
connect
(
this
,
&
WimaGOperationArea
::
pathChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
connect
(
&
_borderPolygonOffset
,
&
SettingsFact
::
rawValueChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
}
src/Wima/WimaGOperationArea.h
View file @
81769297
...
@@ -12,28 +12,18 @@ class WimaGOperationArea : public WimaArea
...
@@ -12,28 +12,18 @@ class WimaGOperationArea : public WimaArea
{
{
Q_OBJECT
Q_OBJECT
public:
public:
WimaGOperationArea
();
WimaGOperationArea
(
QObject
*
parent
=
nullptr
);
WimaGOperationArea
(
QObject
*
parent
);
WimaGOperationArea
(
const
WimaGOperationArea
&
other
,
QObject
*
parent
=
nullptr
);
WimaGOperationArea
(
const
WimaArea
&
other
,
QObject
*
parent
=
nullpt
r
);
WimaGOperationArea
&
operator
=
(
WimaGOperationArea
othe
r
);
Q_PROPERTY
(
Fact
*
bottomLayerAltitude
READ
bottomLayerAltitude
CONSTANT
)
Q_PROPERTY
(
Fact
*
bottomLayerAltitude
READ
bottomLayerAltitude
CONSTANT
)
Q_PROPERTY
(
Fact
*
numberOfLayers
READ
numberOfLayers
CONSTANT
)
Q_PROPERTY
(
Fact
*
numberOfLayers
READ
numberOfLayers
CONSTANT
)
Q_PROPERTY
(
Fact
*
layerDistance
READ
layerDistance
CONSTANT
)
Q_PROPERTY
(
Fact
*
layerDistance
READ
layerDistance
CONSTANT
)
Q_PROPERTY
(
Fact
*
borderPolygonOffset
READ
borderPolygonOffset
CONSTANT
)
Q_PROPERTY
(
Fact
*
borderPolygonOffset
READ
borderPolygonOffset
CONSTANT
)
/*Q_PROPERTY(QmlObjectListModel* vehicleList READ vehicleList NOTIFY vehicleListChanged)
Q_PROPERTY(QmlObjectListModel* vehiclePolygons READ vehiclePolygons NOTIFY vehiclePolygonsChanged)*/
Q_PROPERTY
(
QGCMapPolygon
*
borderPolygon
READ
borderPolygon
NOTIFY
borderPolygonChanged
)
Q_PROPERTY
(
QGCMapPolygon
*
borderPolygon
READ
borderPolygon
NOTIFY
borderPolygonChanged
)
Q_INVOKABLE
void
addVehicle
(
WimaVehicle
*
vehicle
);
void
setVehicleCorridor
(
WimaVCorridor
*
corridor
);
Q_INVOKABLE
void
removeVehicle
(
int
vehicleIndex
);
void
setVehicleCorridor
(
WimaVCorridor
*
corridor
);
/*Q_INVOKABLE void recalculatesubPolygons ();
Q_INVOKABLE void removeAllVehicles ();
Q_INVOKABLE void addVehiclePolygon ();
Q_INVOKABLE void removeVehiclePolygon (int polygonIndex);
Q_INVOKABLE void removeVehiclePolygon (WimaVehicleMeasurementPolygon *wimaPolygon);*/
// Overrides from WimaPolygon
// Overrides from WimaPolygon
QString
mapVisualQML
(
void
)
const
{
return
"WimaGOperationAreaMapVisual.qml"
;}
QString
mapVisualQML
(
void
)
const
{
return
"WimaGOperationAreaMapVisual.qml"
;}
...
@@ -44,16 +34,18 @@ public:
...
@@ -44,16 +34,18 @@ public:
Fact
*
numberOfLayers
(
void
)
{
return
&
_numberOfLayers
;}
Fact
*
numberOfLayers
(
void
)
{
return
&
_numberOfLayers
;}
Fact
*
layerDistance
(
void
)
{
return
&
_layerDistance
;}
Fact
*
layerDistance
(
void
)
{
return
&
_layerDistance
;}
Fact
*
borderPolygonOffset
(
void
)
{
return
&
_borderPolygonOffset
;}
Fact
*
borderPolygonOffset
(
void
)
{
return
&
_borderPolygonOffset
;}
/*QmlObjectListModel* vehicleList (void) const { return _vehicleList;}
QmlObjectListModel* vehiclePolygons (void) const { return _vehiclePolygons;}*/
WimaVCorridor
*
vehicleCorridor
(
void
)
{
return
_vehicleCorridor
;}
QGCMapPolygon
*
borderPolygon
(
void
)
{
return
&
_borderPolygon
;}
QGCMapPolygon
*
borderPolygon
(
void
)
{
return
&
_borderPolygon
;}
// Member Methodes
// Member Methodes
void
saveToJson
(
QJsonObject
&
json
);
void
saveToJson
(
QJsonObject
&
json
);
bool
loadFromJson
(
const
QJsonObject
&
json
,
QString
&
errorString
);
bool
loadFromJson
(
const
QJsonObject
&
json
,
QString
&
errorString
);
// Friends
friend
void
swap
(
WimaGOperationArea
&
area1
,
WimaGOperationArea
&
area2
);
friend
void
print
(
const
WimaGOperationArea
&
area
,
QString
outputStr
);
friend
void
print
(
const
WimaGOperationArea
&
area
);
// Static Variables
static
const
char
*
settingsGroup
;
static
const
char
*
settingsGroup
;
static
const
char
*
bottomLayerAltitudeName
;
static
const
char
*
bottomLayerAltitudeName
;
static
const
char
*
numberOfLayersName
;
static
const
char
*
numberOfLayersName
;
...
@@ -77,6 +69,10 @@ private slots:
...
@@ -77,6 +69,10 @@ private slots:
private:
private:
// Member Methodes
void
init
();
// Members
QMap
<
QString
,
FactMetaData
*>
_metaDataMap
;
QMap
<
QString
,
FactMetaData
*>
_metaDataMap
;
SettingsFact
_bottomLayerAltitude
;
SettingsFact
_bottomLayerAltitude
;
...
@@ -84,10 +80,6 @@ private:
...
@@ -84,10 +80,6 @@ private:
SettingsFact
_layerDistance
;
SettingsFact
_layerDistance
;
SettingsFact
_borderPolygonOffset
;
SettingsFact
_borderPolygonOffset
;
/*QmlObjectListModel* _vehicleList;
QmlObjectListModel* _vehiclePolygons;*/
WimaVCorridor
*
_vehicleCorridor
;
QGCMapPolygon
_borderPolygon
;
QGCMapPolygon
_borderPolygon
;
};
};
...
...
src/Wima/WimaServiceArea.cc
View file @
81769297
...
@@ -2,22 +2,25 @@
...
@@ -2,22 +2,25 @@
const
char
*
WimaServiceArea
::
wimaServiceAreaName
=
"Service Area"
;
const
char
*
WimaServiceArea
::
wimaServiceAreaName
=
"Service Area"
;
WimaServiceArea
::
WimaServiceArea
()
:
WimaServiceArea
(
nullptr
)
{
}
WimaServiceArea
::
WimaServiceArea
(
QObject
*
parent
)
WimaServiceArea
::
WimaServiceArea
(
QObject
*
parent
)
:
WimaArea
(
parent
)
:
WimaArea
(
parent
)
{
{
this
->
setObjectName
(
wimaServiceAreaName
);
init
(
);
}
}
WimaServiceArea
::
WimaServiceArea
(
const
WimaArea
&
other
,
QObject
*
parent
)
WimaServiceArea
::
WimaServiceArea
(
const
Wima
Service
Area
&
other
,
QObject
*
parent
)
:
WimaArea
(
other
,
parent
)
:
WimaArea
(
other
,
parent
)
{
{
this
->
setObjectName
(
wimaServiceAreaName
);
init
();
}
WimaServiceArea
&
WimaServiceArea
::
operator
=
(
WimaServiceArea
other
)
{
swap
(
*
this
,
other
);
return
*
this
;
}
}
void
WimaServiceArea
::
setTakeOffPosition
(
const
QGeoCoordinate
&
coordinate
)
void
WimaServiceArea
::
setTakeOffPosition
(
const
QGeoCoordinate
&
coordinate
)
...
@@ -36,18 +39,6 @@ void WimaServiceArea::setLandPosition(const QGeoCoordinate &coordinate)
...
@@ -36,18 +39,6 @@ void WimaServiceArea::setLandPosition(const QGeoCoordinate &coordinate)
}
}
}
}
void
WimaServiceArea
::
setVehicleCorridor
(
WimaVCorridor
&
corridor
)
{
if
(
&
corridor
!=
_vehicleCorridor
){
_vehicleCorridor
=
&
corridor
;
emit
vehicleCorridorChanged
(
*
_vehicleCorridor
);
}
else
{
qWarning
(
"WimaServiceArea::setVehicleCorridor(): new corridor equals old _vehicleCorridor!"
);
}
}
void
WimaServiceArea
::
saveToJson
(
QJsonObject
&
json
)
void
WimaServiceArea
::
saveToJson
(
QJsonObject
&
json
)
{
{
this
->
WimaArea
::
saveToJson
(
json
);
this
->
WimaArea
::
saveToJson
(
json
);
...
@@ -66,3 +57,30 @@ bool WimaServiceArea::loadFromJson(const QJsonObject &json, QString &errorString
...
@@ -66,3 +57,30 @@ bool WimaServiceArea::loadFromJson(const QJsonObject &json, QString &errorString
}
}
}
}
void
print
(
const
WimaServiceArea
&
area
)
{
QString
message
;
print
(
area
,
message
);
qWarning
()
<<
message
;
}
void
print
(
const
WimaServiceArea
&
area
,
QString
&
outputStr
)
{
print
(
static_cast
<
const
WimaArea
&>
(
area
),
outputStr
);
outputStr
.
append
(
QString
(
"Takeoff Position: %s
\n
"
).
arg
(
area
.
_takeOffPosition
.
toString
(
QGeoCoordinate
::
Degrees
)));
outputStr
.
append
(
QString
(
"Land Position: %s
\n
"
).
arg
(
area
.
_landPosition
.
toString
(
QGeoCoordinate
::
Degrees
)));
}
void
swap
(
WimaServiceArea
&
area1
,
WimaServiceArea
&
area2
)
{
using
std
::
swap
;
swap
(
area1
.
_takeOffPosition
,
area2
.
_takeOffPosition
);
swap
(
area1
.
_landPosition
,
area2
.
_landPosition
);
}
void
WimaServiceArea
::
init
()
{
this
->
setObjectName
(
wimaServiceAreaName
);
}
src/Wima/WimaServiceArea.h
View file @
81769297
...
@@ -8,9 +8,9 @@ class WimaServiceArea : public WimaArea
...
@@ -8,9 +8,9 @@ class WimaServiceArea : public WimaArea
{
{
Q_OBJECT
Q_OBJECT
public:
public:
WimaServiceArea
();
WimaServiceArea
(
QObject
*
parent
=
nullptr
);
WimaServiceArea
(
QObject
*
parent
);
WimaServiceArea
(
const
WimaServiceArea
&
other
,
QObject
*
parent
);
WimaServiceArea
(
const
WimaArea
&
other
,
QObject
*
parent
);
WimaServiceArea
&
operator
=
(
WimaServiceArea
other
);
Q_PROPERTY
(
const
QGeoCoordinate
&
takeOffPosition
READ
takeOffPosition
WRITE
setTakeOffPosition
NOTIFY
takeOffPositionChanged
)
Q_PROPERTY
(
const
QGeoCoordinate
&
takeOffPosition
READ
takeOffPosition
WRITE
setTakeOffPosition
NOTIFY
takeOffPositionChanged
)
Q_PROPERTY
(
const
QGeoCoordinate
&
landPosition
READ
landPosition
WRITE
setLandPosition
NOTIFY
landPositionChanged
)
Q_PROPERTY
(
const
QGeoCoordinate
&
landPosition
READ
landPosition
WRITE
setLandPosition
NOTIFY
landPositionChanged
)
...
@@ -23,13 +23,11 @@ public:
...
@@ -23,13 +23,11 @@ public:
// Property acessors
// Property acessors
const
QGeoCoordinate
&
takeOffPosition
(
void
)
const
{
return
_takeOffPosition
;}
const
QGeoCoordinate
&
takeOffPosition
(
void
)
const
{
return
_takeOffPosition
;}
const
QGeoCoordinate
&
landPosition
(
void
)
const
{
return
_landPosition
;}
const
QGeoCoordinate
&
landPosition
(
void
)
const
{
return
_landPosition
;}
WimaVCorridor
*
vehicleCorridor
(
void
)
const
{
return
_vehicleCorridor
;}
// Property setters
// Property setters
void
setTakeOffPosition
(
const
QGeoCoordinate
&
coordinate
);
void
setTakeOffPosition
(
const
QGeoCoordinate
&
coordinate
);
void
setLandPosition
(
const
QGeoCoordinate
&
coordinate
);
void
setLandPosition
(
const
QGeoCoordinate
&
coordinate
);
void
setVehicleCorridor
(
WimaVCorridor
&
corridor
);
// Member Methodes
// Member Methodes
void
saveToJson
(
QJsonObject
&
json
);
void
saveToJson
(
QJsonObject
&
json
);
...
@@ -38,13 +36,21 @@ public:
...
@@ -38,13 +36,21 @@ public:
// static Members
// static Members
static
const
char
*
wimaServiceAreaName
;
static
const
char
*
wimaServiceAreaName
;
// Friends
friend
void
swap
(
WimaServiceArea
&
area1
,
WimaServiceArea
&
area2
);
friend
void
print
(
const
WimaServiceArea
&
area
,
QString
&
outputStr
);
friend
void
print
(
const
WimaServiceArea
&
area
);
signals:
signals:
void
takeOffPositionChanged
(
void
);
void
takeOffPositionChanged
(
void
);
void
landPositionChanged
(
void
);
void
landPositionChanged
(
void
);
void
vehicleCorridorChanged
(
WimaVCorridor
&
corridor
);
void
vehicleCorridorChanged
(
WimaVCorridor
&
corridor
);
private:
private:
// Member Methodes
void
init
();
// Members
QGeoCoordinate
_takeOffPosition
;
QGeoCoordinate
_takeOffPosition
;
QGeoCoordinate
_landPosition
;
QGeoCoordinate
_landPosition
;
WimaVCorridor
*
_vehicleCorridor
;
};
};
src/Wima/WimaVCorridor.cc
View file @
81769297
...
@@ -2,46 +2,25 @@
...
@@ -2,46 +2,25 @@
const
char
*
WimaVCorridor
::
wimaVCorridorName
=
"Corridor"
;
const
char
*
WimaVCorridor
::
wimaVCorridorName
=
"Corridor"
;
WimaVCorridor
::
WimaVCorridor
()
:
WimaVCorridor
(
nullptr
)
{
}
WimaVCorridor
::
WimaVCorridor
(
QObject
*
parent
)
WimaVCorridor
::
WimaVCorridor
(
QObject
*
parent
)
:
WimaArea
(
parent
)
:
WimaArea
(
parent
)
,
_serviceArea
(
nullptr
)
,
_opArea
(
nullptr
)
{
{
this
->
setObjectName
(
wimaVCorridorName
);
init
(
);
}
}
WimaVCorridor
::
WimaVCorridor
(
const
WimaArea
&
other
,
QObject
*
parent
)
WimaVCorridor
::
WimaVCorridor
(
const
WimaVCorridor
&
other
,
QObject
*
parent
)
:
WimaArea
(
other
,
parent
)
:
WimaArea
(
other
,
parent
)
,
_serviceArea
(
nullptr
)
,
_opArea
(
nullptr
)
{
{
this
->
setObjectName
(
wimaVCorridorName
);
init
(
);
}
}
void
WimaVCorridor
::
setServiceArea
(
WimaServiceArea
&
serviceArea
)
WimaVCorridor
&
WimaVCorridor
::
operator
=
(
WimaVCorridor
other
)
{
{
if
(
&
serviceArea
!=
_serviceArea
){
swap
(
*
this
,
other
);
_serviceArea
=
&
serviceArea
;
emit
serviceAreaChanged
(
_serviceArea
);
}
else
{
qWarning
(
"WimaVCorridor::setServiceArea(): new serviceArea does not differ from old _serviceArea!"
);
}
}
void
WimaVCorridor
::
setOpArea
(
WimaGOperationArea
&
opArea
)
return
*
this
;
{
if
(
&
opArea
!=
_opArea
){
_opArea
=
&
opArea
;
emit
opAreaChanged
(
_opArea
);
}
else
{
qWarning
(
"WimaVCorridor::setOpArea(): new opArea does not differ from old _opArea!"
);
}
}
}
void
WimaVCorridor
::
saveToJson
(
QJsonObject
&
json
)
void
WimaVCorridor
::
saveToJson
(
QJsonObject
&
json
)
...
@@ -61,3 +40,27 @@ bool WimaVCorridor::loadFromJson(const QJsonObject &json, QString &errorString)
...
@@ -61,3 +40,27 @@ bool WimaVCorridor::loadFromJson(const QJsonObject &json, QString &errorString)
return
false
;
return
false
;
}
}
}
}
void
WimaVCorridor
::
init
()
{
this
->
setObjectName
(
wimaVCorridorName
);
}
void
print
(
const
WimaVCorridor
&
area
)
{
QString
message
;
print
(
area
,
message
);
qWarning
()
<<
message
;
}
void
print
(
const
WimaVCorridor
&
area
,
QString
&
outputString
)
{
print
(
static_cast
<
const
WimaArea
&>
(
area
),
outputString
);
}
void
swap
(
WimaVCorridor
&
area1
,
WimaVCorridor
&
area2
)
{
using
std
::
swap
;
swap
(
static_cast
<
WimaArea
&>
(
area1
),
static_cast
<
WimaArea
&>
(
area2
));
}
src/Wima/WimaVCorridor.h
View file @
81769297
...
@@ -9,32 +9,33 @@ class WimaVCorridor : public WimaArea
...
@@ -9,32 +9,33 @@ class WimaVCorridor : public WimaArea
{
{
Q_OBJECT
Q_OBJECT
public:
public:
WimaVCorridor
();
WimaVCorridor
(
QObject
*
parent
=
nullptr
);
WimaVCorridor
(
QObject
*
parent
);
WimaVCorridor
(
const
WimaVCorridor
&
other
,
QObject
*
parent
=
nullptr
);
WimaVCorridor
(
const
WimaArea
&
other
,
QObject
*
parent
);
WimaVCorridor
&
operator
=
(
WimaVCorridor
other
);
// Overrides from WimaPolygon
// Overrides from WimaPolygon
QString
mapVisualQML
(
void
)
const
{
return
"WimaVCorridorMapVisual.qml"
;}
QString
mapVisualQML
(
void
)
const
{
return
"WimaVCorridorMapVisual.qml"
;}
QString
editorQML
(
void
)
const
{
return
"WimaVCorridorEditor.qml"
;}
QString
editorQML
(
void
)
const
{
return
"WimaVCorridorEditor.qml"
;}
// Methodes
// Methodes
void
setServiceArea
(
WimaServiceArea
&
serviceArea
);
void
setOpArea
(
WimaGOperationArea
&
opArea
);
WimaServiceArea
*
serviceArea
(
void
)
const
{
return
_serviceArea
;}
WimaGOperationArea
*
opArea
(
void
)
const
{
return
_opArea
;}
void
saveToJson
(
QJsonObject
&
json
);
void
saveToJson
(
QJsonObject
&
json
);
bool
loadFromJson
(
const
QJsonObject
&
json
,
QString
&
errorString
);
bool
loadFromJson
(
const
QJsonObject
&
json
,
QString
&
errorString
);
// static Members
// static Members
static
const
char
*
wimaVCorridorName
;
static
const
char
*
wimaVCorridorName
;
// Friends
friend
void
swap
(
WimaVCorridor
&
area1
,
WimaVCorridor
&
area2
);
friend
void
print
(
const
WimaVCorridor
&
area
,
QString
&
outputString
);
friend
void
print
(
const
WimaVCorridor
&
area
);
signals:
signals:
void
serviceAreaChanged
(
WimaServiceArea
*
serviceArea
);
void
serviceAreaChanged
(
WimaServiceArea
*
serviceArea
);
void
opAreaChanged
(
WimaGOperationArea
*
opArea
);
void
opAreaChanged
(
WimaGOperationArea
*
opArea
);
private:
private:
WimaServiceArea
*
_serviceArea
;
void
init
();
WimaGOperationArea
*
_opArea
;
};
};
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