AreaData.cc 3.4 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 128 129 130 131 132 133 134 135 136 137
#include "WimaPlanData.h"

AreaData::AreaData(QObject *parent) : QObject(parent) {}

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

AreaData &AreaData::operator=(const AreaData &other) {
  this->append(other.measurementArea());
  this->append(other.serviceArea());
  this->append(other.joinedArea());
  this->append(other.corridor());

  return *this;
}

void AreaData::append(const WimaJoinedAreaData &areaData) {
  if (_joinedArea != areaData) {
    _joinedArea = areaData;
    emit joinedAreaChanged();
  }
}

void AreaData::append(const WimaServiceAreaData &areaData) {
  if (_serviceArea != areaData) {
    _serviceArea = areaData;
    emit serviceAreaChanged();
  }
}

void AreaData::append(const WimaCorridorData &areaData) {
  if (_corridor != areaData) {
    _corridor = areaData;
    emit corridorChanged();
  }
}

void AreaData::append(const WimaMeasurementAreaData &areaData) {
  if (_measurementArea != areaData) {
    _measurementArea = areaData;
    emit measurementAreaChanged();

    if (_measurementArea.coordinateList().size() > 0) {
      setOrigin(_measurementArea.coordinateList().first());
    } else {
      setOrigin(QGeoCoordinate());
    }
  }
}

void AreaData::append(const WimaJoinedArea &areaData) {
  if (_joinedArea != areaData) {
    _joinedArea = areaData;
    emit joinedAreaChanged();
  }
}

void AreaData::append(const WimaArea &areaData) {
  if (_serviceArea != areaData) {
    _serviceArea = areaData;
    emit serviceAreaChanged();
  }
}

void AreaData::append(const WimaCorridor &areaData) {
  if (_corridor != areaData) {
    _corridor = areaData;
    emit corridorChanged();
  }
}

void AreaData::append(const WimaMeasurementArea &areaData) {
  if (_measurementArea != areaData) {
    _measurementArea = areaData;
    emit measurementAreaChanged();

    if (_measurementArea.coordinateList().size() > 0) {
      setOrigin(_measurementArea.coordinateList().first());
    } else {
      setOrigin(QGeoCoordinate());
    }
  }
}

void AreaData::clear() { *this = AreaData(); }

const QGeoCoordinate &AreaData::origin() const { return _origin; }

bool AreaData::isValid() {
  return _measurementArea.coordinateList().size() >= 3 &&
         _serviceArea.coordinateList().size() >= 3 && _origin.isValid();
}

const WimaJoinedAreaData &AreaData::joinedArea() const {
  return this->_joinedArea;
}

const WimaServiceAreaData &AreaData::serviceArea() const {
  return this->_serviceArea;
}

const WimaCorridorData &AreaData::corridor() const {
  return this->_corridor;
}

const WimaMeasurementAreaData &AreaData::measurementArea() const {
  return this->_measurementArea;
}

WimaJoinedAreaData &AreaData::joinedArea() { return this->_joinedArea; }

WimaServiceAreaData &AreaData::serviceArea() { return this->_serviceArea; }

WimaCorridorData &AreaData::corridor() { return this->_corridor; }

WimaMeasurementAreaData &AreaData::measurementArea() {
  return this->_measurementArea;
}

bool AreaData::operator==(const AreaData &other) const {
  return this->_joinedArea == other._joinedArea &&
         this->_measurementArea == other._measurementArea &&
         this->_corridor == other._corridor &&
         this->_serviceArea == other._serviceArea;
}
bool AreaData::operator!=(const AreaData &other) const {
  return !(*this == other);
}

void AreaData::setOrigin(const QGeoCoordinate &origin) {
  if (this->_origin != origin) {
    this->_origin = origin;
    emit originChanged();
  }
}