WimaGlobalMeasurementPolygon.cc 2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
#include "WimaGlobalMeasurementPolygon.h"



WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QObject *parent):
    WimaPolygon (parent)
{

}

11 12 13 14 15 16
WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other, QObject *parent):
    WimaPolygon (other, parent)
{

}

17 18 19
void WimaGlobalMeasurementPolygon::addVehicle(Vehicle *vehicle)
{
    if(vehicle != nullptr){
20 21
        _vehicleList->append(vehicle);
        emit vehicleListChanged();
22 23 24 25 26
    }
}

void WimaGlobalMeasurementPolygon::removeVehicle(int vehicleIndex)
{
27 28 29
    if(vehicleIndex >= 0 && vehicleIndex < _vehicleList->count()){
        _vehicleList->removeAt(vehicleIndex);
        emit vehicleListChanged();
30 31 32
    }
}

33
void WimaGlobalMeasurementPolygon::recalculatesubPolygons()
34 35
{
    int vehicleCount = _vehicleList->count();
36
    QScopedPointer<QList<QGCMapPolygon*>> listQGCPoly(this->splitPolygonArea(vehicleCount));
37

38 39 40 41 42 43
    int polyCount = listQGCPoly->size();
    _subPolygons->clear();
    for(int i = 0; i < polyCount; i++){
        WimaVehicleMeasurementPolygon* subPoly = new WimaVehicleMeasurementPolygon(listQGCPoly->takeAt(i), this);
        _subPolygons->append(subPoly);
    }
44 45 46 47 48 49 50 51 52 53 54
}

void WimaGlobalMeasurementPolygon::removeAllVehicles()
{
    int counter = _vehicleList->count()-1;

    while(counter >= 0){
        _vehicleList->removeAt(0);
        counter--;
    }

55
    emit vehicleListChanged();
56 57 58 59 60 61
}

void WimaGlobalMeasurementPolygon::setBottomLayerAltitude(double altitude)
{
    if(altitude > 0 && altitude != _bottomLayerAltitude){
        _bottomLayerAltitude = altitude;
62
        emit bottomLayerAltitudeChanged();
63 64 65 66 67 68 69
    }
}

void WimaGlobalMeasurementPolygon::setNumberOfLayers(int numberOfLayers)
{
    if(numberOfLayers > 0 && _numberOfLayers != numberOfLayers){
        _numberOfLayers = numberOfLayers;
70
        emit numberOfLayersChanged();
71 72 73 74 75 76 77
    }
}

void WimaGlobalMeasurementPolygon::setLayerDistance(double distance)
{
    if(distance > 0 && distance != _layerDistance){
        _layerDistance = distance;
78
        emit layerDistanceChanged();
79 80
    }
}