Fixed path marker inaccuracy issue.
[GPXSee.git] / src / graph.h
blob31a9d0339bfb1bf6a5aa2f851aaaa9367e3a8218
1 #ifndef GRAPH_H
2 #define GRAPH_H
4 #include <QVector>
5 #include <QDebug>
6 #include <cmath>
8 enum GraphType {Distance, Time};
10 class GraphPoint
12 public:
13 GraphPoint(qreal s = NAN, qreal t = NAN, qreal y = NAN)
14 : _s(s), _t(t), _y(y) {}
16 qreal s() const {return _s;}
17 qreal t() const {return _t;}
18 qreal y() const {return _y;}
19 qreal x(GraphType type) const {return (type == Distance) ? _s : _t;}
21 void setS(qreal s) {_s = s;}
22 void setT(qreal t) {_t = t;}
23 void setY(qreal y) {_y = y;}
25 private:
26 qreal _s;
27 qreal _t;
28 qreal _y;
31 Q_DECLARE_TYPEINFO(GraphPoint, Q_PRIMITIVE_TYPE);
32 QDebug operator<<(QDebug dbg, const GraphPoint &point);
35 class Graph : public QVector<GraphPoint>
37 public:
38 Graph() : QVector<GraphPoint>() {_time = true;}
39 void append(const GraphPoint &p)
41 if (std::isnan(p.t()))
42 _time = false;
43 QVector<GraphPoint>::append(p);
46 bool hasTime() const {return _time;}
48 private:
49 bool _time;
52 #endif // GRAPH_H