#pragma once

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

#include "QScopedPointer"

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(QmlObjectListModel*      vehicleList                 READ vehicleList                                                    NOTIFY vehicleListChanged)
    Q_PROPERTY(QGCMapPolyline*          entryPolyline               READ entryPolyline                                                  NOTIFY entryPolylineChanged)

    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 "WimaGlobalMeasurementPolygonMapVisual.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;}
    QmlObjectListModel*                         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);


    static const char* settingsGroup;


signals:
    void bottomLayerAltitudeChanged     (void);
    void numberOfLayersChanged          (void);
    void layerDistanceChanged           (void);
    void vehicleListChanged             (void);
    void entryPolylineChanged           (void);
    void subPolygonsChanged             (void);


private:
    QMap<QString, FactMetaData*> _metaDataMap;

    SettingsFact            _bottomLayerAltitude;
    SettingsFact            _numberOfLayers;
    SettingsFact            _layerDistance;


    QmlObjectListModel*     _vehicleList;
    QGCMapPolyline*         _entryPolyline;





    SettingsFact

};

