WimaMeasurementArea.h 2.79 KB
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1
#pragma once
2

3
#include <QFutureWatcher>
Valentin Platzgummer's avatar
Valentin Platzgummer committed
4
#include <QObject>
Valentin Platzgummer's avatar
Valentin Platzgummer committed
5
#include <QTimer>
6

Valentin Platzgummer's avatar
Valentin Platzgummer committed
7
#include "WimaArea.h"
8

Valentin Platzgummer's avatar
Valentin Platzgummer committed
9
#include "SettingsFact.h"
10

11 12 13 14 15 16 17 18 19 20 21 22 23 24
class TileData : public QObject {
public:
  QmlObjectListModel tiles;
  QVariantList tileCenterPoints;

  TileData();
  ~TileData();

  TileData &operator=(const TileData &other);

  void clear();
  std::size_t size() const;
};

25 26
class WimaMeasurementArea : public WimaArea {
  Q_OBJECT
27
public:
28 29 30 31
  WimaMeasurementArea(QObject *parent = nullptr);
  WimaMeasurementArea(const WimaMeasurementArea &other,
                      QObject *parent = nullptr);
  WimaMeasurementArea &operator=(const WimaMeasurementArea &other);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
32
  ~WimaMeasurementArea();
33

Valentin Platzgummer's avatar
Valentin Platzgummer committed
34 35 36 37 38 39
  Q_PROPERTY(Fact *tileHeight READ tileHeight CONSTANT)
  Q_PROPERTY(Fact *tileWidth READ tileWidth CONSTANT)
  Q_PROPERTY(Fact *minTileArea READ minTileArea CONSTANT)
  Q_PROPERTY(Fact *transectDistance READ transectDistance CONSTANT)
  Q_PROPERTY(Fact *minTransectLength READ minTransectLength CONSTANT)
  Q_PROPERTY(Fact *showTiles READ showTiles CONSTANT)
40 41
  Q_PROPERTY(QmlObjectListModel *tiles READ tiles NOTIFY tilesChanged)
  Q_PROPERTY(int maxTiles READ maxTiles NOTIFY maxTilesChanged)
42 43

  // Overrides from WimaPolygon
Valentin Platzgummer's avatar
Valentin Platzgummer committed
44 45 46 47 48 49 50 51 52
  QString mapVisualQML(void) const;
  QString editorQML(void) const;

  Fact *tileHeight();
  Fact *tileWidth();
  Fact *minTileArea();
  Fact *transectDistance();
  Fact *minTransectLength();
  Fact *showTiles();
53
  QmlObjectListModel *tiles();
54
  const QmlObjectListModel *tiles() const;
55 56
  const QVariantList &tileCenterPoints() const; // List of QGeoCoordinate
  const TileData &tileData() const;
57 58
  int maxTiles() const;
  bool ready() const;
59 60 61 62 63 64 65 66 67 68 69 70 71 72

  // Member Methodes
  void saveToJson(QJsonObject &json);
  bool loadFromJson(const QJsonObject &json, QString &errorString);

  // Friends
  friend void print(const WimaMeasurementArea &area, QString outputStr);
  friend void print(const WimaMeasurementArea &area);

  // Static Variables
  static const char *settingsGroup;
  static const char *tileHeightName;
  static const char *tileWidthName;
  static const char *minTileAreaName;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
73 74 75
  static const char *transectDistanceName;
  static const char *minTransectLengthName;
  static const char *showTilesName;
76
  static const char *WimaMeasurementAreaName;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
77 78

signals:
79 80
  void tilesChanged();
  void maxTilesChanged();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
81 82

public slots:
83

Valentin Platzgummer's avatar
Valentin Platzgummer committed
84 85 86
private slots:
  void doUpdate();
  void deferUpdate();
87
  void storeTiles();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
88

Valentin Platzgummer's avatar
Valentin Platzgummer committed
89
private:
90 91
  // Member Methodes
  void init();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
92

93 94
  // Members
  QMap<QString, FactMetaData *> _metaDataMap;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
95

96
  SettingsFact _tileHeight;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
97
  SettingsFact _tileWidth;
98 99 100
  SettingsFact _minTileArea;
  SettingsFact _transectDistance;
  SettingsFact _minTransectLength;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
101 102 103 104
  SettingsFact _showTiles;

  // Tile stuff.
  QTimer _timer;
105 106 107
  using DataPtr = std::shared_ptr<TileData>;
  TileData _tileData;
  QFutureWatcher<DataPtr> _watcher;
108
  bool _calculating;
109
};