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

#include "TransectStyleComplexItem.h"

5 6 7
#include "Geometry/PolygonCalculus.h"
#include "Geometry/PlanimetryCalculus.h"
#include "Geometry/GeoUtilities.h"
8
#include "QVector"
9
#include "Geometry/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
    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)
Valentin Platzgummer's avatar
Valentin Platzgummer committed
25
    Q_PROPERTY(Fact* fixedDirection     READ fixedDirection                                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 comprehensiveUpdate(void); // triggers a slow recalculation of the transects
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();
Valentin Platzgummer's avatar
Valentin Platzgummer committed
43
    Fact            *fixedDirection();
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;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
72
    static const char* fixedDirectionName;
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;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
80
    static const char* jsonfixedDirectionKey;
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
    static const long triggerTime = 50; // trigger time (ms) for _triggerSlowRecalcTimer

88 89
signals:
    void refPointChanged();
90
    void isInitializedChanged();
91

92 93
private slots:
    // Overrides from TransectStyleComplexItem
94 95 96 97 98 99 100
    void _rebuildTransectsPhase1    (void) final; // calls _rebuildTransectsFast or _rebuildTransectsSlow depending on _fastRecalc
    void _rebuildTransectsFast      (void);
    void _rebuildTransectsSlow      (void); // the slow version of _rebuildTransectsFast which properly connects the _transects
    void _triggerSlowRecalc         (void);
    bool _generateTransectPath      (QVector<QVector<QPointF>> &transectPath, const QPolygonF &surveyPolygon);
    bool _rebuildTransectsInputCheck(QPolygonF &poly);
    void _rebuildTransectsToGeo     (const QVector<QPointF> &path, const QGeoCoordinate &reference);
101 102
    void _recalcComplexDistance     (void) final;
    void _recalcCameraShots         (void) final;
103
    void _reverseTransects          (void);
104 105
    bool _shortestPath              (const QGeoCoordinate &start, const QGeoCoordinate &destination, QVector<QGeoCoordinate> &shortestPath);

106 107

signals:
108

109

110
private:
Valentin Platzgummer's avatar
Valentin Platzgummer committed
111 112 113 114 115
    void _appendLoadedMissionItems(QList<MissionItem*>& items, QObject* missionItemParent);
    void _buildAndAppendMissionItems(QList<MissionItem*>& items, QObject* missionItemParent);



116
    QGeoCoordinate _referencePoint; // center of the circular lanes, e.g. base station
117 118 119

    QMap<QString, FactMetaData*> _metaDataMap;

120 121 122
    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
Valentin Platzgummer's avatar
Valentin Platzgummer committed
123
    SettingsFact            _fixedDirection; // bool value, determining if transects have fixed direction or not
124
    SettingsFact            _reverse; // reverses the _transects path
125
    SettingsFact            _maxWaypoints; // the maximum number of waypoints _transects (TransectStyleComplexItem) can contain (to avoid performance hits)
126

127
    QTimer _triggerSlowRecalcTimer;
Valentin Platzgummer's avatar
Valentin Platzgummer committed
128

129
    bool _isInitialized; // indicates if the polygon and refpoint etc. are initialized, prevents reinitialisation from gui and execution of _rebuildTransectsPhase1 during init from gui
130
    bool _reverseOnly; // if this is true _rebuildTransectsPhase1() will reverse the path only, _rebuildTransectsPhase1() resets _reverseOnly
131
    bool _doFastRecalc; // fast recalc of transects if set, see _rebuildTransectsPhase1 for furhter explanation
132 133 134 135
};



136 137