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
00d7ea68
Commit
00d7ea68
authored
Mar 29, 2019
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding .qml files for WimaPolygons
parent
2ff5f135
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
735 additions
and
354 deletions
+735
-354
UnitTest.qrc
UnitTest.qrc
+1
-3
WimaGlobalMeasurementPolygonMapVisual.qml
WimaGlobalMeasurementPolygonMapVisual.qml
+86
-0
qgroundcontrol.pro
qgroundcontrol.pro
+0
-3
qgroundcontrol.qrc
qgroundcontrol.qrc
+4
-3
WimaController.cc
src/MissionManager/WimaController.cc
+80
-10
WimaController.h
src/MissionManager/WimaController.h
+15
-9
WimaFlyArea.cc
src/MissionManager/WimaFlyArea.cc
+0
-81
WimaFlyArea.h
src/MissionManager/WimaFlyArea.h
+0
-74
WimaGlobalMeasurementPolygon.cc
src/MissionManager/WimaGlobalMeasurementPolygon.cc
+16
-11
WimaGlobalMeasurementPolygon.h
src/MissionManager/WimaGlobalMeasurementPolygon.h
+13
-14
WimaPolygon.cc
src/MissionManager/WimaPolygon.cc
+15
-6
WimaPolygon.h
src/MissionManager/WimaPolygon.h
+24
-16
WimaServicePolygon.cc
src/MissionManager/WimaServicePolygon.cc
+8
-15
WimaServicePolygon.h
src/MissionManager/WimaServicePolygon.h
+11
-19
WimaVehicle.cc
src/MissionManager/WimaVehicle.cc
+41
-1
WimaVehicle.h
src/MissionManager/WimaVehicle.h
+24
-4
WimaVehicleCorridor.h
src/MissionManager/WimaVehicleCorridor.h
+2
-4
WimaVehicleMeasurementPolygon.h
src/MissionManager/WimaVehicleMeasurementPolygon.h
+3
-4
QGCApplication.cc
src/QGCApplication.cc
+0
-2
QGroundControl.Controls.qmldir
src/QmlControls/QGroundControl.Controls.qmldir
+5
-1
FlyAreaEditor.qml
src/WimaView/FlyAreaEditor.qml
+0
-47
WimaGlobalMeasurementPolygonMapVisual.qml
src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml
+86
-0
WimaItemEditor.qml
src/WimaView/WimaItemEditor.qml
+0
-0
WimaItemEditor_old.qml
src/WimaView/WimaItemEditor_old.qml
+142
-0
WimaMapVisual.qml
src/WimaView/WimaMapVisual.qml
+47
-0
WimaServicePolygonMapVisual.qml
src/WimaView/WimaServicePolygonMapVisual.qml
+86
-0
WimaView.qml
src/WimaView/WimaView.qml
+26
-27
No files found.
UnitTest.qrc
View file @
00d7ea68
...
...
@@ -15,7 +15,5 @@
<file alias="PolygonBadXml.kml">src/MissionManager/UnitTest/PolygonBadXml.kml</file>
<file alias="PolygonBadCoordinatesNode.kml">src/MissionManager/UnitTest/PolygonBadCoordinatesNode.kml</file>
</qresource>
<qresource prefix="/">
<file>src/WimaView/FlyAreaMapVisual.qml</file>
</qresource>
<qresource prefix="/"/>
</RCC>
WimaGlobalMeasurementPolygonMapVisual.qml
0 → 100644
View file @
00d7ea68
/****************************************************************************
*
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import
QtQuick
2.3
import
QtQuick
.
Controls
1.2
import
QtLocation
5.3
import
QtPositioning
5.3
import
QGroundControl
1.0
import
QGroundControl
.
ScreenTools
1.0
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
Controls
1.0
import
QGroundControl
.
FlightMap
1.0
/// Wima Global Measurement Area visuals
Item
{
id
:
_root
property
var
map
///< Map control to place item in
property
var
qgcView
///< QGCView to use for popping dialogs
property
var
_missionItem
:
object
property
var
_polygon
:
object
.
polygon
signal
clicked
(
int
sequenceNumber
)
/// Add an initial 4 sided polygon if there is none
function
_addInitialPolygon
()
{
if
(
_polygon
.
count
<
3
)
{
// Initial polygon is inset to take 2/3rds space
var
rect
=
Qt
.
rect
(
map
.
centerViewport
.
x
,
map
.
centerViewport
.
y
,
map
.
centerViewport
.
width
,
map
.
centerViewport
.
height
)
rect
.
x
+=
(
rect
.
width
*
0.25
)
/
2
rect
.
y
+=
(
rect
.
height
*
0.25
)
/
2
rect
.
width
*=
0.75
rect
.
height
*=
0.75
var
centerCoord
=
map
.
toCoordinate
(
Qt
.
point
(
rect
.
x
+
(
rect
.
width
/
2
),
rect
.
y
+
(
rect
.
height
/
2
)),
false
/* clipToViewPort */
)
var
topLeftCoord
=
map
.
toCoordinate
(
Qt
.
point
(
rect
.
x
,
rect
.
y
),
false
/* clipToViewPort */
)
var
topRightCoord
=
map
.
toCoordinate
(
Qt
.
point
(
rect
.
x
+
rect
.
width
,
rect
.
y
),
false
/* clipToViewPort */
)
var
bottomLeftCoord
=
map
.
toCoordinate
(
Qt
.
point
(
rect
.
x
,
rect
.
y
+
rect
.
height
),
false
/* clipToViewPort */
)
var
bottomRightCoord
=
map
.
toCoordinate
(
Qt
.
point
(
rect
.
x
+
rect
.
width
,
rect
.
y
+
rect
.
height
),
false
/* clipToViewPort */
)
// Adjust polygon to max size
var
maxSize
=
100
var
halfWidthMeters
=
Math
.
min
(
topLeftCoord
.
distanceTo
(
topRightCoord
),
maxSize
)
/
2
var
halfHeightMeters
=
Math
.
min
(
topLeftCoord
.
distanceTo
(
bottomLeftCoord
),
maxSize
)
/
2
topLeftCoord
=
centerCoord
.
atDistanceAndAzimuth
(
halfWidthMeters
,
-
90
).
atDistanceAndAzimuth
(
halfHeightMeters
,
0
)
topRightCoord
=
centerCoord
.
atDistanceAndAzimuth
(
halfWidthMeters
,
90
).
atDistanceAndAzimuth
(
halfHeightMeters
,
0
)
bottomLeftCoord
=
centerCoord
.
atDistanceAndAzimuth
(
halfWidthMeters
,
-
90
).
atDistanceAndAzimuth
(
halfHeightMeters
,
180
)
bottomRightCoord
=
centerCoord
.
atDistanceAndAzimuth
(
halfWidthMeters
,
90
).
atDistanceAndAzimuth
(
halfHeightMeters
,
180
)
_polygon
.
appendVertex
(
topLeftCoord
)
_polygon
.
appendVertex
(
topRightCoord
)
_polygon
.
appendVertex
(
bottomRightCoord
)
_polygon
.
appendVertex
(
bottomLeftCoord
)
}
}
Component.onCompleted
:
{
_addInitialPolygon
()
}
Component.onDestruction
:
{
}
QGCMapPolygonVisuals
{
qgcView
:
_root
.
qgcView
mapControl
:
map
mapPolygon
:
_polygon
interactive
:
_missionItem
.
isCurrentItem
borderWidth
:
1
borderColor
:
"
black
"
interiorColor
:
"
green
"
interiorOpacity
:
0.25
}
}
qgroundcontrol.pro
View file @
00d7ea68
...
...
@@ -413,7 +413,6 @@ HEADERS += \
src
/
MissionManager
/
WimaVehicleCorridor
.
h
\
src
/
MissionManager
/
WimaVehicleMeasurementPolygon
.
h
\
src
/
MissionManager
/
WimaGlobalMeasurementPolygon
.
h
\
src
/
MissionManager
/
WimaPolygonContainer
.
h
\
src
/
MissionManager
/
WimaVehicle
.
h
SOURCES
+=
\
...
...
@@ -423,13 +422,11 @@ SOURCES += \
src
/
api
/
QmlComponentInfo
.
cc
\
src
/
comm
/
MavlinkMessagesTimer
.
cc
\
src
/
MissionManager
/
WimaController
.
cc
\
src
/
MissionManager
/
WimaFlyArea
.
cc
\
src
/
MissionManager
/
WimaPolygon
.
cc
\
src
/
MissionManager
/
WimaServicePolygon
.
cc
\
src
/
MissionManager
/
WimaVehicleCorridor
.
cc
\
src
/
MissionManager
/
WimaVehicleMeasurementPolygon
.
cc
\
src
/
MissionManager
/
WimaGlobalMeasurementPolygon
.
cc
\
src
/
MissionManager
/
WimaPolygonContainer
.
cc
\
src
/
MissionManager
/
WimaVehicle
.
cc
#
...
...
qgroundcontrol.qrc
View file @
00d7ea68
...
...
@@ -210,9 +210,10 @@
<file alias="VirtualJoystick.qml">src/FlightDisplay/VirtualJoystick.qml</file>
<file alias="QGroundControl/Controls/WimaToolBar.qml">src/WimaView/WimaToolBar.qml</file>
<file alias="WimaView.qml">src/WimaView/WimaView.qml</file>
<file alias="QGroundControl/Controls/FlyAreaPolygonMapVisual.qml">src/WimaView/FlyAreaPolygonMapVisual.qml</file>
<file alias="QGroundControl/Controls/FlyAreaEditor.qml">src/WimaView/FlyAreaEditor.qml</file>
<file alias="QGroundControl/Controls/FlyAreaItemEditor.qml">src/WimaView/FlyAreaItemEditor.qml</file>
<file alias="QGroundControl/Controls/WimaMapVisual.qml">src/WimaView/WimaMapVisual.qml</file>
<file alias="QGroundControl/Controls/WimaGlobalMeasurementPolygonMapVisual.qml">src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml</file>
<file alias="QGroundControl/Controls/WimaServicePolygonMapVisual.qml">src/WimaView/WimaServicePolygonMapVisual.qml</file>
<file alias="WimaItemEditor.qml">src/WimaView/WimaItemEditor.qml</file>
</qresource>
<qresource prefix="/json">
<file alias="APMMavlinkStreamRate.SettingsGroup.json">src/Settings/APMMavlinkStreamRate.SettingsGroup.json</file>
...
...
src/MissionManager/WimaController.cc
View file @
00d7ea68
...
...
@@ -2,11 +2,11 @@
#include "MissionController.h"
WimaController
::
WimaController
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_planView
(
true
)
QObject
(
parent
)
,
_planView
(
true
)
,
_visualItems
(
new
QmlObjectListModel
(
parent
))
{
connect
(
this
,
&
WimaController
::
currentPolygonIndexChanged
,
this
,
&
WimaController
::
recalcPolygonInteractivity
);
}
void
WimaController
::
setMasterController
(
PlanMasterController
*
masterC
)
...
...
@@ -21,18 +21,30 @@ void WimaController::setMissionController(MissionController *missionC)
emit
missionControllerChanged
();
}
void
WimaController
::
setCurrentPolygonIndex
(
int
index
)
{
if
(
index
>
0
&&
index
<
_visualItems
->
count
()
&&
index
!=
_currentPolygonIndex
){
_currentPolygonIndex
=
index
;
emit
currentPolygonIndexChanged
(
index
);
}
}
void
WimaController
::
addGlobalMeasurementArea
()
{
WimaGlobalMeasurementPolygon
*
poly
=
new
WimaGlobalMeasurementPolygon
(
this
);
_visualItems
.
append
(
poly
);
WimaGlobalMeasurementPolygon
*
newPoly
=
new
WimaGlobalMeasurementPolygon
(
this
);
_visualItems
->
append
(
newPoly
);
int
newIndex
=
_visualItems
->
count
()
-
1
;
_currentPolygonIndex
=
newIndex
;
emit
currentPolygonIndexChanged
(
newIndex
);
emit
visualItemsChanged
();
}
void
WimaController
::
removeArea
(
int
index
)
{
if
(
index
>
0
&&
index
<
_visualItems
.
size
()){
_visualItems
.
removeAt
(
index
);
if
(
index
>
0
&&
index
<
_visualItems
->
count
()){
_visualItems
->
removeAt
(
index
);
emit
visualItemsChanged
();
}
else
{
...
...
@@ -43,16 +55,74 @@ void WimaController::removeArea(int index)
void
WimaController
::
addServiceArea
()
{
WimaServicePolygon
*
poly
=
new
WimaServicePolygon
(
this
);
_visualItems
.
append
(
poly
);
resetAllIsCurrentPolygon
();
WimaServicePolygon
*
newPoly
=
new
WimaServicePolygon
(
this
);
newPoly
->
setIsCurrentPolygon
(
true
);
_visualItems
->
append
(
newPoly
);
emit
visualItemsChanged
();
}
void
WimaController
::
startMission
()
{
}
void
WimaController
::
abortMission
()
{
}
void
WimaController
::
pauseMission
()
{
}
void
WimaController
::
resumeMission
()
{
}
void
WimaController
::
saveMission
()
{
}
void
WimaController
::
loadMission
()
{
}
void
WimaController
::
recalcVehicleCorridor
()
{
}
void
WimaController
::
recalcVehicleMeasurementAreas
()
{
}
void
WimaController
::
recalcAll
()
{
}
void
WimaController
::
recalcPolygonInteractivity
(
int
index
)
{
resetAllIsCurrentPolygon
();
WimaPolygon
*
interactivePoly
=
qobject_cast
<
WimaPolygon
*>
(
_visualItems
->
get
(
index
));
interactivePoly
->
setIsCurrentPolygon
(
true
);
}
void
WimaController
::
resetAllIsCurrentPolygon
()
{
int
itemCount
=
_visualItems
->
count
();
for
(
int
i
=
0
;
i
<
itemCount
;
i
++
)
{
WimaPolygon
*
iteratorPoly
=
qobject_cast
<
WimaPolygon
*>
(
_visualItems
->
get
(
i
));
iteratorPoly
->
setIsCurrentPolygon
(
false
);
}
}
src/MissionManager/WimaController.h
View file @
00d7ea68
#
ifndef
WIMACONTROLLER_H
#define WIMACONTROLLER_H
#
pragma
once
#include <QObject>
#include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
#include "WimaPolygon.h"
#include "WimaGlobalMeasurementPolygon.h"
#include "WimaServicePolygon.h"
#include "WimaPolygonContainer.h"
#include "PlanMasterController.h"
#include "MissionController.h"
...
...
@@ -21,13 +21,15 @@ public:
Q_PROPERTY
(
PlanMasterController
*
masterController
READ
masterController
WRITE
setMasterController
NOTIFY
masterControllerChanged
)
Q_PROPERTY
(
MissionController
*
missionController
READ
missionController
WRITE
setMissionController
NOTIFY
missionControllerChanged
)
Q_PROPERTY
(
QList
<
WimaPolygon
*>&
visualItems
READ
visualItems
NOTIFY
visualItemsChanged
)
Q_PROPERTY
(
QList
<
WimaPolygon
*>&
editorItems
READ
editorItems
NOTIFY
visualItemsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
visualItems
READ
visualItems
NOTIFY
visualItemsChanged
)
Q_PROPERTY
(
int
currentPolygonIndex
READ
currentPolygonIndex
WRITE
setCurrentPolygonIndex
NOTIFY
currentPolygonIndexChanged
)
// Property accessors
PlanMasterController
*
masterController
(
void
)
const
{
return
_masterController
;}
MissionController
*
missionController
(
void
)
const
{
return
_missionController
;}
QList
<
WimaPolygon
*>&
visualItems
(
void
)
{
return
_visualItemsContainer
.
returnFlatList
();
}
QmlObjectListModel
*
visualItems
(
void
)
{
return
_visualItems
;
}
int
currentPolygonIndex
(
void
)
const
{
return
_currentPolygonIndex
;
}
...
...
@@ -35,6 +37,7 @@ public:
// Property setters
void
setMasterController
(
PlanMasterController
*
masterController
);
void
setMissionController
(
MissionController
*
missionController
);
void
setCurrentPolygonIndex
(
int
index
);
Q_INVOKABLE
void
addGlobalMeasurementArea
();
Q_INVOKABLE
void
removeArea
(
int
index
);
...
...
@@ -48,25 +51,28 @@ public:
Q_INVOKABLE
void
saveMission
();
Q_INVOKABLE
void
loadMission
();
Q_INVOKABLE
void
resetAllIsCurrentPolygon
(
void
);
signals:
void
masterControllerChanged
(
void
);
void
missionControllerChanged
(
void
);
void
visualItemsChanged
(
void
);
void
currentPolygonIndexChanged
(
int
index
);
private
slots
:
void
recalcVehicleCorridor
();
void
recalcVehicleMeasurementAreas
();
void
recalcAll
();
void
recalcPolygonInteractivity
(
int
index
);
private:
bool
_planView
;
Q
List
<
WimaPolygon
*>
_visualItems
;
Q
mlObjectListModel
*
_visualItems
;
PlanMasterController
*
_masterController
;
MissionController
*
_missionController
;
int
_currentPolygonIndex
;
};
#endif // WIMACONTROLLER_H
src/MissionManager/WimaFlyArea.cc
deleted
100644 → 0
View file @
2ff5f135
#include "WimaFlyArea.h"
WimaFlyArea
::
WimaFlyArea
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_polygons
(
nullptr
)
{
}
WimaFlyArea
::
WimaFlyArea
(
const
WimaFlyArea
&
other
,
QObject
*
parent
)
:
QObject
(
parent
)
{
*
this
=
other
;
}
const
WimaFlyArea
&
WimaFlyArea
::
operator
=
(
const
WimaFlyArea
&
other
)
{
this
->
_polygons
=
other
.
_polygons
;
return
*
this
;
}
void
WimaFlyArea
::
_init
()
{
_polygons
=
new
QmlObjectListModel
(
this
);
}
void
WimaFlyArea
::
appendFlyAreaPolygon
()
{
QGCMapPolygon
*
newPolygon
=
new
QGCMapPolygon
();
_polygons
->
append
(
newPolygon
);
int
index
=
_polygons
->
count
()
-
1
;
selectCurrentPolygon
(
index
);
emit
polygonsChanged
();
}
void
WimaFlyArea
::
removeFlyAreaPolygon
(
int
index
)
{
if
(
index
>=
0
&&
index
<
_polygons
->
count
())
{
_polygons
->
removeAt
(
index
);
emit
polygonsChanged
();
}
}
void
WimaFlyArea
::
selectCurrentPolygon
(
int
index
)
{
if
(
index
>=
0
&&
index
<
_polygons
->
count
())
{
disselectAllPolygons
();
_currentPolygonIndex
=
index
;
_currentPolygonItem
=
qobject_cast
<
QGCMapPolygon
*>
(
_polygons
->
get
(
index
));
_currentPolygonItem
->
setInteractive
(
true
);
if
(
index
!=
_currentPolygonIndex
){
emit
currentPolygonItemChanged
(
_currentPolygonItem
);
emit
currentPolygonIndexChanged
(
index
);
}
}
}
void
WimaFlyArea
::
disselectAllPolygons
()
{
for
(
int
i
=
0
;
i
<
_polygons
->
count
();
i
++
)
{
QGCMapPolygon
*
polygon
=
qobject_cast
<
QGCMapPolygon
*>
(
_polygons
->
get
(
i
));
polygon
->
setInteractive
(
false
);
}
}
/*void WimaFlyArea::setBottomLayerAltitude(double alt)
{
if(_bottomLayerAltitude != alt){
_bottomLayerAltitude = alt;
emit bottomLayerAltitudeChanged(_bottomLayerAltitude);
}
}*/
src/MissionManager/WimaFlyArea.h
deleted
100644 → 0
View file @
2ff5f135
#ifndef WIMAFLYAREA_H
#define WIMAFLYAREA_H
#include <QObject>
#include "QGCMapPolygon.h"
#include "QmlObjectListModel.h"
class
WimaFlyArea
:
public
QObject
{
Q_OBJECT
public:
WimaFlyArea
(
QObject
*
parent
=
nullptr
);
WimaFlyArea
(
const
WimaFlyArea
&
other
,
QObject
*
parent
=
nullptr
);
const
WimaFlyArea
&
operator
=
(
const
WimaFlyArea
&
other
);
Q_PROPERTY
(
QmlObjectListModel
*
polygons
READ
polygons
NOTIFY
polygonsChanged
)
Q_PROPERTY
(
QGCMapPolygon
*
currentPolygonItem
READ
currentPolygonItem
NOTIFY
currentPolygonItemChanged
)
Q_PROPERTY
(
int
currentPolygonIndex
READ
currentPolygonIndex
NOTIFY
currentPolygonIndexChanged
)
//Q_PROPERTY(QList<double>* bottomLayerAltitude READ bottomLayerAltitude WRITE setBottomLayerAltitude NOTIFY bottomLayerAltitudeChanged)
//Q_PROPERTY(QList<int>* layerNumber READ layerNumber WRITE setLayerNumber NOTIFY layerNumberChanged)
//Q_PROPERTY(QList<double>* layerDistance READ layerDistance WRITE setLayerDistance NOTIFY layerDistanceChanged)
Q_INVOKABLE
void
appendFlyAreaPolygon
();
Q_INVOKABLE
void
removeFlyAreaPolygon
(
int
index
);
Q_INVOKABLE
void
selectCurrentPolygon
(
int
index
);
Q_INVOKABLE
void
disselectAllPolygons
();
// Property Accessors
QmlObjectListModel
*
polygons
(
void
)
{
return
_polygons
;}
QGCMapPolygon
*
currentPolygonItem
(
void
)
{
return
_currentPolygonItem
;}
int
currentPolygonIndex
(
void
)
{
return
_currentPolygonIndex
;}
//QList<double>* bottomLayerAltitude (void) { return _bottomLayerAltitude;}
//QList<int>* layerNumber (void) { return _layerNumber;}
//QList<double>* layerDistance (void) { return _layerDistance;}
// Property Writers
//void setBottomLayerAltitude(double alt);
//void setLayerNumber(int layerNumber);
//void setLayerDistance(double dist);
// Methodes
void
_init
(
void
);
signals:
void
polygonsChanged
(
void
);
void
currentPolygonItemChanged
(
QGCMapPolygon
*
polygon
);
void
currentPolygonIndexChanged
(
int
index
);
void
bottomLayerAltitudeChanged
(
double
alt
);
void
layerNumberChanged
(
int
alt
);
void
layerDistanceChanged
(
double
dist
);
public
slots
:
private:
QmlObjectListModel
*
_polygons
;
QGCMapPolygon
*
_currentPolygonItem
;
int
_currentPolygonIndex
;
bool
_visible
;
//QList<double>* _bottomLayerAltitude;
//QList<int>* _layerNumber;
//QList<double>* _layerDistance;
};
#endif // WIMAFLYAREA_H
src/MissionManager/WimaGlobalMeasurementPolygon.cc
View file @
00d7ea68
...
...
@@ -17,25 +17,30 @@ WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other,
void
WimaGlobalMeasurementPolygon
::
addVehicle
(
Vehicle
*
vehicle
)
{
if
(
vehicle
!=
nullptr
){
_vehicleList
.
append
(
vehicle
);
emit
vehicleListChanged
(
_vehicleList
);
_vehicleList
->
append
(
vehicle
);
emit
vehicleListChanged
();
}
}
void
WimaGlobalMeasurementPolygon
::
removeVehicle
(
int
vehicleIndex
)
{
if
(
vehicleIndex
>=
0
&&
vehicleIndex
<
_vehicleList
.
count
()){
_vehicleList
.
removeAt
(
vehicleIndex
);
emit
vehicleListChanged
(
_vehicleList
);
if
(
vehicleIndex
>=
0
&&
vehicleIndex
<
_vehicleList
->
count
()){
_vehicleList
->
removeAt
(
vehicleIndex
);
emit
vehicleListChanged
();
}
}
void
WimaGlobalMeasurementPolygon
::
recalculatesubPolygons
()
{
int
vehicleCount
=
_vehicleList
->
count
();
WimaVehicleMeasurementPolygon
*
newPolygon
=
new
WimaVehicleMeasurementPolygon
(
this
);
QScopedPointer
<
QList
<
QGCMapPolygon
*>>
listQGCPoly
(
this
->
splitPolygonArea
(
vehicleCount
)
);
_subPolygons
=
this
->
splitPolygonArea
(
vehicleCount
);
int
polyCount
=
listQGCPoly
->
size
();
_subPolygons
->
clear
();
for
(
int
i
=
0
;
i
<
polyCount
;
i
++
){
WimaVehicleMeasurementPolygon
*
subPoly
=
new
WimaVehicleMeasurementPolygon
(
listQGCPoly
->
takeAt
(
i
),
this
);
_subPolygons
->
append
(
subPoly
);
}
}
void
WimaGlobalMeasurementPolygon
::
removeAllVehicles
()
...
...
@@ -47,14 +52,14 @@ void WimaGlobalMeasurementPolygon::removeAllVehicles()
counter
--
;
}
emit
vehicleListChanged
(
_vehicleList
);
emit
vehicleListChanged
();
}
void
WimaGlobalMeasurementPolygon
::
setBottomLayerAltitude
(
double
altitude
)
{
if
(
altitude
>
0
&&
altitude
!=
_bottomLayerAltitude
){
_bottomLayerAltitude
=
altitude
;
emit
bottomLayerAltitudeChanged
(
altitude
);
emit
bottomLayerAltitudeChanged
();
}
}
...
...
@@ -62,7 +67,7 @@ void WimaGlobalMeasurementPolygon::setNumberOfLayers(int numberOfLayers)
{
if
(
numberOfLayers
>
0
&&
_numberOfLayers
!=
numberOfLayers
){
_numberOfLayers
=
numberOfLayers
;
emit
numberOfLayersChanged
(
numberOfLayers
);
emit
numberOfLayersChanged
();
}
}
...
...
@@ -70,6 +75,6 @@ void WimaGlobalMeasurementPolygon::setLayerDistance(double distance)
{
if
(
distance
>
0
&&
distance
!=
_layerDistance
){
_layerDistance
=
distance
;
emit
layerDistanceChanged
(
distance
);
emit
layerDistanceChanged
();
}
}
src/MissionManager/WimaGlobalMeasurementPolygon.h
View file @
00d7ea68
#ifndef WIMAGLOBALMEASUREMENTPOLYGON_H
#define WIMAGLOBALMEASUREMENTPOLYGON_H
#pragma once
#include <QObject>
#include "WimaPolygon.h"
...
...
@@ -7,6 +6,8 @@
#include "QGCMapPolygon.h"
#include "WimaVehicleMeasurementPolygon.h"
#include "QScopedPointer"
class
WimaGlobalMeasurementPolygon
:
public
WimaPolygon
{
Q_OBJECT
...
...
@@ -17,9 +18,8 @@ public:
Q_PROPERTY
(
double
bottomLayerAltitude
READ
bottomLayerAltitude
WRITE
setBottomLayerAltitude
NOTIFY
bottomLayerAltitudeChanged
)
Q_PROPERTY
(
int
numberOfLayers
READ
numberOfLayers
WRITE
setNumberOfLayers
NOTIFY
numberOfLayersChanged
)
Q_PROPERTY
(
double
layerDistance
READ
layerDistance
WRITE
setLayerDistance
NOTIFY
layerDistanceChanged
)
Q_PROPERTY
(
Q
List
<
Vehicle
*>
vehicleList
READ
vehicleList
NOTIFY
vehicleListChanged
)
Q_PROPERTY
(
Q
mlObjectListModel
*
vehicleList
READ
vehicleList
NOTIFY
vehicleListChanged
)
Q_PROPERTY
(
QGCMapPolyline
*
entryPolyline
READ
entryPolyline
NOTIFY
entryPolylineChanged
)
Q_PROPERTY
(
QList
<
WimaPolygon
*>
subPolygons
READ
subPolygons
NOTIFY
subPolygonsChanged
)
Q_INVOKABLE
void
addVehicle
(
Vehicle
*
vehicle
);
Q_INVOKABLE
void
removeVehicle
(
int
vehicleIndex
);
...
...
@@ -28,14 +28,14 @@ public:
// Overrides from WimaPolygon
QString
mapVisualQML
(
void
)
const
{
return
"WimaGlobalMeasurementPolygonMapVisal.qml"
;}
QString
mapVisualQML
(
void
)
const
{
return
"WimaGlobalMeasurementPolygonMapVis
u
al.qml"
;}
QString
editorQML
(
void
)
const
{
return
"WimaGlobalMeasurementPolygonEditor.qml"
;}
// Property accessors
double
bottomLayerAltitude
(
void
)
const
{
return
_bottomLayerAltitude
;}
int
numberOfLayers
(
void
)
const
{
return
_numberOfLayers
;}
double
layerDistance
(
void
)
const
{
return
_layerDistance
;}
Q
List
<
Vehicle
*>
vehicleList
(
void
)
const
{
return
_vehicleList
;}
Q
mlObjectListModel
*
vehicleList
(
void
)
const
{
return
_vehicleList
;}
QGCMapPolyline
*
entryPolyline
(
void
)
const
{
return
_entryPolyline
;}
// Property setters
...
...
@@ -45,21 +45,20 @@ public:
void
setLayerDistance
(
double
distance
);
signals:
void
bottomLayerAltitudeChanged
(
double
altitude
);
void
numberOfLayersChanged
(
int
numberOfLayers
);
void
layerDistanceChanged
(
double
distance
);
void
vehicleListChanged
(
QList
<
Vehicle
*>
vehicleList
);
void
entryPolylineChanged
(
QGCMapPolyline
*
polyline
);
void
subPolygonsChanged
(
QList
<
WimaPolygon
*>
subPolygons
);
void
bottomLayerAltitudeChanged
(
void
);
void
numberOfLayersChanged
(
void
);
void
layerDistanceChanged
(
void
);
void
vehicleListChanged
(
void
);
void
entryPolylineChanged
(
void
);
void
subPolygonsChanged
(
void
);
private:
double
_bottomLayerAltitude
;
int
_numberOfLayers
;
double
_layerDistance
;
Q
List
<
Vehicle
*>
_vehicleList
;
Q
mlObjectListModel
*
_vehicleList
;
QGCMapPolyline
*
_entryPolyline
;
};
#endif // WIMAGLOBALMEASUREMENTPOLYGON_H
src/MissionManager/WimaPolygon.cc
View file @
00d7ea68
...
...
@@ -3,15 +3,16 @@
WimaPolygon
::
WimaPolygon
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_maxAltitude
(
30
)
,
_vehicle
(
nullptr
)
,
_vehicle
(
parent
)
,
_polygon
(
new
QGCMapPolygon
(
this
))
,
_subPolygons
(
new
QmlObjectListModel
(
this
))
,
_subPolylines
(
new
QmlObjectListModel
(
this
))
{
}
WimaPolygon
::
WimaPolygon
(
QGCMapPolygon
*
other
,
QObject
*
parent
)
:
WimaPolygon
(
parent
)
{
delete
_polygon
;
*
_polygon
=
*
other
;
}
...
...
@@ -27,17 +28,25 @@ void WimaPolygon::setMaxAltitude(double alt)
void
WimaPolygon
::
setVehicle
(
Vehicle
*
vehicle
)
{
if
(
_vehicle
!=
vehicle
){
_vehicle
=
vehicle
;
if
(
_vehicle
.
vehicle
()
!=
vehicle
){
_vehicle
.
setVehicle
(
vehicle
)
;
emit
vehicleChanged
();
}
}
QGCMapPolygon
*
WimaPolygon
::
splitPolygonArea
(
int
numberOfFractions
)
void
WimaPolygon
::
setIsCurrentPolygon
(
bool
isCurrentPolygon
)
{
_isCurrentPolygon
=
isCurrentPolygon
;
emit
isCurrentPolygonChanged
();
}
QList
<
QGCMapPolygon
*>*
WimaPolygon
::
splitPolygonArea
(
int
numberOfFractions
)
{
if
(
numberOfFractions
>
0
){
QGCMapPolygon
*
poly
=
new
QGCMapPolygon
(
this
->
polygon
(),
this
);
return
poly
;
QList
<
QGCMapPolygon
*>*
list
=
new
QList
<
QGCMapPolygon
*>
();
list
->
append
(
poly
);
return
list
;
}
return
nullptr
;
}
...
...
src/MissionManager/WimaPolygon.h
View file @
00d7ea68
#
ifndef WIMAPOLYGON_H
#define WIMAPOLYGON_H
#
pragma once
#include "QGCMapPolygon.h"
#include "QGCMapPolyline.h"
#include "Vehicle.h"
#include "qobject.h"
#include "WimaVehicle.h"
...
...
@@ -22,15 +25,17 @@ public:
Q_PROPERTY
(
QString
editorQML
READ
editorQML
CONSTANT
)
Q_PROPERTY
(
Vehicle
*
vehicle
READ
vehicle
WRITE
setVehicle
NOTIFY
vehicleChanged
)
Q_PROPERTY
(
QGCMapPolygon
*
polygon
READ
polygon
NOTIFY
polygonChanged
)
Q_PROPERTY
(
QList
<
WimaPolygon
*>
subPolygons
READ
subPolygons
NOTIFY
subPolygonsChanged
)
Q_PROPERTY
(
QList
<
QGCMapPolyline
*>
subPolylines
READ
subPolylines
NOTIFY
subPolylinesChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
subPolygons
READ
subPolygons
NOTIFY
subPolygonsChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
subPolylines
READ
subPolylines
NOTIFY
subPolylinesChanged
)
Q_PROPERTY
(
bool
isCurrentPolygon
READ
isCurrentPolygon
WRITE
setIsCurrentPolygon
NOTIFY
isCurrentPolygonChanged
)
//Property accessors
double
maxAltitude
(
void
)
const
{
return
_maxAltitude
;}
Vehicle
*
vehicle
(
void
)
const
{
return
_vehicle
;}
Vehicle
*
vehicle
(
void
)
const
{
return
_vehicle
.
vehicle
()
;}
QGCMapPolygon
*
polygon
(
void
)
const
{
return
_polygon
;}
QList
<
WimaPolygon
*>
subPolygons
(
void
)
const
{
return
_subPolygons
;}
QList
<
QGCMapPolyline
*>
subPolylines
(
void
)
const
{
return
_subPolylines
;}
QmlObjectListModel
*
subPolygons
(
void
)
const
{
return
_subPolygons
;}
QmlObjectListModel
*
subPolylines
(
void