AirspaceRulesetsProvider.h 6.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/****************************************************************************
 *
 *   (c) 2017 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#pragma once

//-----------------------------------------------------------------------------
/**
 * @class AirspaceRulesetsProvider
 * Base class that queries for airspace rulesets
 */

Gus Grubba's avatar
Gus Grubba committed
18 19
#include "QmlObjectListModel.h"

20
#include <QObject>
Gus Grubba's avatar
Gus Grubba committed
21
#include <QGeoCoordinate>
22

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
//-----------------------------------------------------------------------------
class AirspaceRuleFeature : public QObject
{
    Q_OBJECT
public:

    enum Type {
        Unknown,
        Boolean,
        Float,
        String,
    };

    enum Measurement {
        UnknownMeasurement,
        Speed,
        Weight,
        Distance,
    };

    enum Unit {
        UnknownUnit,
        Kilogram,
        Meters,
        MetersPerSecond,
    };

    Q_ENUM(Type)
    Q_ENUM(Measurement)
    Q_ENUM(Unit)

    AirspaceRuleFeature(QObject* parent = NULL);

56
    Q_PROPERTY(quint32          id              READ id             CONSTANT)
57
    Q_PROPERTY(Type             type            READ type           CONSTANT)
58
    Q_PROPERTY(Unit             unit            READ unit           CONSTANT)
59 60 61
    Q_PROPERTY(Measurement      measurement     READ measurement    CONSTANT)
    Q_PROPERTY(QString          name            READ name           CONSTANT)
    Q_PROPERTY(QString          description     READ description    CONSTANT)
62
    Q_PROPERTY(QVariant         value           READ value          WRITE setValue  NOTIFY valueChanged)
63

64
    virtual quint32         id              () = 0;
65
    virtual Type            type            () = 0;
66 67
    virtual Unit            unit            () = 0;
    virtual Measurement     measurement     () = 0;
68 69 70
    virtual QString         name            () = 0;
    virtual QString         description     () = 0;
    virtual QVariant        value           () = 0;
71 72 73 74
    virtual void            setValue        (const QVariant val) = 0;

signals:
    void valueChanged   ();
75 76
};

Gus Grubba's avatar
Gus Grubba committed
77 78
//-----------------------------------------------------------------------------
class AirspaceRule : public QObject
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
{
    Q_OBJECT
public:

    enum Status {
        Unknown,                ///< The status of the rule is unknown.
        Conflicting,            ///< The rule is conflicting.
        NotConflicting,         ///< The rule is not conflicting, all good to go.
        MissingInfo,            ///< The evaluation requires further information.
        Informational           ///< The rule is of informational nature.
    };

    Q_ENUM(Status)

    AirspaceRule(QObject* parent = NULL);

    Q_PROPERTY(Status           status          READ status         CONSTANT)
    Q_PROPERTY(QString          shortText       READ shortText      CONSTANT)
    Q_PROPERTY(QString          description     READ description    CONSTANT)

    virtual Status          status          () = 0;
    virtual QString         shortText       () = 0;
    virtual QString         description     () = 0;
};

//-----------------------------------------------------------------------------
class AirspaceRuleSet : public QObject
Gus Grubba's avatar
Gus Grubba committed
106 107 108
{
    Q_OBJECT
public:
109 110

    enum SelectionType {
Gus Grubba's avatar
Gus Grubba committed
111 112 113
      Pickone,              ///< One rule from the overall set needs to be picked.
      Required,             ///< Satisfying the RuleSet is required.
      Optional              ///< Satisfying the RuleSet is not required.
114 115 116 117
    };

    Q_ENUM(SelectionType)

118
    AirspaceRuleSet(QObject* parent = NULL);
Gus Grubba's avatar
Gus Grubba committed
119

120 121
    Q_PROPERTY(QString          id              READ id             CONSTANT)
    Q_PROPERTY(QString          name            READ name           CONSTANT)
Gus Grubba's avatar
Gus Grubba committed
122
    Q_PROPERTY(QString          shortName       READ shortName      CONSTANT)
123 124 125
    Q_PROPERTY(QString          description     READ description    CONSTANT)
    Q_PROPERTY(bool             isDefault       READ isDefault      CONSTANT)
    Q_PROPERTY(SelectionType    selectionType   READ selectionType  CONSTANT)
Gus Grubba's avatar
Gus Grubba committed
126
    Q_PROPERTY(bool             selected        READ selected       WRITE setSelected   NOTIFY selectedChanged)
127
    Q_PROPERTY(QmlObjectListModel* rules        READ rules          CONSTANT)
Gus Grubba's avatar
Gus Grubba committed
128

129 130 131 132
    virtual QString         id              () = 0;
    virtual QString         description     () = 0;
    virtual bool            isDefault       () = 0;
    virtual QString         name            () = 0;
Gus Grubba's avatar
Gus Grubba committed
133
    virtual QString         shortName       () = 0;
134
    virtual SelectionType   selectionType   () = 0;
Gus Grubba's avatar
Gus Grubba committed
135 136
    virtual bool            selected        () = 0;
    virtual void            setSelected     (bool sel) = 0;
137
    virtual QmlObjectListModel* rules       () = 0;             ///< List of AirspaceRule
Gus Grubba's avatar
Gus Grubba committed
138 139 140 141

signals:
    void    selectedChanged                 ();

Gus Grubba's avatar
Gus Grubba committed
142 143 144
};

//-----------------------------------------------------------------------------
145 146 147
class AirspaceRulesetsProvider : public QObject {
    Q_OBJECT
public:
Gus Grubba's avatar
Gus Grubba committed
148 149 150
    AirspaceRulesetsProvider        (QObject* parent = NULL);
    ~AirspaceRulesetsProvider       () = default;

151 152 153
    Q_PROPERTY(bool                 valid               READ valid              NOTIFY ruleSetsChanged)
    Q_PROPERTY(QString              selectedRuleSets    READ selectedRuleSets   NOTIFY selectedRuleSetsChanged)
    Q_PROPERTY(QmlObjectListModel*  ruleSets            READ ruleSets           NOTIFY ruleSetsChanged)
154
    Q_PROPERTY(QmlObjectListModel*  features            READ features           NOTIFY ruleSetsChanged)
Gus Grubba's avatar
Gus Grubba committed
155

156
    virtual bool                valid       () = 0;             ///< Current ruleset is valid
157
    virtual QmlObjectListModel* ruleSets    () = 0;             ///< List of AirspaceRuleSet
158
    virtual QmlObjectListModel* features    () = 0;             ///< List of AirspaceRuleFeature (Aggregate of all features of selected rulesets)
159
    virtual QString         selectedRuleSets() = 0;             ///< All selected rules concatenated into a string
160
    /**
Gus Grubba's avatar
Gus Grubba committed
161
     * Set region of interest that should be queried. When finished, the rulesChanged() signal will be emmited.
162 163
     * @param center Center coordinate for ROI
     */
Gus Grubba's avatar
Gus Grubba committed
164 165
    virtual void        setROI      (const QGeoCoordinate& center) = 0;

166
signals:
167 168
    void ruleSetsChanged            ();
    void selectedRuleSetsChanged    ();
169 170
};