AirMapAdvisoryManager.h 2.52 KB
Newer Older
Gus Grubba's avatar
Gus Grubba committed
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
Gus Grubba's avatar
Gus Grubba committed
4 5 6 7 8 9 10 11
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#pragma once

Gus Grubba's avatar
Gus Grubba committed
12 13
#include "QmlObjectListModel.h"

Gus Grubba's avatar
Gus Grubba committed
14 15 16 17 18
#include "LifetimeChecker.h"

#include "AirspaceAdvisoryProvider.h"
#include "AirMapSharedState.h"

19
#include "QGCGeoBoundingCube.h"
Gus Grubba's avatar
Gus Grubba committed
20 21 22 23

#include "airmap/status.h"

/**
Gus Grubba's avatar
Gus Grubba committed
24
 * @file AirMapAdvisoryManager.h
Gus Grubba's avatar
Gus Grubba committed
25 26 27
 * Advisory information provided by AirMap.
 */

Gus Grubba's avatar
Gus Grubba committed
28 29
//-----------------------------------------------------------------------------
class AirMapAdvisory : public AirspaceAdvisory
Gus Grubba's avatar
Gus Grubba committed
30 31
{
    Q_OBJECT
Gus Grubba's avatar
Gus Grubba committed
32
    friend class AirMapAdvisoryManager;
33
    friend class AirMapFlightPlanManager;
Gus Grubba's avatar
Gus Grubba committed
34
public:
Gus Grubba's avatar
Gus Grubba committed
35
    AirMapAdvisory (QObject* parent = nullptr);
Gus Grubba's avatar
Gus Grubba committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49
    QString         id              () override { return _id; }
    QString         name            () override { return _name; }
    AdvisoryType    type            () override { return _type; }
    QGeoCoordinate  coordinates     () override { return _coordinates; }
    qreal           radius          () override { return _radius; }
    AirspaceAdvisoryProvider::AdvisoryColor color () override { return _color; }
private:
    QString         _id;
    QString         _name;
    AdvisoryType    _type;
    QGeoCoordinate  _coordinates;
    qreal           _radius;
    AirspaceAdvisoryProvider::AdvisoryColor _color;
};
Gus Grubba's avatar
Gus Grubba committed
50

Gus Grubba's avatar
Gus Grubba committed
51
//-----------------------------------------------------------------------------
Gus Grubba's avatar
Gus Grubba committed
52
class AirMapAdvisoryManager : public AirspaceAdvisoryProvider, public LifetimeChecker
Gus Grubba's avatar
Gus Grubba committed
53 54 55
{
    Q_OBJECT
public:
56 57 58 59
    AirMapAdvisoryManager                   (AirMapSharedState &shared, QObject *parent = nullptr);
    bool                valid               () override { return _valid; }
    AdvisoryColor       airspaceColor       () override { return _airspaceColor; }
    QmlObjectListModel* advisories          () override { return &_advisories; }
60
    void                setROI              (const QGCGeoBoundingCube& roi, bool reset = false) override;
Gus Grubba's avatar
Gus Grubba committed
61
signals:
62
    void                error               (const QString& what, const QString& airmapdMessage, const QString& airmapdDetails);
Gus Grubba's avatar
Gus Grubba committed
63
private:
64
    void                _requestAdvisories  ();
Gus Grubba's avatar
Gus Grubba committed
65 66 67
private:
    bool                _valid;
    AirMapSharedState&  _shared;
68
    QGCGeoBoundingCube  _lastROI;
69
    QmlObjectListModel  _advisories;
Gus Grubba's avatar
Gus Grubba committed
70
    AdvisoryColor       _airspaceColor;
Gus Grubba's avatar
Gus Grubba committed
71
};