WimaPlanData.cc 3.67 KB
Newer Older
1 2
#include "WimaPlanData.h"

3
WimaPlanData::WimaPlanData(QObject *parent) : QObject(parent) {}
4 5

WimaPlanData::WimaPlanData(const WimaPlanData &other, QObject *parent)
6 7
    : QObject(parent) {
  *this = other;
8 9 10 11 12 13 14 15
}

/*!
 * \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.
 */
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
WimaPlanData &WimaPlanData::operator=(const WimaPlanData &other) {
  // copy wima areas
  QList<const WimaAreaData *> areaList = other.areaList();
  _areaList.clear();
  for (int i = 0; i < areaList.size(); i++) {
    const WimaAreaData *areaData = areaList[i];
    // determine area type and append
    if (areaData->type() == WimaJoinedAreaData::typeString) {
      this->append(*qobject_cast<const WimaJoinedAreaData *>(areaData));
    } else if (areaData->type() == WimaServiceAreaData::typeString) {
      this->append(*qobject_cast<const WimaServiceAreaData *>(areaData));
    } else if (areaData->type() == WimaMeasurementAreaData::typeString) {
      this->append(*qobject_cast<const WimaMeasurementAreaData *>(areaData));
    } else if (areaData->type() == WimaCorridorData::typeString) {
      this->append(*qobject_cast<const WimaCorridorData *>(areaData));
31
    }
32
  }
33

34 35
  // copy mission items
  _missionItems = other.missionItems();
36

37
  return *this;
38 39 40 41 42 43 44
}

/*!
 * \fn void WimaPlanData::append(const WimaAreaData &areaData)
 *
 * Adds a WimaAreaData item.
 */
45 46
void WimaPlanData::append(const WimaJoinedAreaData &areaData) {
  _joinedArea = areaData;
47

48 49 50
  if (!_areaList.contains(&_joinedArea)) {
    _areaList.append(&_joinedArea);
  }
51 52 53 54 55 56 57
}

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

61 62 63
  if (!_areaList.contains(&_serviceArea)) {
    _areaList.append(&_serviceArea);
  }
64 65 66 67 68 69 70
}

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

74 75 76
  if (!_areaList.contains(&_corridor)) {
    _areaList.append(&_corridor);
  }
77 78 79 80 81 82 83
}

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

87 88 89
  if (!_areaList.contains(&_measurementArea)) {
    _areaList.append(&_measurementArea);
  }
90 91
}

92 93 94 95
void WimaPlanData::setTransects(const QList<QList<QGeoCoordinate>> &transects) {
  _transects = transects;
}

96 97 98 99 100
void WimaPlanData::append(const QList<MissionItem *> &missionItems) {
  for (auto *item : missionItems) {
    item->setParent(this);
    _missionItems.append(item);
  }
101 102
}

103 104 105 106 107
/*!
 * \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
 *
 * Clears all stored objects
 */
108 109 110
void WimaPlanData::clear() {
  _areaList.clear();
  _missionItems.clear();
111 112
}

113 114
const QList<const WimaAreaData *> &WimaPlanData::areaList() const {
  return _areaList;
115 116
}

117 118 119 120
const QList<QList<QGeoCoordinate>> &WimaPlanData::transects() const {
  return _transects;
}

121
const QList<MissionItem *> &WimaPlanData::missionItems() const {
122
  return _missionItems;
123 124
}

125 126 127 128 129 130
/*!
 * \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.
131 132
 * It stores a QList of \c WimaAreaData objects, called area data list,
 * containing the data of serveral \c WimaAreas generated by the \c WimaPlaner.
133 134 135
 *
 * \sa QList
 */