WimaMeasurementAreaData.cc 3.65 KB
Newer Older
1
#include "WimaMeasurementAreaData.h"
2
#include "SnakeTile.h"
3 4 5 6

const char *WimaMeasurementAreaData::typeString = "WimaMeasurementAreaData";

WimaMeasurementAreaData::WimaMeasurementAreaData(QObject *parent)
7
    : WimaAreaData(parent) {}
8

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

15 16 17 18
WimaMeasurementAreaData::WimaMeasurementAreaData(
    const WimaMeasurementArea &other, QObject *parent)
    : WimaAreaData(parent) {
  *this = other;
19 20
}

21 22 23 24
bool WimaMeasurementAreaData::
operator==(const WimaMeasurementAreaData &other) const {
  return this->WimaAreaData::operator==(other) &&
         this->_tileData == other.tileData() &&
25
         this->_progress == other.progress() &&
26 27 28 29 30 31 32 33
         this->center() == other.center();
}

bool WimaMeasurementAreaData::
operator!=(const WimaMeasurementAreaData &other) const {
  return !(*this == other);
}

34 35 36
void WimaMeasurementAreaData::setTileData(const TileData &d) {
  if (this->_tileData != d) {
    this->_tileData = d;
37 38
    this->_progress.fill(0, d.size());
    emit progressChanged();
39 40 41 42 43
    emit tileDataChanged();
  }
}

void WimaMeasurementAreaData::setProgress(const QVector<int> &d) {
44
  if (this->_progress != d && d.size() == this->_tileData.tiles.count()) {
45 46 47 48 49
    this->_progress = d;
    emit progressChanged();
  }
}

50 51 52 53 54
/*!
 * \overload operator=();
 *
 * Assigns \a other to the invoking object.
 */
55 56
WimaMeasurementAreaData &WimaMeasurementAreaData::
operator=(const WimaMeasurementAreaData &other) {
57 58 59
  WimaAreaData::operator=(other);
  setTileData(other._tileData);
  setProgress(other._progress);
60

61
  return *this;
62 63 64 65 66 67 68
}

/*!
 * \overload operator=();
 *
 * Assigns \a other to the invoking object.
 */
69 70
WimaMeasurementAreaData &WimaMeasurementAreaData::
operator=(const WimaMeasurementArea &other) {
71 72 73 74 75 76 77 78
  WimaAreaData::operator=(other);
  if (other.ready()) {
    setTileData(other.tileData());
    setProgress(other.progress());
  } else {
    qWarning() << "WimaMeasurementAreaData::operator=(): WimaMeasurementArea "
                  "not ready.";
  }
79

80
  return *this;
81 82
}

83 84 85 86
QString WimaMeasurementAreaData::mapVisualQML() const {
  return QStringLiteral("WimaMeasurementAreaDataVisual.qml");
}

87 88
QString WimaMeasurementAreaData::type() const { return this->typeString; }

89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
QmlObjectListModel *WimaMeasurementAreaData::tiles() {
  return &this->_tileData.tiles;
}

const QmlObjectListModel *WimaMeasurementAreaData::tiles() const {
  return &this->_tileData.tiles;
}

const QVariantList &WimaMeasurementAreaData::tileCenterPoints() const {
  return this->_tileData.tileCenterPoints;
}

QVariantList &WimaMeasurementAreaData::tileCenterPoints() {
  return this->_tileData.tileCenterPoints;
}

const TileData &WimaMeasurementAreaData::tileData() const {
106
  return this->_tileData;
107 108
}

109
TileData &WimaMeasurementAreaData::tileData() { return this->_tileData; }
110 111 112 113 114 115 116

const QVector<int> &WimaMeasurementAreaData::progress() const {
  return this->_progress;
}

QVector<int> &WimaMeasurementAreaData::progress() { return this->_progress; }

117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
bool operator==(const WimaMeasurementAreaData &m1,
                const WimaMeasurementArea &m2) {
  return operator==(*static_cast<const WimaAreaData *>(&m1),
                    *static_cast<const WimaArea *>(&m2)) &&
         m1.tileData() == m2.tileData() && m1.progress() == m2.progress();
}

bool operator!=(const WimaMeasurementAreaData &m1,
                const WimaMeasurementArea &m2) {
  return !(m1 == m2);
}

bool operator==(const WimaMeasurementArea &m1,
                const WimaMeasurementAreaData &m2) {
  return m2 == m1;
}

bool operator!=(const WimaMeasurementArea &m1,
                const WimaMeasurementAreaData &m2) {
  return m2 != m1;
}