StructureScanComplexItem.h 9.41 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * 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

Q_DECLARE_LOGGING_CATEGORY(StructureScanComplexItemLog)

23 24
class PlanMasterController;

25 26 27 28 29
class StructureScanComplexItem : public ComplexMissionItem
{
    Q_OBJECT

public:
30
    /// @param flyView true: Created for use in the Fly View, false: Created for use in the Plan View
31
    /// @param kmlOrSHPFile Polygon comes from this file, empty for default polygon
32
    StructureScanComplexItem(PlanMasterController* masterController, bool flyView, const QString& kmlOrSHPFile, QObject* parent);
33

34
    Q_PROPERTY(CameraCalc*      cameraCalc                  READ cameraCalc                                                 CONSTANT)
35
    Q_PROPERTY(Fact*            entranceAlt                 READ entranceAlt                                                CONSTANT)
DonLakeFlyer's avatar
DonLakeFlyer committed
36
    Q_PROPERTY(Fact*            structureHeight             READ structureHeight                                            CONSTANT)
37
    Q_PROPERTY(Fact*            scanBottomAlt               READ scanBottomAlt                                              CONSTANT)
38
    Q_PROPERTY(Fact*            layers                      READ layers                                                     CONSTANT)
39
    Q_PROPERTY(Fact*            gimbalPitch                 READ gimbalPitch                                                CONSTANT)
40
    Q_PROPERTY(Fact*            startFromTop                READ startFromTop                                               CONSTANT)
41 42
    Q_PROPERTY(double           bottomFlightAlt             READ bottomFlightAlt                                            NOTIFY bottomFlightAltChanged)
    Q_PROPERTY(double           topFlightAlt                READ topFlightAlt                                               NOTIFY topFlightAltChanged)
43 44 45 46
    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)
47

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

56 57
    double          bottomFlightAlt         (void) const;
    double          topFlightAlt            (void) const;
58 59 60 61 62
    int             cameraShots             (void) const;
    double          timeBetweenShots        (void);
    QGCMapPolygon*  structurePolygon        (void) { return &_structurePolygon; }
    QGCMapPolygon*  flightPolygon           (void) { return &_flightPolygon; }

63 64 65
    Q_INVOKABLE void rotateEntryPoint(void);

    // Overrides from ComplexMissionItem
66 67 68 69 70 71
    QString patternName         (void) const final { return name; }
    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"); }
72 73

    // Overrides from VisualMissionItem
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
    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 { return true; }
    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 { return coordinate(); }
    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(); }
    double              specifiedGimbalPitch        (void) final { return std::numeric_limits<double>::quiet_NaN(); }
    void                appendMissionItems          (QList<MissionItem*>& items, QObject* missionItemParent) final;
    void                setMissionFlightStatus      (MissionController::MissionFlightStatus_t& missionFlightStatus) final;
    void                applyNewAltitude            (double newAltitude) final;
    double              additionalTimeDelay         (void) const final { return 0; }
    ReadyForSaveState   readyForSaveState           (void) const final;
    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;
    double              amslEntryAlt                (void) const final;
    double              amslExitAlt                 (void) const final { return amslEntryAlt(); };
    double              minAMSLAltitude             (void) const final;
    double              maxAMSLAltitude             (void) const final;

    static const QString name;
104 105 106

    static const char* jsonComplexItemTypeValue;

107
    static const char* settingsGroup;
108
    static const char* scanBottomAltName;
109 110
    static const char* structureHeightName;
    static const char* layersName;
111
    static const char* gimbalPitchName;
112
    static const char* startFromTopName;
113

114 115 116
signals:
    void cameraShotsChanged             (int cameraShots);
    void timeBetweenShotsChanged        (void);
117 118
    void bottomFlightAltChanged         (void);
    void topFlightAltChanged            (void);
119
    void _updateFlightPathSegmentsSignal(void);
120 121

private slots:
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
    void _segmentTerrainCollisionChanged            (bool terrainCollision) final;
    void _setDirty                                  (void);
    void _polygonDirtyChanged                       (bool dirty);
    void _flightPathChanged                         (void);
    void _clearInternal                             (void);
    void _updateCoordinateAltitudes                 (void);
    void _rebuildFlightPolygon                      (void);
    void _recalcCameraShots                         (void);
    void _recalcLayerInfo                           (void);
    void _updateLastSequenceNumber                  (void);
    void _updateGimbalPitch                         (void);
    void _signalTopBottomAltChanged                 (void);
    void _recalcScanDistance                        (void);
    void _updateWizardMode                          (void);
    void _updateFlightPathSegmentsDontCallDirectly  (void);
    void _minAMSLAltChanged                         (void);
    void _maxAMSLAltChanged                         (void);
139 140

private:
141 142
    void    _setCameraShots                 (int cameraShots);
    double  _triggerDistance                (void) const;
143

144 145
    QMap<QString, FactMetaData*> _metaDataMap;

146
    int             _sequenceNumber;
147 148
    QGCMapPolygon   _structurePolygon;
    QGCMapPolygon   _flightPolygon;
149
    int             _entryVertex;       // Polygon vertex which is used as the mission entry point
150 151 152 153
    bool            _ignoreRecalc;
    double          _scanDistance;
    int             _cameraShots;
    double          _timeBetweenShots;
154
    double          _vehicleSpeed;
155
    CameraCalc      _cameraCalc;
156 157


158
    SettingsFact    _scanBottomAltFact;
159 160
    SettingsFact    _structureHeightFact;
    SettingsFact    _layersFact;
161
    SettingsFact    _gimbalPitchFact;
162
    SettingsFact    _startFromTopFact;
163
    SettingsFact    _entranceAltFact;
164 165

    static const char* _jsonCameraCalcKey;
166

167 168
    static const char* _entranceAltName; // This value cannot be overriden

169
    friend class StructureScanComplexItemTest;
170 171 172
};

#endif