CameraSection.h 3.86 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

10
#pragma once
11

12
#include "Section.h"
13 14 15 16
#include "ComplexMissionItem.h"
#include "MissionItem.h"
#include "Fact.h"

17
class CameraSection : public Section
18 19 20 21
{
    Q_OBJECT

public:
22
    CameraSection(Vehicle* vehicle, QObject* parent = NULL);
23

24
    // These nume values must match the json meta data
25 26 27 28
    enum CameraAction {
        CameraActionNone,
        TakePhotosIntervalTime,
        TakePhotoIntervalDistance,
29 30 31
        StopTakingPhotos,
        TakeVideo,
        StopTakingVideo
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
    };
    Q_ENUMS(CameraAction)

    Q_PROPERTY(bool     specifyGimbal                   READ specifyGimbal                  WRITE setSpecifyGimbal              NOTIFY specifyGimbalChanged)
    Q_PROPERTY(Fact*    gimbalPitch                     READ gimbalPitch                                                        CONSTANT)
    Q_PROPERTY(Fact*    gimbalYaw                       READ gimbalYaw                                                          CONSTANT)
    Q_PROPERTY(Fact*    cameraAction                    READ cameraAction                                                       CONSTANT)
    Q_PROPERTY(Fact*    cameraPhotoIntervalTime         READ cameraPhotoIntervalTime                                            CONSTANT)
    Q_PROPERTY(Fact*    cameraPhotoIntervalDistance     READ cameraPhotoIntervalDistance                                        CONSTANT)

    bool    specifyGimbal               (void) const { return _specifyGimbal; }
    Fact*   gimbalYaw                   (void) { return &_gimbalYawFact; }
    Fact*   gimbalPitch                 (void) { return &_gimbalPitchFact; }
    Fact*   cameraAction                (void) { return &_cameraActionFact; }
    Fact*   cameraPhotoIntervalTime     (void) { return &_cameraPhotoIntervalTimeFact; }
    Fact*   cameraPhotoIntervalDistance (void) { return &_cameraPhotoIntervalDistanceFact; }

49 50
    void setSpecifyGimbal   (bool specifyGimbal);

DonLakeFlyer's avatar
DonLakeFlyer committed
51 52 53
    ///< @return The gimbal yaw specified by this item, NaN if not specified
    double specifiedGimbalYaw(void) const;

54 55 56 57 58
    // Overrides from Section
    bool available          (void) const override { return _available; }
    bool dirty              (void) const override { return _dirty; }
    void setAvailable       (bool available) override;
    void setDirty           (bool dirty) override;
59
    bool scanForSection     (QmlObjectListModel* visualItems, int scanIndex) override;
60 61 62
    void appendSectionItems (QList<MissionItem*>& items, QObject* missionItemParent, int& seqNum) override;
    int  itemCount          (void) const override;
    bool settingsSpecified  (void) const override {return _settingsSpecified; }
63 64 65

signals:
    bool specifyGimbalChanged       (bool specifyGimbal);
DonLakeFlyer's avatar
DonLakeFlyer committed
66
    void specifiedGimbalYawChanged  (double gimbalYaw);
67 68 69

private slots:
    void _setDirty(void);
70
    void _setDirtyAndUpdateItemCount(void);
DonLakeFlyer's avatar
DonLakeFlyer committed
71
    void _updateSpecifiedGimbalYaw(void);
72 73 74
    void _specifyGimbalChanged(bool specifyGimbal);
    void _updateSettingsSpecified(void);
    void _cameraActionChanged(void);
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94

private:
    bool    _available;
    bool    _settingsSpecified;
    bool    _specifyGimbal;
    Fact    _gimbalYawFact;
    Fact    _gimbalPitchFact;
    Fact    _cameraActionFact;
    Fact    _cameraPhotoIntervalDistanceFact;
    Fact    _cameraPhotoIntervalTimeFact;
    bool    _dirty;

    static QMap<QString, FactMetaData*> _metaDataMap;

    static const char* _gimbalPitchName;
    static const char* _gimbalYawName;
    static const char* _cameraActionName;
    static const char* _cameraPhotoIntervalDistanceName;
    static const char* _cameraPhotoIntervalTimeName;
};