From 5c9a3ca82c55bcee37f8669c928fbea8d67c4574 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Thu, 25 Jan 2018 03:09:44 -0500 Subject: [PATCH] Yet some more --- qgroundcontrol.pro | 6 ++-- src/Airmap/AirMapFlightManager.cc | 4 ++- src/Airmap/AirMapFlightManager.h | 4 +-- src/Airmap/AirMapManager.h | 29 ++++++---------- src/Airmap/AirMapRestrictionManager.h | 8 +++-- src/Airmap/AirMapRulesetsManager.h | 12 ++++--- src/Airmap/AirMapSettings.cc | 1 - src/Airmap/AirMapSettings.h | 1 - src/Airmap/AirMapTelemetry.cc | 5 ++- src/Airmap/AirMapTelemetry.h | 5 ++- src/Airmap/AirMapTrafficMonitor.h | 10 +++++- src/Airmap/AirMapVehicleManager.cc | 3 +- src/Airmap/AirMapVehicleManager.h | 5 +-- src/Airmap/AirmapWeatherInformation.cc | 3 +- src/Airmap/AirmapWeatherInformation.h | 9 +++-- src/Airmap/LifetimeChecker.h | 29 ++++++++++++++++ .../AirspaceAuthorization.h | 28 ++++++++++++++++ src/AirspaceManagement/AirspaceController.cc | 33 +++++++++++++++++-- src/AirspaceManagement/AirspaceController.h | 9 ++--- ...rspaceManagement.cc => AirspaceManager.cc} | 9 ++++- ...AirspaceManagement.h => AirspaceManager.h} | 16 ++++----- src/AirspaceManagement/AirspaceRestriction.h | 1 + .../AirspaceRestrictionProvider.h | 5 ++- .../AirspaceRulesetsProvider.h | 2 +- .../AirspaceVehicleManager.cc | 7 ++-- .../AirspaceVehicleManager.h | 9 +++-- src/MissionManager/GeoFenceManager.h | 2 +- src/Vehicle/Vehicle.h | 2 +- 28 files changed, 186 insertions(+), 71 deletions(-) create mode 100644 src/Airmap/LifetimeChecker.h create mode 100644 src/AirspaceManagement/AirspaceAuthorization.h rename src/AirspaceManagement/{AirspaceManagement.cc => AirspaceManager.cc} (93%) rename src/AirspaceManagement/{AirspaceManagement.h => AirspaceManager.h} (93%) diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 9c9a8a25d..0d8110e96 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -1064,8 +1064,9 @@ contains (DEFINES, QGC_AIRMAP_ENABLED) { src/AirspaceManagement HEADERS += \ + src/AirspaceManagement/AirspaceAuthorization.h \ src/AirspaceManagement/AirspaceController.h \ - src/AirspaceManagement/AirspaceManagement.h \ + src/AirspaceManagement/AirspaceManager.h \ src/AirspaceManagement/AirspaceRestriction.h \ src/AirspaceManagement/AirspaceRestrictionProvider.h \ src/AirspaceManagement/AirspaceRulesetsProvider.h \ @@ -1074,7 +1075,7 @@ contains (DEFINES, QGC_AIRMAP_ENABLED) { SOURCES += \ src/AirspaceManagement/AirspaceController.cc \ - src/AirspaceManagement/AirspaceManagement.cc \ + src/AirspaceManagement/AirspaceManager.cc \ src/AirspaceManagement/AirspaceRestriction.cc \ src/AirspaceManagement/AirspaceRestrictionProvider.cc \ src/AirspaceManagement/AirspaceRulesetsProvider.cc \ @@ -1099,6 +1100,7 @@ contains (DEFINES, QGC_AIRMAP_ENABLED) { src/Airmap/AirMapTrafficMonitor.h \ src/Airmap/AirMapVehicleManager.h \ src/Airmap/AirmapWeatherInformation.h \ + src/Airmap/LifetimeChecker.h \ SOURCES += \ src/Airmap/AirMapFlightManager.cc \ diff --git a/src/Airmap/AirMapFlightManager.cc b/src/Airmap/AirMapFlightManager.cc index 5846535b3..e3136af24 100644 --- a/src/Airmap/AirMapFlightManager.cc +++ b/src/Airmap/AirMapFlightManager.cc @@ -7,8 +7,10 @@ * ****************************************************************************/ -#include "AirMapManager.h" #include "AirMapFlightManager.h" +#include "AirMapManager.h" + +#include "MissionItem.h" AirMapFlightManager::AirMapFlightManager(AirMapSharedState& shared) : _shared(shared) diff --git a/src/Airmap/AirMapFlightManager.h b/src/Airmap/AirMapFlightManager.h index 6d80f50ac..1cd6dd8b7 100644 --- a/src/Airmap/AirMapFlightManager.h +++ b/src/Airmap/AirMapFlightManager.h @@ -9,11 +9,11 @@ #pragma once +#include "LifetimeChecker.h" + #include #include -#include "AirMapManager.h" - //----------------------------------------------------------------------------- /// class to upload a flight class AirMapFlightManager : public QObject, public LifetimeChecker diff --git a/src/Airmap/AirMapManager.h b/src/Airmap/AirMapManager.h index 287914a6e..fc6f9f3b4 100644 --- a/src/Airmap/AirMapManager.h +++ b/src/Airmap/AirMapManager.h @@ -9,32 +9,23 @@ #pragma once -#include "QGCToolbox.h" +#include "AirspaceManager.h" + #include "QGCLoggingCategory.h" -#include "AirspaceManagement.h" -#include "AirMapSharedState.h" #include #include -Q_DECLARE_LOGGING_CATEGORY(AirMapManagerLog) +#include -//----------------------------------------------------------------------------- -/** - * @class LifetimeChecker - * Base class which helps to check if an object instance still exists. - * A subclass can take a weak pointer from _instance and then check if the object was deleted. - * This is used in callbacks that access 'this', but the instance might already be deleted (e.g. vehicle disconnect). - */ -class LifetimeChecker -{ -public: - LifetimeChecker() : _instance(this, [](void*){}) { } - virtual ~LifetimeChecker() = default; +class QGCToolbox; +class AirMapSharedState; +class AirspaceVehicleManager; +class AirspaceRestrictionProvider; +class AirspaceRulesetsProvider; +class AirspaceWeatherInfoProvider; -protected: - std::shared_ptr _instance; -}; +Q_DECLARE_LOGGING_CATEGORY(AirMapManagerLog) //----------------------------------------------------------------------------- /** diff --git a/src/Airmap/AirMapRestrictionManager.h b/src/Airmap/AirMapRestrictionManager.h index 0c96b3130..cb842ede7 100644 --- a/src/Airmap/AirMapRestrictionManager.h +++ b/src/Airmap/AirMapRestrictionManager.h @@ -9,10 +9,14 @@ #pragma once -#include -#include "AirMapManager.h" +#include "LifetimeChecker.h" #include "AirspaceRestrictionProvider.h" +#include +#include + +class AirMapSharedState; + /** * @file AirMapRestrictionManager.h * Class to download polygons from AirMap diff --git a/src/Airmap/AirMapRulesetsManager.h b/src/Airmap/AirMapRulesetsManager.h index 904ab6914..f2ac4badf 100644 --- a/src/Airmap/AirMapRulesetsManager.h +++ b/src/Airmap/AirMapRulesetsManager.h @@ -9,16 +9,18 @@ #pragma once +#include "LifetimeChecker.h" +#include "AirspaceRulesetsProvider.h" + +#include + +class AirMapSharedState; + /** * @file AirMapRulesetsManager.h * Class to download rulesets from AirMap */ -#include -#include "AirMapManager.h" -#include "AirspaceRulesetsProvider.h" -#include "AirMapSharedState.h" - class AirMapRulesetsManager : public AirspaceRulesetsProvider, public LifetimeChecker { Q_OBJECT diff --git a/src/Airmap/AirMapSettings.cc b/src/Airmap/AirMapSettings.cc index c3de29a42..b559d6e6a 100644 --- a/src/Airmap/AirMapSettings.cc +++ b/src/Airmap/AirMapSettings.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "AirMapSettings.h" -#include "QGCPalette.h" #include "QGCApplication.h" #include diff --git a/src/Airmap/AirMapSettings.h b/src/Airmap/AirMapSettings.h index 4d6ba52fe..f095dd7b6 100644 --- a/src/Airmap/AirMapSettings.h +++ b/src/Airmap/AirMapSettings.h @@ -10,7 +10,6 @@ #pragma once #include "SettingsGroup.h" -#include "QGCMAVLink.h" class AirMapSettings : public SettingsGroup { diff --git a/src/Airmap/AirMapTelemetry.cc b/src/Airmap/AirMapTelemetry.cc index 7c15027b3..264117dbb 100644 --- a/src/Airmap/AirMapTelemetry.cc +++ b/src/Airmap/AirMapTelemetry.cc @@ -7,8 +7,11 @@ * ****************************************************************************/ -#include "AirMapManager.h" #include "AirMapTelemetry.h" +#include "AirMapSharedState.h" +#include "AirMapManager.h" + +#include "QGCMAVLink.h" AirMapTelemetry::AirMapTelemetry(AirMapSharedState& shared) : _shared(shared) diff --git a/src/Airmap/AirMapTelemetry.h b/src/Airmap/AirMapTelemetry.h index 17d0cabf3..b826d4925 100644 --- a/src/Airmap/AirMapTelemetry.h +++ b/src/Airmap/AirMapTelemetry.h @@ -9,8 +9,11 @@ #pragma once +#include "LifetimeChecker.h" + #include -#include "AirMapManager.h" + +class AirMapSharedState; /// class to send telemetry data to AirMap class AirMapTelemetry : public QObject, public LifetimeChecker diff --git a/src/Airmap/AirMapTrafficMonitor.h b/src/Airmap/AirMapTrafficMonitor.h index c2e29d4ef..f7764301c 100644 --- a/src/Airmap/AirMapTrafficMonitor.h +++ b/src/Airmap/AirMapTrafficMonitor.h @@ -9,8 +9,16 @@ #pragma once +#include "LifetimeChecker.h" + #include -#include "AirMapManager.h" +#include + +#include "airmap/traffic.h" + +#include + +class AirMapSharedState; /** * @class AirMapTrafficMonitor diff --git a/src/Airmap/AirMapVehicleManager.cc b/src/Airmap/AirMapVehicleManager.cc index 44deb7b71..cf1046efa 100644 --- a/src/Airmap/AirMapVehicleManager.cc +++ b/src/Airmap/AirMapVehicleManager.cc @@ -7,11 +7,12 @@ * ****************************************************************************/ -#include "AirMapManager.h" #include "AirMapVehicleManager.h" +#include "AirMapSharedState.h" #include "AirMapFlightManager.h" #include "AirMapTelemetry.h" #include "AirMapTrafficMonitor.h" +#include "AirMapManager.h" #include "Vehicle.h" diff --git a/src/Airmap/AirMapVehicleManager.h b/src/Airmap/AirMapVehicleManager.h index 0fd1e2d68..e7abf12df 100644 --- a/src/Airmap/AirMapVehicleManager.h +++ b/src/Airmap/AirMapVehicleManager.h @@ -9,10 +9,11 @@ #pragma once -#include -#include "AirspaceManagement.h" +#include "AirspaceManager.h" #include "AirspaceVehicleManager.h" +#include "QGCToolbox.h" + /// AirMap per vehicle management class. class AirMapSharedState; diff --git a/src/Airmap/AirmapWeatherInformation.cc b/src/Airmap/AirmapWeatherInformation.cc index bcc7aef5b..8a36aa6f6 100644 --- a/src/Airmap/AirmapWeatherInformation.cc +++ b/src/Airmap/AirmapWeatherInformation.cc @@ -7,8 +7,9 @@ * ****************************************************************************/ -#include "AirMapManager.h" #include "AirmapWeatherInformation.h" +#include "AirMapSharedState.h" +#include "AirMapManager.h" #define WEATHER_UPDATE_DISTANCE 50000 //-- 50km threshold for weather updates #define WEATHER_UPDATE_TIME 30 * 60 * 60 * 1000 //-- 30 minutes threshold for weather updates diff --git a/src/Airmap/AirmapWeatherInformation.h b/src/Airmap/AirmapWeatherInformation.h index 0973de7f7..882f7d48d 100644 --- a/src/Airmap/AirmapWeatherInformation.h +++ b/src/Airmap/AirmapWeatherInformation.h @@ -9,13 +9,13 @@ #pragma once -#include -#include -#include +#include "LifetimeChecker.h" -#include "AirMapManager.h" #include "AirspaceWeatherInfoProvider.h" +#include +#include + /** * @file AirMapWeatherInformation.h * Weather information provided by AirMap. @@ -24,7 +24,6 @@ class AirMapWeatherInformation : public AirspaceWeatherInfoProvider, public LifetimeChecker { Q_OBJECT - friend class AirMapManager; public: AirMapWeatherInformation(AirMapSharedState &shared, QObject *parent = nullptr); diff --git a/src/Airmap/LifetimeChecker.h b/src/Airmap/LifetimeChecker.h new file mode 100644 index 000000000..8b50de2b8 --- /dev/null +++ b/src/Airmap/LifetimeChecker.h @@ -0,0 +1,29 @@ +/**************************************************************************** + * + * (c) 2017 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include + +//----------------------------------------------------------------------------- +/** + * @class LifetimeChecker + * Base class which helps to check if an object instance still exists. + * A subclass can take a weak pointer from _instance and then check if the object was deleted. + * This is used in callbacks that access 'this', but the instance might already be deleted (e.g. vehicle disconnect). + */ +class LifetimeChecker +{ +public: + LifetimeChecker() : _instance(this, [](void*){}) { } + virtual ~LifetimeChecker() = default; + +protected: + std::shared_ptr _instance; +}; diff --git a/src/AirspaceManagement/AirspaceAuthorization.h b/src/AirspaceManagement/AirspaceAuthorization.h new file mode 100644 index 000000000..08d94efce --- /dev/null +++ b/src/AirspaceManagement/AirspaceAuthorization.h @@ -0,0 +1,28 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +#pragma once + +#include + +//----------------------------------------------------------------------------- +/** + * Contains the status of the Airspace authorization + */ +class AirspaceAuthorization : public QObject { + Q_OBJECT +public: + enum PermitStatus { + PermitUnknown = 0, + PermitPending, + PermitAccepted, + PermitRejected, + }; + Q_ENUM(PermitStatus) +}; diff --git a/src/AirspaceManagement/AirspaceController.cc b/src/AirspaceManagement/AirspaceController.cc index d30ca3c55..faa4d4824 100644 --- a/src/AirspaceManagement/AirspaceController.cc +++ b/src/AirspaceManagement/AirspaceController.cc @@ -7,11 +7,13 @@ * ****************************************************************************/ -#include "AirMapManager.h" #include "AirspaceController.h" -#include "AirspaceManagement.h" +#include "AirspaceManager.h" +#include "AirspaceWeatherInfoProvider.h" + #include "QGCApplication.h" #include "QGCQGeoCoordinate.h" +#include "QmlObjectListModel.h" AirspaceController::AirspaceController(QObject* parent) : QObject(parent) @@ -19,7 +21,32 @@ AirspaceController::AirspaceController(QObject* parent) { } -void AirspaceController::setROI(QGeoCoordinate center, double radius) +void +AirspaceController::setROI(QGeoCoordinate center, double radius) { _manager->setROI(center, radius); } + +QmlObjectListModel* +AirspaceController::polygons() +{ + return _manager->polygonRestrictions(); +} + +QmlObjectListModel* +AirspaceController::circles() +{ + return _manager->circularRestrictions(); +} + +QString +AirspaceController::providerName() +{ + return _manager->name(); +} + +AirspaceWeatherInfoProvider* +AirspaceController::weatherInfo() +{ + return _manager->weatherInfo(); +} diff --git a/src/AirspaceManagement/AirspaceController.h b/src/AirspaceManagement/AirspaceController.h index 0baf3582f..28f413865 100644 --- a/src/AirspaceManagement/AirspaceController.h +++ b/src/AirspaceManagement/AirspaceController.h @@ -9,10 +9,11 @@ #pragma once -#include "AirspaceManagement.h" -#include "AirmapWeatherInformation.h" -#include "QmlObjectListModel.h" -#include "QGCMapPolygon.h" +#include + +class AirspaceManager; +class QmlObjectListModel; +class AirspaceWeatherInfoProvider; class AirspaceController : public QObject { diff --git a/src/AirspaceManagement/AirspaceManagement.cc b/src/AirspaceManagement/AirspaceManager.cc similarity index 93% rename from src/AirspaceManagement/AirspaceManagement.cc rename to src/AirspaceManagement/AirspaceManager.cc index cdb66627a..8a3b35b89 100644 --- a/src/AirspaceManagement/AirspaceManagement.cc +++ b/src/AirspaceManagement/AirspaceManager.cc @@ -8,7 +8,14 @@ ****************************************************************************/ -#include "AirspaceManagement.h" +#include "AirspaceManager.h" +#include "AirspaceWeatherInfoProvider.h" +#include "AirspaceRestrictionProvider.h" +#include "AirspaceRulesetsProvider.h" + +#include "Vehicle.h" +#include "QGCApplication.h" +#include "QmlObjectListModel.h" QGC_LOGGING_CATEGORY(AirspaceManagementLog, "AirspaceManagementLog") diff --git a/src/AirspaceManagement/AirspaceManagement.h b/src/AirspaceManagement/AirspaceManager.h similarity index 93% rename from src/AirspaceManagement/AirspaceManagement.h rename to src/AirspaceManagement/AirspaceManager.h index 01407c148..07cfa3f70 100644 --- a/src/AirspaceManagement/AirspaceManagement.h +++ b/src/AirspaceManagement/AirspaceManager.h @@ -10,7 +10,7 @@ #pragma once /** - * @file AirspaceManagement.h + * @file AirspaceManager.h * This file contains the interface definitions used by an airspace management implementation (AirMap). * There are 3 base classes that must be subclassed: * - AirspaceManager @@ -23,16 +23,8 @@ * each vehicle could have its own restrictions. */ -#include "AirspaceController.h" -#include "AirspaceRestrictionProvider.h" -#include "AirspaceRulesetsProvider.h" -#include "AirspaceVehicleManager.h" -#include "AirspaceWeatherInfoProvider.h" - #include "QGCToolbox.h" #include "QGCLoggingCategory.h" -#include "QmlObjectListModel.h" -#include "Vehicle.h" #include #include @@ -40,6 +32,12 @@ #include #include +class Vehicle; +class QGCApplication; +class QmlObjectListModel; +class AirspaceWeatherInfoProvider; +class AirspaceRestrictionProvider; +class AirspaceRulesetsProvider; Q_DECLARE_LOGGING_CATEGORY(AirspaceManagementLog) diff --git a/src/AirspaceManagement/AirspaceRestriction.h b/src/AirspaceManagement/AirspaceRestriction.h index cb099ad1e..4cd8c48f6 100644 --- a/src/AirspaceManagement/AirspaceRestriction.h +++ b/src/AirspaceManagement/AirspaceRestriction.h @@ -11,6 +11,7 @@ #include #include +#include /** * @class AirspaceRestriction diff --git a/src/AirspaceManagement/AirspaceRestrictionProvider.h b/src/AirspaceManagement/AirspaceRestrictionProvider.h index 9aec3c9cd..3bd39fd61 100644 --- a/src/AirspaceManagement/AirspaceRestrictionProvider.h +++ b/src/AirspaceManagement/AirspaceRestrictionProvider.h @@ -15,7 +15,10 @@ */ #include -#include "AirspaceRestriction.h" +#include + +class AirspacePolygonRestriction; +class AirspaceCircularRestriction; class AirspaceRestrictionProvider : public QObject { Q_OBJECT diff --git a/src/AirspaceManagement/AirspaceRulesetsProvider.h b/src/AirspaceManagement/AirspaceRulesetsProvider.h index 0b935e32e..49a0aa3f3 100644 --- a/src/AirspaceManagement/AirspaceRulesetsProvider.h +++ b/src/AirspaceManagement/AirspaceRulesetsProvider.h @@ -16,7 +16,7 @@ */ #include -#include +#include class AirspaceRulesetsProvider : public QObject { Q_OBJECT diff --git a/src/AirspaceManagement/AirspaceVehicleManager.cc b/src/AirspaceManagement/AirspaceVehicleManager.cc index cdd5ae4e8..5379ef26b 100644 --- a/src/AirspaceManagement/AirspaceVehicleManager.cc +++ b/src/AirspaceManagement/AirspaceVehicleManager.cc @@ -8,13 +8,14 @@ ****************************************************************************/ -#include "AirspaceManagement.h" -#include +#include "AirspaceManager.h" +#include "Vehicle.h" +#include "MissionItem.h" AirspaceVehicleManager::AirspaceVehicleManager(const Vehicle& vehicle) : _vehicle(vehicle) { - connect(&_vehicle, &Vehicle::armedChanged, this, &AirspaceVehicleManager::_vehicleArmedChanged); + connect(&_vehicle, &Vehicle::armedChanged, this, &AirspaceVehicleManager::_vehicleArmedChanged); connect(&_vehicle, &Vehicle::mavlinkMessageReceived, this, &AirspaceVehicleManager::vehicleMavlinkMessageReceived); } diff --git a/src/AirspaceManagement/AirspaceVehicleManager.h b/src/AirspaceManagement/AirspaceVehicleManager.h index 36a5799f5..12805f01c 100644 --- a/src/AirspaceManagement/AirspaceVehicleManager.h +++ b/src/AirspaceManagement/AirspaceVehicleManager.h @@ -9,9 +9,14 @@ #pragma once -#include -#include "MissionItem.h" +#include "AirspaceAuthorization.h" +#include "QGCMAVLink.h" +#include +#include +#include + +class MissionItem; class Vehicle; //----------------------------------------------------------------------------- diff --git a/src/MissionManager/GeoFenceManager.h b/src/MissionManager/GeoFenceManager.h index 9c7bdd58d..e65a0ff20 100644 --- a/src/MissionManager/GeoFenceManager.h +++ b/src/MissionManager/GeoFenceManager.h @@ -14,7 +14,7 @@ #include #if defined(QGC_AIRMAP_ENABLED) -#include "AirspaceManagement.h" +#include "AirspaceManager.h" #endif #include "QGCLoggingCategory.h" diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 7a43e7c79..a296d1ec3 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -21,7 +21,7 @@ #include "UASMessageHandler.h" #include "SettingsFact.h" #if defined(QGC_AIRMAP_ENABLED) -#include "AirspaceManagement.h" +#include "AirspaceManager.h" #include "AirspaceVehicleManager.h" #endif -- 2.22.0