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
02709fef
Commit
02709fef
authored
Mar 24, 2017
by
Donald Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New Follow Vehicle user model
parent
1723a2d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
39 deletions
+76
-39
FlightDisplayViewMap.qml
src/FlightDisplay/FlightDisplayViewMap.qml
+76
-27
FlightMap.qml
src/FlightMap/FlightMap.qml
+0
-12
No files found.
src/FlightDisplay/FlightDisplayViewMap.qml
View file @
02709fef
...
...
@@ -33,16 +33,18 @@ FlightMap {
property
var
rightPanelWidth
property
var
qgcView
///< QGCView control which contains this map
property
bool
_followVehicleSetting
:
true
///< User facing setting for follow vehicle
property
bool
_followVehicle
:
_followVehicleSetting
&&
_activeVehicleCoordinateValid
///< Control map follow vehicle functionality
property
var
_activeVehicle
:
QGroundControl
.
multiVehicleManager
.
activeVehicle
property
bool
_activeVehicleCoordinateValid
:
_activeVehicle
?
_activeVehicle
.
coordinateValid
:
false
property
var
activeVehicleCoordinate
:
_activeVehicle
?
_activeVehicle
.
coordinate
:
QtPositioning
.
coordinate
()
property
var
_gotoHereCoordinate
:
QtPositioning
.
coordinate
()
property
int
_retaskSequence
:
0
property
real
_toolButtonTopMargin
:
parent
.
height
-
ScreenTools
.
availableHeight
+
(
ScreenTools
.
defaultFontPixelHeight
/
2
)
property
bool
_firstVehicleCoordinate
:
false
property
bool
_centerUpdateFromTimer
:
true
property
bool
_disableVehicleTracking
:
false
property
bool
_keepVehicleCentered
:
_mainIsMap
?
false
:
true
property
bool
_followVehicleSetting
:
true
///< User facing setting for follow vehicle
property
bool
_followVehicle
:
_followVehicleSetting
&&
_activeVehicleCoordinateValid
///< Control map follow vehicle functionality
property
bool
_firstVehiclePosition
:
true
Component.onCompleted
:
{
QGroundControl
.
flightMapPosition
=
center
...
...
@@ -51,45 +53,92 @@ FlightMap {
onZoomLevelChanged
:
QGroundControl
.
flightMapZoom
=
zoomLevel
onCenterChanged
:
{
if
(
_centerUpdateFromTimer
)
{
_centerUpdateFromTimer
=
false
}
else
{
vehicleCenterTimer
.
restart
()
// When the user pans the map we leave things alone until the panRecenterTimer fires
Connections
{
target
:
gesture
onPanFinished
:
{
_disableVehicleTracking
=
true
panRecenterTimer
.
start
()
}
QGroundControl
.
flightMapPosition
=
center
onFlickFinished
:
{
_disableVehicleTracking
=
true
panRecenterTimer
.
start
()
}
}
onActiveVehicleCoordinateChanged
:
{
if
(
!
_firstVehicleCoordinate
&&
_activeVehicleCoordinateValid
)
{
_firstVehicleCoordinate
=
true
updateMapToVehiclePosition
()
}
onCenterChanged
:
QGroundControl
.
flightMapPosition
=
center
function
pointInRect
(
point
,
rect
)
{
return
point
.
x
>
rect
.
x
&&
point
.
x
<
rect
.
x
+
rect
.
width
&&
point
.
y
>
rect
.
y
&&
point
.
y
<
rect
.
y
+
rect
.
height
;
}
property
real
_animatedLatitudeStart
property
real
_animatedLatitudeStop
property
real
_animatedLongitudeStart
property
real
_animatedLongitudeStop
property
real
animatedLatitude
property
real
animatedLongitude
onAnimatedLatitudeChanged
:
flightMap
.
center
=
QtPositioning
.
coordinate
(
animatedLatitude
,
animatedLongitude
)
onAnimatedLongitudeChanged
:
flightMap
.
center
=
QtPositioning
.
coordinate
(
animatedLatitude
,
animatedLongitude
)
NumberAnimation
on
animatedLatitude
{
id
:
animateLat
;
from
:
_animatedLatitudeStart
;
to
:
_animatedLatitudeStop
;
duration
:
1000
}
NumberAnimation
on
animatedLongitude
{
id
:
animateLong
;
from
:
_animatedLongitudeStart
;
to
:
_animatedLongitudeStop
;
duration
:
1000
}
function
animatedMapRecenter
(
fromCoord
,
toCoord
)
{
_animatedLatitudeStart
=
fromCoord
.
latitude
_animatedLongitudeStart
=
fromCoord
.
longitude
_animatedLatitudeStop
=
toCoord
.
latitude
_animatedLongitudeStop
=
toCoord
.
longitude
animateLat
.
start
()
animateLong
.
start
()
}
function
recenterNeeded
()
{
var
vehiclePoint
=
flightMap
.
fromCoordinate
(
activeVehicleCoordinate
,
false
/* clipToViewport */
)
var
centerViewport
=
Qt
.
rect
(
0
,
0
,
width
,
height
)
return
!
pointInRect
(
vehiclePoint
,
centerViewport
)
}
function
updateMapToVehiclePosition
()
{
if
(
_followVehicle
)
{
_initialMapPositionSet
=
true
_firstVehicleCoordinate
=
true
_centerUpdateFromTimer
=
true
flightMap
.
center
=
activeVehicleCoordinate
if
(
_followVehicle
&&
!
_disableVehicleTracking
)
{
if
(
_keepVehicleCentered
)
{
_firstVehiclePosition
=
true
flightMap
.
center
=
activeVehicleCoordinate
}
else
{
if
(
_firstVehiclePosition
)
{
_firstVehiclePosition
=
false
flightMap
.
center
=
activeVehicleCoordinate
}
else
if
(
recenterNeeded
())
{
animatedMapRecenter
(
flightMap
.
center
,
activeVehicleCoordinate
)
}
}
}
}
Timer
{
id
:
vehicleCenterTimer
interval
:
5000
running
:
true
triggeredOnStart
:
true
repeat
:
true
id
:
panRecenterTimer
interval
:
10000
running
:
false
onTriggered
:
{
triggeredOnStart
=
false
_disableVehicleTracking
=
false
updateMapToVehiclePosition
()
}
}
Timer
{
interval
:
500
running
:
true
repeat
:
true
onTriggered
:
updateMapToVehiclePosition
()
}
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
true
}
QGCMapPalette
{
id
:
mapPal
;
lightColors
:
isSatelliteMap
}
...
...
@@ -231,7 +280,7 @@ FlightMap {
MapPolyline
{
line.width
:
3
line.color
:
"
red
"
z
:
QGroundControl
.
zOrderMapItems
-
1
z
:
QGroundControl
.
zOrderMapItems
-
2
path
:
[
object
.
coordinate1
,
object
.
coordinate2
,
...
...
src/FlightMap/FlightMap.qml
View file @
02709fef
...
...
@@ -72,18 +72,6 @@ Map {
ExclusiveGroup
{
id
:
mapTypeGroup
}
property
bool
_initialMapPositionSet
:
false
Connections
{
target
:
mainWindow
onGcsPositionChanged
:
{
if
(
!
_initialMapPositionSet
)
{
_initialMapPositionSet
=
true
center
=
mainWindow
.
gcsPosition
}
}
}
function
updateActiveMapType
()
{
var
settings
=
QGroundControl
.
settingsManager
.
flightMapSettings
var
fullMapName
=
settings
.
mapProvider
.
enumStringValue
+
"
"
+
settings
.
mapType
.
enumStringValue
...
...
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