EditPositionDialogController.h 2.29 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 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/****************************************************************************
 *
 *   (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 <QObject>
#include <QGeoCoordinate>

#include "FactSystem.h"

class EditPositionDialogController : public QObject
{
    Q_OBJECT
    
public:
    EditPositionDialogController(void);
    
    Q_PROPERTY(QGeoCoordinate   coordinate  READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
    Q_PROPERTY(Fact*            latitude    READ latitude                       CONSTANT)
    Q_PROPERTY(Fact*            longitude   READ longitude                      CONSTANT)
    Q_PROPERTY(Fact*            zone        READ zone                           CONSTANT)
    Q_PROPERTY(Fact*            hemisphere  READ hemisphere                     CONSTANT)
    Q_PROPERTY(Fact*            easting     READ easting                        CONSTANT)
    Q_PROPERTY(Fact*            northing    READ northing                       CONSTANT)

    QGeoCoordinate  coordinate(void) const { return _coordinate; }
    Fact* latitude  (void) { return &_latitudeFact; }
    Fact* longitude (void) { return &_longitudeFact; }
    Fact* zone      (void) { return &_zoneFact; }
    Fact* hemisphere(void) { return &_hemisphereFact; }
    Fact* easting   (void) { return &_eastingFact; }
    Fact* northing  (void) { return &_northingFact; }

    void setCoordinate(QGeoCoordinate coordinate);

    Q_INVOKABLE void initValues(void);
    Q_INVOKABLE void setFromGeo(void);
    Q_INVOKABLE void setFromUTM(void);

signals:
    void coordinateChanged(QGeoCoordinate coordinate);

private:
    static QMap<QString, FactMetaData*> _metaDataMap;

    QGeoCoordinate _coordinate;

    Fact _latitudeFact;
    Fact _longitudeFact;
    Fact _zoneFact;
    Fact _hemisphereFact;
    Fact _eastingFact;
    Fact _northingFact;

    static const char*  _latitudeFactName;
    static const char*  _longitudeFactName;
    static const char*  _zoneFactName;
    static const char*  _hemisphereFactName;
    static const char*  _eastingFactName;
    static const char*  _northingFactName;
};