WimaPolygon.cc 907 Bytes
Newer Older
1 2 3
#include "WimaPolygon.h"

WimaPolygon::WimaPolygon(QObject *parent) :
4
    QObject                 (parent)
5 6
  ,_maxAltitude             (30)
  ,_vehicle                 (nullptr)
7
  ,_polygon                 (new QGCMapPolygon(this))
8 9 10
{
}

11 12 13
WimaPolygon::WimaPolygon(QGCMapPolygon *other, QObject *parent):
    WimaPolygon(parent)
{
14
    delete _polygon;
15 16 17 18
    *_polygon = *other;
}


19 20 21 22
void WimaPolygon::setMaxAltitude(double alt)
{
    if(alt > 0 && alt != _maxAltitude){
        _maxAltitude = alt;
23
        emit maxAltitudeChanged();
24 25 26 27 28 29 30 31
    }
}


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

36
QGCMapPolygon* WimaPolygon::splitPolygonArea(int numberOfFractions)
37 38
{
    if(numberOfFractions > 0){
39 40
        QGCMapPolygon* poly = new QGCMapPolygon(this->polygon(), this);
        return poly;
41 42 43 44 45
    }
    return nullptr;
}