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

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

5

6

Valentin Platzgummer's avatar
Valentin Platzgummer committed
7 8 9
WimaServiceArea::WimaServiceArea(QObject *parent)
    :   WimaArea (parent)
{
10
    init();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
11 12
}

13
WimaServiceArea::WimaServiceArea(const WimaServiceArea &other, QObject *parent)
Valentin Platzgummer's avatar
Valentin Platzgummer committed
14
    :    WimaArea (other, parent)
15
{
16 17 18
    init();
}

19 20 21 22 23 24 25 26 27 28 29 30
/*!
 * \overload operator=()
 *
 * Calls the inherited operator WimaArea::operator=().
 */
WimaServiceArea &WimaServiceArea::operator=(const WimaServiceArea &other)
{
    WimaArea::operator=(other);

    return *this;
}

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

39
void WimaServiceArea::setLandPosition(const QGeoCoordinate &coordinate)
40
{
41 42
    if(_landPosition != coordinate){
        _landPosition = coordinate;
43 44 45 46
        emit landPositionChanged();
    }
}

47 48 49 50 51 52 53
void WimaServiceArea::saveToJson(QJsonObject &json)
{
    this->WimaArea::saveToJson(json);
    json[areaTypeName] = wimaServiceAreaName;
}

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

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
void print(const WimaServiceArea &area)
{
    QString message;
    print(area, message);
    qWarning() << message;
}

void print(const WimaServiceArea &area, QString &outputStr)
{
    print(static_cast<const WimaArea&>(area), outputStr);
    outputStr.append(QString("Takeoff Position: %s\n").arg(area._takeOffPosition.toString(QGeoCoordinate::Degrees)));
    outputStr.append(QString("Land Position: %s\n").arg(area._landPosition.toString(QGeoCoordinate::Degrees)));
}

void WimaServiceArea::init()
{
    this->setObjectName(wimaServiceAreaName);
}