diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-11-07 11:06:42 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-11-07 11:06:42 +0900 |
commit | 7550fadd26887ce59c6e0ca5320e6ec6fb61a72a (patch) | |
tree | 150eb9f7a729f1a90edea163590247ab3e2b2c76 /app/qcheapruler.hpp | |
parent | ae47635e56c4af4d816a76e5186e945768543679 (diff) |
add tbtnavi source
Diffstat (limited to 'app/qcheapruler.hpp')
-rw-r--r-- | app/qcheapruler.hpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/app/qcheapruler.hpp b/app/qcheapruler.hpp new file mode 100644 index 0000000..6c569a8 --- /dev/null +++ b/app/qcheapruler.hpp @@ -0,0 +1,61 @@ +#pragma once + +#include <QGeoCoordinate> +#include <QJSValue> +#include <QObject> +#include <QtCore> + +#include <mapbox/cheap_ruler.hpp> + +namespace cr = mapbox::cheap_ruler; + +class QCheapRuler : public QObject{ + Q_OBJECT + Q_PROPERTY(double distance READ distance NOTIFY distanceChanged) + Q_PROPERTY(double currentDistance READ currentDistance NOTIFY currentDistanceChanged) + Q_PROPERTY(QGeoCoordinate currentPosition READ currentPosition NOTIFY currentPositionChanged) + Q_PROPERTY(QJSValue path READ path WRITE setPath NOTIFY pathChanged) + +public: + QCheapRuler(); + ~QCheapRuler(); + + double distance() const; + + double currentDistance() const; + + QGeoCoordinate currentPosition() const; + + QJSValue path() const; + void setPath(const QJSValue &value); + + Q_INVOKABLE void setCurrentCoordinate(QString,QString); + Q_INVOKABLE void startnaviDemo(); + Q_INVOKABLE void stopnaviDemo(); + +public slots: + void readRoutePosition(); + +signals: + void distanceChanged(); + void currentDistanceChanged(); + void currentPositionChanged(); + void pathChanged(); + void arrivedDest(); + +private: + cr::CheapRuler ruler() const; + void readCoordinateFromFile(); + void setCurrentPosition(double,double); + + ulong m_index = 0; + double m_distance = 0.; + double m_currentDistance = 0.; + QGeoCoordinate m_currentPosition = QGeoCoordinate(36.12546, -115.1729906); + + cr::line_string m_path; + + cr::line_string m_routpoint; + + QTimer *m_Timer; +}; |