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

3
#include "QScopedPointer"
Valentin Platzgummer's avatar
Valentin Platzgummer committed
4
#include <QObject>
5

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

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

Valentin Platzgummer's avatar
Valentin Platzgummer committed
10 11

class WimaMeasurementArea : public WimaArea
12
{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
13
    Q_OBJECT
14
public:
Valentin Platzgummer's avatar
Valentin Platzgummer committed
15 16
    WimaMeasurementArea(QObject* parent = nullptr);
    WimaMeasurementArea(const WimaMeasurementArea &other, QObject *parent = nullptr);
17
    WimaMeasurementArea &operator=(const WimaMeasurementArea &other);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
18

19 20 21 22 23
    Q_PROPERTY(Fact*                bottomLayerAltitude     READ bottomLayerAltitudeFact    CONSTANT)
    Q_PROPERTY(Fact*                numberOfLayers          READ numberOfLayersFact         CONSTANT)
    Q_PROPERTY(Fact*                layerDistance           READ layerDistanceFact          CONSTANT)
    Q_PROPERTY(Fact*                borderPolygonOffset     READ borderPolygonOffsetFact    CONSTANT)
    Q_PROPERTY(QGCMapPolygon*       borderPolygon           READ borderPolygon              NOTIFY borderPolygonChanged)
Valentin Platzgummer's avatar
Valentin Platzgummer committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37

    // Overrides from WimaPolygon
    QString         mapVisualQML    (void) const { return "WimaMeasurementAreaMapVisual.qml";}
    QString         editorQML       (void) const { return "WimaMeasurementAreaEditor.qml";}

    // Property accessors
    Fact*           bottomLayerAltitudeFact (void)          { return &_bottomLayerAltitude;}
    Fact*           numberOfLayersFact      (void)          { return &_numberOfLayers;}
    Fact*           layerDistanceFact       (void)          { return &_layerDistance;}
    Fact*           borderPolygonOffsetFact (void)          { return &_borderPolygonOffset;}
    double          bottomLayerAltitude     (void) const    { return _bottomLayerAltitude.rawValue().toDouble();}
    int             numberOfLayers          (void) const    { return _numberOfLayers.rawValue().toInt();}
    double          layerDistance           (void) const    { return _layerDistance.rawValue().toDouble();}
    double          borderPolygonOffset     (void) const    { return _borderPolygonOffset.rawValue().toDouble();}
38
    QGCMapPolygon*  borderPolygon           (void)          { return &_borderPolygon;}
Valentin Platzgummer's avatar
Valentin Platzgummer committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

    // 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* bottomLayerAltitudeName;
    static const char* numberOfLayersName;
    static const char* layerDistanceName;
    static const char* borderPolygonOffsetName;
    static const char* WimaMeasurementAreaName;

signals:
    void bottomLayerAltitudeChanged     (void);
    void numberOfLayersChanged          (void);
    void layerDistanceChanged           (void);
    void polylineChanged                (void);
    void vehicleCorridorChanged         (WimaVCorridor* corridor);
    void borderPolygonChanged           (void);
63
    void borderPolygonOffsetChanged     (void);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

public slots:
    void setBottomLayerAltitude (double altitude);
    void setNumberOfLayers      (double numLayers);
    void setLayerDistance       (double layerDistance);
    void setBorderPolygonOffset (double offset);
private slots:
    void recalcBorderPolygon            (void);
private:
    // Member Methodes
    void init();

    // Members
    QMap<QString, FactMetaData*> _metaDataMap;

    SettingsFact            _bottomLayerAltitude;
    SettingsFact            _numberOfLayers;
    SettingsFact            _layerDistance;
    SettingsFact            _borderPolygonOffset;

    QGCMapPolygon           _borderPolygon;
85 86
};

Valentin Platzgummer's avatar
Valentin Platzgummer committed
87