#ifndef WIMAGLOBALMEASUREMENTPOLYGON_H
#define WIMAGLOBALMEASUREMENTPOLYGON_H

#include <QObject>
#include "WimaPolygon.h"
#include "QGCMapPolyline.h"
#include "QGCMapPolygon.h"
#include "WimaVehicleMeasurementPolygon.h"

class WimaGlobalMeasurementPolygon : public WimaPolygon
{
    Q_OBJECT
public:
    WimaGlobalMeasurementPolygon(QObject* parent);
    WimaGlobalMeasurementPolygon(QGCMapPolygon* other, QObject* parent);

    Q_PROPERTY(double                   bottomLayerAltitude         READ bottomLayerAltitude        WRITE setBottomLayerAltitude        NOTIFY bottomLayerAltitudeChanged)
    Q_PROPERTY(int                      numberOfLayers              READ numberOfLayers             WRITE setNumberOfLayers             NOTIFY numberOfLayersChanged)
    Q_PROPERTY(double                   layerDistance               READ layerDistance              WRITE setLayerDistance              NOTIFY layerDistanceChanged)
    Q_PROPERTY(QList<Vehicle*>          vehicleList                 READ vehicleList                                                    NOTIFY vehicleListChanged)
    Q_PROPERTY(QGCMapPolyline*          entryPolyline               READ entryPolyline                                                  NOTIFY entryPolylineChanged)
    Q_PROPERTY( QList<WimaPolygon*>     subPolygons                 READ subPolygons                                                    NOTIFY subPolygonsChanged)

    Q_INVOKABLE void addVehicle(Vehicle *vehicle);
    Q_INVOKABLE void removeVehicle(int vehicleIndex);
    Q_INVOKABLE void recalculatesubPolygons();
    Q_INVOKABLE void removeAllVehicles();


    // Overrides from WimaPolygon
    QString         mapVisualQML    (void) const { return "WimaGlobalMeasurementPolygonMapVisal.qml";}
    QString         editorQML       (void) const { return "WimaGlobalMeasurementPolygonEditor.qml";}

    // Property accessors
    double                                      bottomLayerAltitude     (void) const { return _bottomLayerAltitude;}
    int                                         numberOfLayers          (void) const { return _numberOfLayers;}
    double                                      layerDistance           (void) const { return _layerDistance;}
    QList<Vehicle*>                             vehicleList             (void) const { return _vehicleList;}
    QGCMapPolyline*                             entryPolyline           (void) const { return _entryPolyline;}

    // Property setters

    void setBottomLayerAltitude     (double altitude);
    void setNumberOfLayers          (int numberOfLayers);
    void setLayerDistance           (double distance);

signals:
    void bottomLayerAltitudeChanged     (double altitude);
    void numberOfLayersChanged          (int numberOfLayers);
    void layerDistanceChanged           (double distance);
    void vehicleListChanged             (QList<Vehicle*> vehicleList);
    void entryPolylineChanged           (QGCMapPolyline* polyline);
    void subPolygonsChanged             (QList<WimaPolygon*> subPolygons);


private:
    double                  _bottomLayerAltitude;
    int                     _numberOfLayers;
    double                  _layerDistance;
    QList<Vehicle*>         _vehicleList;
    QGCMapPolyline*         _entryPolyline;

};

#endif // WIMAGLOBALMEASUREMENTPOLYGON_H
