Commit cff65ebe authored by DonLakeFlyer's avatar DonLakeFlyer

Better initial map positions and planned home position support

parent 079ffd7a
...@@ -307,7 +307,7 @@ INCLUDEPATH += \ ...@@ -307,7 +307,7 @@ INCLUDEPATH += \
src/FollowMe \ src/FollowMe \
src/GPS \ src/GPS \
src/Joystick \ src/Joystick \
src/MissionEditor \ src/PlanView \
src/MissionManager \ src/MissionManager \
src/PositionManager \ src/PositionManager \
src/QmlControls \ src/QmlControls \
...@@ -462,7 +462,7 @@ HEADERS += \ ...@@ -462,7 +462,7 @@ HEADERS += \
src/MissionManager/MissionController.h \ src/MissionManager/MissionController.h \
src/MissionManager/MissionItem.h \ src/MissionManager/MissionItem.h \
src/MissionManager/MissionManager.h \ src/MissionManager/MissionManager.h \
src/MissionManager/MissionSettingsComplexItem.h \ src/MissionManager/MissionSettingsItem.h \
src/MissionManager/PlanElementController.h \ src/MissionManager/PlanElementController.h \
src/MissionManager/QGCMapPolygon.h \ src/MissionManager/QGCMapPolygon.h \
src/MissionManager/RallyPoint.h \ src/MissionManager/RallyPoint.h \
...@@ -640,7 +640,7 @@ SOURCES += \ ...@@ -640,7 +640,7 @@ SOURCES += \
src/MissionManager/MissionController.cc \ src/MissionManager/MissionController.cc \
src/MissionManager/MissionItem.cc \ src/MissionManager/MissionItem.cc \
src/MissionManager/MissionManager.cc \ src/MissionManager/MissionManager.cc \
src/MissionManager/MissionSettingsComplexItem.cc \ src/MissionManager/MissionSettingsItem.cc \
src/MissionManager/PlanElementController.cc \ src/MissionManager/PlanElementController.cc \
src/MissionManager/QGCMapPolygon.cc \ src/MissionManager/QGCMapPolygon.cc \
src/MissionManager/RallyPoint.cc \ src/MissionManager/RallyPoint.cc \
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<file alias="MainWindowInner.qml">src/ui/MainWindowInner.qml</file> <file alias="MainWindowInner.qml">src/ui/MainWindowInner.qml</file>
<file alias="MainWindowNative.qml">src/ui/MainWindowNative.qml</file> <file alias="MainWindowNative.qml">src/ui/MainWindowNative.qml</file>
<file alias="MavlinkSettings.qml">src/ui/preferences/MavlinkSettings.qml</file> <file alias="MavlinkSettings.qml">src/ui/preferences/MavlinkSettings.qml</file>
<file alias="MissionEditor.qml">src/MissionEditor/MissionEditor.qml</file> <file alias="PlanView.qml">src/PlanView/PlanView.qml</file>
<file alias="MixersComponent.qml">src/AutoPilotPlugins/Common/MixersComponent.qml</file> <file alias="MixersComponent.qml">src/AutoPilotPlugins/Common/MixersComponent.qml</file>
<file alias="MockLink.qml">src/ui/preferences/MockLink.qml</file> <file alias="MockLink.qml">src/ui/preferences/MockLink.qml</file>
<file alias="MockLinkSettings.qml">src/ui/preferences/MockLinkSettings.qml</file> <file alias="MockLinkSettings.qml">src/ui/preferences/MockLinkSettings.qml</file>
...@@ -47,32 +47,32 @@ ...@@ -47,32 +47,32 @@
<file alias="PX4FlowSensor.qml">src/VehicleSetup/PX4FlowSensor.qml</file> <file alias="PX4FlowSensor.qml">src/VehicleSetup/PX4FlowSensor.qml</file>
<file alias="QGroundControl/Controls/AnalyzePage.qml">src/AnalyzeView/AnalyzePage.qml</file> <file alias="QGroundControl/Controls/AnalyzePage.qml">src/AnalyzeView/AnalyzePage.qml</file>
<file alias="QGroundControl/Controls/AppMessages.qml">src/QmlControls/AppMessages.qml</file> <file alias="QGroundControl/Controls/AppMessages.qml">src/QmlControls/AppMessages.qml</file>
<file alias="QGroundControl/Controls/CameraSection.qml">src/MissionEditor/CameraSection.qml</file> <file alias="QGroundControl/Controls/CameraSection.qml">src/PlanView/CameraSection.qml</file>
<file alias="QGroundControl/Controls/ClickableColor.qml">src/QmlControls/ClickableColor.qml</file> <file alias="QGroundControl/Controls/ClickableColor.qml">src/QmlControls/ClickableColor.qml</file>
<file alias="QGroundControl/Controls/DropButton.qml">src/QmlControls/DropButton.qml</file> <file alias="QGroundControl/Controls/DropButton.qml">src/QmlControls/DropButton.qml</file>
<file alias="QGroundControl/Controls/ExclusiveGroupItem.qml">src/QmlControls/ExclusiveGroupItem.qml</file> <file alias="QGroundControl/Controls/ExclusiveGroupItem.qml">src/QmlControls/ExclusiveGroupItem.qml</file>
<file alias="QGroundControl/Controls/FactSliderPanel.qml">src/QmlControls/FactSliderPanel.qml</file> <file alias="QGroundControl/Controls/FactSliderPanel.qml">src/QmlControls/FactSliderPanel.qml</file>
<file alias="QGroundControl/Controls/FlightModeDropdown.qml">src/QmlControls/FlightModeDropdown.qml</file> <file alias="QGroundControl/Controls/FlightModeDropdown.qml">src/QmlControls/FlightModeDropdown.qml</file>
<file alias="QGroundControl/Controls/FlightModeMenu.qml">src/QmlControls/FlightModeMenu.qml</file> <file alias="QGroundControl/Controls/FlightModeMenu.qml">src/QmlControls/FlightModeMenu.qml</file>
<file alias="QGroundControl/Controls/FWLandingPatternMapVisual.qml">src/MissionEditor/FWLandingPatternMapVisual.qml</file> <file alias="QGroundControl/Controls/FWLandingPatternMapVisual.qml">src/PlanView/FWLandingPatternMapVisual.qml</file>
<file alias="QGroundControl/Controls/GeoFenceEditor.qml">src/MissionEditor/GeoFenceEditor.qml</file> <file alias="QGroundControl/Controls/GeoFenceEditor.qml">src/PlanView/GeoFenceEditor.qml</file>
<file alias="QGroundControl/Controls/GeoFenceMapVisuals.qml">src/MissionEditor/GeoFenceMapVisuals.qml</file> <file alias="QGroundControl/Controls/GeoFenceMapVisuals.qml">src/PlanView/GeoFenceMapVisuals.qml</file>
<file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file> <file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
<file alias="QGroundControl/Controls/JoystickThumbPad.qml">src/QmlControls/JoystickThumbPad.qml</file> <file alias="QGroundControl/Controls/JoystickThumbPad.qml">src/QmlControls/JoystickThumbPad.qml</file>
<file alias="QGroundControl/Controls/MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file> <file alias="QGroundControl/Controls/MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
<file alias="QGroundControl/Controls/MainToolBarIndicators.qml">src/ui/toolbar/MainToolBarIndicators.qml</file> <file alias="QGroundControl/Controls/MainToolBarIndicators.qml">src/ui/toolbar/MainToolBarIndicators.qml</file>
<file alias="QGroundControl/Controls/MissionCommandDialog.qml">src/QmlControls/MissionCommandDialog.qml</file> <file alias="QGroundControl/Controls/MissionCommandDialog.qml">src/QmlControls/MissionCommandDialog.qml</file>
<file alias="QGroundControl/Controls/MissionItemEditor.qml">src/MissionEditor/MissionItemEditor.qml</file> <file alias="QGroundControl/Controls/MissionItemEditor.qml">src/PlanView/MissionItemEditor.qml</file>
<file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">src/QmlControls/MissionItemIndexLabel.qml</file> <file alias="QGroundControl/Controls/MissionItemIndexLabel.qml">src/QmlControls/MissionItemIndexLabel.qml</file>
<file alias="QGroundControl/Controls/MissionItemMapVisual.qml">src/MissionEditor/MissionItemMapVisual.qml</file> <file alias="QGroundControl/Controls/MissionItemMapVisual.qml">src/PlanView/MissionItemMapVisual.qml</file>
<file alias="QGroundControl/Controls/MissionItemStatus.qml">src/MissionEditor/MissionItemStatus.qml</file> <file alias="QGroundControl/Controls/MissionItemStatus.qml">src/PlanView/MissionItemStatus.qml</file>
<file alias="QGroundControl/Controls/MissionSettingsMapVisual.qml">src/MissionEditor/MissionSettingsMapVisual.qml</file> <file alias="QGroundControl/Controls/MissionSettingsMapVisual.qml">src/PlanView/MissionSettingsMapVisual.qml</file>
<file alias="QGroundControl/Controls/ModeSwitchDisplay.qml">src/QmlControls/ModeSwitchDisplay.qml</file> <file alias="QGroundControl/Controls/ModeSwitchDisplay.qml">src/QmlControls/ModeSwitchDisplay.qml</file>
<file alias="QGroundControl/Controls/MultiRotorMotorDisplay.qml">src/QmlControls/MultiRotorMotorDisplay.qml</file> <file alias="QGroundControl/Controls/MultiRotorMotorDisplay.qml">src/QmlControls/MultiRotorMotorDisplay.qml</file>
<file alias="QGroundControl/Controls/OfflineMapButton.qml">src/QmlControls/OfflineMapButton.qml</file> <file alias="QGroundControl/Controls/OfflineMapButton.qml">src/QmlControls/OfflineMapButton.qml</file>
<file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file> <file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file>
<file alias="QGroundControl/Controls/ParameterEditorDialog.qml">src/QmlControls/ParameterEditorDialog.qml</file> <file alias="QGroundControl/Controls/ParameterEditorDialog.qml">src/QmlControls/ParameterEditorDialog.qml</file>
<file alias="QGroundControl/Controls/PlanToolBar.qml">src/MissionEditor/PlanToolBar.qml</file> <file alias="QGroundControl/Controls/PlanToolBar.qml">src/PlanView/PlanToolBar.qml</file>
<file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file> <file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file>
<file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file> <file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file>
<file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file> <file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file>
...@@ -98,17 +98,17 @@ ...@@ -98,17 +98,17 @@
<file alias="QGroundControl/Controls/QGCViewMessage.qml">src/QmlControls/QGCViewMessage.qml</file> <file alias="QGroundControl/Controls/QGCViewMessage.qml">src/QmlControls/QGCViewMessage.qml</file>
<file alias="QGroundControl/Controls/QGCViewPanel.qml">src/QmlControls/QGCViewPanel.qml</file> <file alias="QGroundControl/Controls/QGCViewPanel.qml">src/QmlControls/QGCViewPanel.qml</file>
<file alias="QGroundControl/Controls/qmldir">src/QmlControls/QGroundControl.Controls.qmldir</file> <file alias="QGroundControl/Controls/qmldir">src/QmlControls/QGroundControl.Controls.qmldir</file>
<file alias="QGroundControl/Controls/RallyPointEditorHeader.qml">src/MissionEditor/RallyPointEditorHeader.qml</file> <file alias="QGroundControl/Controls/RallyPointEditorHeader.qml">src/PlanView/RallyPointEditorHeader.qml</file>
<file alias="QGroundControl/Controls/RallyPointItemEditor.qml">src/MissionEditor/RallyPointItemEditor.qml</file> <file alias="QGroundControl/Controls/RallyPointItemEditor.qml">src/PlanView/RallyPointItemEditor.qml</file>
<file alias="QGroundControl/Controls/RCChannelMonitor.qml">src/QmlControls/RCChannelMonitor.qml</file> <file alias="QGroundControl/Controls/RCChannelMonitor.qml">src/QmlControls/RCChannelMonitor.qml</file>
<file alias="QGroundControl/Controls/RoundButton.qml">src/QmlControls/RoundButton.qml</file> <file alias="QGroundControl/Controls/RoundButton.qml">src/QmlControls/RoundButton.qml</file>
<file alias="QGroundControl/Controls/SectionHeader.qml">src/MissionEditor/SectionHeader.qml</file> <file alias="QGroundControl/Controls/SectionHeader.qml">src/PlanView/SectionHeader.qml</file>
<file alias="QGroundControl/Controls/SetupPage.qml">src/AutoPilotPlugins/Common/SetupPage.qml</file> <file alias="QGroundControl/Controls/SetupPage.qml">src/AutoPilotPlugins/Common/SetupPage.qml</file>
<file alias="QGroundControl/Controls/SignalStrength.qml">src/ui/toolbar/SignalStrength.qml</file> <file alias="QGroundControl/Controls/SignalStrength.qml">src/ui/toolbar/SignalStrength.qml</file>
<file alias="QGroundControl/Controls/SimpleItemMapVisual.qml">src/MissionEditor/SimpleItemMapVisual.qml</file> <file alias="QGroundControl/Controls/SimpleItemMapVisual.qml">src/PlanView/SimpleItemMapVisual.qml</file>
<file alias="QGroundControl/Controls/SliderSwitch.qml">src/QmlControls/SliderSwitch.qml</file> <file alias="QGroundControl/Controls/SliderSwitch.qml">src/QmlControls/SliderSwitch.qml</file>
<file alias="QGroundControl/Controls/SubMenuButton.qml">src/QmlControls/SubMenuButton.qml</file> <file alias="QGroundControl/Controls/SubMenuButton.qml">src/QmlControls/SubMenuButton.qml</file>
<file alias="QGroundControl/Controls/SurveyMapVisual.qml">src/MissionEditor/SurveyMapVisual.qml</file> <file alias="QGroundControl/Controls/SurveyMapVisual.qml">src/PlanView/SurveyMapVisual.qml</file>
<file alias="QGroundControl/Controls/VehicleRotationCal.qml">src/QmlControls/VehicleRotationCal.qml</file> <file alias="QGroundControl/Controls/VehicleRotationCal.qml">src/QmlControls/VehicleRotationCal.qml</file>
<file alias="QGroundControl/Controls/VehicleSummaryRow.qml">src/QmlControls/VehicleSummaryRow.qml</file> <file alias="QGroundControl/Controls/VehicleSummaryRow.qml">src/QmlControls/VehicleSummaryRow.qml</file>
<file alias="QGroundControl/Controls/ToolStrip.qml">src/QmlControls/ToolStrip.qml</file> <file alias="QGroundControl/Controls/ToolStrip.qml">src/QmlControls/ToolStrip.qml</file>
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
<file alias="QGroundControl/FlightMap/QGCCompassWidget.qml">src/FlightMap/Widgets/QGCCompassWidget.qml</file> <file alias="QGroundControl/FlightMap/QGCCompassWidget.qml">src/FlightMap/Widgets/QGCCompassWidget.qml</file>
<file alias="QGCInstrumentWidget.qml">src/FlightMap/Widgets/QGCInstrumentWidget.qml</file> <file alias="QGCInstrumentWidget.qml">src/FlightMap/Widgets/QGCInstrumentWidget.qml</file>
<file alias="QGCInstrumentWidgetAlternate.qml">src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml</file> <file alias="QGCInstrumentWidgetAlternate.qml">src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml</file>
<file alias="QGroundControl/FlightMap/QGCMapPolygonControls.qml">src/MissionEditor/QGCMapPolygonControls.qml</file> <file alias="QGroundControl/FlightMap/QGCMapPolygonControls.qml">src/PlanView/QGCMapPolygonControls.qml</file>
<file alias="QGroundControl/FlightMap/QGCPitchIndicator.qml">src/FlightMap/Widgets/QGCPitchIndicator.qml</file> <file alias="QGroundControl/FlightMap/QGCPitchIndicator.qml">src/FlightMap/Widgets/QGCPitchIndicator.qml</file>
<file alias="QGroundControl/FlightMap/QGCVideoBackground.qml">src/FlightMap/QGCVideoBackground.qml</file> <file alias="QGroundControl/FlightMap/QGCVideoBackground.qml">src/FlightMap/QGCVideoBackground.qml</file>
<file alias="QGroundControl/FlightMap/qmldir">src/FlightMap/qmldir</file> <file alias="QGroundControl/FlightMap/qmldir">src/FlightMap/qmldir</file>
...@@ -168,10 +168,10 @@ ...@@ -168,10 +168,10 @@
<file alias="SerialSettings.qml">src/ui/preferences/SerialSettings.qml</file> <file alias="SerialSettings.qml">src/ui/preferences/SerialSettings.qml</file>
<file alias="SetupParameterEditor.qml">src/VehicleSetup/SetupParameterEditor.qml</file> <file alias="SetupParameterEditor.qml">src/VehicleSetup/SetupParameterEditor.qml</file>
<file alias="SetupView.qml">src/VehicleSetup/SetupView.qml</file> <file alias="SetupView.qml">src/VehicleSetup/SetupView.qml</file>
<file alias="SimpleItemEditor.qml">src/MissionEditor/SimpleItemEditor.qml</file> <file alias="SimpleItemEditor.qml">src/PlanView/SimpleItemEditor.qml</file>
<file alias="SurveyItemEditor.qml">src/MissionEditor/SurveyItemEditor.qml</file> <file alias="SurveyItemEditor.qml">src/PlanView/SurveyItemEditor.qml</file>
<file alias="FWLandingPatternEditor.qml">src/MissionEditor/FWLandingPatternEditor.qml</file> <file alias="FWLandingPatternEditor.qml">src/PlanView/FWLandingPatternEditor.qml</file>
<file alias="MissionSettingsEditor.qml">src/MissionEditor/MissionSettingsEditor.qml</file> <file alias="MissionSettingsEditor.qml">src/PlanView/MissionSettingsEditor.qml</file>
<file alias="TcpSettings.qml">src/ui/preferences/TcpSettings.qml</file> <file alias="TcpSettings.qml">src/ui/preferences/TcpSettings.qml</file>
<file alias="test.qml">src/test.qml</file> <file alias="test.qml">src/test.qml</file>
<file alias="UdpSettings.qml">src/ui/preferences/UdpSettings.qml</file> <file alias="UdpSettings.qml">src/ui/preferences/UdpSettings.qml</file>
......
...@@ -34,42 +34,54 @@ FlightMap { ...@@ -34,42 +34,54 @@ FlightMap {
property var qgcView ///< QGCView control which contains this map property var qgcView ///< QGCView control which contains this map
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _activeVehicleCoordinateValid: _activeVehicle ? _activeVehicle.coordinateValid : false property var _activeVehicleCoordinate: _activeVehicle ? _activeVehicle.coordinate : QtPositioning.coordinate()
property var activeVehicleCoordinate: _activeVehicle ? _activeVehicle.coordinate : QtPositioning.coordinate()
property var _gotoHereCoordinate: QtPositioning.coordinate() property var _gotoHereCoordinate: QtPositioning.coordinate()
property int _retaskSequence: 0 property int _retaskSequence: 0
property real _toolButtonTopMargin: parent.height - ScreenTools.availableHeight + (ScreenTools.defaultFontPixelHeight / 2) property real _toolButtonTopMargin: parent.height - ScreenTools.availableHeight + (ScreenTools.defaultFontPixelHeight / 2)
property bool _disableVehicleTracking: false property bool _disableVehicleTracking: false
property bool _keepVehicleCentered: _mainIsMap ? false : true property bool _keepVehicleCentered: _mainIsMap ? false : true
property bool _followVehicleSetting: true ///< User facing setting for follow vehicle property bool _firstVehiclePositionReceived: false
property bool _followVehicle: _followVehicleSetting && _activeVehicleCoordinateValid ///< Control map follow vehicle functionality property bool _userPanned: false
property bool _firstVehiclePosition: true
Component.onCompleted: { Component.onCompleted: {
QGroundControl.flightMapPosition = center QGroundControl.flightMapPosition = center
QGroundControl.flightMapZoom = zoomLevel QGroundControl.flightMapZoom = zoomLevel
possibleCenterToGCSPosition()
} }
// Track last known map position and zoom in settings
onZoomLevelChanged: QGroundControl.flightMapZoom = zoomLevel onZoomLevelChanged: QGroundControl.flightMapZoom = zoomLevel
onCenterChanged: QGroundControl.flightMapPosition = center
// We move the map to the gcs position id:
// - We don't have a vehicle position yet
// - The user has not futzed with the map
onGcsPositionChanged: possibleCenterToGCSPosition()
function possibleCenterToGCSPosition() {
if (!_firstVehiclePositionReceived && !_userPanned && gcsPosition.isValid) {
center = gcsPosition
}
}
// When the user pans the map we leave things alone until the panRecenterTimer fires // When the user pans the map we stop responding to vehicle coordinate updates until the panRecenterTimer fires
Connections { Connections {
target: gesture target: gesture
onPanFinished: { onPanFinished: {
_userPanned = true
_disableVehicleTracking = true _disableVehicleTracking = true
panRecenterTimer.start() panRecenterTimer.start()
} }
onFlickFinished: { onFlickFinished: {
_userPanned = true
_disableVehicleTracking = true _disableVehicleTracking = true
panRecenterTimer.start() panRecenterTimer.start()
} }
} }
onCenterChanged: QGroundControl.flightMapPosition = center
function pointInRect(point, rect) { function pointInRect(point, rect) {
return point.x > rect.x && return point.x > rect.x &&
point.x < rect.x + rect.width && point.x < rect.x + rect.width &&
...@@ -100,22 +112,22 @@ FlightMap { ...@@ -100,22 +112,22 @@ FlightMap {
} }
function recenterNeeded() { function recenterNeeded() {
var vehiclePoint = flightMap.fromCoordinate(activeVehicleCoordinate, false /* clipToViewport */) var vehiclePoint = flightMap.fromCoordinate(_activeVehicleCoordinate, false /* clipToViewport */)
var centerViewport = Qt.rect(0, 0, width, height) var centerViewport = Qt.rect(0, 0, width, height)
return !pointInRect(vehiclePoint, centerViewport) return !pointInRect(vehiclePoint, centerViewport)
} }
function updateMapToVehiclePosition() { function updateMapToVehiclePosition() {
if (_followVehicle && !_disableVehicleTracking) { if (_activeVehicleCoordinate.isValid && !_disableVehicleTracking) {
if (_keepVehicleCentered) { if (_keepVehicleCentered) {
_firstVehiclePosition = true _firstVehiclePositionReceived = true
flightMap.center = activeVehicleCoordinate flightMap.center = _activeVehicleCoordinate
} else { } else {
if (_firstVehiclePosition) { if (!_firstVehiclePositionReceived) {
_firstVehiclePosition = false _firstVehiclePositionReceived = true
flightMap.center = activeVehicleCoordinate flightMap.center = _activeVehicleCoordinate
} else if (recenterNeeded()) { } else if (recenterNeeded()) {
animatedMapRecenter(flightMap.center, activeVehicleCoordinate) animatedMapRecenter(flightMap.center, _activeVehicleCoordinate)
} }
} }
} }
...@@ -266,10 +278,6 @@ FlightMap { ...@@ -266,10 +278,6 @@ FlightMap {
CenterMapDropPanel { CenterMapDropPanel {
map: _flightMap map: _flightMap
fitFunctions: mapFitFunctions fitFunctions: mapFitFunctions
showFollowVehicle: true
followVehicle: _followVehicleSetting
onFollowVehicleChanged: _followVehicleSetting = followVehicle
} }
} }
......
...@@ -7,13 +7,6 @@ ...@@ -7,13 +7,6 @@
* *
****************************************************************************/ ****************************************************************************/
/**
* @file
* @brief QGC Map Background
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import QtLocation 5.3 import QtLocation 5.3
...@@ -27,34 +20,21 @@ import QGroundControl.ScreenTools 1.0 ...@@ -27,34 +20,21 @@ import QGroundControl.ScreenTools 1.0
import QGroundControl.MultiVehicleManager 1.0 import QGroundControl.MultiVehicleManager 1.0
import QGroundControl.Vehicle 1.0 import QGroundControl.Vehicle 1.0
import QGroundControl.Mavlink 1.0 import QGroundControl.Mavlink 1.0
import QGroundControl.QGCPositionManager 1.0
Map { Map {
id: _map id: _map
zoomLevel: QGroundControl.flightMapZoom
center: QGroundControl.flightMapPosition
gesture.flickDeceleration: 3000
plugin: Plugin { name: "QGroundControl" }
property string mapName: 'defaultMap' property string mapName: 'defaultMap'
property bool isSatelliteMap: activeMapType.name.indexOf("Satellite") > -1 || activeMapType.name.indexOf("Hybrid") > -1 property bool isSatelliteMap: activeMapType.name.indexOf("Satellite") > -1 || activeMapType.name.indexOf("Hybrid") > -1
property var gcsPosition: QtPositioning.coordinate()
readonly property real maxZoomLevel: 20 readonly property real maxZoomLevel: 20
property variant scaleLengths: [5, 10, 25, 50, 100, 150, 250, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000, 2000000]
function formatDistance(meters)
{
var dist = Math.round(meters)
if (dist > 1000 ){
if (dist > 100000){
dist = Math.round(dist / 1000)
}
else{
dist = Math.round(dist / 100)
dist = dist / 10
}
dist = dist + " km"
}
else{
dist = dist + " m"
}
return dist
}
function setVisibleRegion(region) { function setVisibleRegion(region) {
// This works around a bug on Qt where if you set a visibleRegion and then the user moves or zooms the map // This works around a bug on Qt where if you set a visibleRegion and then the user moves or zooms the map
...@@ -64,13 +44,18 @@ Map { ...@@ -64,13 +44,18 @@ Map {
_map.visibleRegion = region _map.visibleRegion = region
} }
zoomLevel: 18 ExclusiveGroup { id: mapTypeGroup }
center: QGroundControl.lastKnownHomePosition
gesture.flickDeceleration: 3000
plugin: Plugin { name: "QGroundControl" } // Update ground station position
Connections {
target: QGroundControl.qgcPositionManger
ExclusiveGroup { id: mapTypeGroup } onLastPositionUpdated: {
if (valid && lastPosition.latitude && Math.abs(lastPosition.latitude) > 0.001 && lastPosition.longitude && Math.abs(lastPosition.longitude) > 0.001) {
gcsPosition = QtPositioning.coordinate(lastPosition.latitude,lastPosition.longitude)
}
}
}
function updateActiveMapType() { function updateActiveMapType() {
var settings = QGroundControl.settingsManager.flightMapSettings var settings = QGroundControl.settingsManager.flightMapSettings
...@@ -99,8 +84,8 @@ Map { ...@@ -99,8 +84,8 @@ Map {
MapQuickItem { MapQuickItem {
anchorPoint.x: sourceItem.anchorPointX anchorPoint.x: sourceItem.anchorPointX
anchorPoint.y: sourceItem.anchorPointY anchorPoint.y: sourceItem.anchorPointY
visible: mainWindow.gcsPosition.isValid visible: gcsPosition.isValid
coordinate: mainWindow.gcsPosition coordinate: gcsPosition
sourceItem: MissionItemIndexLabel { sourceItem: MissionItemIndexLabel {
label: "Q" label: "Q"
} }
......
...@@ -25,8 +25,6 @@ ColumnLayout { ...@@ -25,8 +25,6 @@ ColumnLayout {
property var fitFunctions property var fitFunctions
property bool showMission: true property bool showMission: true
property bool showAllItems: true property bool showAllItems: true
property bool showFollowVehicle: false
property bool followVehicle: false
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
...@@ -70,7 +68,7 @@ ColumnLayout { ...@@ -70,7 +68,7 @@ ColumnLayout {
QGCButton { QGCButton {
text: qsTr("Current Location") text: qsTr("Current Location")
Layout.fillWidth: true Layout.fillWidth: true
enabled: mainWindow.gcsPosition.isValid && !followVehicleCheckBox.checked enabled: mainWindow.gcsPosition.isValid
onClicked: { onClicked: {
dropPanel.hide() dropPanel.hide()
...@@ -81,23 +79,11 @@ ColumnLayout { ...@@ -81,23 +79,11 @@ ColumnLayout {
QGCButton { QGCButton {
text: qsTr("Vehicle") text: qsTr("Vehicle")
Layout.fillWidth: true Layout.fillWidth: true
enabled: _activeVehicle && _activeVehicle.latitude != 0 && _activeVehicle.longitude != 0 && !followVehicleCheckBox.checked enabled: _activeVehicle && _activeVehicle.coordinate.isValid
onClicked: { onClicked: {
dropPanel.hide() dropPanel.hide()
map.center = activeVehicle.coordinate map.center = activeVehicle.coordinate
} }
} }
QGCCheckBox {
id: followVehicleCheckBox
text: qsTr("Follow Vehicle")
checked: followVehicle
visible: showFollowVehicle
onClicked: {
dropPanel.hide()
root.followVehicle = checked
}
}
} // Column } // Column
This diff is collapsed.
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
class CoordinateVector; class CoordinateVector;
class VisualMissionItem; class VisualMissionItem;
class MissionItem; class MissionItem;
class MissionSettingsItem;
Q_DECLARE_LOGGING_CATEGORY(MissionControllerLog) Q_DECLARE_LOGGING_CATEGORY(MissionControllerLog)
...@@ -50,7 +51,6 @@ public: ...@@ -50,7 +51,6 @@ public:
} MissionFlightStatus_t; } MissionFlightStatus_t;
// Mission settings // Mission settings
Q_PROPERTY(QGeoCoordinate plannedHomePosition READ plannedHomePosition NOTIFY plannedHomePositionChanged)
Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged) Q_PROPERTY(QmlObjectListModel* visualItems READ visualItems NOTIFY visualItemsChanged)
Q_PROPERTY(QmlObjectListModel* waypointLines READ waypointLines NOTIFY waypointLinesChanged) Q_PROPERTY(QmlObjectListModel* waypointLines READ waypointLines NOTIFY waypointLinesChanged)
Q_PROPERTY(QStringList complexMissionItemNames READ complexMissionItemNames NOTIFY complexMissionItemNamesChanged) Q_PROPERTY(QStringList complexMissionItemNames READ complexMissionItemNames NOTIFY complexMissionItemNamesChanged)
...@@ -107,7 +107,6 @@ public: ...@@ -107,7 +107,6 @@ public:
// Property accessors // Property accessors
QGeoCoordinate plannedHomePosition (void);
QmlObjectListModel* visualItems (void) { return _visualItems; } QmlObjectListModel* visualItems (void) { return _visualItems; }
QmlObjectListModel* waypointLines (void) { return &_waypointLines; } QmlObjectListModel* waypointLines (void) { return &_waypointLines; }
QStringList complexMissionItemNames (void) const; QStringList complexMissionItemNames (void) const;
...@@ -121,7 +120,6 @@ public: ...@@ -121,7 +120,6 @@ public:
double missionMaxTelemetry (void) const { return _missionFlightStatus.maxTelemetryDistance; } double missionMaxTelemetry (void) const { return _missionFlightStatus.maxTelemetryDistance; }
signals: signals:
void plannedHomePositionChanged(QGeoCoordinate plannedHomePosition);
void visualItemsChanged(void); void visualItemsChanged(void);
void waypointLinesChanged(void); void waypointLinesChanged(void);
void newItemsFromVehicle(void); void newItemsFromVehicle(void);
...@@ -137,13 +135,11 @@ signals: ...@@ -137,13 +135,11 @@ signals:
private slots: private slots:
void _newMissionItemsAvailableFromVehicle(bool removeAllRequested); void _newMissionItemsAvailableFromVehicle(bool removeAllRequested);
void _itemCommandChanged(void); void _itemCommandChanged(void);
void _activeVehicleHomePositionAvailableChanged(bool homePositionAvailable);
void _activeVehicleHomePositionChanged(const QGeoCoordinate& homePosition); void _activeVehicleHomePositionChanged(const QGeoCoordinate& homePosition);
void _inProgressChanged(bool inProgress); void _inProgressChanged(bool inProgress);
void _currentMissionItemChanged(int sequenceNumber); void _currentMissionItemChanged(int sequenceNumber);
void _recalcWaypointLines(void); void _recalcWaypointLines(void);
void _recalcMissionFlightStatus(void); void _recalcMissionFlightStatus(void);
void _homeCoordinateChanged(void);
void _updateContainsItems(void); void _updateContainsItems(void);
private: private:
...@@ -176,6 +172,7 @@ private: ...@@ -176,6 +172,7 @@ private:
void _setMissionMaxTelemetry(double missionMaxTelemetry); void _setMissionMaxTelemetry(double missionMaxTelemetry);
static void _scanForAdditionalSettings(QmlObjectListModel* visualItems, Vehicle* vehicle); static void _scanForAdditionalSettings(QmlObjectListModel* visualItems, Vehicle* vehicle);
static bool _convertToMissionItems(QmlObjectListModel* visualMissionItems, QList<MissionItem*>& rgMissionItems, QObject* missionItemParent); static bool _convertToMissionItems(QmlObjectListModel* visualMissionItems, QList<MissionItem*>& rgMissionItems, QObject* missionItemParent);
void _setPlannedHomePositionFromFirstCoordinate(void);
// Overrides from PlanElementController // Overrides from PlanElementController
void _activeVehicleBeingRemoved(void) final; void _activeVehicleBeingRemoved(void) final;
...@@ -183,6 +180,7 @@ private: ...@@ -183,6 +180,7 @@ private:
private: private:
QmlObjectListModel* _visualItems; QmlObjectListModel* _visualItems;
MissionSettingsItem* _settingsItem;
QmlObjectListModel _waypointLines; QmlObjectListModel _waypointLines;
CoordVectHashTable _linesTable; CoordVectHashTable _linesTable;
bool _firstItemsFromVehicle; bool _firstItemsFromVehicle;
......
[ [
{
"name": "PlannedHomePositionLatitude",
"shortDescription": "Planned home position latitude",
"type": "double",
"decimalPlaces": 7,
"defaultValue": 37.803784
},
{
"name": "PlannedHomePositionLongitude",
"shortDescription": "Planned home position longitude",
"type": "double",
"decimalPlaces": 7,
"defaultValue": -122.462276
},
{ {
"name": "PlannedHomePositionAltitude", "name": "PlannedHomePositionAltitude",
"shortDescription": "Planned home position altitude", "shortDescription": "Planned home position altitude",
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
Q_DECLARE_LOGGING_CATEGORY(MissionSettingsComplexItemLog) Q_DECLARE_LOGGING_CATEGORY(MissionSettingsComplexItemLog)
class MissionSettingsComplexItem : public ComplexMissionItem class MissionSettingsItem : public ComplexMissionItem
{ {
Q_OBJECT Q_OBJECT
public: public:
MissionSettingsComplexItem(Vehicle* vehicle, QObject* parent = NULL); MissionSettingsItem(Vehicle* vehicle, QObject* parent = NULL);
enum MissionEndAction { enum MissionEndAction {
MissionEndNoAction, MissionEndNoAction,
...@@ -36,14 +36,10 @@ public: ...@@ -36,14 +36,10 @@ public:
Q_PROPERTY(bool specifyMissionFlightSpeed READ specifyMissionFlightSpeed WRITE setSpecifyMissionFlightSpeed NOTIFY specifyMissionFlightSpeedChanged) Q_PROPERTY(bool specifyMissionFlightSpeed READ specifyMissionFlightSpeed WRITE setSpecifyMissionFlightSpeed NOTIFY specifyMissionFlightSpeedChanged)
Q_PROPERTY(Fact* missionFlightSpeed READ missionFlightSpeed CONSTANT) Q_PROPERTY(Fact* missionFlightSpeed READ missionFlightSpeed CONSTANT)
Q_PROPERTY(Fact* missionEndAction READ missionEndAction CONSTANT) Q_PROPERTY(Fact* missionEndAction READ missionEndAction CONSTANT)
Q_PROPERTY(Fact* plannedHomePositionLatitude READ plannedHomePositionLatitude CONSTANT)
Q_PROPERTY(Fact* plannedHomePositionLongitude READ plannedHomePositionLongitude CONSTANT)
Q_PROPERTY(Fact* plannedHomePositionAltitude READ plannedHomePositionAltitude CONSTANT) Q_PROPERTY(Fact* plannedHomePositionAltitude READ plannedHomePositionAltitude CONSTANT)
Q_PROPERTY(QObject* cameraSection READ cameraSection CONSTANT) Q_PROPERTY(QObject* cameraSection READ cameraSection CONSTANT)
bool specifyMissionFlightSpeed (void) const { return _specifyMissionFlightSpeed; } bool specifyMissionFlightSpeed (void) const { return _specifyMissionFlightSpeed; }
Fact* plannedHomePositionLatitude (void) { return &_plannedHomePositionLatitudeFact; }
Fact* plannedHomePositionLongitude(void) { return &_plannedHomePositionLongitudeFact; }
Fact* plannedHomePositionAltitude (void) { return &_plannedHomePositionAltitudeFact; } Fact* plannedHomePositionAltitude (void) { return &_plannedHomePositionAltitudeFact; }
Fact* missionFlightSpeed (void) { return &_missionFlightSpeedFact; } Fact* missionFlightSpeed (void) { return &_missionFlightSpeedFact; }
Fact* missionEndAction (void) { return &_missionEndActionFact; } Fact* missionEndAction (void) { return &_missionEndActionFact; }
...@@ -79,8 +75,8 @@ public: ...@@ -79,8 +75,8 @@ public:
QString commandDescription (void) const final { return "Mission Settings"; } QString commandDescription (void) const final { return "Mission Settings"; }
QString commandName (void) const final { return "Mission Settings"; } QString commandName (void) const final { return "Mission Settings"; }
QString abbreviation (void) const final { return "H"; } QString abbreviation (void) const final { return "H"; }
QGeoCoordinate coordinate (void) const final; QGeoCoordinate coordinate (void) const final { return _plannedHomePositionCoordinate; }
QGeoCoordinate exitCoordinate (void) const final { return coordinate(); } QGeoCoordinate exitCoordinate (void) const final { return _plannedHomePositionCoordinate; }
int sequenceNumber (void) const final { return _sequenceNumber; } int sequenceNumber (void) const final { return _sequenceNumber; }
double specifiedFlightSpeed (void) final; double specifiedFlightSpeed (void) final;
double specifiedGimbalYaw (void) final; double specifiedGimbalYaw (void) final;
...@@ -102,14 +98,13 @@ signals: ...@@ -102,14 +98,13 @@ signals:
private slots: private slots:
void _setDirtyAndUpdateLastSequenceNumber (void); void _setDirtyAndUpdateLastSequenceNumber (void);
void _setDirtyAndUpdateCoordinate (void);
void _setDirty (void); void _setDirty (void);
void _cameraSectionDirtyChanged (bool dirty); void _cameraSectionDirtyChanged (bool dirty);
void _updateAltitudeInCoordinate (QVariant value);
private: private:
bool _specifyMissionFlightSpeed; bool _specifyMissionFlightSpeed;
Fact _plannedHomePositionLatitudeFact; QGeoCoordinate _plannedHomePositionCoordinate; // Does not include altitde
Fact _plannedHomePositionLongitudeFact;
Fact _plannedHomePositionAltitudeFact; Fact _plannedHomePositionAltitudeFact;
Fact _missionFlightSpeedFact; Fact _missionFlightSpeedFact;
Fact _missionEndActionFact; Fact _missionEndActionFact;
...@@ -120,8 +115,6 @@ private: ...@@ -120,8 +115,6 @@ private:
static QMap<QString, FactMetaData*> _metaDataMap;