StructureScanComplexItem.h 8.32 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/


#ifndef StructureScanComplexItem_H
#define StructureScanComplexItem_H

#include "ComplexMissionItem.h"
#include "MissionItem.h"
#include "SettingsFact.h"
#include "QGCLoggingCategory.h"
#include "QGCMapPolygon.h"
19
#include "CameraCalc.h"
20 21 22 23 24 25 26 27

Q_DECLARE_LOGGING_CATEGORY(StructureScanComplexItemLog)

class StructureScanComplexItem : public ComplexMissionItem
{
    Q_OBJECT

public:
28 29
    /// @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
30 31
    /// @param kmlOrSHPFile Polygon comes from this file, empty for default polygon
    StructureScanComplexItem(Vehicle* vehicle, bool flyView, const QString& kmlOrSHPFile, QObject* parent);
32

33
    Q_PROPERTY(CameraCalc*      cameraCalc                  READ cameraCalc                                                 CONSTANT)
34 35
    Q_PROPERTY(Fact*            entranceAlt                 READ entranceAlt                                                CONSTANT)
    Q_PROPERTY(Fact*            scanBottomAlt               READ scanBottomAlt                                              CONSTANT)
DonLakeFlyer's avatar
DonLakeFlyer committed
36
    Q_PROPERTY(Fact*            structureHeight             READ structureHeight                                            CONSTANT)
37
    Q_PROPERTY(Fact*            layers                      READ layers                                                     CONSTANT)
38
    Q_PROPERTY(Fact*            gimbalPitch                 READ gimbalPitch                                                CONSTANT)
39
    Q_PROPERTY(Fact*            startFromTop                READ startFromTop                                               CONSTANT)
40 41 42 43 44
    Q_PROPERTY(bool             altitudeRelative            READ altitudeRelative           WRITE setAltitudeRelative       NOTIFY altitudeRelativeChanged)
    Q_PROPERTY(int              cameraShots                 READ cameraShots                                                NOTIFY cameraShotsChanged)
    Q_PROPERTY(double           timeBetweenShots            READ timeBetweenShots                                           NOTIFY timeBetweenShotsChanged)
    Q_PROPERTY(QGCMapPolygon*   structurePolygon            READ structurePolygon                                           CONSTANT)
    Q_PROPERTY(QGCMapPolygon*   flightPolygon               READ flightPolygon                                              CONSTANT)
45

46
    CameraCalc* cameraCalc  (void) { return &_cameraCalc; }
47 48
    Fact* entranceAlt       (void) { return &_entranceAltFact; }
    Fact* scanBottomAlt     (void) { return &_scanBottomAltFact; }
DonLakeFlyer's avatar
DonLakeFlyer committed
49
    Fact* structureHeight   (void) { return &_structureHeightFact; }
50
    Fact* layers            (void) { return &_layersFact; }
51
    Fact* gimbalPitch       (void) { return &_gimbalPitchFact; }
52
    Fact* startFromTop      (void) { return &_startFromTopFact; }
53

54 55 56 57 58 59 60
    bool            altitudeRelative        (void) const { return _altitudeRelative; }
    int             cameraShots             (void) const;
    double          timeBetweenShots        (void);
    QGCMapPolygon*  structurePolygon        (void) { return &_structurePolygon; }
    QGCMapPolygon*  flightPolygon           (void) { return &_flightPolygon; }

    void setAltitudeRelative        (bool altitudeRelative);
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

    Q_INVOKABLE void rotateEntryPoint(void);

    // Overrides from ComplexMissionItem

    double          complexDistance     (void) const final { return _scanDistance; }
    int             lastSequenceNumber  (void) const final;
    bool            load                (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final;
    double          greatestDistanceTo  (const QGeoCoordinate &other) const final;
    QString         mapVisualQML        (void) const final { return QStringLiteral("StructureScanMapVisual.qml"); }

    // Overrides from VisualMissionItem

    bool            dirty                   (void) const final { return _dirty; }
    bool            isSimpleItem            (void) const final { return false; }
    bool            isStandaloneCoordinate  (void) const final { return false; }
    bool            specifiesCoordinate     (void) const final;
    bool            specifiesAltitudeOnly   (void) const final { return false; }
    QString         commandDescription      (void) const final { return tr("Structure Scan"); }
    QString         commandName             (void) const final { return tr("Structure Scan"); }
    QString         abbreviation            (void) const final { return "S"; }
    QGeoCoordinate  coordinate              (void) const final;
    QGeoCoordinate  exitCoordinate          (void) const final;
    int             sequenceNumber          (void) const final { return _sequenceNumber; }
    double          specifiedFlightSpeed    (void) final { return std::numeric_limits<double>::quiet_NaN(); }
    double          specifiedGimbalYaw      (void) final { return std::numeric_limits<double>::quiet_NaN(); }
87
    double          specifiedGimbalPitch    (void) final { return std::numeric_limits<double>::quiet_NaN(); }
88 89 90
    void            appendMissionItems      (QList<MissionItem*>& items, QObject* missionItemParent) final;
    void            setMissionFlightStatus  (MissionController::MissionFlightStatus_t& missionFlightStatus) final;
    void            applyNewAltitude        (double newAltitude) final;
91
    double          additionalTimeDelay     (void) const final { return 0; }
92 93 94 95 96 97 98 99 100 101 102 103

    bool coordinateHasRelativeAltitude      (void) const final { return _altitudeRelative; }
    bool exitCoordinateHasRelativeAltitude  (void) const final { return _altitudeRelative; }
    bool exitCoordinateSameAsEntry          (void) const final { return true; }

    void setDirty           (bool dirty) final;
    void setCoordinate      (const QGeoCoordinate& coordinate) final { Q_UNUSED(coordinate); }
    void setSequenceNumber  (int sequenceNumber) final;
    void save               (QJsonArray&  missionItems) final;

    static const char* jsonComplexItemTypeValue;

104
    static const char* settingsGroup;
105
    static const char* scanBottomAltName;
106 107
    static const char* structureHeightName;
    static const char* layersName;
108
    static const char* gimbalPitchName;
109
    static const char* startFromTopName;
110

111 112 113 114 115 116 117
signals:
    void cameraShotsChanged             (int cameraShots);
    void timeBetweenShotsChanged        (void);
    void altitudeRelativeChanged        (bool altitudeRelative);

private slots:
    void _setDirty(void);
118 119 120 121 122 123
    void _polygonDirtyChanged       (bool dirty);
    void _flightPathChanged         (void);
    void _clearInternal             (void);
    void _updateCoordinateAltitudes (void);
    void _rebuildFlightPolygon      (void);
    void _recalcCameraShots         (void);
DonLakeFlyer's avatar
DonLakeFlyer committed
124
    void _recalcLayerInfo           (void);
125
    void _updateLastSequenceNumber  (void);
126
    void _updateGimbalPitch         (void);
127
    void _validateEntryVertex       (void);
128 129 130 131 132 133 134

private:
    void _setExitCoordinate(const QGeoCoordinate& coordinate);
    void _setScanDistance(double scanDistance);
    void _setCameraShots(int cameraShots);
    double _triggerDistance(void) const;

135 136
    QMap<QString, FactMetaData*> _metaDataMap;

137 138
    int             _sequenceNumber;
    bool            _dirty;
139 140
    QGCMapPolygon   _structurePolygon;
    QGCMapPolygon   _flightPolygon;
141 142 143 144 145 146 147 148
    bool            _altitudeRelative;
    int             _entryVertex;       // Polygon vertext which is used as the mission entry point

    bool            _ignoreRecalc;
    double          _scanDistance;
    int             _cameraShots;
    double          _timeBetweenShots;
    double          _cruiseSpeed;
149
    CameraCalc      _cameraCalc;
150 151


152
    SettingsFact    _scanBottomAltFact;
153 154
    SettingsFact    _structureHeightFact;
    SettingsFact    _layersFact;
155
    SettingsFact    _gimbalPitchFact;
156
    SettingsFact    _startFromTopFact;
157
    SettingsFact    _entranceAltFact;
158 159 160

    static const char* _jsonCameraCalcKey;
    static const char* _jsonAltitudeRelativeKey;
161

162 163
    static const char* _entranceAltName; // This value cannot be overriden

164
    friend class StructureScanComplexItemTest;
165 166 167
};

#endif