Commit a12cefae authored by Don Gagne's avatar Don Gagne

Merge pull request #2071 from DonLakeFlyer/TabletPosition

Use tablet position for initial Fly/Plan location
parents 3eca3cca 115d986d
...@@ -41,6 +41,9 @@ import QGroundControl.Controllers 1.0 ...@@ -41,6 +41,9 @@ import QGroundControl.Controllers 1.0
Item { Item {
id: root id: root
property alias latitude: flightMap.latitude
property alias longitude: flightMap.longitude
// Top margin for all widgets. Used to prevent overlap with the toolbar // Top margin for all widgets. Used to prevent overlap with the toolbar
property real topMargin: 0 property real topMargin: 0
...@@ -114,7 +117,6 @@ Item { ...@@ -114,7 +117,6 @@ Item {
QGroundControl.flightMapSettings.saveMapSetting(flightMap.mapName, _showMapBackgroundKey, setBool(_showMap)) QGroundControl.flightMapSettings.saveMapSetting(flightMap.mapName, _showMapBackgroundKey, setBool(_showMap))
} }
FlightMap { FlightMap {
id: flightMap id: flightMap
anchors.fill: parent anchors.fill: parent
...@@ -126,6 +128,8 @@ Item { ...@@ -126,6 +128,8 @@ Item {
property var rootVehicleCoordinate: _vehicleCoordinate property var rootVehicleCoordinate: _vehicleCoordinate
property bool rootLoadCompleted: false property bool rootLoadCompleted: false
property bool _followVehicle: true
onRootVehicleCoordinateChanged: updateMapPosition(false /* force */) onRootVehicleCoordinateChanged: updateMapPosition(false /* force */)
Component.onCompleted: flightMapDelayLoader.source = "FlightDisplayViewDelayLoadInner.qml" Component.onCompleted: flightMapDelayLoader.source = "FlightDisplayViewDelayLoadInner.qml"
...@@ -136,9 +140,6 @@ Item { ...@@ -136,9 +140,6 @@ Item {
flightMap.longitude = root._vehicleCoordinate.longitude flightMap.longitude = root._vehicleCoordinate.longitude
} }
} }
property bool _followVehicle: true
// Home position // Home position
MissionItemIndicator { MissionItemIndicator {
label: "H" label: "H"
...@@ -194,6 +195,11 @@ Item { ...@@ -194,6 +195,11 @@ Item {
id: flightMapDelayLoader id: flightMapDelayLoader
anchors.fill: parent anchors.fill: parent
} }
// Used to make pinch zoom work
MouseArea {
anchors.fill: parent
}
} // Flight Map } // Flight Map
Loader { Loader {
......
...@@ -60,10 +60,10 @@ QGCView { ...@@ -60,10 +60,10 @@ QGCView {
property var _homePositionManager: QGroundControl.homePositionManager property var _homePositionManager: QGroundControl.homePositionManager
property string _homePositionName: _homePositionManager.homePositions.get(0).name property string _homePositionName: _homePositionManager.homePositions.get(0).name
property var offlineHomePosition: _homePositionManager.homePositions.get(0).coordinate //property var offlineHomePosition: _homePositionManager.homePositions.get(0).coordinate
property var liveHomePosition: controller.liveHomePosition property var liveHomePosition: controller.liveHomePosition
property var liveHomePositionAvailable: controller.liveHomePositionAvailable property var liveHomePositionAvailable: controller.liveHomePositionAvailable
property var homePosition: offlineHomePosition // live or offline depending on state //property var homePosition: offlineHomePosition // live or offline depending on state
property bool _syncNeeded: controller.missionItems.dirty property bool _syncNeeded: controller.missionItems.dirty
property bool _syncInProgress: _activeVehicle ? _activeVehicle.missionManager.inProgress : false property bool _syncInProgress: _activeVehicle ? _activeVehicle.missionManager.inProgress : false
...@@ -103,13 +103,14 @@ QGCView { ...@@ -103,13 +103,14 @@ QGCView {
} }
function updateHomePosition() { function updateHomePosition() {
homePosition = liveHomePositionAvailable ? liveHomePosition : offlineHomePosition if (liveHomePositionAvailable) {
_missionItems.get(0).coordinate = homePosition _missionItems.get(0).coordinate = liveHomePosition
_missionItems.get(0).homePositionValid = true _missionItems.get(0).homePositionValid = true
}
} }
Component.onCompleted: updateHomePosition() Component.onCompleted: updateHomePosition()
onOfflineHomePositionChanged: updateHomePosition() //onOfflineHomePositionChanged: updateHomePosition()
onLiveHomePositionAvailableChanged: updateHomePosition() onLiveHomePositionAvailableChanged: updateHomePosition()
onLiveHomePositionChanged: updateHomePosition() onLiveHomePositionChanged: updateHomePosition()
...@@ -124,11 +125,8 @@ QGCView { ...@@ -124,11 +125,8 @@ QGCView {
id: editorMap id: editorMap
anchors.fill: parent anchors.fill: parent
mapName: "MissionEditor" mapName: "MissionEditor"
latitude: tabletPosition.latitude
Component.onCompleted: { longitude: tabletPosition.longitude
latitude = homePosition.latitude
longitude = homePosition.longitude
}
readonly property real animationDuration: 500 readonly property real animationDuration: 500
...@@ -161,8 +159,8 @@ QGCView { ...@@ -161,8 +159,8 @@ QGCView {
coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces) coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces) coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces) coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
if (homePositionManagerButton.checked) { if (false /*homePositionManagerButton.checked*/) {
offlineHomePosition = coordinate //offlineHomePosition = coordinate
} else if (addMissionItemsButton.checked) { } else if (addMissionItemsButton.checked) {
var index = controller.addMissionItem(coordinate) var index = controller.addMissionItem(coordinate)
addMissionItemsButtonAutoOffTimer.start() addMissionItemsButtonAutoOffTimer.start()
...@@ -242,7 +240,7 @@ QGCView { ...@@ -242,7 +240,7 @@ QGCView {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
width: _rightPanelWidth width: _rightPanelWidth
visible: !homePositionManagerButton.checked && _missionItems.count > 1 visible: _missionItems.count > 1
opacity: _rightPanelOpacity opacity: _rightPanelOpacity
z: editorMap.zOrderTopMost z: editorMap.zOrderTopMost
...@@ -259,7 +257,8 @@ QGCView { ...@@ -259,7 +257,8 @@ QGCView {
MissionItemEditor { MissionItemEditor {
missionItem: object missionItem: object
width: parent.width width: parent.width
readOnly: object.sequenceNumber == 0 && liveHomePositionAvailable readOnly: object.sequenceNumber == 0
visible: !readOnly || object.homePositionValid
onClicked: setCurrentItem(object.sequenceNumber) onClicked: setCurrentItem(object.sequenceNumber)
...@@ -283,6 +282,9 @@ QGCView { ...@@ -283,6 +282,9 @@ QGCView {
} }
} // Item - Mission Item editor } // Item - Mission Item editor
/*
Home Position Manager is commented out for now until a better implementation is completed
// Home Position Manager // Home Position Manager
Rectangle { Rectangle {
id: homePositionManager id: homePositionManager
...@@ -554,6 +556,7 @@ QGCView { ...@@ -554,6 +556,7 @@ QGCView {
} }
} // Column - Online view } // Column - Online view
} // Item - Home Position Manager } // Item - Home Position Manager
*/
// Help Panel // Help Panel
Rectangle { Rectangle {
...@@ -652,6 +655,9 @@ QGCView { ...@@ -652,6 +655,9 @@ QGCView {
"Delete the currently selected mission item." "Delete the currently selected mission item."
} }
/*
Home Position Manager commented until more complete implementation is done
Image { Image {
id: homePositionManagerHelpIcon id: homePositionManagerHelpIcon
anchors.topMargin: ScreenTools.defaultFontPixelHeight anchors.topMargin: ScreenTools.defaultFontPixelHeight
...@@ -674,11 +680,12 @@ QGCView { ...@@ -674,11 +680,12 @@ QGCView {
"When enabled, allows you to select/add/update flying field locations. " + "When enabled, allows you to select/add/update flying field locations. " +
"You can save multiple flying field locations for use while creating missions while you are not connected to your vehicle." "You can save multiple flying field locations for use while creating missions while you are not connected to your vehicle."
} }
*/
Image { Image {
id: mapCenterHelpIcon id: mapCenterHelpIcon
anchors.topMargin: ScreenTools.defaultFontPixelHeight anchors.topMargin: ScreenTools.defaultFontPixelHeight
anchors.top: homePositionManagerHelpText.bottom anchors.top: deleteHelpText.bottom
width: ScreenTools.defaultFontPixelHeight * 3 width: ScreenTools.defaultFontPixelHeight * 3
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
mipmap: true mipmap: true
...@@ -795,6 +802,9 @@ QGCView { ...@@ -795,6 +802,9 @@ QGCView {
} }
} }
/*
Home Position Manager commented until more complete implementation is done
RoundButton { RoundButton {
id: homePositionManagerButton id: homePositionManagerButton
anchors.margins: _margin anchors.margins: _margin
...@@ -804,12 +814,13 @@ QGCView { ...@@ -804,12 +814,13 @@ QGCView {
exclusiveGroup: _dropButtonsExclusiveGroup exclusiveGroup: _dropButtonsExclusiveGroup
z: editorMap.zOrderWidgets z: editorMap.zOrderWidgets
} }
*/
DropButton { DropButton {
id: centerMapButton id: centerMapButton
anchors.margins: _margin anchors.margins: _margin
anchors.left: parent.left anchors.left: parent.left
anchors.top: homePositionManagerButton.bottom anchors.top: deleteMissionItemButton.bottom
dropDirection: dropRight dropDirection: dropRight
buttonImage: "/qmlimages/MapCenter.svg" buttonImage: "/qmlimages/MapCenter.svg"
viewportMargins: ScreenTools.defaultFontPixelWidth / 2 viewportMargins: ScreenTools.defaultFontPixelWidth / 2
...@@ -824,11 +835,12 @@ QGCView { ...@@ -824,11 +835,12 @@ QGCView {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
QGCButton { QGCButton {
text: "Home" text: "Home"
enabled: liveHomePositionAvailable
onClicked: { onClicked: {
centerMapButton.hideDropDown() centerMapButton.hideDropDown()
editorMap.center = QtPositioning.coordinate(homePosition.latitude, homePosition.longitude) editorMap.center = liveHomePosition
} }
} }
......
...@@ -84,6 +84,21 @@ Item { ...@@ -84,6 +84,21 @@ Item {
toolbarLoader.source = "MainToolBar.qml" toolbarLoader.source = "MainToolBar.qml"
} }
// Detect tablet position
property var tabletPosition: QtPositioning.coordinate(37.803784, -122.462276)
PositionSource {
id: positionSource
updateInterval: 1000
active: ScreenTools.isMobile
onPositionChanged: {
tabletPosition = positionSource.position.coordinate
_root.latitude = tabletPosition.latitude
_root.longitude = tabletPosition.longitude
positionSource.active = false
}
}
Loader { Loader {
id: toolbarLoader id: toolbarLoader
width: parent.width width: parent.width
...@@ -110,7 +125,8 @@ Item { ...@@ -110,7 +125,8 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: false visible: false
property real zOrder: _root.zOrderTopMost property real zOrder: _root.zOrderTopMost
property var tabletPosition: _root.tabletPosition
} }
Loader { Loader {
...@@ -121,6 +137,7 @@ Item { ...@@ -121,6 +137,7 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: false visible: false
property real zOrder: _root.zOrderTopMost property real zOrder: _root.zOrderTopMost
property var tabletPosition: _root.tabletPosition
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment