diff --git a/src/MissionManager/GeoFenceController.cc b/src/MissionManager/GeoFenceController.cc index 64e89a5ccffa70b2bbafc4295056e2873a8faf2b..e9acf663ffdf1e63cafc4b706f0bd3402f111e1d 100644 --- a/src/MissionManager/GeoFenceController.cc +++ b/src/MissionManager/GeoFenceController.cc @@ -342,8 +342,10 @@ void GeoFenceController::_setReturnPointFromManager(QGeoCoordinate breachReturnP void GeoFenceController::_managerLoadComplete(void) { // Fly view always reloads on _loadComplete - // Plan view only reloads on _loadComplete if specifically requested - if (_flyView || _itemsRequested) { + // Plan view only reloads if: + // - Load was specifically requested + // - There is no current Plan + if (_flyView || _itemsRequested || isEmpty()) { _setReturnPointFromManager(_geoFenceManager->breachReturnPoint()); _setFenceFromManager(_geoFenceManager->polygons(), _geoFenceManager->circles()); setDirty(false); @@ -519,3 +521,9 @@ void GeoFenceController::_parametersReady(void) connect(_px4ParamCircularFenceFact, &Fact::rawValueChanged, this, &GeoFenceController::paramCircularFenceChanged); emit paramCircularFenceChanged(); } + +bool GeoFenceController::isEmpty(void) const +{ + return _polygons.count() == 0 && _circles.count() == 0 && !_breachReturnPoint.isValid(); + +} diff --git a/src/MissionManager/GeoFenceController.h b/src/MissionManager/GeoFenceController.h index 65c098d6916272fd8639ee41c7d669987b0f25d6..43d267dd36407e79af8883a24bbe2470124e4a21 100644 --- a/src/MissionManager/GeoFenceController.h +++ b/src/MissionManager/GeoFenceController.h @@ -82,7 +82,8 @@ public: QmlObjectListModel* circles (void) { return &_circles; } QGeoCoordinate breachReturnPoint (void) const { return _breachReturnPoint; } - void setBreachReturnPoint(const QGeoCoordinate& breachReturnPoint); + void setBreachReturnPoint (const QGeoCoordinate& breachReturnPoint); + bool isEmpty (void) const; signals: void breachReturnPointChanged (QGeoCoordinate breachReturnPoint); diff --git a/src/MissionManager/MissionController.cc b/src/MissionManager/MissionController.cc index 14c138de4b9b4eaea885cbe75470c5535b3a5144..69d577968c8378188c8391102654007be23bd895 100644 --- a/src/MissionManager/MissionController.cc +++ b/src/MissionManager/MissionController.cc @@ -148,8 +148,10 @@ void MissionController::_newMissionItemsAvailableFromVehicle(bool removeAllReque qCDebug(MissionControllerLog) << "_newMissionItemsAvailableFromVehicle flyView:count" << _flyView << _missionManager->missionItems().count(); // Fly view always reloads on _loadComplete - // Plan view only reloads on _loadComplete if specifically requested - if (_flyView || removeAllRequested || _itemsRequested || _visualItems->count() <= 1) { + // Plan view only reloads if: + // - Load was specifically requested + // - There is no current Plan + if (_flyView || removeAllRequested || _itemsRequested || isEmpty()) { // Fly Mode (accept if): // - Always accepts new items from the vehicle so Fly view is kept up to date // Edit Mode (accept if): @@ -2174,3 +2176,8 @@ void MissionController::_complexBoundingBoxChanged() { _updateTimer.start(UPDATE_TIMEOUT); } + +bool MissionController::isEmpty(void) const +{ + return _visualItems->count() <= 1; +} diff --git a/src/MissionManager/MissionController.h b/src/MissionManager/MissionController.h index 6fa43f346c8efae974d2945eaded4d2825c3a481..16d2c549cfcff22eb98b6f6443b4e999d0695ad0 100644 --- a/src/MissionManager/MissionController.h +++ b/src/MissionManager/MissionController.h @@ -196,6 +196,8 @@ public: int batteryChangePoint (void) const { return _missionFlightStatus.batteryChangePoint; } ///< -1 for not supported, 0 for not needed int batteriesRequired (void) const { return _missionFlightStatus.batteriesRequired; } ///< -1 for not supported + bool isEmpty (void) const; + // These are the names shown in the UI for the pattern items. They are public so custom builds can remove the ones // they don't want through the QGCCorePlugin:: static const QString patternFWLandingName; diff --git a/src/MissionManager/PlanMasterController.cc b/src/MissionManager/PlanMasterController.cc index c872b765fd3f79fd223f993ee2be4dd3e4ac44da..6cc9c256bee41adde985760f918cbefaa53814e1 100644 --- a/src/MissionManager/PlanMasterController.cc +++ b/src/MissionManager/PlanMasterController.cc @@ -576,3 +576,10 @@ bool PlanMasterController::syncInProgress(void) const _geoFenceController.syncInProgress() || _rallyPointController.syncInProgress(); } + +bool PlanMasterController::isEmpty(void) const +{ + return _missionController.isEmpty() && + _geoFenceController.isEmpty() && + _rallyPointController.isEmpty(); +} diff --git a/src/MissionManager/PlanMasterController.h b/src/MissionManager/PlanMasterController.h index fed93869e61c0911a1b0dab2219e1b341683eefa..829f550955a790cb25807c4f92fab972f47263c4 100644 --- a/src/MissionManager/PlanMasterController.h +++ b/src/MissionManager/PlanMasterController.h @@ -84,6 +84,7 @@ public: QString currentPlanFile (void) const { return _currentPlanFile; } QStringList loadNameFilters (void) const; QStringList saveNameFilters (void) const; + bool isEmpty (void) const; QJsonDocument saveToJson (); diff --git a/src/MissionManager/RallyPointController.cc b/src/MissionManager/RallyPointController.cc index 732d080b718d3055a21c63ae5be88fe527480b7c..e6f150f50ea3fc9b3b36149b607777c72976de64 100644 --- a/src/MissionManager/RallyPointController.cc +++ b/src/MissionManager/RallyPointController.cc @@ -202,8 +202,10 @@ QString RallyPointController::editorQml(void) const void RallyPointController::_managerLoadComplete(void) { // Fly view always reloads on _loadComplete - // Plan view only reloads on _loadComplete if specifically requested - if (_flyView || _itemsRequested) { + // Plan view only reloads if: + // - Load was specifically requested + // - There is no current Plan + if (_flyView || _itemsRequested || isEmpty()) { _points.clearAndDeleteContents(); QObjectList pointList; for (int i=0; i<_rallyPointManager->points().count(); i++) { @@ -318,3 +320,8 @@ bool RallyPointController::showPlanFromManagerVehicle (void) } } } + +bool RallyPointController::isEmpty(void) const +{ + return _points.count() == 0; +} diff --git a/src/MissionManager/RallyPointController.h b/src/MissionManager/RallyPointController.h index d443b39ea25fc835d4992c254f42fccd46bf856c..0823b9bf0ca329b8f8463d698771bc12a870dd5e 100644 --- a/src/MissionManager/RallyPointController.h +++ b/src/MissionManager/RallyPointController.h @@ -54,7 +54,8 @@ public: QString editorQml (void) const; QObject* currentRallyPoint (void) const { return _currentRallyPoint; } - void setCurrentRallyPoint(QObject* rallyPoint); + void setCurrentRallyPoint (QObject* rallyPoint); + bool isEmpty (void) const; signals: void currentRallyPointChanged(QObject* rallyPoint);