CameraCalc.h 5.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

#pragma once

#include "CameraSpec.h"

class Vehicle;

class CameraCalc : public CameraSpec
{
    Q_OBJECT

public:
    CameraCalc(Vehicle* vehicle, QObject* parent = NULL);

23
    Q_PROPERTY(QString          cameraName                  READ cameraName         WRITE setCameraName NOTIFY cameraNameChanged)
DonLakeFlyer's avatar
DonLakeFlyer committed
24 25 26
    Q_PROPERTY(QString          customCameraName            READ customCameraName                       CONSTANT)                   ///< Camera name for custom camera setting
    Q_PROPERTY(QString          manualCameraName            READ manualCameraName                       CONSTANT)                   ///< Camera name for manual camera setting
    Q_PROPERTY(bool             isManualCamera              READ isManualCamera                         NOTIFY cameraNameChanged)   ///< true: using manual camera
27 28 29 30 31 32 33
    Q_PROPERTY(Fact*            valueSetIsDistance          READ valueSetIsDistance                     CONSTANT)                   ///< true: distance specified, resolution calculated
    Q_PROPERTY(Fact*            distanceToSurface           READ distanceToSurface                      CONSTANT)                   ///< Distance to surface for image foot print calculation
    Q_PROPERTY(Fact*            imageDensity                READ imageDensity                           CONSTANT)                   ///< Image density on surface (cm/px)
    Q_PROPERTY(Fact*            frontalOverlap              READ frontalOverlap                         CONSTANT)
    Q_PROPERTY(Fact*            sideOverlap                 READ sideOverlap                            CONSTANT)
    Q_PROPERTY(Fact*            adjustedFootprintSide       READ adjustedFootprintSide                  CONSTANT)                   ///< Side footprint adjusted down for overlap
    Q_PROPERTY(Fact*            adjustedFootprintFrontal    READ adjustedFootprintFrontal               CONSTANT)                   ///< Frontal footprint adjusted down for overlap
34 35

    // The following values are calculated from the camera properties
36 37
    Q_PROPERTY(double imageFootprintSide    READ imageFootprintSide     NOTIFY imageFootprintSideChanged)       ///< Size of image size side in meters
    Q_PROPERTY(double imageFootprintFrontal READ imageFootprintFrontal  NOTIFY imageFootprintFrontalChanged)    ///< Size of image size frontal in meters
38

39 40 41 42
    static QString customCameraName(void);
    static QString manualCameraName(void);
    QString cameraName(void) const { return _cameraName; }
    void setCameraName(QString cameraName);
43

44 45 46 47 48 49 50 51
    Fact* valueSetIsDistance        (void) { return &_valueSetIsDistanceFact; }
    Fact* distanceToSurface         (void) { return &_distanceToSurfaceFact; }
    Fact* imageDensity              (void) { return &_imageDensityFact; }
    Fact* frontalOverlap            (void) { return &_frontalOverlapFact; }
    Fact* sideOverlap               (void) { return &_sideOverlapFact; }
    Fact* adjustedFootprintSide     (void) { return &_adjustedFootprintSideFact; }
    Fact* adjustedFootprintFrontal  (void) { return &_adjustedFootprintFrontalFact; }

DonLakeFlyer's avatar
DonLakeFlyer committed
52 53 54
    bool    isManualCamera          (void) { return cameraName() == manualCameraName(); }
    double  imageFootprintSide      (void) const { return _imageFootprintSide; }
    double  imageFootprintFrontal   (void) const { return _imageFootprintFrontal; }
55 56 57 58 59 60 61 62

    bool dirty      (void) const { return _dirty; }
    void setDirty   (bool dirty);

    void save(QJsonObject& json) const;
    bool load(const QJsonObject& json, QString& errorString);

signals:
63
    void cameraNameChanged              (QString cameraName);
64 65 66 67 68 69 70 71 72 73
    void dirtyChanged                   (bool dirty);
    void imageFootprintSideChanged      (double imageFootprintSide);
    void imageFootprintFrontalChanged   (double imageFootprintFrontal);

private slots:
    void _recalcTriggerDistance(void);

private:
    Vehicle*        _vehicle;
    bool            _dirty;
74
    QString         _cameraName;
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
    bool            _disableRecalc;

    QMap<QString, FactMetaData*> _metaDataMap;

    Fact _valueSetIsDistanceFact;
    Fact _distanceToSurfaceFact;
    Fact _imageDensityFact;
    Fact _frontalOverlapFact;
    Fact _sideOverlapFact;
    Fact _adjustedFootprintSideFact;
    Fact _adjustedFootprintFrontalFact;

    double _imageFootprintSide;
    double _imageFootprintFrontal;

    QVariantList _knownCameraList;

    static const char* _valueSetIsDistanceName;
    static const char* _distanceToSurfaceName;
    static const char* _imageDensityName;
    static const char* _frontalOverlapName;
    static const char* _sideOverlapName;
    static const char* _adjustedFootprintSideName;
    static const char* _adjustedFootprintFrontalName;
99 100 101 102 103 104 105 106 107 108
    static const char* _jsonCameraNameKey;

    // The following are deprecated usage and only included in order to convert older formats

    enum CameraSpecType {
        CameraSpecNone,
        CameraSpecCustom,
        CameraSpecKnown
    };

109
    static const char* _jsonCameraSpecTypeKey;
110
};