Skip to content
WimaPolygon.h 2.41 KiB
Newer Older
#ifndef WIMAPOLYGON_H
#define WIMAPOLYGON_H

#include "QGCMapPolygon.h"
#include "Vehicle.h"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
#include "qobject.h"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
class WimaPolygon : public QObject //abstract base class for all WimaPolygons
{
    Q_OBJECT
public:
    WimaPolygon(QObject* parent = nullptr);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
    WimaPolygon(QGCMapPolygon* other, QObject* parent = nullptr);



    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(Vehicle*             vehicle                     READ vehicle                    WRITE setVehicle                    NOTIFY vehicleChanged)
Valentin Platzgummer's avatar
Valentin Platzgummer committed
    Q_PROPERTY(QGCMapPolygon*       polygon                     READ polygon                                                        NOTIFY polygonChanged)

    //Property accessors
Valentin Platzgummer's avatar
Valentin Platzgummer committed
    double                  maxAltitude         (void) const    { return _maxAltitude;}
    Vehicle*                vehicle             (void) const    { return _vehicle;}
    QGCMapPolygon*          polygon             (void) const    { return _polygon;}
Valentin Platzgummer's avatar
Valentin Platzgummer committed

    virtual QString                     mapVisualQML    (void) const = 0;
    virtual QString                     editorQML       (void) const = 0;
    virtual QList<WimaPolygon*>&        subPolygons     (void) { return _subPolygons;}

    //Property setters
    void        setMaxAltitude     (double alt);
    void        setName            (QString name);
    void        setVehicle         (Vehicle* vehicle);

    /// Splits the polygon in numberOfFractions fractions with equal area.
    ///     @param polygonFractions The polygon List to add the fractions to.
    ///     @param numberOfFractions The number of fractions to split the polygon to.
    Q_INVOKABLE QmlObjectListModel* splitPolygonArea(int numberOfFractions);


signals:
    void    maxAltitudeChanged      (double alt);
    void    vehicleChanged          (Vehicle* vehicle);

protected:
    QGCMapPolygon* extractQGCPolygon(void);

private:


    double                  _maxAltitude;
    Vehicle*                _vehicle;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
    QGCMapPolygon*          _polygon;
    QList<WimaPolygon*>     _subPolygons;
};

#endif // WIMAPOLYGON_H