CircularSurveyComplexItem.h 5.92 KB
Newer Older
1 2 3 4
# pragma once

#include "TransectStyleComplexItem.h"

5 6 7 8 9
#include "PolygonCalculus.h"
#include "PlanimetryCalculus.h"
#include "GeoUtilities.h"
#include "QVector"
#include "Circle.h"
10
#include "SettingsFact.h"
11

12 13 14 15 16 17 18 19 20
class CircularSurveyComplexItem :public TransectStyleComplexItem
{
    Q_OBJECT
public:
    /// @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
    CircularSurveyComplexItem(Vehicle* vehicle, bool flyView, const QString& kmlOrShpFile, QObject* parent);

21 22 23 24 25
    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(Fact* isSnakePath        READ isSnakePath                                CONSTANT)
26
    Q_PROPERTY(Fact* reverse            READ reverse                                    CONSTANT)
27
    Q_PROPERTY(Fact* maxWaypoints       READ maxWaypoints                                    CONSTANT)
28
    Q_PROPERTY(bool  isInitialized      READ isInitialized      WRITE setIsInitialized  NOTIFY isInitializedChanged)
29

30
    Q_INVOKABLE void resetReference(void);
31
    Q_INVOKABLE void setReferencePointBeingChanged(bool changeing); // used by gui to indicate a changeing reference point (dagging by user)
32

33 34
    // Property setters
    void setRefPoint(const QGeoCoordinate &refPt);
Valentin Platzgummer's avatar
Valentin Platzgummer committed
35
    // Set this to true if survey was automatically generated, prevents initialisation from gui.
36
    void setIsInitialized(bool isInitialized);
37 38

    // Property getters
39 40
    QGeoCoordinate  refPoint()      const;
    Fact            *deltaR();
41
    Fact            *deltaAlpha();    
42
    Fact            *transectMinLength();
43
    Fact            *isSnakePath();
44
    Fact            *reverse();
45
    Fact            *maxWaypoints();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
46
    // Is true if survey was automatically generated, prevents initialisation from gui.
47
    bool            isInitialized();
48
    bool            referencePointBeingChanged(); // returns true if the referencepoint is being changed (dragged by user)
49

50 51
    // Overrides from ComplexMissionItem
    bool    load                (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
52
    QString mapVisualQML        (void) const final { return QStringLiteral("CircularSurveyMapVisual.qml"); }
53 54 55 56 57 58 59 60 61

    // Overrides from TransectStyleComplexItem
    void    save                (QJsonArray&  planItems) final;
    bool    specifiesCoordinate (void) const final { return true; }
    void    appendMissionItems  (QList<MissionItem*>& items, QObject* missionItemParent) final;
    void    applyNewAltitude    (double newAltitude) final;
    double  timeBetweenShots    (void) final;

    // Overrides from VisualMissionionItem
62 63 64
    QString commandDescription  (void) const final { return tr("Circular Survey"); }
    QString commandName         (void) const final { return tr("Circular Survey"); }
    QString abbreviation        (void) const final { return tr("C.S."); }
65 66 67
    bool    readyForSave        (void) const final;
    double  additionalTimeDelay (void) const final;

68 69 70
    static const char* settingsGroup;    
    static const char* deltaRName;
    static const char* deltaAlphaName;
71
    static const char* transectMinLengthName;
72
    static const char* isSnakePathName;
73
    static const char* reverseName;
74
    static const char* maxWaypointsName;
75

Valentin Platzgummer's avatar
Valentin Platzgummer committed
76 77 78
    static const char* jsonComplexItemTypeValue;
    static const char* jsonDeltaRKey;
    static const char* jsonDeltaAlphaKey;
79
    static const char* jsonTransectMinLengthKey;
80
    static const char* jsonIsSnakePathKey;
81
    static const char* jsonReverseKey;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
82 83 84 85
    static const char* jsonReferencePointLongKey;
    static const char* jsonReferencePointLatKey;
    static const char* jsonReferencePointAltKey;

86 87
signals:
    void refPointChanged();
88
    void isInitializedChanged();
89

90 91
private slots:
    // Overrides from TransectStyleComplexItem
92
    void _rebuildTransectsPhase1    (void) final; // do not call this function, it is called by TransectStyleComplexItem::_rebuildTransects()
93 94
    void _recalcComplexDistance     (void) final;
    void _recalcCameraShots         (void) final;
95
    void _reverseTransects          (void);
96 97

signals:
98

99

100
private:
Valentin Platzgummer's avatar
Valentin Platzgummer committed
101 102 103 104 105
    void _appendLoadedMissionItems(QList<MissionItem*>& items, QObject* missionItemParent);
    void _buildAndAppendMissionItems(QList<MissionItem*>& items, QObject* missionItemParent);



106
    QGeoCoordinate _referencePoint; // center of the circular lanes, e.g. base station
107 108 109

    QMap<QString, FactMetaData*> _metaDataMap;

110 111 112 113
    SettingsFact            _deltaR; // distance between two neighbour circles
    SettingsFact            _deltaAlpha; // angle discretisation of the circles
    SettingsFact            _transectMinLength; // minimal transect lenght, transects are rejected if they are shorter than this value
    SettingsFact            _isSnakePath; // bool value, determining if transects are connected in a snake like or zig zag like manner
114
    SettingsFact            _reverse; // reverses the _transects path
115
    SettingsFact            _maxWaypoints; // the maximum number of waypoints _transects (TransectStyleComplexItem) can contain (to avoid performance hits)
116 117

    QTimer _updateTimer;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
118

119
    bool _isInitialized; // indicates if the polygon and refpoint etc. are initialized, prevents reinitialisation from gui and execution of _rebuildTransectsPhase1 during init from gui
120 121
    bool _reverseOnly; // if this is true _rebuildTransectsPhase1() will reverse the path only, _rebuildTransectsPhase1() resets _reverseOnly
    bool _referencePointBeingChanged; // is set to true by gui, if user is changeing the reference point
122 123 124 125

    int _updateCounter;


126 127 128 129
};