@ -126,17 +126,59 @@ FlightMap {
@@ -126,17 +126,59 @@ FlightMap {
animateLong . start ( )
}
function _insetRect ( ) {
/ / r e t u r n s t h e r e c t a n g l e f o r m e d b y t h e f o u r c e n t e r i n s e t s
/ / u s e d f o r c h e c k i n g i f v e h i c l e i s u n d e r u i , a n d a s a t a r g e t f o r r e c e n t e r i n g t h e v i e w
function _insetCenterRect ( ) {
return Qt . rect ( toolInsets . leftEdgeCenterInset ,
toolInsets . topEdgeCenterInset ,
_root . width - toolInsets . leftEdgeCenterInset - toolInsets . rightEdgeCenterInset ,
_root . height - toolInsets . topEdgeCenterInset - toolInsets . bottomEdgeCenterInset )
}
/ / r e t u r n s t h e f o u r r e c t a n g l e s f o r m e d b y t h e 8 c o r n e r i n s e t s
/ / u s e d f o r d e t e c t i n g i f t h e v e h i c l e h a s f l o w n u n d e r t h e i n s t r u m e n t p a n e l , v i r t u a l j o y s t i c k e t c
function _insetCornerRects ( ) {
var rects = {
"topleft" : Qt . rect ( 0 , 0 ,
toolInsets . leftEdgeTopInset ,
toolInsets . topEdgeLeftInset ) ,
"topright" : Qt . rect ( _root . width - toolInsets . rightEdgeTopInset , 0 ,
toolInsets . rightEdgeTopInset ,
toolInsets . topEdgeRightInset ) ,
"bottomleft" : Qt . rect ( 0 , _root . height - toolInsets . bottomEdgeLeftInset ,
toolInsets . leftEdgeBottomInset ,
toolInsets . bottomEdgeLeftInset ) ,
"bottomright" : Qt . rect ( _root . width - toolInsets . rightEdgeBottomInset , _root . height - toolInsets . bottomEdgeRightInset ,
toolInsets . rightEdgeBottomInset ,
toolInsets . bottomEdgeRightInset ) }
return rects
}
function recenterNeeded ( ) {
var vehiclePoint = _root . fromCoordinate ( _activeVehicleCoordinate , false /* clipToViewport */ )
var insetRect = _insetRect ( )
return ! pointInRect ( vehiclePoint , insetRect )
var centerRect = _insetCenterRect ( )
/ / r e t u r n ! p o i n t I n R e c t ( v e h i c l e P o i n t , i n s e t R e c t )
/ / I f w e a r e o u t s i d e t h e c e n t e r i n s e t r e c t a n g l e , r e c e n t e r
if ( ! pointInRect ( vehiclePoint , centerRect ) ) {
return true
}
/ / i f w e a r e i n s i d e t h e c e n t e r i n s e t r e c t a n g l e
/ / t h e n a d d i t i o n a l l y c h e c k i f w e a r e u n d e r n e a t h o n e o f t h e c o r n e r i n s e t r e c t a n g l e s
var cornerRects = _insetCornerRects ( )
if ( pointInRect ( vehiclePoint , cornerRects [ "topleft" ] ) ) {
return true
} else if ( pointInRect ( vehiclePoint , cornerRects [ "topright" ] ) ) {
return true
} else if ( pointInRect ( vehiclePoint , cornerRects [ "bottomleft" ] ) ) {
return true
} else if ( pointInRect ( vehiclePoint , cornerRects [ "bottomright" ] ) ) {
return true
}
/ / i f w e a r e i n s i d e t h e c e n t e r i n s e t r e c t a n g l e , a n d n o t u n d e r a n y c o r n e r e l e m e n t s
return false
}
function updateMapToVehiclePosition ( ) {
@ -151,8 +193,8 @@ FlightMap {
@@ -151,8 +193,8 @@ FlightMap {
if ( firstVehiclePositionReceived && recenterNeeded ( ) ) {
/ / M o v e t h e m a p s u c h t h a t t h e v e h i c l e i s c e n t e r e d w i t h i n t h e i n s e t a r e a
var vehiclePoint = _root . fromCoordinate ( _activeVehicleCoordinate , false /* clipToViewport */ )
var i nsetRect = _insetRect ( )
var centerInsetPoint = Qt . point ( i nsetRect. x + i nsetRect. width / 2 , i nsetRect. y + i nsetRect. height / 2 )
var centerI nsetRect = _insetCenter Rect ( )
var centerInsetPoint = Qt . point ( centerI nsetRect. x + centerI nsetRect. width / 2 , centerI nsetRect. y + centerI nsetRect. height / 2 )
var centerOffset = Qt . point ( ( _root . width / 2 ) - centerInsetPoint . x , ( _root . height / 2 ) - centerInsetPoint . y )
var vehicleOffsetPoint = Qt . point ( vehiclePoint . x + centerOffset . x , vehiclePoint . y + centerOffset . y )
var vehicleOffsetCoord = _root . toCoordinate ( vehicleOffsetPoint , false /* clipToViewport */ )