1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 13:41:16 +01:00
GPXSee/src/graph.h

53 lines
942 B
C
Raw Normal View History

2016-09-19 00:55:03 +02:00
#ifndef GRAPH_H
#define GRAPH_H
#include <QVector>
2016-11-05 20:00:14 +01:00
#include <QDebug>
2016-09-19 23:35:04 +02:00
#include <cmath>
2016-09-19 00:55:03 +02:00
2016-09-19 23:35:04 +02:00
enum GraphType {Distance, Time};
class GraphPoint
2016-09-19 00:55:03 +02:00
{
public:
2016-09-19 23:35:04 +02:00
GraphPoint(qreal s = NAN, qreal t = NAN, qreal y = NAN)
: _s(s), _t(t), _y(y) {}
qreal s() const {return _s;}
qreal t() const {return _t;}
qreal y() const {return _y;}
qreal x(GraphType type) const {return (type == Distance) ? _s : _t;}
2016-09-19 00:55:03 +02:00
2016-09-19 23:35:04 +02:00
void setS(qreal s) {_s = s;}
void setT(qreal t) {_t = t;}
void setY(qreal y) {_y = y;}
private:
qreal _s;
qreal _t;
qreal _y;
2016-09-19 00:55:03 +02:00
};
2016-11-05 20:00:14 +01:00
Q_DECLARE_TYPEINFO(GraphPoint, Q_PRIMITIVE_TYPE);
2016-11-14 22:12:43 +01:00
QDebug operator<<(QDebug dbg, const GraphPoint &point);
2016-11-05 20:00:14 +01:00
2016-11-05 17:33:29 +01:00
class Graph : public QVector<GraphPoint>
{
public:
Graph() : QVector<GraphPoint>() {_time = true;}
void append(const GraphPoint &p)
{
if (std::isnan(p.t()))
_time = false;
QVector<GraphPoint>::append(p);
}
bool hasTime() const {return _time;}
private:
bool _time;
};
2016-09-19 23:35:04 +02:00
2016-09-19 00:55:03 +02:00
#endif // GRAPH_H