Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
81769297
Commit
81769297
authored
Jun 25, 2019
by
Valentin Platzgummer
Browse files
changed wima classes to copy and swap idiom
parent
2b61da4b
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
src/MissionManager/QGCMapPolygon.cc
View file @
81769297
...
...
@@ -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
{
if
(
vertex
>=
0
&&
vertex
<
_polygonPath
.
count
())
{
...
...
src/MissionManager/QGCMapPolygon.h
View file @
81769297
...
...
@@ -105,6 +105,12 @@ public:
void
setCenterDrag
(
bool
centerDrag
);
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
;
signals:
...
...
src/QmlControls/QmlObjectListModel.cc
View file @
81769297
...
...
@@ -268,3 +268,12 @@ void QmlObjectListModel::clearAndDeleteContents()
clear
();
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:
void
beginReset
()
{
beginResetModel
();
}
void
endReset
()
{
endResetModel
();
}
// Friends
friend
void
swap
(
QmlObjectListModel
&
list1
,
QmlObjectListModel
&
list2
);
signals:
void
countChanged
(
int
count
);
void
dirtyChanged
(
bool
dirtyChanged
);
...
...
src/Wima/WimaArea.cc
View file @
81769297
...
...
@@ -6,42 +6,32 @@ const char* WimaArea::wimaAreaName = "WimaArea";
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
)
:
QGCMapPolygon
(
other
,
parent
)
WimaArea
::
WimaArea
(
QObject
*
parent
)
:
QGCMapPolygon
(
parent
)
{
this
->
setObjectName
(
wimaAreaName
);
init
(
);
_maxAltitude
=
30
;
_wimaVehicle
=
new
WimaVehicle
(
this
);
}
WimaArea
::
WimaArea
(
const
WimaArea
&
other
,
QObject
*
parent
)
:
WimaArea
(
parent
)
:
QGCMapPolygon
(
other
,
parent
)
{
this
->
setObjectName
(
wimaAreaName
);
init
(
);
this
->
setPath
(
other
.
path
());
this
->
setCenter
(
other
.
center
());
this
->
setCenterDrag
(
other
.
centerDrag
());
this
->
setInteractive
(
other
.
interactive
());
_maxAltitude
=
other
.
maxAltitude
();
_wimaVehicle
=
other
.
vehicle
();
}
WimaArea
&
WimaArea
::
operator
=
(
WimaArea
other
)
{
swap
(
*
this
,
other
);
// copy-swap-idiom
return
*
this
;
}
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)
{
...
...
@@ -127,7 +110,7 @@ void WimaArea::join(QList<WimaArea *>* polyList, WimaArea* joinedPoly)
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
)
{
...
...
@@ -156,7 +139,7 @@ void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly)
if
(
crossContainsWalker
==
true
)
{
joinedPoly
.
appendVertices
(
crossPoly
->
coordinateList
());
return
;
return
true
;
}
...
...
@@ -222,22 +205,28 @@ void WimaArea::join(WimaArea &poly1, WimaArea &poly2, WimaArea &joinedPoly)
}
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
{
qWarning
(
"WimaArea::joinPolygons(poly1, poly2): poly->count() < 3"
);
return
;
return
false
;
}
}
void
WimaArea
::
join
(
WimaArea
&
poly
)
bool
WimaArea
::
join
(
WimaArea
&
poly
)
{
WimaArea
joinedArea
;
join
(
*
this
,
poly
,
joinedArea
);
this
->
setPath
(
joinedArea
.
path
());
return
;
if
(
join
(
*
this
,
poly
,
joinedArea
)
)
{
this
->
setPath
(
joinedArea
.
path
());
return
true
;
}
else
{
return
false
;
}
}
bool
WimaArea
::
isDisjunct
(
QList
<
WimaArea
*>*
polyList
)
...
...
@@ -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
);
bigPoly
.
offset
(
0.1
);
// hack to compensate for numerical issues, migh be replaced in the future...
if
(
bigPoly
.
containsCoordinate
(
c1
)
&&
bigPoly
.
containsCoordinate
(
c2
))
{
poly
.
offset
(
0.1
);
// hack to compensate for numerical issues, migh be replaced in the future...
if
(
poly
.
containsCoordinate
(
c1
)
&&
poly
.
containsCoordinate
(
c2
))
{
QList
<
QGeoCoordinate
>
intersectionList
;
QList
<
QPair
<
int
,
int
>>
neighbourlist
;
QGCMapPolyline
line
;
line
.
appendVertex
(
c1
);
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
){
return
c1
.
distanceTo
(
c2
);
}
else
{
...
...
@@ -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
{
QGeoCoordinate
coordinate
;
double
distance
=
std
::
numeric_limits
<
qreal
>::
infinity
();
...
...
@@ -477,7 +468,7 @@ void WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &e
Node
*
Node
=
&
nodeList
.
last
();
if
(
Node
->
predecessorNode
==
nullptr
)
{
qWarning
(
"WimaArea::dijkstraPath(): Error, no path found!"
);
return
;
return
false
;
}
while
(
1
)
{
...
...
@@ -489,6 +480,40 @@ void WimaArea::dijkstraPath(const QGeoCoordinate &start, const QGeoCoordinate &e
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
)
...
...
@@ -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
{
Q_OBJECT
public:
WimaArea
();
WimaArea
(
QObject
*
parent
);
WimaArea
(
const
QGCMapPolygon
&
other
,
QObject
*
parent
);
WimaArea
(
const
WimaArea
&
other
,
QObject
*
parent
);
WimaArea
(
QObject
*
parent
=
nullptr
);
WimaArea
(
const
WimaArea
&
other
,
QObject
*
parent
=
nullptr
);
WimaArea
&
operator
=
(
WimaArea
other
);
Q_PROPERTY
(
double
maxAltitude
READ
maxAltitude
WRITE
setMaxAltitude
NOTIFY
maxAltitudeChanged
)
Q_PROPERTY
(
QString
mapVisualQML
READ
mapVisualQML
CONSTANT
)
Q_PROPERTY
(
QString
editorQML
READ
editorQML
CONSTANT
)
Q_PROPERTY
(
WimaVehicle
*
vehicle
READ
vehicle
WRITE
setVehicle
NOTIFY
vehicleChanged
)
//Property accessors
double
maxAltitude
(
void
)
const
{
return
_maxAltitude
;}
WimaVehicle
*
vehicle
(
void
)
const
{
return
_wimaVehicle
;}
virtual
QString
mapVisualQML
(
void
)
const
{
return
"WimaAreaMapVisual.qml"
;}
virtual
QString
editorQML
(
void
)
const
{
return
"WimaAreaEditor.qml"
;}
...
...
@@ -39,10 +35,6 @@ public:
void
setVehicle
(
WimaVehicle
*
vehicle
);
// 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
int
getClosestVertexIndex
(
const
QGeoCoordinate
&
coordinate
)
const
;
//iterates over all vertices in _polygon and returns that one closest to coordinate
...
...
@@ -52,9 +44,9 @@ public:
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)
/// see https://en.wikipedia.org/wiki/Simple_polygon
/// @return t
he joined polygon of poly1 and poly2 if possible, poly1
else
static
void
join
(
WimaArea
&
poly1
,
WimaArea
&
poly2
,
WimaArea
&
joinedPoly
);
void
join
(
WimaArea
&
poly
);
/// @return t
rue if polygons have been joined, false
else
static
bool
join
(
WimaArea
&
poly1
,
WimaArea
&
poly2
,
WimaArea
&
joinedPoly
);
bool
join
(
WimaArea
&
poly
);
bool
isDisjunct
(
QList
<
WimaArea
*>*
polyList
);
// change to & notation, if necessary
bool
isDisjunct
(
WimaArea
*
poly1
,
WimaArea
*
poly2
);
// change to & notation, if necessary
/// calculates the next polygon vertex index
...
...
@@ -77,13 +69,25 @@ public:
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.
/// @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
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
);
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
// Accurracy used to compute isDisjunct
static
const
double
numericalAccuracy
;
...
...
@@ -98,7 +102,9 @@ signals:
protected:
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:
Q_PROPERTY
(
PlanMasterController
*
masterController
READ
masterController
WRITE
setMasterController
NOTIFY
masterControllerChanged
)
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
(
QString
currentFile
READ
currentFile
NOTIFY
currentFileChanged
)
Q_PROPERTY
(
QStringList
loadNameFilters
READ
loadNameFilters
CONSTANT
)
Q_PROPERTY
(
QStringList
saveNameFilters
READ
saveNameFilters
CONSTANT
)
Q_PROPERTY
(
QString
fileExtension
READ
fileExtension
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
(
WimaDataContainer
*
dataContainer
READ
dataContainer
WRITE
setDataContainer
NOTIFY
dataContainerChanged
)
Q_PROPERTY
(
bool
readyForSaveSend
READ
readyForSaveSend
NOTIFY
readyForSaveSendChanged
)
// Property accessors
PlanMasterController
*
masterController
(
void
)
const
{
return
_masterController
;
}
MissionController
*
missionController
(
void
)
const
{
return
_missionController
;
}
QmlObjectListModel
*
visualItems
(
void
)
const
;
const
QmlObjectListModel
*
visualItems
(
void
)
const
;
int
currentPolygonIndex
(
void
)
const
{
return
_currentPolygonIndex
;
}
QString
currentFile
(
void
)
const
{
return
_currentFile
;
}
QStringList
loadNameFilters
(
void
)
const
;
QStringList
saveNameFilters
(
void
)
const
;
QString
fileExtension
(
void
)
const
{
return
wimaFileExtension
;
}
QGeoCoordinate
joinedAreaCenter
(
void
)
const
;
WimaArea
*
joinedArea
(
void
)
const
;
WimaArea
joinedArea
(
void
)
const
;
WimaDataContainer
*
dataContainer
(
void
)
const
{
return
_container
;
}
bool
flyView
(
void
)
const
{
return
_flyView
;
}
bool
readyForSaveSend
(
void
)
const
{
return
_readyForSaveSend
;
}
...
...
@@ -100,6 +101,7 @@ public:
// Member Methodes
QJsonDocument
saveToJson
(
FileType
fileType
);
void
setReadyForSaveSend
(
bool
ready
);
signals:
void
masterControllerChanged
(
void
);
...
...
@@ -109,26 +111,30 @@ signals:
void
currentFileChanged
();
void
joinedAreaChanged
();
void
dataContainerChanged
();
void
readyForSaveSendChanged
(
bool
ready
);
private
slots
:
void
recalcVehicleCorridor
();
void
recalcVehicleMeasurementAreas
();
void
recalcAll
();
void
recalcPolygonInteractivity
(
int
index
);
void
updateJoinedArea
();
void
uploadToContainer
();
void
downloadFromContainer
();
void
recalcPolygonInteractivity
(
int
index
);
bool
updateJoinedArea
();
void
updateContainer
();
void
downloadFromContainer
();
void
setOpArea
(
const
WimaGOperationArea
&
area
);
void
setSerArea
(
const
WimaServiceArea
&
area
);
void
setCorridor
(
const
WimaVCorridor
&
area
);
void
setJoinedArea
(
const
WimaArea
&
area
);
private:
bool
_flyView
;
bool
_readyForSaveSend
;
PlanMasterController
*
_masterController
;
MissionController
*
_missionController
;
int
_currentPolygonIndex
;
QString
_currentFile
;
WimaDataContainer
*
_container
;
QmlObjectListModel
*
_visualItems
;
WimaArea
*
_joinedArea
;
QmlObjectListModel
_visualItems
;
WimaArea
_joinedArea
;
WimaGOperationArea
_opArea
;
WimaServiceArea
_serArea
;
WimaVCorridor
_corridor
;
};
src/Wima/WimaDataContainer.cc
View file @
81769297
#include
"WimaDataContainer.h"
WimaDataContainer
::
WimaDataContainer
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_visualItems
(
this
)
,
_joinedArea
(
this
)
:
QObject
(
parent
)
,
_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 @@
#include
"QmlObjectListModel.h"
#include
"WimaArea.h"
#include
"WimaGOperationArea.h"
#include
"WimaServiceArea.h"
#include
"WimaVCorridor.h"
class
WimaDataContainer
:
public
QObject
{
...
...
@@ -13,21 +16,29 @@ class WimaDataContainer : public QObject
public:
explicit
WimaDataContainer
(
QObject
*
parent
=
nullptr
);
QmlObjectListModel
*
visualItems
(
void
)
{
return
&
_visualItems
;
}
//use setVisualItems to modify list
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
setVisualItems
(
const
QmlObjectListModel
&
list
);
void
setJoinedArea
(
const
WimaArea
&
joinedArea
);
void
setOpArea
(
const
WimaGOperationArea
&
opArea
);
void
setSerArea
(
const
WimaServiceArea
&
serArea
);
void
setCorridor
(
const
WimaVCorridor
&
corridor
);
signals:
void
joinedAreaChanged
();
void
visualItemsChanged
();
void
joinedAreaChanged
(
const
WimaArea
&
area
);
void
opAreaChanged
(
const
WimaGOperationArea
&
area
);
void
serAreaChanged
(
const
WimaServiceArea
&
area
);
void
corridorChanged
(
const
WimaVCorridor
&
area
);
public
slots
:
private:
QmlObjectListModel
_visualItems
;
WimaArea
_joinedArea
;
WimaGOperationArea
_opArea
;
WimaServiceArea
_serArea
;
WimaVCorridor
_corridor
;
};
#endif // WIMADATACONTAINER_H
src/Wima/WimaGOperationArea.cc
View file @
81769297
...
...
@@ -8,69 +8,24 @@ const char* WimaGOperationArea::layerDistanceName = "LayerDistance
const
char
*
WimaGOperationArea
::
borderPolygonOffsetName
=
"BorderPolygonOffset"
;
const
char
*
WimaGOperationArea
::
wimaGOperationAreaName
=
"Operation Area"
;
WimaGOperationArea
::
WimaGOperationArea
()
:
WimaGOperationArea
(
nullptr
)
{
}
WimaGOperationArea
::
WimaGOperationArea
(
QObject
*
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
);
connect
(
this
,
&
WimaGOperationArea
::
pathChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
connect
(
&
_borderPolygonOffset
,
&
SettingsFact
::
rawValueChanged
,
this
,
&
WimaGOperationArea
::
recalcBorderPolygon
);
init
();
}
WimaGOperationArea
::
WimaGOperationArea
(
const
WimaArea
&
other
,
QObject
*
parent
)
WimaGOperationArea
::
WimaGOperationArea
(
const
Wima
GOperation
Area
&
other
,
QObject
*
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
);
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
();
}
init
();
}
void
WimaGOperationArea
::
removeVehicle
(
int
vehicleIndex
)
WimaGOperationArea
&
WimaGOperationArea
::
operator
=
(
WimaGOperationArea
other
)
{
if
(
vehicleIndex
>=
0
){
_wimaVehicle
=
nullptr
;
emit
vehicleChanged
();
}
}
swap
(
*
this
,
other
);
void
WimaGOperationArea
::
setVehicleCorridor
(
WimaVCorridor
*
corridor
)
{
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!"
);
}
return
*
this
;
}
void
WimaGOperationArea
::
saveToJson
(
QJsonObject
&
json
)
...
...
@@ -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());
QGCMapPolygon
polyCopy
=
this
->
toQGCPolygon
(
*
this
);
polyCopy
.
offset
(
_borderPolygonOffset
.
rawValue
().
toDouble
());
_borderPolygon
.
setPath
(
polyCopy
.
path
());
polyCopy
.
deleteLater
();
emit
borderPolygonChanged
();
QString
message
;
print
(
area
,
message
);
qWarning
()
<<
message
;
}
/*
void WimaGOperationArea
::recalculatesubPolygons(
)
void
print
(
const
WimaGOperationArea
&
area
,
QString
outputStr
)
{
int vehicleCount = _vehicleList->count();
QScopedPointer<QList<QGCMapPolygon*>> listQGCPoly(this->splitPolygonArea(vehicleCount));
int polyCount = listQGCPoly->size();
_vehiclePolygons->clear();
for(int i = 0; i < polyCount; i++){
WimaVehicleMeasurementPolygon* subPoly = new WimaVehicleMeasurementPolygon(listQGCPoly->takeAt(i), this);
_vehiclePolygons->append(subPoly);
print
(
static_cast
<
const
WimaArea
&>
(
area
),
outputStr
);
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
()));
outputStr
.
append
(
QString
(
"Layer Distance: %.3f
\n
"
).
arg
(
area
.
_layerDistance
.
rawValue
().
toDouble
()));
outputStr
.
append
(
QString
(
"Border Polygon Offset: %.3f
\n
"
).
arg
(
area
.
_borderPolygonOffset
.
rawValue
().
toDouble
()));
outputStr
.
append
(
QString
(
"Border Polygon Coordinates
\n
"
).
arg
(
area
.
_borderPolygonOffset
.
rawValue
().
toDouble
()));
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();
if(count > 0){
do{
_vehicleList->removeAt(0);
count--;
}while(count > 0);
emit vehicleListChanged();
}
using
std
::
swap
;
swap
(
area1
.
_metaDataMap
,
area2
.
_metaDataMap
);
swap
(
area1
.
_bottomLayerAltitude
,
area2
.
_bottomLayerAltitude
);
swap
(
area1
.
_numberOfLayers
,
area2
.
_numberOfLayers
);
swap
(
area1
.
_layerDistance
,
area2
.
_layerDistance
);
swap
(
area1
.
_borderPolygonOffset
,
area2
.
_borderPolygonOffset
);
swap
(
area1
.
_borderPolygon
,
area2
.
_borderPolygon
);
}
void WimaGOperationArea::addVehiclePolygon()
void
WimaGOperationArea
::
recalcBorderPolygon
()
{
_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
vehicle
Polygon
s
Changed();
emit
border
PolygonChanged
();
}
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)
{
if(wimaPolygon != nullptr){
QObject* removedPolygon = _vehiclePolygons->removeOne(wimaPolygon);
if(removedPolygon){
emit vehiclePolygonsChanged();
}else {
qWarning("Polygon not inside polygon list.");
}
}else {
qWarning("Not a valid Polygon.");
}
}*/
_metaDataMap
=
FactMetaData
::
createMapFromJsonFile
(
QStringLiteral
(
":/json/WimaGOperationArea.SettingsGroup.json"
),
this
/* QObject parent */
);
_bottomLayerAltitude
=
SettingsFact
(
settingsGroup
,
_metaDataMap
[
bottomLayerAltitudeName
],
this
/* QObject parent */
);
_numberOfLayers
=
SettingsFact
(
settingsGroup
,
_metaDataMap
[
numberOfLayersName
],
this
/* QObject parent */
);
_layerDistance
=
SettingsFact
(
settingsGroup
,
_metaDataMap
[
layerDistanceName
],
this
/* QObject parent */
);
_borderPolygonOffset
=
SettingsFact
(
settingsGroup
,
_metaDataMap
[
borderPolygonOffsetName
],
this
/* QObject parent */
);
_borderPolygon
=
new
QGCMapPolygon
(
this
);
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
{
Q_OBJECT
public:
WimaGOperationArea
();
WimaGOperationArea
(
QObject
*
parent
);
WimaGOperationArea
(
const
Wima
Area
&
other
,
QObject
*
parent
=
nullptr
);
WimaGOperationArea
(
QObject
*
parent
=
nullptr
);
WimaGOperationArea
(
const
WimaGOperationArea
&
other
,
QObject
*
parent
=
nullptr
);
WimaGOperationArea
&
operator
=
(
WimaGOperation
Area
other
);
Q_PROPERTY
(
Fact
*
bottomLayerAltitude
READ
bottomLayerAltitude
CONSTANT
)
Q_PROPERTY
(
Fact
*
numberOfLayers
READ
numberOfLayers
CONSTANT
)
Q_PROPERTY
(
Fact
*
layerDistance
READ
layerDistance
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_INVOKABLE
void
addVehicle
(
WimaVehicle
*
vehicle
);
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);*/
void
setVehicleCorridor
(
WimaVCorridor
*
corridor
);
// Overrides from WimaPolygon
QString
mapVisualQML
(
void
)
const
{
return
"WimaGOperationAreaMapVisual.qml"
;}
...
...
@@ -44,16 +34,18 @@ public:
Fact
*
numberOfLayers
(
void
)
{
return
&
_numberOfLayers
;}
Fact
*
layerDistance
(
void
)
{
return
&
_layerDistance
;}
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
;}
// Member Methodes
void
saveToJson
(
QJsonObject
&
json
);
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
*
bottomLayerAltitudeName
;
static
const
char
*
numberOfLayersName
;
...
...
@@ -77,6 +69,10 @@ private slots:
private:
// Member Methodes
void
init
();
// Members
QMap
<
QString
,
FactMetaData
*>
_metaDataMap
;
SettingsFact
_bottomLayerAltitude
;
...
...
@@ -84,10 +80,6 @@ private:
SettingsFact
_layerDistance
;
SettingsFact
_borderPolygonOffset
;
/*QmlObjectListModel* _vehicleList;
QmlObjectListModel* _vehiclePolygons;*/
WimaVCorridor
*
_vehicleCorridor
;
QGCMapPolygon
_borderPolygon
;
};
...
...
src/Wima/WimaServiceArea.cc
View file @
81769297
...
...
@@ -2,22 +2,25 @@
const
char
*
WimaServiceArea
::
wimaServiceAreaName
=
"Service Area"
;
WimaServiceArea
::
WimaServiceArea
()
:
WimaServiceArea
(
nullptr
)
{
}
WimaServiceArea
::
WimaServiceArea
(
QObject
*
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
)
{
this
->
setObjectName
(
wimaServiceAreaName
);
init
();
}
WimaServiceArea
&
WimaServiceArea
::
operator
=
(
WimaServiceArea
other
)
{
swap
(
*
this
,
other
);
return
*
this
;
}
void
WimaServiceArea
::
setTakeOffPosition
(
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
)
{
this
->
WimaArea
::
saveToJson
(
json
);
...
...
@@ -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
{
Q_OBJECT
public:
WimaServiceArea
();
WimaServiceArea
(
QObject
*
parent
);
WimaServiceArea
(
const
Wima
Area
&
other
,
QObject
*
parent
);
WimaServiceArea
(
QObject
*
parent
=
nullptr
);
WimaServiceArea
(
const
WimaServiceArea
&
other
,
QObject
*
parent
);
WimaServiceArea
&
operator
=
(
WimaService
Area
other
);
Q_PROPERTY
(
const
QGeoCoordinate
&
takeOffPosition
READ
takeOffPosition
WRITE
setTakeOffPosition
NOTIFY
takeOffPositionChanged
)
Q_PROPERTY
(
const
QGeoCoordinate
&
landPosition
READ
landPosition
WRITE
setLandPosition
NOTIFY
landPositionChanged
)
...
...
@@ -23,13 +23,11 @@ public:
// Property acessors
const
QGeoCoordinate
&
takeOffPosition
(
void
)
const
{
return
_takeOffPosition
;}
const
QGeoCoordinate
&
landPosition
(
void
)
const
{
return
_landPosition
;}
WimaVCorridor
*
vehicleCorridor
(
void
)
const
{
return
_vehicleCorridor
;}
// Property setters
void
setTakeOffPosition
(
const
QGeoCoordinate
&
coordinate
);
void
setLandPosition
(
const
QGeoCoordinate
&
coordinate
);
void
setVehicleCorridor
(
WimaVCorridor
&
corridor
);
// Member Methodes
void
saveToJson
(
QJsonObject
&
json
);
...
...
@@ -38,13 +36,21 @@ public:
// static Members
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:
void
takeOffPositionChanged
(
void
);
void
landPositionChanged
(
void
);
void
vehicleCorridorChanged
(
WimaVCorridor
&
corridor
);
private:
// Member Methodes
void
init
();
// Members
QGeoCoordinate
_takeOffPosition
;
QGeoCoordinate
_landPosition
;
WimaVCorridor
*
_vehicleCorridor
;
};
src/Wima/WimaVCorridor.cc
View file @
81769297
...
...
@@ -2,46 +2,25 @@
const
char
*
WimaVCorridor
::
wimaVCorridorName
=
"Corridor"
;
WimaVCorridor
::
WimaVCorridor
()
:
WimaVCorridor
(
nullptr
)
{
}
WimaVCorridor
::
WimaVCorridor
(
QObject
*
parent
)
:
WimaArea
(
parent
)
,
_serviceArea
(
nullptr
)
,
_opArea
(
nullptr
)
:
WimaArea
(
parent
)
{
this
->
setObjectName
(
wimaVCorridorName
);
init
(
);
}
WimaVCorridor
::
WimaVCorridor
(
const
WimaArea
&
other
,
QObject
*
parent
)
:
WimaArea
(
other
,
parent
)
,
_serviceArea
(
nullptr
)
,
_opArea
(
nullptr
)
WimaVCorridor
::
WimaVCorridor
(
const
WimaVCorridor
&
other
,
QObject
*
parent
)
:
WimaArea
(
other
,
parent
)
{
this
->
setObjectName
(
wimaVCorridorName
);
init
(
);
}
void
WimaVCorridor
::
setServiceArea
(
WimaServiceArea
&
serviceArea
)
WimaVCorridor
&
WimaVCorridor
::
operator
=
(
WimaVCorridor
other
)
{
if
(
&
serviceArea
!=
_serviceArea
){
_serviceArea
=
&
serviceArea
;
emit
serviceAreaChanged
(
_serviceArea
);
}
else
{
qWarning
(
"WimaVCorridor::setServiceArea(): new serviceArea does not differ from old _serviceArea!"
);
}
}
swap
(
*
this
,
other
);
void
WimaVCorridor
::
setOpArea
(
WimaGOperationArea
&
opArea
)
{
if
(
&
opArea
!=
_opArea
){
_opArea
=
&
opArea
;
emit
opAreaChanged
(
_opArea
);
}
else
{
qWarning
(
"WimaVCorridor::setOpArea(): new opArea does not differ from old _opArea!"
);
}
return
*
this
;
}
void
WimaVCorridor
::
saveToJson
(
QJsonObject
&
json
)
...
...
@@ -61,3 +40,27 @@ bool WimaVCorridor::loadFromJson(const QJsonObject &json, QString &errorString)
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
{
Q_OBJECT
public:
WimaVCorridor
();
WimaVCorridor
(
QObject
*
parent
);
WimaVCorridor
(
const
WimaArea
&
other
,
QObject
*
parent
);
WimaVCorridor
(
QObject
*
parent
=
nullptr
);
WimaVCorridor
(
const
WimaVCorridor
&
other
,
QObject
*
parent
=
nullptr
);
WimaVCorridor
&
operator
=
(
WimaVCorridor
other
);
// Overrides from WimaPolygon
QString
mapVisualQML
(
void
)
const
{
return
"WimaVCorridorMapVisual.qml"
;}
QString
editorQML
(
void
)
const
{
return
"WimaVCorridorEditor.qml"
;}
// 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
);
bool
loadFromJson
(
const
QJsonObject
&
json
,
QString
&
errorString
);
// static Members
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:
void
serviceAreaChanged
(
WimaServiceArea
*
serviceArea
);
void
opAreaChanged
(
WimaGOperationArea
*
opArea
);
private:
WimaServiceArea
*
_serviceArea
;
WimaGOperationArea
*
_opArea
;
void
init
();
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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