TransectStyleComplexItemTest.h 3.91 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 19 20 21 22 23 24 25 26 27 28 29 30 31
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

#pragma once

#include "UnitTest.h"
#include "MultiSignalSpy.h"
#include "CorridorScanComplexItem.h"

#include <QGeoCoordinate>

class TransectStyleItem;

class TransectStyleComplexItemTest : public UnitTest
{
    Q_OBJECT
    
public:
    TransectStyleComplexItemTest(void);

protected:
    void init(void) final;
    void cleanup(void) final;
    
private slots:
32 33 34 35
    void _testDirty             (void);
    void _testRebuildTransects  (void);
    void _testDistanceSignalling(void);
    void _testAltMode           (void);
36 37

private:
38 39
    void _setSurveyAreaPolygon  (void);
    void _adjustSurveAreaPolygon(void);
40 41 42 43 44

    enum {
        // These signals are from TransectStyleComplexItem
        cameraShotsChangedIndex = 0,
        timeBetweenShotsChangedIndex,
DonLakeFlyer's avatar
DonLakeFlyer committed
45
        visualTransectPointsChangedIndex,
46 47 48 49 50 51
        coveredAreaChangedIndex,
        // These signals are from ComplexItem
        dirtyChangedIndex,
        complexDistanceChangedIndex,
        greatestDistanceToChangedIndex,
        additionalTimeDelayChangedIndex,
52 53
        // These signals are from VisualMissionItem
        lastSequenceNumberChangedIndex,
54 55 56 57 58
        maxSignalIndex
    };

    enum {
        // These signals are from TransectStyleComplexItem
DonLakeFlyer's avatar
DonLakeFlyer committed
59 60 61 62
        cameraShotsChangedMask =                1 << cameraShotsChangedIndex,
        timeBetweenShotsChangedMask =           1 << timeBetweenShotsChangedIndex,
        visualTransectPointsChangedMask =       1 << visualTransectPointsChangedIndex,
        coveredAreaChangedMask =                1 << coveredAreaChangedIndex,
63
        // These signals are from ComplexItem
DonLakeFlyer's avatar
DonLakeFlyer committed
64 65 66 67
        dirtyChangedMask =                      1 << dirtyChangedIndex,
        complexDistanceChangedMask =            1 << complexDistanceChangedIndex,
        greatestDistanceToChangedMask =         1 << greatestDistanceToChangedIndex,
        additionalTimeDelayChangedMask =        1 << additionalTimeDelayChangedIndex,
68
        // These signals are from VisualMissionItem
DonLakeFlyer's avatar
DonLakeFlyer committed
69
        lastSequenceNumberChangedMask =         1 << lastSequenceNumberChangedIndex,
70 71 72 73 74 75 76
    };

    static const size_t _cSignals = maxSignalIndex;
    const char*         _rgSignals[_cSignals];

    Vehicle*                _offlineVehicle;
    MultiSignalSpy*         _multiSpy;
77
    QList<QGeoCoordinate>   _polygonVertices;
78 79 80 81 82 83 84 85
    TransectStyleItem*      _transectStyleItem;
};

class TransectStyleItem : public TransectStyleComplexItem
{
    Q_OBJECT

public:
86
    TransectStyleItem(Vehicle* vehicle, QObject* parent = nullptr);
87 88 89 90 91 92 93 94 95 96

    // Overrides from ComplexMissionItem
    QString mapVisualQML        (void) const final { return QString(); }
    bool    load                (const QJsonObject& complexObject, int sequenceNumber, QString& errorString) final { Q_UNUSED(complexObject); Q_UNUSED(sequenceNumber); Q_UNUSED(errorString); return false; }

    // Overrides from VisualMissionItem
    void    save                (QJsonArray&  missionItems) final { Q_UNUSED(missionItems); }
    bool    specifiesCoordinate (void) const final { return true; }
    void    appendMissionItems  (QList<MissionItem*>& items, QObject* missionItemParent) final { Q_UNUSED(items); Q_UNUSED(missionItemParent); }
    void    applyNewAltitude    (double newAltitude) final { Q_UNUSED(newAltitude); }
97
    double  additionalTimeDelay (void) const final { return 0; }
98

99
    bool rebuildTransectsPhase1Called;
100 101
    bool recalcComplexDistanceCalled;
    bool recalcCameraShotsCalled;
102

103 104
private slots:
    // Overrides from TransectStyleComplexItem
105 106 107
    void _rebuildTransectsPhase1    (void) final;
    void _recalcComplexDistance     (void) final;
    void _recalcCameraShots         (void) final;
108
};