diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 9c9a8a25d8289f60df3e7b60164c8ff3f260e8ea..0d8110e96498dee1f4f7c65d3bf15c7a0d7fe8bf 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 5846535b3b41de9f294e2c28fba681f39e152b29..e3136af24b1277baefbd385b9014f703feeee001 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 6d80f50ac7fc26156e0fbc708fbe21c800a42fb9..1cd6dd8b7827c7aef212d682ed5c0612d83c3e8a 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 287914a6e15ea8a90e71a4741dfc066fa85afe3f..fc6f9f3b41bd7668f759076434493e8cb338e8ff 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 0c96b3130e550fdadea27626d061a1f8740b7dbd..cb842ede7d2fdbdffe1d124ab915462b3d28d185 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 904ab69143e75b639a339e738ebcd1318af12a55..f2ac4badfa54aad38773cfd4a23dad2e1da2d9f8 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 c3de29a42b623a004533e8a656ea174bd81ad04b..b559d6e6a2975c6c52445881c59134301c362317 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 4d6ba52fe6b796253c5d4b297126ad75fdda899a..f095dd7b6c5c89b839e25a01e133247375dae30d 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 7c15027b318aae3075d25595149e96468bde498b..264117dbbb3b3964c41ff89333fc14221e3cff99 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 17d0cabf33e3c59016730de414903f30a53d7799..b826d49251cd698d8f10727a84fcb48130e89916 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 c2e29d4ef43529ed4ac07f91ffcfab7ea8c3c78a..f7764301ca4e36b95c7c4e7321023107e44c833b 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 44deb7b719d8d5fd6e388cf8a3e010b6833f500e..cf1046efa3a6dd3603ef25881225416cba3fb481 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 0fd1e2d686a17bcb62293c59ce8934101cf32828..e7abf12df8a2665bd2692486a481890f10022429 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 bcc7aef5be60ae458bc1572e2bfd2871b8d40d01..8a36aa6f6fbae78a17398a8247771ecbdbc79958 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 0973de7f721021cb1ad3eed07a45ad3eaf96d721..882f7d48d85259ce771d423708afe6c3752a1406 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 0000000000000000000000000000000000000000..8b50de2b8bc4a4a4ad93b7445d9ad791204b128b --- /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 0000000000000000000000000000000000000000..08d94efce6396a1ba77a60bb33aff124f0dd3d6a --- /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 d30ca3c55cbb020a15364d067c2f9b558951be59..faa4d4824a2c93b868953c9bb3f3167cdc15fb6b 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 0baf3582f9c34a9872a0c129096ffd16795e5dba..28f4138656232c98dd1cac05a0114d1a5a6c69b1 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 cdb66627a0dbfe92ef80dd81588335b1eebc689a..8a3b35b899774cb6ff42122d080976055ba19eba 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 01407c148ef2790b7525775b959fa28e51386654..07cfa3f70a198f33b2ff5d475da50161b33c5274 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 cb099ad1e48f78070007c91d831bdedef0bd8e03..4cd8c48f6d653a61fb3d1da4b038732ef306c940 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 9aec3c9cd13a6e63d77572c8aec0a387025db574..3bd39fd611426ff257686a694eb362a5eaf95625 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 0b935e32e5dfea1cf4e1965d9ed44b53796ad0bc..49a0aa3f30931cc3d9ffaf3ffebe1cafb4eb0557 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 cdd5ae4e8f589af3ce2f9a634ff3d8fbe5a46233..5379ef26b9993a8baf4e5d50eeeca661888e556f 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 36a5799f5b36b3cd5242e31e379fd6c424aa2afa..12805f01c54dbcfdac826479820c3db590719919 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 9c7bdd58db4d86861272ca0c375f130883b97a77..e65a0ff208d2204478ebbc8acf7c2e09bbc86810 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 7a43e7c794068321b7887643d449b6f0de3866b7..a296d1ec341a47360a2d87ea4749c90f8a4e46ab 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