ComplexMissionItem.h 3.46 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 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.
 *
 ****************************************************************************/
9

10 11 12
#ifndef ComplexMissionItem_H
#define ComplexMissionItem_H

13
#include "VisualMissionItem.h"
14
#include "QGCGeo.h"
15

Don Gagne's avatar
Don Gagne committed
16 17
#include <QSettings>

18
class ComplexMissionItem : public VisualMissionItem
19 20
{
    Q_OBJECT
21

22
public:
23
    ComplexMissionItem(Vehicle* vehicle, bool flyView, QObject* parent);
24

25 26
    const ComplexMissionItem& operator=(const ComplexMissionItem& other);

Don Gagne's avatar
Don Gagne committed
27 28 29
    Q_PROPERTY(double       complexDistance     READ complexDistance                            NOTIFY complexDistanceChanged)
    Q_PROPERTY(bool         presetsSupported    READ presetsSupported                           CONSTANT)
    Q_PROPERTY(QStringList  presetNames         READ presetNames                                NOTIFY presetNamesChanged)
30

31
    /// @return The distance covered the complex mission item in meters.
32
    /// Signals complexDistanceChanged
33
    virtual double complexDistance(void) const = 0;
34

35 36
    /// Load the complex mission item from Json
    ///     @param complexObject Complex mission item json object
Don Gagne's avatar
Don Gagne committed
37
    ///     @param sequenceNumber Sequence number for first MISSION_ITEM in survey
38 39
    ///     @param[out] errorString Error if load fails
    /// @return true: load success, false: load failed, errorString set
Don Gagne's avatar
Don Gagne committed
40
    virtual bool load(const QJsonObject& complexObject, int sequenceNumber, QString& errorString) = 0;
41

Don Gagne's avatar
Don Gagne committed
42 43 44 45 46 47 48 49
    /// Loads the specified preset into the complex item.
    ///     @param name Preset name.
    Q_INVOKABLE virtual void loadPreset(const QString& name);

    /// Saves the current state of the complex item as the named preset.
    ///     @param name User visible name for preset. Will replace existing preset if already exists.
    Q_INVOKABLE virtual void savePreset(const QString& name);

Don Gagne's avatar
Don Gagne committed
50 51
     Q_INVOKABLE void deletePreset(const QString& name);

Don Gagne's avatar
Don Gagne committed
52

53 54 55
    /// Get the point of complex mission item furthest away from a coordinate
    ///     @param other QGeoCoordinate to which distance is calculated
    /// @return the greatest distance from any point of the complex item to some coordinate
56
    /// Signals greatestDistanceToChanged
57
    virtual double greatestDistanceTo(const QGeoCoordinate &other) const = 0;
58

Don Gagne's avatar
Don Gagne committed
59 60 61 62 63 64 65 66
    /// Returns the list of currently saved presets for this complex item type.
    ///     @param name User visible name for preset. Will replace existing preset if already exists.
    virtual QStringList presetNames(void);

    /// Returns the name of the settings group for presets.
    ///     Empty string signals no support for presets.
    virtual QString presetsSettingsGroup(void) { return QString(); }

Don Gagne's avatar
Don Gagne committed
67
    bool presetsSupported(void) { return !presetsSettingsGroup().isEmpty(); }
Don Gagne's avatar
Don Gagne committed
68

Don Gagne's avatar
Don Gagne committed
69 70 71
    /// This mission item attribute specifies the type of the complex item.
    static const char* jsonComplexItemTypeKey;

72
signals:
73
    void complexDistanceChanged     (void);
74
    void boundingCubeChanged        (void);
75
    void greatestDistanceToChanged  (void);
Don Gagne's avatar
Don Gagne committed
76 77 78 79 80 81 82 83 84 85
    void presetNamesChanged         (void);

protected:
    void        _savePresetJson (const QString& name, QJsonObject& presetObject);
    QJsonObject _loadPresetJson (const QString& name);


    QMap<QString, FactMetaData*> _metaDataMap;

    static const char* _presetSettingsKey;
86 87 88
};

#endif