#ifndef WIMAPOLYGON_H
#define WIMAPOLYGON_H

#include "QGCMapPolygon.h"
#include "Vehicle.h"



class WimaPolygon : public QGCMapPolygon //abstract base class for all WimaPolygons
{
    Q_OBJECT
public:
    WimaPolygon(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)
    Q_PROPERTY(QmlObjectListModel*  polygonFractions            READ polygonFractions                                               NOTIFY polygonFractionsChanged)

    //Property accessors
    double      maxAltitude     (void) const     { return _maxAltitude;}
    Vehicle*    vehicle         (void) const     { return _vehicle;}

    virtual QString         mapVisualQML    (void) const = 0;
    virtual QString         editorQML       (void) const = 0;

    //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);
    void    polygonFractionsChanged (QmlObjectListModel* pfrac);

protected:
    QGCMapPolygon* extractQGCPolygon(void);

private:


    double                  _maxAltitude;
    Vehicle*                _vehicle;
    QmlObjectListModel*     _polygonFractions;
};

#endif // WIMAPOLYGON_H
