WimaArea.h 4.8 KB
Newer Older
1
#pragma once
2

3
#include "QGCMapPolygon.h"
4
#include "QGCMapPolyline.h"
5 6
#include "Vehicle.h"
#include "qobject.h"
7 8 9
#include <QLineF>
#include <QPointF>
#include "QGCGeo.h"
10
#include <QPair>
11

12 13
#include "GeoUtilities.h"
#include "PolygonCalculus.h"
14
#include "PlanimetryCalculus.h"
15

16
class WimaArea : public QGCMapPolygon //abstract base class for all WimaAreas
17
{
18
    Q_OBJECT
19
public:
20 21
    WimaArea(QObject* parent = nullptr);
    WimaArea(const WimaArea& other, QObject* parent = nullptr);
22
    WimaArea &operator=(const WimaArea &other);
23 24


25 26 27 28 29 30 31
    Q_PROPERTY(double           maxAltitude             READ maxAltitude                WRITE setMaxAltitude            NOTIFY maxAltitudeChanged)
    Q_PROPERTY(QString          mapVisualQML            READ mapVisualQML                                               CONSTANT)
    Q_PROPERTY(QString          editorQML               READ editorQML                                                  CONSTANT)
    Q_PROPERTY(Fact*            borderPolygonOffset     READ borderPolygonOffsetFact                                    CONSTANT)
    Q_PROPERTY(QGCMapPolygon*   borderPolygon           READ borderPolygon                                              NOTIFY borderPolygonChanged)
    Q_PROPERTY(Fact*            showBorderPolygon       READ showBorderPolygon                                          CONSTANT)
    Q_PROPERTY(bool             wimaAreaInteractive     READ wimaAreaInteractive        WRITE setWimaAreaInteractive    NOTIFY wimaAreaInteractiveChanged)
32

33 34

    //Property accessors
35 36 37 38 39
    double          maxAltitude             (void) const    { return _maxAltitude;}
    Fact*           borderPolygonOffsetFact (void)          { return &_borderPolygonOffset;}
    Fact*           showBorderPolygon       (void)          { return &_showBorderPolygon;}
    double          borderPolygonOffset     (void) const    { return _borderPolygonOffset.rawValue().toDouble();}
    QGCMapPolygon*  borderPolygon           (void)          { return &_borderPolygon;}
40 41 42
    bool            wimaAreaInteractive     (void) const    { return _wimaAreaInteractive;}

    void            setWimaAreaInteractive          (bool interactive);
43

44
    // overrides from WimaArea
45 46
    virtual QString                 mapVisualQML    (void) const { return ""; }
    virtual QString                 editorQML       (void) const { return ""; }
47 48

    // Member Methodes
49 50 51
    int             getClosestVertexIndex   (const QGeoCoordinate& coordinate) const;
    QGeoCoordinate  getClosestVertex        (const QGeoCoordinate& coordinate) const;
    QGCMapPolygon   toQGCPolygon            () const;
52
    bool            join                    (WimaArea &area);
53
    bool            join                    (WimaArea &area, QString &errorString);
54 55
    int             nextVertexIndex         (int index) const;
    int             previousVertexIndex     (int index) const;
56 57
    bool            isSimplePolygon         () const;
    bool            containsCoordinate      (const QGeoCoordinate &coordinate) const;
58 59 60 61 62 63


    void saveToJson     (QJsonObject& jsonObject);
    bool loadFromJson   (const QJsonObject &jsonObject, QString& errorString);

    // static Methodes
64
    static QGCMapPolygon    toQGCPolygon        (const WimaArea& area);
65
    static bool             join                (const WimaArea &area1, const WimaArea &area2, WimaArea& joinedArea, QString &errorString);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
66
    static bool             join                (const WimaArea &area1, const WimaArea &area2, WimaArea& joinedArea);
67

68

69 70 71 72
    // Friends
    friend void print(const WimaArea& area, QString& outputString);
    friend void print(const WimaArea& area);

73
    // static Members
74
    // Accurracy used to compute isDisjunct
75
    static const double epsilonMeter;
76 77
    static const char*  maxAltitudeName;
    static const char*  wimaAreaName;
78 79
    static const char*  areaTypeName;    
    static const char*  borderPolygonOffsetName;
80
    static const char*  showBorderPolygonName;
81
    static const char*  settingsGroup;
82 83

signals:
84
    void    maxAltitudeChanged              (void);
85 86
    void    borderPolygonChanged           (void);
    void    borderPolygonOffsetChanged     (void);
87
    void    wimaAreaInteractiveChanged             (void);
88

89
public slots:
90 91 92
    void setMaxAltitude         (double altitude);
    void setShowBorderPolygon   (bool showBorderPolygon);
    void setBorderPolygonOffset (double offset);
93

94
private slots:
95 96 97
    void recalcPolygons             (void);
    void updatePolygonConnections   (QVariant value);
    void recalcInteractivity        (void);
98

99 100 101

private:
    void init();
102 103 104 105 106 107 108 109

    double                          _maxAltitude;

    QMap<QString, FactMetaData*>    _metaDataMap;
    SettingsFact                    _borderPolygonOffset;
    SettingsFact                    _showBorderPolygon;

    QGCMapPolygon                   _borderPolygon;
110 111

    bool                            _wimaAreaInteractive;
112 113
};

114

115 116 117