WimaServiceArea.cc 1.59 KB
Newer Older
1 2
#include "WimaServiceArea.h"

3 4
const char* WimaServiceArea::wimaServiceAreaName = "Service Area";

Valentin Platzgummer's avatar
Valentin Platzgummer committed
5 6
WimaServiceArea::WimaServiceArea()
    :   WimaServiceArea(nullptr)
7 8 9
{

}
10

Valentin Platzgummer's avatar
Valentin Platzgummer committed
11 12 13 14 15 16 17 18
WimaServiceArea::WimaServiceArea(QObject *parent)
    :   WimaArea (parent)
{
    this->setObjectName(wimaServiceAreaName);
}

WimaServiceArea::WimaServiceArea(const WimaArea &other, QObject *parent)
    :    WimaArea (other, parent)
19
{
20
    this->setObjectName(wimaServiceAreaName);
21 22
}

23
void WimaServiceArea::setTakeOffPosition(const QGeoCoordinate &coordinate)
24
{
25 26
    if(_takeOffPosition != coordinate){
        _takeOffPosition = coordinate;
27 28 29 30
        emit takeOffPositionChanged();
    }
}

31
void WimaServiceArea::setLandPosition(const QGeoCoordinate &coordinate)
32
{
33 34
    if(_landPosition != coordinate){
        _landPosition = coordinate;
35 36 37 38
        emit landPositionChanged();
    }
}

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
void WimaServiceArea::setVehicleCorridor(WimaVCorridor &corridor)
{

    if (&corridor != _vehicleCorridor){
        _vehicleCorridor = &corridor;
        emit vehicleCorridorChanged(*_vehicleCorridor);
    }
    else {
        qWarning("WimaServiceArea::setVehicleCorridor(): new corridor equals old _vehicleCorridor!");
    }
}

void WimaServiceArea::saveToJson(QJsonObject &json)
{
    this->WimaArea::saveToJson(json);
    json[areaTypeName] = wimaServiceAreaName;
}

bool WimaServiceArea::loadFromJson(const QJsonObject &json, QString &errorString)
58
{
59 60 61 62 63 64 65
    if ( this->WimaArea::loadFromJson(json, errorString)) {
        bool retVal = true;
        // code for loading here
        return retVal;
    } else {
        qWarning() << errorString;
        return false;
66 67 68
    }
}