WimaAreaData.cc 3.13 KB
Newer Older
1 2 3
#include "WimaAreaData.h"

const char *WimaAreaData::typeString = "WimaAreaData";
Valentin Platzgummer's avatar
Valentin Platzgummer committed
4 5 6 7 8 9

WimaAreaData::WimaAreaData(QObject *parent) : QObject(parent)
{
    _maxAltitude = 0;
}

10 11 12 13 14 15 16
WimaAreaData::WimaAreaData(const WimaAreaData &other, QObject *parent)
    : QObject (parent)
{
    *this = other;
}

WimaAreaData::WimaAreaData(const WimaArea &other, QObject *parent)
Valentin Platzgummer's avatar
Valentin Platzgummer committed
17 18
    : QObject (parent)
{
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    *this = other;
}

/*!
 * \fn WimaAreaData &WimaAreaData::operator=(const WimaAreaData &otherData)
 *
 * Copies the maximum altitude and the path of the \c WimaAreaData \a otherData to the calling object.
 * Returns a reference to the calling object.
 */
WimaAreaData &WimaAreaData::operator=(const WimaAreaData &otherData)
{
    setMaxAltitude(otherData.maxAltitude());
    setPath(otherData.path());

    return *this;
}

/*!
 * \overload operator=()
 *
 * Copies the maximum altitude and the path of \c WimaArea \a otherArea to the calling object.
 * Returns a reference to the calling object.
 */
WimaAreaData &WimaAreaData::operator=(const WimaArea &otherArea)
{
    setMaxAltitude(otherArea.maxAltitude());
    setPath(otherArea.coordinateList());

    return *this;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
}

/*!
 * \fn double WimaAreaData::maxAltitude()
 *
 * Returns the maximum altitude at which vehicles are allowed to fly.
 */
double WimaAreaData::maxAltitude() const
{
    return _maxAltitude;
}

/*!
 * \fn double WimaAreaData::maxAltitude()
 *
 * Returns the path (vertex list defining the \l {Simple Polygon}).
 */
65
QVariantList WimaAreaData::path() const
Valentin Platzgummer's avatar
Valentin Platzgummer committed
66 67 68 69
{
    return _path;
}

70 71 72 73 74 75 76 77 78 79
/*!
 * \fn QString WimaAreaData::type()
 *
 * Returns the type name of the object. Used to destinguish between derived objects.
 */
QString WimaAreaData::type() const
{
    return typeString;
}

Valentin Platzgummer's avatar
Valentin Platzgummer committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
/*!
 * \fn void WimaAreaData::setMaxAltitude(double maxAltitude)
 *
 * Sets the maximum altitude member to \a maxAltitude and emits the \c maxAltitudeChanged() signal if
 * \a maxAltitude differs from the members value.
 */
void WimaAreaData::setMaxAltitude(double maxAltitude)
{
    if ( !qFuzzyCompare(_maxAltitude, maxAltitude) ) {
        _maxAltitude = maxAltitude;

        emit maxAltitudeChanged(_maxAltitude);
    }
}

95 96 97 98 99 100 101
void WimaAreaData::setPath(const QVariantList &coordinateList)
{
    _path.clear();
    _path.append(coordinateList);
}


Valentin Platzgummer's avatar
Valentin Platzgummer committed
102 103 104 105 106 107 108 109 110 111 112 113
/*!
 * \fn void WimaAreaData::setPath(const QList<QGeoCoordinate> &coordinateList)
 *
 * Sets the path member to \a coordinateList by copying all entries of \a coordinateList.
 * Emits the \c pathChanged() signal.
 */
void WimaAreaData::setPath(const QList<QGeoCoordinate> &coordinateList)
{
    _path.clear();

    // copy all coordinates to _path
    for(int i = 0; i < coordinateList.size(); i++) {
114
        _path.append(QVariant::fromValue(coordinateList.value(i)));
Valentin Platzgummer's avatar
Valentin Platzgummer committed
115 116 117 118 119 120 121 122 123
    }

    emit pathChanged(_path);
}

/*!
 * \class WimaArea::WimaAreaData
 * \brief Class to store and exchange data of a \c WimaArea Object.
 * Class to store and exchange data of a \c WimaArea Object. In contrast to \c WimaArea this class
124 125
 * does not uses the QGC Fact System. It is designed to exchange data between the \c WimaPlaner and
 * the \c WimaController class. And it is the base class for any derived data objects
Valentin Platzgummer's avatar
Valentin Platzgummer committed
126 127 128
 *
 * \sa WimaArea
 */