CircularSurvey.h 3.99 KB
Newer Older
1 2 3 4 5 6 7 8
#pragma once

#include <QFutureWatcher>
#include <QVector>

#include "SettingsFact.h"
#include "TransectStyleComplexItem.h"

9 10
class RoutingWorker;
class RoutingData;
11

12 13 14
class CircularSurvey : public TransectStyleComplexItem {
  Q_OBJECT
public:
15
  using PtrRoutingData = QSharedPointer<RoutingData>;
16

17 18 19 20 21 22 23
  /// @param vehicle Vehicle which this is being contructed for
  /// @param flyView true: Created for use in the Fly View, false: Created for
  /// use in the Plan View
  /// @param kmlOrShpFile Polygon comes from this file, empty for default
  /// polygon
  CircularSurvey(Vehicle *vehicle, bool flyView, const QString &kmlOrShpFile,
                 QObject *parent);
24
  ~CircularSurvey();
25 26 27 28 29 30 31

  Q_PROPERTY(QGeoCoordinate refPoint READ refPoint WRITE setRefPoint NOTIFY
                 refPointChanged)
  Q_PROPERTY(Fact *deltaR READ deltaR CONSTANT)
  Q_PROPERTY(Fact *deltaAlpha READ deltaAlpha CONSTANT)
  Q_PROPERTY(Fact *transectMinLength READ transectMinLength CONSTANT)
  Q_PROPERTY(bool calculating READ calculating NOTIFY calculatingChanged)
32
  Q_PROPERTY(bool hidePolygon READ hidePolygon NOTIFY hidePolygonChanged)
33 34

  Q_INVOKABLE void resetReference(void);
35
  Q_INVOKABLE void reverse(void);
36 37 38

  // Property setters
  void setRefPoint(const QGeoCoordinate &refPt);
39 40 41
  void setHidePolygon(bool hide);
  void setDepot(const QGeoCoordinate &depot);
  void setSafeArea(const QList<QGeoCoordinate> &safeArea);
42 43 44 45 46 47

  // Property getters
  QGeoCoordinate refPoint() const;
  Fact *deltaR();
  Fact *deltaAlpha();
  Fact *transectMinLength();
48 49 50 51
  bool calculating() const;
  bool hidePolygon() const;
  QGeoCoordinate depot() const;
  QList<QGeoCoordinate> safeArea() const;
52

53
  // Overrides
54
  bool load(const QJsonObject &complexObject, int sequenceNumber,
55 56 57 58
            QString &errorString) override final;
  QString mapVisualQML(void) const override final;
  void save(QJsonArray &planItems) override final;
  bool specifiesCoordinate(void) const override final;
59
  void appendMissionItems(QList<MissionItem *> &items,
60 61 62 63 64 65 66 67
                          QObject *missionItemParent) override final;
  void applyNewAltitude(double newAltitude) override final;
  double timeBetweenShots(void) override final;
  QString commandDescription(void) const override final;
  QString commandName(void) const override final;
  QString abbreviation(void) const override final;
  bool readyForSave(void) const override final;
  double additionalTimeDelay(void) const override final;
68 69 70 71 72 73 74 75 76 77 78 79 80

  static const char *settingsGroup;
  static const char *deltaRName;
  static const char *deltaAlphaName;
  static const char *transectMinLengthName;
  static const char *CircularSurveyName;
  static const char *refPointLongitudeName;
  static const char *refPointLatitudeName;
  static const char *refPointAltitudeName;

signals:
  void refPointChanged();
  void calculatingChanged();
81 82 83
  void hidePolygonChanged();
  void depotChanged();
  void safeAreaChanged();
84 85 86 87 88 89

private slots:
  // Overrides from TransectStyleComplexItem
  void _rebuildTransectsPhase1(void) final;
  void _recalcComplexDistance(void) final;
  void _recalcCameraShots(void) final;
90
  void _setTransects(PtrRoutingData pRoute);
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

private:
  void _appendLoadedMissionItems(QList<MissionItem *> &items,
                                 QObject *missionItemParent);
  void _buildAndAppendMissionItems(QList<MissionItem *> &items,
                                   QObject *missionItemParent);

  // center of the circular lanes, e.g. base station
  QGeoCoordinate _referencePoint;

  QMap<QString, FactMetaData *> _metaDataMap;
  // distance between two neighbour circles
  SettingsFact _deltaR;
  // angle discretisation of the circles
  SettingsFact _deltaAlpha;
  // minimal transect lenght, transects are rejected if they are shorter than
  // this value
  SettingsFact _minLength;

110
  using PtrWorker = std::shared_ptr<RoutingWorker>;
111
  PtrWorker _pWorker;
112 113
  PtrRoutingData _workerOutput;
  QList<QList<QGeoCoordinate>> _rawTransects;
114 115
  bool _needsStoring;
  bool _needsReversal;
116 117 118 119
  bool _hidePolygon;

  QGeoCoordinate _depot;
  QList<QGeoCoordinate> _safeArea;
120
};