diff --git a/src/MissionManager/MissionController.cc b/src/MissionManager/MissionController.cc index bc085196e1486577ef467330e344155b145997b1..9505a1bd9bf46398b36336b443d2d0cddf1a623d 100644 --- a/src/MissionManager/MissionController.cc +++ b/src/MissionManager/MissionController.cc @@ -395,9 +395,8 @@ VisualMissionItem* MissionController::insertSimpleMissionItem(QGeoCoordinate coo VisualMissionItem* MissionController::insertTakeoffItem(QGeoCoordinate /*coordinate*/, int visualItemIndex, bool makeCurrentItem) { int sequenceNumber = _nextSequenceNumber(); - TakeoffMissionItem * newItem = new TakeoffMissionItem(_controllerVehicle->vtol() ? MAV_CMD_NAV_VTOL_TAKEOFF : MAV_CMD_NAV_TAKEOFF, _controllerVehicle, _flyView, _settingsItem, this); + TakeoffMissionItem * newItem = new TakeoffMissionItem(_controllerVehicle->vtol() ? MAV_CMD_NAV_VTOL_TAKEOFF : MAV_CMD_NAV_TAKEOFF, _managerVehicle, _flyView, _settingsItem, this); newItem->setSequenceNumber(sequenceNumber); - newItem->setWizardMode(true); _initVisualItem(newItem); if (newItem->specifiesAltitude()) { @@ -1705,8 +1704,6 @@ void MissionController::_initAllVisualItems(void) } } - _settingsItem->setHomePositionFromVehicle(_managerVehicle); - connect(_settingsItem, &MissionSettingsItem::coordinateChanged, this, &MissionController::_recalcAll); connect(_settingsItem, &MissionSettingsItem::coordinateChanged, this, &MissionController::plannedHomePositionChanged); @@ -1831,7 +1828,7 @@ bool MissionController::_findPreviousAltitude(int newIndex, double* prevAltitude { bool found = false; double foundAltitude = 0; - int foundAltitudeMode; + int foundAltitudeMode = QGroundControlQmlGlobal::AltitudeModeNone; if (newIndex > _visualItems->count()) { return false; @@ -1879,9 +1876,8 @@ MissionSettingsItem* MissionController::_addMissionSettings(QmlObjectListModel* { qCDebug(MissionControllerLog) << "_addMissionSettings"; - MissionSettingsItem* settingsItem = new MissionSettingsItem(_controllerVehicle, _flyView, visualItems); + MissionSettingsItem* settingsItem = new MissionSettingsItem(_managerVehicle, _flyView, visualItems); visualItems->insert(0, settingsItem); - settingsItem->setHomePositionFromVehicle(_managerVehicle); if (visualItems == _visualItems) { _settingsItem = settingsItem; diff --git a/src/MissionManager/MissionSettingsItem.cc b/src/MissionManager/MissionSettingsItem.cc index c4fa6934aa230275d8f6224dc4b29d84eb28a2ff..9d13a50efed5732ae4616fe952262efbdb36fcf6 100644 --- a/src/MissionManager/MissionSettingsItem.cc +++ b/src/MissionManager/MissionSettingsItem.cc @@ -47,17 +47,16 @@ MissionSettingsItem::MissionSettingsItem(Vehicle* vehicle, bool flyView, QObject connect(this, &MissionSettingsItem::specifyMissionFlightSpeedChanged, this, &MissionSettingsItem::_setDirtyAndUpdateLastSequenceNumber); connect(&_cameraSection, &CameraSection::itemCountChanged, this, &MissionSettingsItem::_setDirtyAndUpdateLastSequenceNumber); connect(&_speedSection, &CameraSection::itemCountChanged, this, &MissionSettingsItem::_setDirtyAndUpdateLastSequenceNumber); - connect(this, &MissionSettingsItem::terrainAltitudeChanged, this, &MissionSettingsItem::_setHomeAltFromTerrain); - + connect(&_cameraSection, &CameraSection::dirtyChanged, this, &MissionSettingsItem::_sectionDirtyChanged); + connect(&_speedSection, &SpeedSection::dirtyChanged, this, &MissionSettingsItem::_sectionDirtyChanged); + connect(&_cameraSection, &CameraSection::specifiedGimbalYawChanged, this, &MissionSettingsItem::specifiedGimbalYawChanged); + connect(&_cameraSection, &CameraSection::specifiedGimbalPitchChanged, this, &MissionSettingsItem::specifiedGimbalPitchChanged); + connect(&_speedSection, &SpeedSection::specifiedFlightSpeedChanged, this, &MissionSettingsItem::specifiedFlightSpeedChanged); + connect(_vehicle, &Vehicle::homePositionChanged, this, &MissionSettingsItem::_updateHomePosition); connect(&_plannedHomePositionAltitudeFact, &Fact::rawValueChanged, this, &MissionSettingsItem::_updateAltitudeInCoordinate); - connect(&_cameraSection, &CameraSection::dirtyChanged, this, &MissionSettingsItem::_sectionDirtyChanged); - connect(&_speedSection, &SpeedSection::dirtyChanged, this, &MissionSettingsItem::_sectionDirtyChanged); - - connect(&_cameraSection, &CameraSection::specifiedGimbalYawChanged, this, &MissionSettingsItem::specifiedGimbalYawChanged); - connect(&_cameraSection, &CameraSection::specifiedGimbalPitchChanged, this, &MissionSettingsItem::specifiedGimbalPitchChanged); - connect(&_speedSection, &SpeedSection::specifiedFlightSpeedChanged, this, &MissionSettingsItem::specifiedFlightSpeedChanged); + _updateHomePosition(_vehicle->homePosition()); } int MissionSettingsItem::lastSequenceNumber(void) const @@ -285,3 +284,10 @@ QString MissionSettingsItem::abbreviation(void) const { return _flyView ? tr("H") : tr("Launch"); } + +void MissionSettingsItem::_updateHomePosition(const QGeoCoordinate& homePosition) +{ + if (_flyView) { + setCoordinate(homePosition); + } +} diff --git a/src/MissionManager/MissionSettingsItem.h b/src/MissionManager/MissionSettingsItem.h index 62d4d2caff4082285c1351b586e371aa43303266..61062e9b2af059129edbff09d2e039555910120e 100644 --- a/src/MissionManager/MissionSettingsItem.h +++ b/src/MissionManager/MissionSettingsItem.h @@ -100,6 +100,7 @@ private slots: void _updateAltitudeInCoordinate (QVariant value); void _setHomeAltFromTerrain (double terrainAltitude); void _setCoordinateWorker (const QGeoCoordinate& coordinate); + void _updateHomePosition (const QGeoCoordinate& homePosition); private: QGeoCoordinate _plannedHomePositionCoordinate; // Does not include altitude diff --git a/src/MissionManager/TakeoffMissionItem.cc b/src/MissionManager/TakeoffMissionItem.cc index eb448fe8fae7e169c371866c18463e2346246908..ab0d11716e79813401b24c6361f86008e0b2f9ea 100644 --- a/src/MissionManager/TakeoffMissionItem.cc +++ b/src/MissionManager/TakeoffMissionItem.cc @@ -58,6 +58,13 @@ void TakeoffMissionItem::_init(void) _initLaunchTakeoffAtSameLocation(); + if (_launchTakeoffAtSameLocation && homePosition.isValid()) { + _wizardMode = false; + SimpleMissionItem::setCoordinate(homePosition); + } else { + _wizardMode = true; + } + setDirty(false); }