#include "WimaPolygon.h"

WimaPolygon::WimaPolygon(QObject *parent) :
    QGCMapPolygon           (parent)
  ,_maxAltitude             (30)
  ,_vehicle                 (nullptr)
  ,_polygonFractions        (new QmlObjectListModel(this))
{
}

void WimaPolygon::setMaxAltitude(double alt)
{
    if(alt > 0 && alt != _maxAltitude){
        _maxAltitude = alt;
        emit maxAltitudeChanged(_maxAltitude);
    }
}


void WimaPolygon::setVehicle(Vehicle *vehicle)
{
    if(_vehicle != vehicle){
        _vehicle = vehicle;
        emit vehicleChanged(_vehicle);
    }
}

QmlObjectListModel* WimaPolygon::splitPolygonArea(int numberOfFractions)
{
    if(numberOfFractions > 0){
        _polygonFractions->append(this);
        emit polygonFractionsChanged(_polygonFractions);

        return _polygonFractions;
    }
    return nullptr;
}

QGCMapPolygon *WimaPolygon::extractQGCPolygon()
{
    QGCMapPolygon* newPolygon = new QGCMapPolygon(this->parent());

}
