#ifndef WIMAPOLYGON_H
#define WIMAPOLYGON_H

#include "QGCMapPolygon.h"
#include "QGCMapPolyline.h"
#include "Vehicle.h"
#include "qobject.h"



class WimaPolygon : public QObject //abstract base class for all WimaPolygons
{
    Q_OBJECT
public:
    WimaPolygon(QObject* parent = nullptr);
    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)
    Q_PROPERTY(QGCMapPolygon*           polygon                     READ polygon                                                        NOTIFY polygonChanged)
    Q_PROPERTY(QList<WimaPolygon*>      subPolygons                 READ subPolygons                                                    NOTIFY subPolygonsChanged)
    Q_PROPERTY(QList<QGCMapPolyline*>   subPolylines                READ subPolylines                                                   NOTIFY  subPolylinesChanged)

    //Property accessors
    double                  maxAltitude         (void) const    { return _maxAltitude;}
    Vehicle*                vehicle             (void) const    { return _vehicle;}
    QGCMapPolygon*          polygon             (void) const    { return _polygon;}
    QList<WimaPolygon*>     subPolygons         (void) const    { return _subPolygons;}
    QList<QGCMapPolyline*>  subPolylines        (void) const    { return _subPolylines;}

    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);


    QGCMapPolygon* splitPolygonArea(int numberOfFractions);


signals:
    void    maxAltitudeChanged      (void);
    void    vehicleChanged          (void);
    void    subPolygons             (void);


private:


    double                  _maxAltitude;
    Vehicle*                _vehicle;
    QGCMapPolygon*          _polygon;
    QList<WimaPolygon*>     _subPolygons;
    QList<QGCMapPolyline*>  _subPolylines;
};

#endif // WIMAPOLYGON_H
