WimaPlanData_old.cc 3.46 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 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 48 49 50 51 52 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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
#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) {
  // 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));
    }
  }

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

  return *this;
}

/*!
 * \fn void WimaPlanData::append(const WimaAreaData &areaData)
 *
 * Adds a WimaAreaData item.
 */
void WimaPlanData::append(const WimaJoinedAreaData &areaData) {
  _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);
  }
}

void WimaPlanData::append(const QList<MissionItem *> &missionItems) {
  for (auto *item : missionItems) {
    item->setParent(this);
    _missionItems.append(item);
  }
}

/*!
 * \fn void WimaPlanData::append(const WimaServiceAreaData &areaData)
 *
 * Clears all stored objects
 */
void WimaPlanData::clear() {
  _areaList.clear();
  _missionItems.clear();
}

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

const QList<MissionItem> &WimaPlanData::missionItems() const {
  return _missionItems;
}

/*!
 * \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
 */