AirspaceRulesetsProvider.h 6.39 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
#include "QmlObjectListModel.h"
19
#include "QGCGeoBoundingCube.h"
Gus Grubba's avatar
Gus Grubba committed
20

21
#include <QObject>
Gus Grubba's avatar
Gus Grubba committed
22
#include <QGeoCoordinate>
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
//-----------------------------------------------------------------------------
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)

55
    AirspaceRuleFeature(QObject* parent = nullptr);
56

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

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

signals:
    void valueChanged   ();
76 77
};

Gus Grubba's avatar
Gus Grubba committed
78 79
//-----------------------------------------------------------------------------
class AirspaceRule : public QObject
80 81 82 83 84 85 86
{
    Q_OBJECT
public:

    enum Status {
        Conflicting,            ///< The rule is conflicting.
        MissingInfo,            ///< The evaluation requires further information.
Gus Grubba's avatar
Gus Grubba committed
87 88 89
        NotConflicting,         ///< The rule is not conflicting, all good to go.
        Informational,          ///< The rule is of informational nature.
        Unknown,                ///< The status of the rule is unknown.
90 91 92 93
    };

    Q_ENUM(Status)

94
    AirspaceRule(QObject* parent = nullptr);
95

Gus Grubba's avatar
Gus Grubba committed
96 97 98 99
    Q_PROPERTY(Status               status          READ status         CONSTANT)
    Q_PROPERTY(QString              shortText       READ shortText      CONSTANT)
    Q_PROPERTY(QString              description     READ description    CONSTANT)
    Q_PROPERTY(QmlObjectListModel*  features        READ features       CONSTANT)
100

Gus Grubba's avatar
Gus Grubba committed
101 102 103 104
    virtual Status              status          () = 0;
    virtual QString             shortText       () = 0;
    virtual QString             description     () = 0;
    virtual QmlObjectListModel* features        () = 0;     ///< List of AirspaceRuleFeature
105 106 107 108
};

//-----------------------------------------------------------------------------
class AirspaceRuleSet : public QObject
Gus Grubba's avatar
Gus Grubba committed
109 110 111
{
    Q_OBJECT
public:
112 113

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

    Q_ENUM(SelectionType)

121
    AirspaceRuleSet(QObject* parent = nullptr);
Gus Grubba's avatar
Gus Grubba committed
122

123 124
    Q_PROPERTY(QString          id              READ id             CONSTANT)
    Q_PROPERTY(QString          name            READ name           CONSTANT)
Gus Grubba's avatar
Gus Grubba committed
125
    Q_PROPERTY(QString          shortName       READ shortName      CONSTANT)
126 127 128
    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
129
    Q_PROPERTY(bool             selected        READ selected       WRITE setSelected   NOTIFY selectedChanged)
130
    Q_PROPERTY(QmlObjectListModel* rules        READ rules          CONSTANT)
Gus Grubba's avatar
Gus Grubba committed
131

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

signals:
    void    selectedChanged                 ();

Gus Grubba's avatar
Gus Grubba committed
145 146 147
};

//-----------------------------------------------------------------------------
148 149 150
class AirspaceRulesetsProvider : public QObject {
    Q_OBJECT
public:
151
    AirspaceRulesetsProvider        (QObject* parent = nullptr);
Gus Grubba's avatar
Gus Grubba committed
152 153
    ~AirspaceRulesetsProvider       () = default;

154 155 156
    Q_PROPERTY(bool                 valid               READ valid              NOTIFY ruleSetsChanged)
    Q_PROPERTY(QString              selectedRuleSets    READ selectedRuleSets   NOTIFY selectedRuleSetsChanged)
    Q_PROPERTY(QmlObjectListModel*  ruleSets            READ ruleSets           NOTIFY ruleSetsChanged)
Gus Grubba's avatar
Gus Grubba committed
157

158 159
    Q_INVOKABLE virtual void    clearAllFeatures() {;}          ///< Clear all saved (persistent) feature values

160
    virtual bool                valid       () = 0;             ///< Current ruleset is valid
161 162
    virtual QmlObjectListModel* ruleSets    () = 0;             ///< List of AirspaceRuleSet
    virtual QString         selectedRuleSets() = 0;             ///< All selected rules concatenated into a string
163
    /**
Gus Grubba's avatar
Gus Grubba committed
164
     * Set region of interest that should be queried. When finished, the rulesChanged() signal will be emmited.
165 166
     * @param center Center coordinate for ROI
     */
167
    virtual void        setROI      (const QGCGeoBoundingCube& roi, bool reset = false) = 0;
Gus Grubba's avatar
Gus Grubba committed
168

169
signals:
170 171
    void ruleSetsChanged            ();
    void selectedRuleSetsChanged    ();
172 173
};