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
950aaab0
Commit
950aaab0
authored
Jan 22, 2016
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fit map viewport to mission items
parent
94c26ac4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
6 deletions
+54
-6
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+54
-6
No files found.
src/MissionEditor/MissionEditor.qml
View file @
950aaab0
...
...
@@ -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
...
...
@@ -549,7 +597,7 @@ QGCView {
function
accept
()
{
hideDialog
()
controller
.
getMissionItems
()
loadFromVehicle
()
}
}
}
...
...
@@ -563,7 +611,7 @@ QGCView {
function
accept
()
{
hideDialog
()
controller
.
loadMission
FromFile
()
load
FromFile
()
}
}
}
...
...
@@ -606,7 +654,7 @@ QGCView {
if
(
syncNeeded
)
{
_root
.
showDialog
(
syncLoadFromVehicleOverwrite
,
"
Mission overwrite
"
,
_root
.
showDialogDefaultWidth
,
StandardButton
.
Yes
|
StandardButton
.
Cancel
)
}
else
{
controller
.
getMissionItems
()
loadFromVehicle
()
}
}
}
...
...
@@ -633,7 +681,7 @@ QGCView {
if
(
syncNeeded
)
{
_root
.
showDialog
(
syncLoadFromFileOverwrite
,
"
Mission overwrite
"
,
_root
.
showDialogDefaultWidth
,
StandardButton
.
Yes
|
StandardButton
.
Cancel
)
}
else
{
controller
.
loadMission
FromFile
()
load
FromFile
()
}
}
}
...
...
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