CircularGenerator.h 1.86 KB
Newer Older
1 2 3 4
#include "GeneratorBase.h"

#include <QGeoCoordinate>

5 6
#include "SettingsFact.h"

7 8
class MeasurementArea;

9 10 11 12 13 14 15 16 17 18 19 20 21 22
namespace routing {

class CircularGenerator : public GeneratorBase {
  Q_OBJECT
public:
  CircularGenerator(QObject *parent = nullptr);
  CircularGenerator(Data d, QObject *parent = nullptr);

  Q_PROPERTY(QGeoCoordinate reference READ reference WRITE setReference NOTIFY
                 referenceChanged)
  Q_PROPERTY(Fact *distance READ distance CONSTANT)
  Q_PROPERTY(Fact *deltaAlpha READ deltaAlpha CONSTANT)
  Q_PROPERTY(Fact *minLength READ minLength CONSTANT)

23 24
  virtual QString editorQml() const override;
  virtual QString mapVisualQml() const override;
25

26 27
  virtual QString abbreviation() const override;
  virtual QString type() const override;
28

29
  virtual bool get(Work &work) override;
30 31 32 33 34 35 36 37

  QGeoCoordinate reference() const;
  Fact *distance();
  Fact *deltaAlpha();
  Fact *minLength();

  void setReference(const QGeoCoordinate &reference);

38 39 40 41 42 43 44 45 46 47 48
  //!
  //! \brief save Saves the generator.
  //! \param obj Json object for saveing.
  //! \return Returns true on success, false either.
  //!
  //! Saves distance, alpha and minLength.
  //! \note This methode does not save the data.
  //!
  virtual bool save(QJsonObject &obj) const override;
  virtual bool load(const QJsonObject &obj, QString &guiErrorMessage) override;

49
  static const char *settingsGroup;
50
  static const char *typeString;
51 52 53 54 55 56 57 58

signals:
  void referenceChanged();

public slots:
  Q_INVOKABLE void resetReferenceIfInvalid();
  Q_INVOKABLE void resetReference();

59
private slots:
60
  void onAreaListChanged();
61 62 63 64
  void onDataChanged();

private:
  void init();
65
  void setMeasurementArea(MeasurementArea *area);
66 67 68 69 70 71

  QGeoCoordinate _reference;
  QMap<QString, FactMetaData *> _metaDataMap;
  SettingsFact _distance;
  SettingsFact _deltaAlpha;
  SettingsFact _minLength;
72
  MeasurementArea *_measurementArea;
73 74
};
} // namespace routing