#pragma once


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





class WimaPolygon : public QObject //abstract base class for all WimaPolygons
{
    Q_OBJECT
public:
    WimaPolygon(QObject* parent = nullptr);
    WimaPolygon(QGCMapPolygon* other, QObject* parent = nullptr);
    ~WimaPolygon();



    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(bool                     interactive                 READ interactive                WRITE setInteractive                NOTIFY interactiveChanged)
    Q_PROPERTY(int                      count                       READ count                                                          NOTIFY countChanged)

    //Property accessors
    double                  maxAltitude         (void) const    { return _maxAltitude;}
    Vehicle*                vehicle             (void) const    { return _vehicle.vehicle();}
    QGCMapPolygon*          polygon             (void) const    { return _polygon;}
    bool                    interactive         (void) const    { return _polygon->interactive();}
    int                     count               (void) const    { return _polygon->count();}

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


    //Property setters
    void        setMaxAltitude     (double alt);
    void        setVehicle         (Vehicle* vehicle);
    void        setInteractive     (bool interactive);


    // Member Methodes
    QList<QGCMapPolygon*>* splitPolygonArea(QGCMapPolygon *polygonToSplitt, int numberOfFractions); // use QScopedPointer to store return value
    QList<QGCMapPolygon*>* splitPolygonArea(int numberOfFractions); // use QScopedPointer to store return value




signals:
    void    maxAltitudeChanged      (void);
    void    vehicleChanged          (void);
    void    polygonChanged          (void);
    void    interactiveChanged      (void);
    void    polylineChanged         (void);
    void    countChanged            (void);


protected:
    double                  _maxAltitude;
    WimaVehicle             _vehicle;
    QGCMapPolygon*          _polygon;
};


