diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index f049e2b81d6518a5b8a628a1c314488dbb84b636..f1ce3bded2ca70f8e362c211d28315c67c78084e 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -49,7 +49,6 @@ Item { property var _rallyPointController: _planController.rallyPointController property bool _isPipVisible: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_PIPVisibleKey, true) : false property bool _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length - property real _savedZoomLevel: 0 property real _margins: ScreenTools.defaultFontPixelWidth / 2 property real _pipSize: mainWindow.width * 0.2 property alias _guidedController: guidedActionsController @@ -75,25 +74,10 @@ Item { //-- Adjust Margins _flightMapContainer.state = "fullMode" _flightVideo.state = "pipMode" - //-- Save/Restore Map Zoom Level - if(_savedZoomLevel != 0) { - if(mainWindow.flightDisplayMap) { - mainWindow.flightDisplayMap.zoomLevel = _savedZoomLevel - } - } else { - if(mainWindow.flightDisplayMap) { - _savedZoomLevel = mainWindow.flightDisplayMap.zoomLevel - } - } } else { //-- Adjust Margins _flightMapContainer.state = "pipMode" _flightVideo.state = "fullMode" - //-- Set Map Zoom Level - if(mainWindow.flightDisplayMap) { - _savedZoomLevel = mainWindow.flightDisplayMap.zoomLevel - mainWindow.flightDisplayMap.zoomLevel = _savedZoomLevel - 3 - } } } @@ -335,6 +319,7 @@ Item { scaleState: (mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode" Component.onCompleted: { mainWindow.flightDisplayMap = _fMap + _fMap.adjustMapSize() } } } @@ -459,6 +444,7 @@ Item { onActivated: { mainIsMap = !mainIsMap setStates() + _fMap.adjustMapSize() } onHideIt: { setPipVisibility(!state) diff --git a/src/FlightDisplay/FlightDisplayViewMap.qml b/src/FlightDisplay/FlightDisplayViewMap.qml index 0cb2a3194cbd3cac0a06bfe4fc985611a8180287..dc8323ec23f40d31463ca0b4638a07fc34012026 100644 --- a/src/FlightDisplay/FlightDisplayViewMap.qml +++ b/src/FlightDisplay/FlightDisplayViewMap.qml @@ -30,6 +30,8 @@ FlightMap { allowGCSLocationCenter: !userPanned allowVehicleLocationCenter: !_keepVehicleCentered planView: false + zoomLevel: QGroundControl.flightMapZoom + center: QGroundControl.flightMapPosition property alias scaleState: mapScale.state @@ -52,6 +54,7 @@ FlightMap { property bool _disableVehicleTracking: false property bool _keepVehicleCentered: mainIsMap ? false : true + property bool _pipping: false function updateAirspace(reset) { if(_airspaceEnabled) { @@ -63,11 +66,41 @@ FlightMap { } } + function pipIn() { + if(QGroundControl.flightMapZoom > 3) { + _pipping = true; + zoomLevel = QGroundControl.flightMapZoom - 3 + _pipping = false; + } + } + + function pipOut() { + _pipping = true; + zoomLevel = QGroundControl.flightMapZoom + _pipping = false; + } + + function adjustMapSize() { + if(mainIsMap) + pipOut() + else + pipIn() + } + // Track last known map position and zoom from Fly view in settings + onVisibleChanged: { + if(visible) { + adjustMapSize() + center = QGroundControl.flightMapPosition + } + } + onZoomLevelChanged: { - QGroundControl.flightMapZoom = zoomLevel - updateAirspace(false) + if(!_pipping) { + QGroundControl.flightMapZoom = zoomLevel + updateAirspace(false) + } } onCenterChanged: { QGroundControl.flightMapPosition = center diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index ffa8eb6b983253c165f400687f60ce5385db0b9a..08bedd522f9fa3dbc252e640b94484f12e1f4f42 100644 --- a/src/FlightMap/FlightMap.qml +++ b/src/FlightMap/FlightMap.qml @@ -25,8 +25,6 @@ import QGroundControl.QGCPositionManager 1.0 Map { id: _map - zoomLevel: QGroundControl.flightMapZoom - center: QGroundControl.flightMapPosition //-- Qt 5.9 has rotation gesture enabled by default. Here we limit the possible gestures. gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture gesture.flickDeceleration: 3000 @@ -81,7 +79,6 @@ Map { if (gcsPosition.isValid && allowGCSLocationCenter && !firstGCSPositionReceived && !firstVehiclePositionReceived) { firstGCSPositionReceived = true center = gcsPosition - zoomLevel = QGroundControl.flightMapInitialZoom } } diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index 84c0ce63e4aa6a3a407e8588afaf2e42773b426c..3baecc198b16367f5225997ec021a1f1bc2da98d 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -105,8 +105,12 @@ Item { } onVisibleChanged: { - if (visible && !_planMasterController.containsItems) { - toolStrip.simulateClick(toolStrip.fileButtonIndex) + if(visible) { + editorMap.zoomLevel = QGroundControl.flightMapZoom + editorMap.center = QGroundControl.flightMapPosition + if (!_planMasterController.containsItems) { + toolStrip.simulateClick(toolStrip.fileButtonIndex) + } } } @@ -367,28 +371,28 @@ Item { allowVehicleLocationCenter: true planView: true + zoomLevel: QGroundControl.flightMapZoom + center: QGroundControl.flightMapPosition + // This is the center rectangle of the map which is not obscured by tools property rect centerViewport: Qt.rect(_leftToolWidth + _margin, _toolsMargin, editorMap.width - _leftToolWidth - _rightToolWidth - (_margin * 2), mapScale.y - _margin - _toolsMargin) property real _leftToolWidth: toolStrip.x + toolStrip.width property real _rightToolWidth: rightPanel.width + rightPanel.anchors.rightMargin - readonly property real animationDuration: 500 - // Initial map position duplicates Fly view position Component.onCompleted: editorMap.center = QGroundControl.flightMapPosition - Behavior on zoomLevel { - NumberAnimation { - duration: editorMap.animationDuration - easing.type: Easing.InOutQuad - } - } - QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap } - onZoomLevelChanged: updateAirspace(false) - onCenterChanged: updateAirspace(false) + onZoomLevelChanged: { + QGroundControl.flightMapZoom = zoomLevel + updateAirspace(false) + } + onCenterChanged: { + QGroundControl.flightMapPosition = center + updateAirspace(false) + } MouseArea { anchors.fill: parent