Commit 8b938a34 authored by Don Gagne's avatar Don Gagne

Copy Fly view position to Plan

Also added Center to Mission support
parent 5a90520b
......@@ -44,6 +44,9 @@ FlightMap {
property bool _activeVehicleCoordinateValid: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.coordinateValid : false
property var activeVehicleCoordinate: multiVehicleManager.activeVehicle ? multiVehicleManager.activeVehicle.coordinate : QtPositioning.coordinate()
Component.onCompleted: QGroundControl.flightMapPosition = center
onCenterChanged: QGroundControl.flightMapPosition = center
onActiveVehicleCoordinateChanged: {
if (_followVehicle && _activeVehicleCoordinateValid && activeVehicleCoordinate.isValid) {
_initialMapPositionSet = true
......
......@@ -67,7 +67,6 @@ QGCView {
property bool _syncInProgress: _activeVehicle ? _activeVehicle.missionManager.inProgress : false
Component.onCompleted: updateMapToVehiclePosition()
onActiveVehiclePositionChanged: updateMapToVehiclePosition()
Connections {
......@@ -106,29 +105,32 @@ QGCView {
return lon + 180.0
}
/// Fix the map viewport to the current mission items. We don't fit the home position in this process.
/// Fix the map viewport to the current mission items.
function fitViewportToMissionItems() {
var missionItem = _missionItems.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<_missionItems.count; i++) {
missionItem = _missionItems.get(i)
if (missionItem.specifiesCoordinate && !missionItem.standaloneCoordinate) {
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)
if (_missionItems.count == 1) {
editorMap.center = _missionItems.get(0).coordinate
} else {
var missionItem = _missionItems.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<_missionItems.count; i++) {
missionItem = _missionItems.get(i)
if (missionItem.specifiesCoordinate && !missionItem.standaloneCoordinate) {
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)
}
}
editorMap.visibleRegion = QtPositioning.rectangle(QtPositioning.coordinate(north - 90.0, west - 180.0), QtPositioning.coordinate(south - 90.0, east - 180.0))
}
editorMap.visibleRegion = QtPositioning.rectangle(QtPositioning.coordinate(north - 90.0, west - 180.0), QtPositioning.coordinate(south - 90.0, east - 180.0))
}
MissionController {
......@@ -224,6 +226,9 @@ QGCView {
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
......@@ -474,6 +479,15 @@ QGCView {
}
}
QGCButton {
text: "Mission"
onClicked: {
centerMapButton.hideDropDown()
fitViewportToMissionItems()
}
}
QGCButton {
text: "Vehicle"
enabled: activeVehicle && activeVehicle.latitude != 0 && activeVehicle.longitude != 0
......
......@@ -76,6 +76,7 @@ public:
Q_PROPERTY(Fact* offlineEditingFirmwareType READ offlineEditingFirmwareType CONSTANT)
Q_PROPERTY(QGeoCoordinate lastKnownHomePosition READ lastKnownHomePosition CONSTANT)
Q_PROPERTY(QGeoCoordinate flightMapPosition MEMBER _flightMapPosition NOTIFY flightMapPositionChanged)
Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue);
......@@ -142,6 +143,7 @@ signals:
void isMultiplexingEnabledChanged (bool enabled);
void isVersionCheckEnabledChanged (bool enabled);
void mavlinkSystemIDChanged (int id);
void flightMapPositionChanged (QGeoCoordinate flightMapPosition);
private:
FlightMapSettings* _flightMapSettings;
......@@ -152,6 +154,8 @@ private:
bool _virtualTabletJoystick;
QGeoCoordinate _flightMapPosition;
SettingsFact _offlineEditingFirmwareTypeFact;
FactMetaData _offlineEditingFirmwareTypeMetaData;
......
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