@ -86,31 +86,114 @@ QGCView {
@@ -86,31 +86,114 @@ QGCView {
return lon + 180.0
}
/ / / F i x t h e m a p v i e w p o r t t o t h e c u r r e n t m i s s i o n i t e m s .
function fitViewportToMissionItems ( ) {
if ( _visualItems . count == 1 ) {
/ / / F i t s t h e v i s i b l e r e g i o n o f t h e m a p t o i n c l u e s a l l o f t h e s p e c i f i e d c o o r d i n a t e s . I f n o c o o r d i n a t e s
/ / / a r e s p e c i f i e d t h e m a p w i l l f i t t o t h e h o m e p o s i t i o n
function fitMapViewportToAllCoordinates ( coordList ) {
if ( coordList . length == 0 ) {
editorMap . center = _visualItems . get ( 0 ) . coordinate
} else {
var missionItem = _visualItems . get ( 0 )
var north = normalizeLat ( missionItem . coordinate . latitude )
var south = north
var east = normalizeLon ( missionItem . coordinate . longitude )
var west = east
for ( var i = 1 ; i < _visualItems . count ; i ++ ) {
missionItem = _visualItems . get ( i )
if ( missionItem . specifiesCoordinate && ! missionItem . isStandaloneCoordinate ) {
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 )
}
return
}
/ / D e t e r m i n e t h e s i z e o f t h e i n n e r p o r t i o n o f t h e m a p a v a i l a b l e f o r d i s p l a y
var toolbarHeight = qgcView . height - ScreenTools . availableHeight
var rightPanelWidth = _rightPanelWidth
var leftToolWidth = centerMapButton . x + centerMapButton . width
var availableWidth = qgcView . width - rightPanelWidth - leftToolWidth
var availableHeight = qgcView . height - toolbarHeight
/ / C r e a t e t h e n o r m a l i z e d l a t / l o n c o r n e r s f o r t h e c o o r d i n a t e b o u n d i n g r e c t f r o m t h e l i s t o f c o o r d i n a t e s
var north = normalizeLat ( coordList [ 0 ] . latitude )
var south = north
var east = normalizeLon ( coordList [ 0 ] . longitude )
var west = east
for ( var i = 1 ; i < coordList . length ; i ++ ) {
var lat = normalizeLat ( coordList [ i ] . latitude )
var lon = normalizeLon ( coordList [ i ] . longitude )
north = Math . max ( north , lat )
south = Math . min ( south , lat )
east = Math . max ( east , lon )
west = Math . min ( west , lon )
}
/ / E x p a n d t h e c o o r d i n a t e b o u n d i n g r e c t t o m a k e r o o m f o r t h e t o o l s a r o u n d t h e e d g e o f t h e m a p
var latDegreesPerPixel = ( north - south ) / availableWidth
var lonDegreesPerPixel = ( east - west ) / availableHeight
north = Math . min ( north + ( toolbarHeight * latDegreesPerPixel ) , 180 )
west = Math . max ( west - ( leftToolWidth * lonDegreesPerPixel ) , 0 )
east = Math . min ( east + ( rightPanelWidth * lonDegreesPerPixel ) , 360 )
/ / F i x t h e m a p r e g i o n t o t h e n e w b o u n d i n g r e c t
var topLeftCoord = QtPositioning . coordinate ( north - 90.0 , west - 180.0 )
var bottomRightCoord = QtPositioning . coordinate ( south - 90.0 , east - 180.0 )
editorMap . visibleRegion = QtPositioning . rectangle ( topLeftCoord , bottomRightCoord )
}
function addMissionItemCoordsForFit ( coordList ) {
for ( var i = 1 ; i < qgcView . _visualItems . count ; i ++ ) {
missionItem = qgcView . _visualItems . get ( i )
if ( missionItem . specifiesCoordinate && ! missionItem . isStandaloneCoordinate ) {
coordList . push ( missionItem . coordinate )
}
}
}
function fitMapViewportToMissionItems ( ) {
var coordList = [ ]
addMissionItemCoordsForFit ( coordList )
fitMapViewportToAllCoordinates ( coordList )
}
function addFenceItemCoordsForFit ( coordList ) {
if ( geoFenceController . circleSupported ) {
var azimuthList = [ 0 , 180 , 90 , 270 ]
for ( var i = 0 ; i < azimuthList . length ; i ++ ) {
var edgeCoordinate = homePos . coordinate . atDistanceAndAzimuth ( geoFenceController . circleRadius , azimuthList [ i ] )
coordList . push ( edgeCoordinate )
}
}
if ( geoFenceController . polygonSupported && geoFenceController . polygon . count ( ) > 2 ) {
for ( var i = 0 ; i < geoFenceController . polygon . count ( ) ; i ++ ) {
coordList . push ( geoFenceController . polygon . path [ i ] )
}
editorMap . visibleRegion = QtPositioning . rectangle ( QtPositioning . coordinate ( north - 90.0 , west - 180.0 ) , QtPositioning . coordinate ( south - 90.0 , east - 180.0 ) )
}
}
function fitMapViewportToFenceItems ( ) {
var coordList = [ ]
addFenceItemCoordsForFit ( coordList )
fitMapViewportToAllCoordinates ( coordList )
}
function addRallyItemCoordsForFit ( coordList ) {
for ( var i = 0 ; i < rallyPointController . points . count ; i ++ ) {
coordList . push ( rallyPointController . points . get ( i ) . coordinate )
}
}
function fitMapViewportToRallyItems ( ) {
var coordList = [ ]
addRallyItemCoordsForFit ( coordList )
fitMapViewportToAllCoordinates ( coordList )
}
function fitMapViewportToAllItems ( ) {
var coordList = [ ]
addMissionItemCoordsForFit ( coordList )
addFenceItemCoordsForFit ( coordList )
addRallyItemCoordsForFit ( coordList )
fitMapViewportToAllCoordinates ( coordList )
}
property bool _firstMissionLoadComplete : false
property bool _firstFenceLoadComplete : false
property bool _firstRallyLoadComplete : false
property bool _firstLoadComplete : false
function checkFirstLoadComplete ( ) {
if ( ! _firstLoadComplete && _firstMissionLoadComplete && _firstRallyLoadComplete && _firstFenceLoadComplete ) {
_firstLoadComplete = true
fitMapViewportToAllItems ( )
}
}
@ -127,7 +210,7 @@ QGCView {
@@ -127,7 +210,7 @@ QGCView {
qgcView . showDialog ( mobileFilePicker , qsTr ( "Select Mission File" ) , qgcView . showDialogDefaultWidth , StandardButton . Yes | StandardButton . Cancel )
} else {
missionController . loadFromFilePicker ( )
fitViewportToMissionItems ( )
fitMap ViewportToMissionItems ( )
_currentMissionItem = _visualItems . get ( 0 )
}
}
@ -140,13 +223,19 @@ QGCView {
@@ -140,13 +223,19 @@ QGCView {
}
}
function fitViewportToItems ( ) {
fitMapViewportToMissionItems ( )
}
onVisualItemsChanged: {
itemDragger . clearItem ( )
}
onNewItemsFromVehicle: {
fitViewportToMissionItems ( )
fitMap ViewportToMissionItems ( )
setCurrentItem ( 0 )
_firstMissionLoadComplete = true
checkFirstLoadComplete ( )
}
}
@ -168,6 +257,7 @@ QGCView {
@@ -168,6 +257,7 @@ QGCView {
qgcView . showDialog ( mobileFilePicker , qsTr ( "Select Fence File" ) , qgcView . showDialogDefaultWidth , StandardButton . Yes | StandardButton . Cancel )
} else {
geoFenceController . loadFromFilePicker ( )
fitMapViewportToFenceItems ( )
}
}
@ -181,6 +271,22 @@ QGCView {
@@ -181,6 +271,22 @@ QGCView {
}
}
}
function fitViewportToItems ( ) {
fitMapViewportToFenceItems ( )
}
onLoadComplete: {
_firstFenceLoadComplete = true
switch ( _syncDropDownController ) {
case geoFenceController:
fitMapViewportToFenceItems ( )
break
case missionController:
checkFirstLoadComplete ( )
break
}
}
}
RallyPointController {
@ -209,6 +315,23 @@ QGCView {
@@ -209,6 +315,23 @@ QGCView {
qgcView . showDialog ( mobileFilePicker , qsTr ( "Select Rally Point File" ) , qgcView . showDialogDefaultWidth , StandardButton . Yes | StandardButton . Cancel )
} else {
rallyPointController . loadFromFilePicker ( )
fitMapViewportToRallyItems ( )
}
}
function fitViewportToItems ( ) {
fitMapViewportToRallyItems ( )
}
onLoadComplete: {
_firstRallyLoadComplete = true
switch ( _syncDropDownController ) {
case rallyPointController:
fitMapViewportToRallyItems ( )
break
case missionController:
checkFirstLoadComplete ( )
break
}
}
}
@ -246,7 +369,10 @@ QGCView {
@@ -246,7 +369,10 @@ QGCView {
QGCMobileFileDialog {
openDialog: true
fileExtension: _syncDropDownController . fileExtension
onFilenameReturned: _syncDropDownController . loadFromFile ( filename )
onFilenameReturned: {
_syncDropDownController . loadFromFile ( filename )
_syncDropDownController . fitViewportToItems ( )
}
}
}
@ -559,69 +685,31 @@ QGCView {
@@ -559,69 +685,31 @@ QGCView {
_syncDropDownController = rallyPointController
break
}
_syncDropDownController . fitViewportToItems ( )
}
}
Round Button {
QGC Radi oButton {
id: planElementMission
radius: parent . _buttonRadius
buttonImage: "/qmlimages/Plan.svg"
lightBorders: _lightWidgetBorders
exclusiveGroup: planElementSelectorGroup
text: qsTr ( "Mission" )
checked: true
}
QGCLabel {
text: qsTr ( "Mission" )
color: mapPal . text
anchors.verticalCenter: parent . verticalCenter
MouseArea {
anchors.fill: parent
onClicked: planElementMission . checked = true
}
}
Item { height: 1 ; width: 1 }
Round Button {
QGCRadioButton {
id: planElementGeoFence
radius: parent . _buttonRadius
buttonImage: "/qmlimages/Plan.svg"
lightBorders: _lightWidgetBorders
exclusiveGroup: planElementSelectorGroup
}
QGCLabel {
text: qsTr ( "Fence" )
color: mapPal . text
anchors.verticalCenter: parent . verticalCenter
MouseArea {
anchors.fill: parent
onClicked: planElementGeoFence . checked = true
}
text: qsTr ( "Fence" )
}
Item { height: 1 ; width: 1 }
Round Button {
QGCRadioButton {
id: planElementRallyPoints
radius: parent . _buttonRadius
buttonImage: "/qmlimages/Plan.svg"
lightBorders: _lightWidgetBorders
exclusiveGroup: planElementSelectorGroup
}
QGCLabel {
text: qsTr ( "Rally" )
color: mapPal . text
anchors.verticalCenter: parent . verticalCenter
MouseArea {
anchors.fill: parent
onClicked: planElementRallyPoints . checked = true
}
text: qsTr ( "Rally" )
}
} / / R o w - P l a n E l e m e n t S e l e c t o r
@ -872,7 +960,15 @@ QGCView {
@@ -872,7 +960,15 @@ QGCView {
width: ScreenTools . defaultFontPixelWidth * 10
onClicked: {
centerMapButton . hideDropDown ( )
fitViewportToMissionItems ( )
fitMapViewportToMissionItems ( )
}
}
QGCButton {
text: qsTr ( "All items" )
width: ScreenTools . defaultFontPixelWidth * 10
onClicked: {
centerMapButton . hideDropDown ( )
fitMapViewportToAllItems ( )
}
}
QGCButton {