TransectStyleComplexItemTest.h 4.07 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
 *
 * 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"
15
#include "PlanMasterController.h"
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

#include <QGeoCoordinate>

class TransectStyleItem;

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

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

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

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

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

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

76 77 78
    PlanMasterController*   _masterController =     nullptr;
    Vehicle*                _controllerVehicle =    nullptr;
    MultiSignalSpy*         _multiSpy =             nullptr;
79
    QList<QGeoCoordinate>   _polygonVertices;
80
    TransectStyleItem*      _transectStyleItem =    nullptr;
81 82 83 84 85 86 87
};

class TransectStyleItem : public TransectStyleComplexItem
{
    Q_OBJECT

public:
88
    TransectStyleItem(PlanMasterController* masterController, QObject* parent = nullptr);
89 90 91 92 93 94 95 96 97 98

    // 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); }
99
    double  additionalTimeDelay (void) const final { return 0; }
100

101
    bool rebuildTransectsPhase1Called;
102 103
    bool recalcComplexDistanceCalled;
    bool recalcCameraShotsCalled;
104

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