CircularGenerator.h 1.76 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 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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)

  virtual QString editorQml() override;
  virtual QString mapVisualQml() override;

  virtual QString name() override;
  virtual QString abbreviation() override;

  virtual bool get(Generator &generator) override;

  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 50 51 52 53 54 55 56 57 58
  static const char *settingsGroup;

signals:
  void referenceChanged();

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

private:
59 60
  void onAreaListChanged();
  void setMeasurementArea(MeasurementArea *area);
61 62 63 64 65 66

  QGeoCoordinate _reference;
  QMap<QString, FactMetaData *> _metaDataMap;
  SettingsFact _distance;
  SettingsFact _deltaAlpha;
  SettingsFact _minLength;
67
  MeasurementArea *_measurementArea;
68 69 70
};

} // namespace routing