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
8890d874
Commit
8890d874
authored
Jan 22, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2697 from DonLakeFlyer/MissionEdit
Mission editor fixes
parents
46392201
251bbf80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
15 deletions
+80
-15
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+54
-6
MissionController.cc
src/MissionManager/MissionController.cc
+25
-9
MissionController.h
src/MissionManager/MissionController.h
+1
-0
No files found.
src/MissionEditor/MissionEditor.qml
View file @
8890d874
...
...
@@ -91,6 +91,53 @@ QGCView {
}
}
function
loadFromVehicle
()
{
controller
.
getMissionItems
()
}
function
loadFromFile
()
{
controller
.
loadMissionFromFile
()
fitViewportToMissionItems
()
}
function
normalizeLat
(
lat
)
{
// Normalize latitude to range: 0 to 180, S to N
return
lat
+
90.0
}
function
normalizeLon
(
lon
)
{
// Normalize longitude to range: 0 to 360, W to E
return
lon
+
180.0
}
/// Fix the map viewport to the current mission items. We don't fit the home position in this process.
function
fitViewportToMissionItems
()
{
if
(
_missionItems
.
count
<=
1
)
{
return
}
var
missionItem
=
_missionItems
.
get
(
1
)
var
north
=
normalizeLat
(
missionItem
.
coordinate
.
latitude
)
var
south
=
north
var
east
=
normalizeLon
(
missionItem
.
coordinate
.
longitude
)
var
west
=
east
for
(
var
i
=
2
;
i
<
_missionItems
.
count
;
i
++
)
{
missionItem
=
_missionItems
.
get
(
i
)
var
lat
=
normalizeLat
(
missionItem
.
coordinate
.
latitude
)
var
lon
=
normalizeLon
(
missionItem
.
coordinate
.
longitude
)
north
=
Math
.
max
(
north
,
lat
)
south
=
Math
.
min
(
south
,
lat
)
east
=
Math
.
max
(
east
,
lon
)
west
=
Math
.
min
(
west
,
lon
)
}
editorMap
.
visibleRegion
=
QtPositioning
.
rectangle
(
QtPositioning
.
coordinate
(
north
-
90.0
,
west
-
180.0
),
QtPositioning
.
coordinate
(
south
-
90.0
,
east
-
180.0
))
}
MissionController
{
id
:
controller
...
...
@@ -107,6 +154,7 @@ QGCView {
*/
onMissionItemsChanged
:
itemDragger
.
clearItem
()
onNewItemsFromVehicle
:
fitViewportToMissionItems
()
}
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
enabled
}
...
...
@@ -261,11 +309,11 @@ QGCView {
// Add the mission items to the map
MapItemView
{
model
:
controller
.
missionItems
delegate
:
delegate
Component
delegate
:
missionItem
Component
}
Component
{
id
:
delegate
Component
id
:
missionItem
Component
MissionItemIndicator
{
id
:
itemIndicator
...
...
@@ -550,7 +598,7 @@ QGCView {
function
accept
()
{
hideDialog
()
controller
.
getMissionItems
()
loadFromVehicle
()
}
}
}
...
...
@@ -564,7 +612,7 @@ QGCView {
function
accept
()
{
hideDialog
()
controller
.
loadMission
FromFile
()
load
FromFile
()
}
}
}
...
...
@@ -607,7 +655,7 @@ QGCView {
if
(
syncNeeded
)
{
_root
.
showDialog
(
syncLoadFromVehicleOverwrite
,
"
Mission overwrite
"
,
_root
.
showDialogDefaultWidth
,
StandardButton
.
Yes
|
StandardButton
.
Cancel
)
}
else
{
controller
.
getMissionItems
()
loadFromVehicle
()
}
}
}
...
...
@@ -634,7 +682,7 @@ QGCView {
if
(
syncNeeded
)
{
_root
.
showDialog
(
syncLoadFromFileOverwrite
,
"
Mission overwrite
"
,
_root
.
showDialogDefaultWidth
,
StandardButton
.
Yes
|
StandardButton
.
Cancel
)
}
else
{
controller
.
loadMission
FromFile
()
load
FromFile
()
}
}
}
...
...
src/MissionManager/MissionController.cc
View file @
8890d874
...
...
@@ -130,12 +130,13 @@ void MissionController::_setupMissionItems(bool loadFromVehicle, bool forceLoad)
if
(
!
missionManager
||
!
loadFromVehicle
||
missionManager
->
inProgress
())
{
_missionItems
=
new
QmlObjectListModel
(
this
);
qCDebug
(
MissionControllerLog
)
<<
"creating empty set"
;
_initAllMissionItems
();
}
else
{
_missionItems
=
missionManager
->
copyMissionItems
();
qCDebug
(
MissionControllerLog
)
<<
"loading from vehicle count"
<<
_missionItems
->
count
();
_initAllMissionItems
();
emit
newItemsFromVehicle
();
}
_initAllMissionItems
();
}
void
MissionController
::
getMissionItems
(
void
)
...
...
@@ -222,6 +223,7 @@ void MissionController::loadMissionFromFile(void)
#ifndef __mobile__
QString
errorString
;
QString
filename
=
QGCFileDialog
::
getOpenFileName
(
NULL
,
"Select Mission File to load"
);
bool
versionAPM
=
false
;
if
(
filename
.
isEmpty
())
{
return
;
...
...
@@ -244,9 +246,17 @@ void MissionController::loadMissionFromFile(void)
const
QStringList
&
version
=
in
.
readLine
().
split
(
" "
);
if
(
!
(
version
.
size
()
==
3
&&
version
[
0
]
==
"QGC"
&&
version
[
1
]
==
"WPL"
&&
version
[
2
]
==
"120"
))
{
errorString
=
"The mission file is not compatible with the current version of QGroundControl."
;
}
else
{
bool
versionOk
=
false
;
if
(
version
.
size
()
==
3
&&
version
[
0
]
==
"QGC"
&&
version
[
1
]
==
"WPL"
)
{
if
(
version
[
2
]
==
"120"
)
{
versionOk
=
true
;
}
else
if
(
version
[
2
]
==
"110"
)
{
versionOk
=
true
;
versionAPM
=
true
;
}
}
if
(
versionOk
)
{
while
(
!
in
.
atEnd
())
{
MissionItem
*
item
=
new
MissionItem
();
...
...
@@ -257,12 +267,19 @@ void MissionController::loadMissionFromFile(void)
break
;
}
}
}
else
{
errorString
=
"The mission file is not compatible with this version of QGroundControl."
;
}
}
if
(
!
errorString
.
isEmpty
())
{
if
(
errorString
.
isEmpty
())
{
if
(
versionAPM
)
{
// Remove fake home position from APM files
_missionItems
->
removeAt
(
0
);
}
}
else
{
_missionItems
->
clear
();
qgcApp
()
->
showMessage
(
errorString
);
}
_initAllMissionItems
();
...
...
@@ -272,7 +289,6 @@ void MissionController::loadMissionFromFile(void)
void
MissionController
::
saveMissionToFile
(
void
)
{
#ifndef __mobile__
QString
errorString
;
QString
filename
=
QGCFileDialog
::
getSaveFileName
(
NULL
,
"Select file to save mission to"
);
if
(
filename
.
isEmpty
())
{
...
...
@@ -282,7 +298,7 @@ void MissionController::saveMissionToFile(void)
QFile
file
(
filename
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
{
errorString
=
file
.
errorString
(
);
qgcApp
()
->
showMessage
(
file
.
errorString
()
);
}
else
{
QTextStream
out
(
&
file
);
...
...
src/MissionManager/MissionController.h
View file @
8890d874
...
...
@@ -72,6 +72,7 @@ signals:
void
liveHomePositionAvailableChanged
(
bool
homePositionAvailable
);
void
liveHomePositionChanged
(
const
QGeoCoordinate
&
homePosition
);
void
autoSyncChanged
(
bool
autoSync
);
void
newItemsFromVehicle
(
void
);
private
slots
:
void
_newMissionItemsAvailableFromVehicle
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment