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
82aa7678
Commit
82aa7678
authored
Apr 20, 2017
by
DonLakeFlyer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a master controller for all Plan elements
Update the user model to a single controller instead of multiple
parent
da022f97
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
691 additions
and
723 deletions
+691
-723
qgroundcontrol.pro
qgroundcontrol.pro
+2
-0
FlightDisplayView.qml
src/FlightDisplay/FlightDisplayView.qml
+25
-29
FlightDisplayViewMap.qml
src/FlightDisplay/FlightDisplayViewMap.qml
+13
-13
MapFitFunctions.qml
src/FlightMap/Widgets/MapFitFunctions.qml
+17
-15
JsonHelper.cc
src/JsonHelper.cc
+10
-1
JsonHelper.h
src/JsonHelper.h
+8
-2
GeoFenceController.cc
src/MissionManager/GeoFenceController.cc
+20
-80
GeoFenceController.h
src/MissionManager/GeoFenceController.h
+4
-8
MissionController.cc
src/MissionManager/MissionController.cc
+72
-140
MissionController.h
src/MissionManager/MissionController.h
+7
-14
PlanElementController.cc
src/MissionManager/PlanElementController.cc
+0
-23
PlanElementController.h
src/MissionManager/PlanElementController.h
+22
-32
PlanMasterController.cc
src/MissionManager/PlanMasterController.cc
+265
-0
PlanMasterController.h
src/MissionManager/PlanMasterController.h
+96
-0
RallyPointController.cc
src/MissionManager/RallyPointController.cc
+23
-89
RallyPointController.h
src/MissionManager/RallyPointController.h
+4
-9
MissionItemEditor.qml
src/PlanView/MissionItemEditor.qml
+4
-3
PlanToolBar.qml
src/PlanView/PlanToolBar.qml
+17
-18
PlanView.qml
src/PlanView/PlanView.qml
+73
-240
QGCApplication.cc
src/QGCApplication.cc
+2
-3
AppSettings.cc
src/Settings/AppSettings.cc
+1
-0
AppSettings.h
src/Settings/AppSettings.h
+2
-0
Vehicle.cc
src/Vehicle/Vehicle.cc
+4
-4
No files found.
qgroundcontrol.pro
View file @
82aa7678
...
@@ -472,6 +472,7 @@ HEADERS += \
...
@@ -472,6 +472,7 @@ HEADERS += \
src/MissionManager/MissionManager.h \
src/MissionManager/MissionManager.h \
src/MissionManager/MissionSettingsItem.h \
src/MissionManager/MissionSettingsItem.h \
src/MissionManager/PlanElementController.h \
src/MissionManager/PlanElementController.h \
src/MissionManager/PlanMasterController.h \
src/MissionManager/QGCMapPolygon.h \
src/MissionManager/QGCMapPolygon.h \
src/MissionManager/RallyPoint.h \
src/MissionManager/RallyPoint.h \
src/MissionManager/RallyPointController.h \
src/MissionManager/RallyPointController.h \
...
@@ -654,6 +655,7 @@ SOURCES += \
...
@@ -654,6 +655,7 @@ SOURCES += \
src/MissionManager/MissionManager.cc \
src/MissionManager/MissionManager.cc \
src/MissionManager/MissionSettingsItem.cc \
src/MissionManager/MissionSettingsItem.cc \
src/MissionManager/PlanElementController.cc \
src/MissionManager/PlanElementController.cc \
src/MissionManager/PlanMasterController.cc \
src/MissionManager/QGCMapPolygon.cc \
src/MissionManager/QGCMapPolygon.cc \
src/MissionManager/RallyPoint.cc \
src/MissionManager/RallyPoint.cc \
src/MissionManager/RallyPointController.cc \
src/MissionManager/RallyPointController.cc \
...
...
src/FlightDisplay/FlightDisplayView.qml
View file @
82aa7678
...
@@ -38,14 +38,18 @@ QGCView {
...
@@ -38,14 +38,18 @@ QGCView {
property
bool
activeVehicleJoystickEnabled
:
_activeVehicle
?
_activeVehicle
.
joystickEnabled
:
false
property
bool
activeVehicleJoystickEnabled
:
_activeVehicle
?
_activeVehicle
.
joystickEnabled
:
false
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
var
_planMasterController
:
masterController
property
bool
_mainIsMap
:
QGroundControl
.
videoManager
.
hasVideo
?
QGroundControl
.
loadBoolGlobalSetting
(
_mainIsMapKey
,
true
)
:
true
property
var
_missionController
:
_planMasterController
.
missionController
property
bool
_isPipVisible
:
QGroundControl
.
videoManager
.
hasVideo
?
QGroundControl
.
loadBoolGlobalSetting
(
_PIPVisibleKey
,
true
)
:
false
property
var
_geoFenceController
:
_planMasterController
.
geoFenceController
property
real
_savedZoomLevel
:
0
property
var
_rallyPointController
:
_planMasterController
.
rallyPointController
property
real
_margins
:
ScreenTools
.
defaultFontPixelWidth
/
2
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
real
_pipSize
:
mainWindow
.
width
*
0.2
property
bool
_mainIsMap
:
QGroundControl
.
videoManager
.
hasVideo
?
QGroundControl
.
loadBoolGlobalSetting
(
_mainIsMapKey
,
true
)
:
true
property
alias
_guidedController
:
guidedActionsController
property
bool
_isPipVisible
:
QGroundControl
.
videoManager
.
hasVideo
?
QGroundControl
.
loadBoolGlobalSetting
(
_PIPVisibleKey
,
true
)
:
false
property
alias
_altitudeSlider
:
altitudeSlider
property
real
_savedZoomLevel
:
0
property
real
_margins
:
ScreenTools
.
defaultFontPixelWidth
/
2
property
real
_pipSize
:
mainWindow
.
width
*
0.2
property
alias
_guidedController
:
guidedActionsController
property
alias
_altitudeSlider
:
altitudeSlider
readonly
property
bool
isBackgroundDark
:
_mainIsMap
?
(
_flightMap
?
_flightMap
.
isSatelliteMap
:
true
)
:
true
readonly
property
bool
isBackgroundDark
:
_mainIsMap
?
(
_flightMap
?
_flightMap
.
isSatelliteMap
:
true
)
:
true
...
@@ -92,20 +96,14 @@ QGCView {
...
@@ -92,20 +96,14 @@ QGCView {
}
}
}
}
Mission
Controller
{
PlanElemementMaster
Controller
{
id
:
flyMission
Controller
id
:
master
Controller
Component.onCompleted
:
start
(
false
/* editMode */
)
Component.onCompleted
:
start
(
false
/* editMode */
)
onResumeMissionReady
:
guidedActionsController
.
confirmAction
(
guidedActionsController
.
actionResumeMissionReady
)
}
GeoFenceController
{
id
:
flyGeoFenceController
Component.onCompleted
:
start
(
false
/* editMode */
)
}
}
RallyPointController
{
Connections
{
id
:
flyRallyPoint
Controller
target
:
_mission
Controller
Component.onCompleted
:
start
(
false
/* editMode */
)
onResumeMissionReady
:
guidedActionsController
.
confirmAction
(
guidedActionsController
.
actionResumeMissionReady
)
}
}
MessageDialog
{
MessageDialog
{
...
@@ -116,7 +114,7 @@ QGCView {
...
@@ -116,7 +114,7 @@ QGCView {
}
}
Connections
{
Connections
{
target
:
QGroundControl
.
multiVehicleManager
target
:
QGroundControl
.
multiVehicleManager
onActiveVehicleChanged
:
px4JoystickCheck
()
onActiveVehicleChanged
:
px4JoystickCheck
()
}
}
...
@@ -149,7 +147,7 @@ QGCView {
...
@@ -149,7 +147,7 @@ QGCView {
vehicleWasArmed
=
true
vehicleWasArmed
=
true
}
}
}
else
{
}
else
{
if
(
promptForMissionRemove
&&
(
flyMissionController
.
containsItems
||
flyGeoFenceController
.
containsItems
||
flyR
allyPointController
.
containsItems
))
{
if
(
promptForMissionRemove
&&
(
_missionController
.
containsItems
||
_geoFenceController
.
containsItems
||
_r
allyPointController
.
containsItems
))
{
root
.
showDialog
(
removeMissionDialogComponent
,
qsTr
(
"
Flight complete
"
),
showDialogDefaultWidth
,
StandardButton
.
No
|
StandardButton
.
Yes
)
root
.
showDialog
(
removeMissionDialogComponent
,
qsTr
(
"
Flight complete
"
),
showDialogDefaultWidth
,
StandardButton
.
No
|
StandardButton
.
Yes
)
}
}
promptForMissionRemove
=
false
promptForMissionRemove
=
false
...
@@ -169,9 +167,9 @@ QGCView {
...
@@ -169,9 +167,9 @@ QGCView {
message
:
qsTr
(
"
Do you want to remove the mission from the vehicle?
"
)
message
:
qsTr
(
"
Do you want to remove the mission from the vehicle?
"
)
function
accept
()
{
function
accept
()
{
flyM
issionController
.
removeAllFromVehicle
()
_m
issionController
.
removeAllFromVehicle
()
flyG
eoFenceController
.
removeAllFromVehicle
()
_g
eoFenceController
.
removeAllFromVehicle
()
flyR
allyPointController
.
removeAllFromVehicle
()
_r
allyPointController
.
removeAllFromVehicle
()
hideDialog
()
hideDialog
()
}
}
...
@@ -214,9 +212,7 @@ QGCView {
...
@@ -214,9 +212,7 @@ QGCView {
FlightDisplayViewMap
{
FlightDisplayViewMap
{
id
:
_flightMap
id
:
_flightMap
anchors.fill
:
parent
anchors.fill
:
parent
missionController
:
flyMissionController
planMasterController
:
masterController
geoFenceController
:
flyGeoFenceController
rallyPointController
:
flyRallyPointController
guidedActionsController
:
_guidedController
guidedActionsController
:
_guidedController
flightWidgets
:
flightDisplayViewWidgets
flightWidgets
:
flightDisplayViewWidgets
rightPanelWidth
:
ScreenTools
.
defaultFontPixelHeight
*
9
rightPanelWidth
:
ScreenTools
.
defaultFontPixelHeight
*
9
...
@@ -320,7 +316,7 @@ QGCView {
...
@@ -320,7 +316,7 @@ QGCView {
anchors.bottom
:
parent
.
bottom
anchors.bottom
:
parent
.
bottom
qgcView
:
root
qgcView
:
root
useLightColors
:
isBackgroundDark
useLightColors
:
isBackgroundDark
missionController
:
_
flightMap
.
missionController
missionController
:
_missionController
visible
:
singleVehicleView
.
checked
visible
:
singleVehicleView
.
checked
}
}
...
@@ -511,7 +507,7 @@ QGCView {
...
@@ -511,7 +507,7 @@ QGCView {
GuidedActionsController
{
GuidedActionsController
{
id
:
guidedActionsController
id
:
guidedActionsController
missionController
:
flyM
issionController
missionController
:
_m
issionController
confirmDialog
:
guidedActionConfirm
confirmDialog
:
guidedActionConfirm
z
:
_flightVideoPipControl
.
z
+
1
z
:
_flightVideoPipControl
.
z
+
1
...
...
src/FlightDisplay/FlightDisplayViewMap.qml
View file @
82aa7678
...
@@ -34,9 +34,7 @@ FlightMap {
...
@@ -34,9 +34,7 @@ FlightMap {
property
alias
scaleState
:
mapScale
.
state
property
alias
scaleState
:
mapScale
.
state
// The following properties must be set by the consumer
// The following properties must be set by the consumer
property
var
missionController
property
var
planMasterController
property
var
geoFenceController
property
var
rallyPointController
property
var
guidedActionsController
property
var
guidedActionsController
property
var
flightWidgets
property
var
flightWidgets
property
var
rightPanelWidth
property
var
rightPanelWidth
...
@@ -44,6 +42,10 @@ FlightMap {
...
@@ -44,6 +42,10 @@ FlightMap {
property
rect
centerViewport
:
Qt
.
rect
(
0
,
0
,
width
,
height
)
property
rect
centerViewport
:
Qt
.
rect
(
0
,
0
,
width
,
height
)
property
var
_planMasterController
:
planMasterController
property
var
_missionController
:
_planMasterController
.
missionController
property
var
_geoFenceController
:
_planMasterController
.
geoFenceController
property
var
_rallyPointController
:
_planMasterController
.
rallyPointController
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
var
_activeVehicleCoordinate
:
_activeVehicle
?
_activeVehicle
.
coordinate
:
QtPositioning
.
coordinate
()
property
var
_activeVehicleCoordinate
:
_activeVehicle
?
_activeVehicle
.
coordinate
:
QtPositioning
.
coordinate
()
property
var
_gotoHereCoordinate
:
QtPositioning
.
coordinate
()
property
var
_gotoHereCoordinate
:
QtPositioning
.
coordinate
()
...
@@ -132,10 +134,10 @@ FlightMap {
...
@@ -132,10 +134,10 @@ FlightMap {
QGCMapPalette
{
id
:
mapPal
;
lightColors
:
isSatelliteMap
}
QGCMapPalette
{
id
:
mapPal
;
lightColors
:
isSatelliteMap
}
Connections
{
Connections
{
target
:
missionController
target
:
_
missionController
onNewItemsFromVehicle
:
{
onNewItemsFromVehicle
:
{
var
visualItems
=
missionController
.
visualItems
var
visualItems
=
_
missionController
.
visualItems
if
(
visualItems
&&
visualItems
.
count
!=
1
)
{
if
(
visualItems
&&
visualItems
.
count
!=
1
)
{
mapFitFunctions
.
fitMapViewportToMissionItems
()
mapFitFunctions
.
fitMapViewportToMissionItems
()
firstVehiclePositionReceived
=
true
firstVehiclePositionReceived
=
true
...
@@ -151,9 +153,7 @@ FlightMap {
...
@@ -151,9 +153,7 @@ FlightMap {
id
:
mapFitFunctions
id
:
mapFitFunctions
map
:
_flightMap
map
:
_flightMap
usePlannedHomePosition
:
false
usePlannedHomePosition
:
false
mapMissionController
:
missionController
planMasterController
:
_planMasterController
mapGeoFenceController
:
geoFenceController
mapRallyPointController
:
rallyPointController
property
real
leftToolWidth
:
toolStrip
.
x
+
toolStrip
.
width
property
real
leftToolWidth
:
toolStrip
.
x
+
toolStrip
.
width
}
}
...
@@ -188,7 +188,7 @@ FlightMap {
...
@@ -188,7 +188,7 @@ FlightMap {
// Add the mission item visuals to the map
// Add the mission item visuals to the map
Repeater
{
Repeater
{
model
:
_mainIsMap
?
missionController
.
visualItems
:
0
model
:
_mainIsMap
?
_
missionController
.
visualItems
:
0
delegate
:
MissionItemMapVisual
{
delegate
:
MissionItemMapVisual
{
map
:
flightMap
map
:
flightMap
...
@@ -198,12 +198,12 @@ FlightMap {
...
@@ -198,12 +198,12 @@ FlightMap {
// Add lines between waypoints
// Add lines between waypoints
MissionLineView
{
MissionLineView
{
model
:
_mainIsMap
?
missionController
.
waypointLines
:
0
model
:
_mainIsMap
?
_
missionController
.
waypointLines
:
0
}
}
GeoFenceMapVisuals
{
GeoFenceMapVisuals
{
map
:
flightMap
map
:
flightMap
myGeoFenceController
:
geoFenceController
myGeoFenceController
:
_
geoFenceController
interactive
:
false
interactive
:
false
planView
:
false
planView
:
false
homePosition
:
_activeVehicle
&&
_activeVehicle
.
homePosition
.
isValid
?
_activeVehicle
.
homePosition
:
undefined
homePosition
:
_activeVehicle
&&
_activeVehicle
.
homePosition
.
isValid
?
_activeVehicle
.
homePosition
:
undefined
...
@@ -211,7 +211,7 @@ FlightMap {
...
@@ -211,7 +211,7 @@ FlightMap {
// Rally points on map
// Rally points on map
MapItemView
{
MapItemView
{
model
:
rallyPointController
.
points
model
:
_
rallyPointController
.
points
delegate
:
MapQuickItem
{
delegate
:
MapQuickItem
{
id
:
itemIndicator
id
:
itemIndicator
...
@@ -243,7 +243,7 @@ FlightMap {
...
@@ -243,7 +243,7 @@ FlightMap {
// Camera points
// Camera points
MapItemView
{
MapItemView
{
model
:
missionController
.
cameraPoints
model
:
_
missionController
.
cameraPoints
delegate
:
CameraTriggerIndicator
{
delegate
:
CameraTriggerIndicator
{
coordinate
:
object
.
coordinate
coordinate
:
object
.
coordinate
...
...
src/FlightMap/Widgets/MapFitFunctions.qml
View file @
82aa7678
...
@@ -16,9 +16,11 @@ import QGroundControl 1.0
...
@@ -16,9 +16,11 @@ import QGroundControl 1.0
Item
{
Item
{
property
var
map
property
var
map
property
bool
usePlannedHomePosition
///< true: planned home position used for calculations, false: vehicle home position use for calculations
property
bool
usePlannedHomePosition
///< true: planned home position used for calculations, false: vehicle home position use for calculations
property
var
mapGeoFenceController
property
var
planMasterController
property
var
mapMissionController
property
var
mapRallyPointController
property
var
_missionController
:
planMasterController
.
missionController
property
var
_geoFenceController
:
planMasterController
.
geoFenceController
property
var
_rallyPointController
:
planMasterController
.
rallyPointController
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
...
@@ -26,7 +28,7 @@ Item {
...
@@ -26,7 +28,7 @@ Item {
var
homePosition
=
QtPositioning
.
coordinate
()
var
homePosition
=
QtPositioning
.
coordinate
()
var
activeVehicle
=
QGroundControl
.
multiVehicleManager
.
activeVehicle
var
activeVehicle
=
QGroundControl
.
multiVehicleManager
.
activeVehicle
if
(
usePlannedHomePosition
)
{
if
(
usePlannedHomePosition
)
{
homePosition
=
mapM
issionController
.
visualItems
.
get
(
0
).
coordinate
homePosition
=
_m
issionController
.
visualItems
.
get
(
0
).
coordinate
}
else
if
(
activeVehicle
)
{
}
else
if
(
activeVehicle
)
{
homePosition
=
activeVehicle
.
homePosition
homePosition
=
activeVehicle
.
homePosition
}
}
...
@@ -92,8 +94,8 @@ Item {
...
@@ -92,8 +94,8 @@ Item {
if
(
homePosition
.
isValid
)
{
if
(
homePosition
.
isValid
)
{
coordList
.
push
(
homePosition
)
coordList
.
push
(
homePosition
)
}
}
for
(
var
i
=
1
;
i
<
mapM
issionController
.
visualItems
.
count
;
i
++
)
{
for
(
var
i
=
1
;
i
<
_m
issionController
.
visualItems
.
count
;
i
++
)
{
var
missionItem
=
mapM
issionController
.
visualItems
.
get
(
i
)
var
missionItem
=
_m
issionController
.
visualItems
.
get
(
i
)
if
(
missionItem
.
specifiesCoordinate
&&
!
missionItem
.
isStandaloneCoordinate
)
{
if
(
missionItem
.
specifiesCoordinate
&&
!
missionItem
.
isStandaloneCoordinate
)
{
coordList
.
push
(
missionItem
.
coordinate
)
coordList
.
push
(
missionItem
.
coordinate
)
}
}
...
@@ -101,7 +103,7 @@ Item {
...
@@ -101,7 +103,7 @@ Item {
}
}
function
fitMapViewportToMissionItems
()
{
function
fitMapViewportToMissionItems
()
{
if
(
!
mapM
issionController
.
visualItems
)
{
if
(
!
_m
issionController
.
visualItems
)
{
// Being called prior to controller.start
// Being called prior to controller.start
return
return
}
}
...
@@ -112,16 +114,16 @@ Item {
...
@@ -112,16 +114,16 @@ Item {
function
addFenceItemCoordsForFit
(
coordList
)
{
function
addFenceItemCoordsForFit
(
coordList
)
{
var
homePosition
=
fitHomePosition
()
var
homePosition
=
fitHomePosition
()
if
(
homePosition
.
isValid
&&
mapG
eoFenceController
.
circleEnabled
)
{
if
(
homePosition
.
isValid
&&
_g
eoFenceController
.
circleEnabled
)
{
var
azimuthList
=
[
0
,
180
,
90
,
270
]
var
azimuthList
=
[
0
,
180
,
90
,
270
]
for
(
var
i
=
0
;
i
<
azimuthList
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
azimuthList
.
length
;
i
++
)
{
var
edgeCoordinate
=
homePosition
.
atDistanceAndAzimuth
(
mapG
eoFenceController
.
circleRadius
,
azimuthList
[
i
])
var
edgeCoordinate
=
homePosition
.
atDistanceAndAzimuth
(
_g
eoFenceController
.
circleRadius
,
azimuthList
[
i
])
coordList
.
push
(
edgeCoordinate
)
coordList
.
push
(
edgeCoordinate
)
}
}
}
}
if
(
mapGeoFenceController
.
polygonEnabled
&&
mapG
eoFenceController
.
mapPolygon
.
path
.
count
>
2
)
{
if
(
_geoFenceController
.
polygonEnabled
&&
_g
eoFenceController
.
mapPolygon
.
path
.
count
>
2
)
{
for
(
var
i
=
0
;
i
<
mapG
eoFenceController
.
mapPolygon
.
path
.
count
;
i
++
)
{
for
(
var
i
=
0
;
i
<
_g
eoFenceController
.
mapPolygon
.
path
.
count
;
i
++
)
{
coordList
.
push
(
mapG
eoFenceController
.
mapPolygon
.
path
[
i
])
coordList
.
push
(
_g
eoFenceController
.
mapPolygon
.
path
[
i
])
}
}
}
}
}
}
...
@@ -133,8 +135,8 @@ Item {
...
@@ -133,8 +135,8 @@ Item {
}
}
function
addRallyItemCoordsForFit
(
coordList
)
{
function
addRallyItemCoordsForFit
(
coordList
)
{
for
(
var
i
=
0
;
i
<
mapR
allyPointController
.
points
.
count
;
i
++
)
{
for
(
var
i
=
0
;
i
<
_r
allyPointController
.
points
.
count
;
i
++
)
{
coordList
.
push
(
mapR
allyPointController
.
points
.
get
(
i
).
coordinate
)
coordList
.
push
(
_r
allyPointController
.
points
.
get
(
i
).
coordinate
)
}
}
}
}
...
@@ -145,7 +147,7 @@ Item {
...
@@ -145,7 +147,7 @@ Item {
}
}
function
fitMapViewportToAllItems
()
{
function
fitMapViewportToAllItems
()
{
if
(
!
mapM
issionController
.
visualItems
)
{
if
(
!
_m
issionController
.
visualItems
)
{
// Being called prior to controller.start
// Being called prior to controller.start
return
return
}
}
...
...
src/JsonHelper.cc
View file @
82aa7678
...
@@ -125,7 +125,7 @@ bool JsonHelper::parseEnum(const QJsonObject& jsonObject, QStringList& enumStrin
...
@@ -125,7 +125,7 @@ bool JsonHelper::parseEnum(const QJsonObject& jsonObject, QStringList& enumStrin
return
true
;
return
true
;
}
}
bool
JsonHelper
::
isJsonFile
(
const
QByteArray
&
bytes
,
QJsonDocument
&
jsonDoc
)
bool
JsonHelper
::
isJsonFile
(
const
QByteArray
&
bytes
,
QJsonDocument
&
jsonDoc
,
QString
&
errorString
)
{
{
QJsonParseError
error
;
QJsonParseError
error
;
...
@@ -192,6 +192,15 @@ bool JsonHelper::validateQGCJsonFile(const QJsonObject& jsonObject,
...
@@ -192,6 +192,15 @@ bool JsonHelper::validateQGCJsonFile(const QJsonObject& jsonObject,
return
true
;
return
true
;
}
}
void
JsonHelper
::
saveQGCJsonFileHeader
(
QJsonObject
&
jsonObject
,
const
QString
&
fileType
,
int
version
)
{
jsonObject
[
jsonGroundStationKey
]
=
jsonGroundStationValue
;
jsonObject
[
jsonFileTypeKey
]
=
fileType
;
jsonObject
[
jsonVersionKey
]
=
version
;
}
bool
JsonHelper
::
loadGeoCoordinateArray
(
const
QJsonValue
&
jsonValue
,
bool
JsonHelper
::
loadGeoCoordinateArray
(
const
QJsonValue
&
jsonValue
,
bool
altitudeRequired
,
bool
altitudeRequired
,
QVariantList
&
rgVarPoints
,
QVariantList
&
rgVarPoints
,
...
...
src/JsonHelper.h
View file @
82aa7678
...
@@ -20,9 +20,15 @@ class JsonHelper
...
@@ -20,9 +20,15 @@ class JsonHelper
{
{
public:
public:
/// Determines is the specified data is a json file
/// Determines is the specified data is a json file
/// @param jsonDoc Returned json document if json file
/// @return true: file is json, false: file is not json
/// @return true: file is json, false: file is not json
static
bool
isJsonFile
(
const
QByteArray
&
bytes
,
QJsonDocument
&
jsonDoc
);
static
bool
isJsonFile
(
const
QByteArray
&
bytes
,
///< json bytes
QJsonDocument
&
jsonDoc
,
///< returned json document
QString
&
errorString
);
///< error on parse failure
/// Saves the standard file header the json object
static
void
saveQGCJsonFileHeader
(
QJsonObject
&
jsonObject
,
///< root json object
const
QString
&
fileType
,
///< file type for file
int
version
);
///< version number for file
/// Validates the standard parts of a QGC json file:
/// Validates the standard parts of a QGC json file:
/// jsonFileTypeKey - Required and checked to be equal to expectedFileType
/// jsonFileTypeKey - Required and checked to be equal to expectedFileType
...
...
src/MissionManager/GeoFenceController.cc
View file @
82aa7678
...
@@ -89,13 +89,15 @@ void GeoFenceController::_signalAll(void)
...
@@ -89,13 +89,15 @@ void GeoFenceController::_signalAll(void)
emit
dirtyChanged
(
dirty
());
emit
dirtyChanged
(
dirty
());
}
}
void
GeoFenceController
::
_
activeVehicleBeingRemoved
(
void
)
void
GeoFenceController
::
activeVehicleBeingRemoved
(
void
)
{
{
_activeVehicle
->
geoFenceManager
()
->
disconnect
(
this
);
_activeVehicle
->
geoFenceManager
()
->
disconnect
(
this
);
_activeVehicle
=
NULL
;
}
}
void
GeoFenceController
::
_activeVehicleSet
(
void
)
void
GeoFenceController
::
activeVehicleSet
(
Vehicle
*
vehicle
)
{
{
_activeVehicle
=
vehicle
;
GeoFenceManager
*
geoFenceManager
=
_activeVehicle
->
geoFenceManager
();
GeoFenceManager
*
geoFenceManager
=
_activeVehicle
->
geoFenceManager
();
connect
(
geoFenceManager
,
&
GeoFenceManager
::
breachReturnSupportedChanged
,
this
,
&
GeoFenceController
::
breachReturnSupportedChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
breachReturnSupportedChanged
,
this
,
&
GeoFenceController
::
breachReturnSupportedChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
circleEnabledChanged
,
this
,
&
GeoFenceController
::
circleEnabledChanged
);
connect
(
geoFenceManager
,
&
GeoFenceManager
::
circleEnabledChanged
,
this
,
&
GeoFenceController
::
circleEnabledChanged
);
...
@@ -112,97 +114,40 @@ void GeoFenceController::_activeVehicleSet(void)
...
@@ -112,97 +114,40 @@ void GeoFenceController::_activeVehicleSet(void)
_signalAll
();
_signalAll
();
}
}
bool
GeoFenceController
::
_loadJsonFile
(
QJsonDocument
&
jsonDoc
,
QString
&
errorString
)
bool
GeoFenceController
::
load
(
const
QJsonObject
&
json
,
QString
&
errorString
)
{
{
QJsonObject
json
=
jsonDoc
.
object
();
QString
errorStr
;
QString
errorMessage
=
tr
(
"GeoFence: %1"
);
int
fileVersion
;
if
(
json
.
contains
(
_jsonBreachReturnKey
)
&&
if
(
!
JsonHelper
::
validateQGCJsonFile
(
json
,
!
JsonHelper
::
loadGeoCoordinate
(
json
[
_jsonBreachReturnKey
],
false
/* altitudeRequired */
,
_breachReturnPoint
,
errorStr
))
{
_jsonFileTypeValue
,
// expected file type
errorString
=
errorMessage
.
arg
(
errorStr
);
1
,
// minimum supported version
1
,
// maximum supported version
fileVersion
,
errorString
))
{
return
false
;
return
false
;
}
}
if
(
!
_activeVehicle
->
parameterManager
()
->
loadFromJson
(
json
,
false
/* required */
,
errorString
))
{
if
(
!
_mapPolygon
.
loadFromJson
(
json
,
true
,
errorStr
))
{
return
false
;
errorString
=
errorMessage
.
arg
(
errorStr
);
}
if
(
json
.
contains
(
_jsonBreachReturnKey
)
&&
!
JsonHelper
::
loadGeoCoordinate
(
json
[
_jsonBreachReturnKey
],
false
/* altitudeRequired */
,
_breachReturnPoint
,
errorString
))
{
return
false
;
}
if
(
!
_mapPolygon
.
loadFromJson
(
json
,
true
,
errorString
))
{
return
false
;
return
false
;
}
}
_mapPolygon
.
setDirty
(
false
);
_mapPolygon
.
setDirty
(
false
);
setDirty
(
false
);
return
true
;
}
void
GeoFenceController
::
loadFromFile
(
const
QString
&
filename
)
{
QString
errorString
;
if
(
filename
.
isEmpty
())
{
return
;
}
QFile
file
(
filename
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
errorString
=
file
.
errorString
()
+
QStringLiteral
(
" "
)
+
filename
;
}
else
{
QJsonDocument
jsonDoc
;
QByteArray
bytes
=
file
.
readAll
();
_loadJsonFile
(
jsonDoc
,
errorString
);
}
if
(
!
errorString
.
isEmpty
())
{
qgcApp
()
->
showMessage
(
errorString
);
}
_signalAll
();
_signalAll
();
setDirty
(
true
);
return
true
;
}
}
void
GeoFenceController
::
saveToFile
(
const
QString
&
filename
)
void
GeoFenceController
::
save
(
QJsonObject
&
json
)
{
{
if
(
filename
.
isEmpty
())
{
json
[
JsonHelper
::
jsonVersionKey
]
=
1
;
return
;
}
QString
fenceFilename
=
filename
;
if
(
!
QFileInfo
(
filename
).
fileName
().
contains
(
"."
))
{
fenceFilename
+=
QString
(
".%1"
).
arg
(
AppSettings
::
fenceFileExtension
);
}
QFile
file
(
fenceFilename
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
{
qgcApp
()
->
showMessage
(
file
.
errorString
());
}
else
{
QJsonObject
fenceFileObject
;
// top level json object
fenceFileObject
[
JsonHelper
::
jsonFileTypeKey
]
=
_jsonFileTypeValue
;
fenceFileObject
[
JsonHelper
::
jsonVersionKey
]
=
1
;
fenceFileObject
[
JsonHelper
::
jsonGroundStationKey
]
=
JsonHelper
::
jsonGroundStationValue
;
if
(
_breachReturnPoint
.
isValid
())
{
QJsonValue
jsonBreachReturn
;
QJsonValue
jsonBreachReturn
;
JsonHelper
::
saveGeoCoordinate
(
_breachReturnPoint
,
false
/* writeAltitude */
,
jsonBreachReturn
);
JsonHelper
::
saveGeoCoordinate
(
_breachReturnPoint
,
false
/* writeAltitude */
,
jsonBreachReturn
);
fenceFileObject
[
_jsonBreachReturnKey
]
=
jsonBreachReturn
;
json
[
_jsonBreachReturnKey
]
=
jsonBreachReturn
;
_mapPolygon
.
saveToJson
(
fenceFileObject
);
QJsonDocument
saveDoc
(
fenceFileObject
);
file
.
write
(
saveDoc
.
toJson
());
}
}
setDirty
(
false
);
_mapPolygon
.
saveToJson
(
json
);
}
}
void
GeoFenceController
::
removeAll
(
void
)
void
GeoFenceController
::
removeAll
(
void
)
...
@@ -323,11 +268,6 @@ void GeoFenceController::_loadComplete(const QGeoCoordinate& breachReturn, const
...
@@ -323,11 +268,6 @@ void GeoFenceController::_loadComplete(const QGeoCoordinate& breachReturn, const
emit
loadComplete
();
emit
loadComplete
();
}
}
QString
GeoFenceController
::
fileExtension
(
void
)
const
{
return
AppSettings
::
fenceFileExtension
;
}
bool
GeoFenceController
::
containsItems
(
void
)
const
bool
GeoFenceController
::
containsItems
(
void
)
const
{
{
return
_mapPolygon
.
count
()
>
2
;
return
_mapPolygon
.
count
()
>
2
;
...
...
src/MissionManager/GeoFenceController.h
View file @
82aa7678
...
@@ -46,18 +46,18 @@ public:
...
@@ -46,18 +46,18 @@ public:
void
start
(
bool
editMode
)
final
;
void
start
(
bool
editMode
)
final
;
void
startStaticActiveVehicle
(
Vehicle
*
vehicle
)
final
;
void
startStaticActiveVehicle
(
Vehicle
*
vehicle
)
final
;
void
save
(
QJsonObject
&
json
)
final
;
bool
load
(
const
QJsonObject
&
json
,
QString
&
errorString
)
final
;
void
loadFromVehicle
(
void
)
final
;
void
loadFromVehicle
(
void
)
final
;
void
sendToVehicle
(
void
)
final
;
void
sendToVehicle
(
void
)
final
;
void
loadFromFile
(
const
QString
&
filename
)
final
;
void
saveToFile
(
const
QString
&
filename
)
final
;
void
removeAll
(
void
)
final
;
void
removeAll
(
void
)
final
;
void
removeAllFromVehicle
(
void
)
final
;
void
removeAllFromVehicle
(
void
)
final
;
bool
syncInProgress
(
void
)
const
final
;
bool
syncInProgress
(
void
)
const
final
;
bool
dirty
(
void
)
const
final
;
bool
dirty
(
void
)
const
final
;
void
setDirty
(
bool
dirty
)
final
;
void
setDirty
(
bool
dirty
)
final
;
bool
containsItems
(
void
)
const
final
;
bool
containsItems
(
void
)
const
final
;
void
activeVehicleBeingRemoved
(
void
)
final
;
QString
fileExtension
(
void
)
const
final
;
void
activeVehicleSet
(
Vehicle
*
vehicle
)
final
;
bool
circleEnabled
(
void
)
const
;
bool
circleEnabled
(
void
)
const
;
Fact
*
circleRadiusFact
(
void
)
const
;
Fact
*
circleRadiusFact
(
void
)
const
;
...
@@ -95,10 +95,6 @@ private slots:
...
@@ -95,10 +95,6 @@ private slots:
private:
private:
void
_init
(
void
);
void
_init
(
void
);
void
_signalAll
(
void
);
void
_signalAll
(
void
);
bool
_loadJsonFile
(
QJsonDocument
&
jsonDoc
,
QString
&
errorString
);
void
_activeVehicleBeingRemoved
(
void
)
final
;
void
_activeVehicleSet
(
void
)
final
;
bool
_dirty
;
bool
_dirty
;
QGCMapPolygon
_mapPolygon
;
QGCMapPolygon
_mapPolygon
;
...
...
src/MissionManager/MissionController.cc
View file @
82aa7678
This diff is collapsed.
Click to expand it.
src/MissionManager/MissionController.h
View file @
82aa7678
...
@@ -98,13 +98,6 @@ public:
...
@@ -98,13 +98,6 @@ public:
/// Updates the altitudes of the items in the current mission to the new default altitude
/// Updates the altitudes of the items in the current mission to the new default altitude
Q_INVOKABLE
void
applyDefaultMissionAltitude
(
void
);
Q_INVOKABLE
void
applyDefaultMissionAltitude
(
void
);
/// Loads the mission items from the specified file
/// @param[in] vehicle Vehicle we are loading items for