WimaPlanData.cc 3.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#include "WimaPlanData.h"

WimaPlanData::WimaPlanData(QObject *parent)
    :   QObject (parent)
{

}

WimaPlanData::WimaPlanData(const WimaPlanData &other, QObject *parent)
    :   QObject (parent)
{
    *this = other;
}

/*!
 * \fn WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other)
 *
 * Copies the data area list of \a other to the calling \c WimaPlanData object.
 * Returns a reference to the calling \c WimaPlanData object.
 */
WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other)
{
23
    // copy wima areas
24 25
    QList<const WimaAreaData*> areaList = other.areaList();
    _areaList.clear();
26 27
    for (int i = 0; i < areaList.size(); i++) {
        const WimaAreaData *areaData = areaList[i];
28
        // determine area type and append
29 30
        if       (areaData->type() == WimaJoinedAreaData::typeString) {
            this->append(*qobject_cast<const WimaJoinedAreaData*>(areaData));
31
        }else if (areaData->type() == WimaServiceAreaData::typeString) {
32
            this->append(*qobject_cast<const WimaServiceAreaData*>(areaData));
33
        }else if (areaData->type() == WimaMeasurementAreaData::typeString) {
34
            this->append(*qobject_cast<const WimaMeasurementAreaData*>(areaData));
35
        }else if (areaData->type() == WimaCorridorData::typeString) {
36
            this->append(*qobject_cast<const WimaCorridorData*>(areaData));
37 38 39
        }
    }

40 41 42
    // copy mission items
    _missionItems = other.missionItems();

43 44 45 46 47 48 49 50 51
    return *this;
}


/*!
 * \fn void WimaPlanData::append(const WimaAreaData &areaData)
 *
 * Adds a WimaAreaData item.
 */
52
void WimaPlanData::append(const WimaJoinedAreaData &areaData)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
{
    _joinedArea = areaData;

    if( !_areaList.contains(&_joinedArea) ) {
        _areaList.append(&_joinedArea);
    }
}

/*!
 * \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
 *
 * Adds a WimaServiceAreaData item.
 */
void WimaPlanData::append(const WimaServiceAreaData &areaData)
{
    _serviceArea = areaData;

    if( !_areaList.contains(&_serviceArea) ) {
        _areaList.append(&_serviceArea);
    }
}

/*!
 * \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
 *
 * Adds a WimaCorridorData item.
 */
void WimaPlanData::append(const WimaCorridorData &areaData)
{
    _corridor = areaData;

    if( !_areaList.contains(&_corridor) ) {
        _areaList.append(&_corridor);
    }
}

/*!
 * \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
 *
 * Adds a WimaMeasurementAreaData item.
 */
void WimaPlanData::append(const WimaMeasurementAreaData &areaData)
{
    _measurementArea = areaData;

    if( !_areaList.contains(&_measurementArea) ) {
        _areaList.append(&_measurementArea);
    }
}

103
void WimaPlanData::append(const QList<MissionItem *> &missionItems)
104
{
105 106 107 108
    for (MissionItem *item : missionItems) {
        MissionItem copy = MissionItem(*item, this);
        _missionItems.append(copy);
    }
109 110
}

111 112 113 114 115 116 117 118
/*!
 * \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
 *
 * Clears all stored objects
 */
void WimaPlanData::clear()
{
    _areaList.clear();
119
    _missionItems.clear();
120 121 122 123 124 125 126
}

QList<const WimaAreaData *> WimaPlanData::areaList() const
{
    return _areaList;
}

127
QList<MissionItem> WimaPlanData::missionItems() const
128 129 130 131
{
    return _missionItems;
}

132 133 134 135 136 137 138 139 140 141 142
/*!
 * \class WimaPlanData
 * \brief Class storing data generated by the \c WimaPlaner class.
 *
 * This class is designed to store data generated by the \c WimaPlaner class and
 * meant for data exchange between the \c WimaController and the \c WimaPlanner.
 * It stores a QList of \c WimaAreaData objects, called area data list, containing the data of serveral \c WimaAreas
 * generated by the \c WimaPlaner.
 *
 * \sa QList
 */