1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-07 07:13:21 +02:00
GPXSee/src/map/transform.h

41 lines
908 B
C
Raw Normal View History

2018-01-08 23:47:45 +01:00
#ifndef TRANSFORM_H
#define TRANSFORM_H
#include <QTransform>
#include <QList>
2018-03-22 20:00:30 +01:00
#include <QDebug>
2018-01-08 23:47:45 +01:00
struct ReferencePoint {
QPoint xy;
QPointF pp;
};
class Transform
{
public:
2018-03-22 20:00:30 +01:00
Transform();
2018-01-08 23:47:45 +01:00
Transform(const QList<ReferencePoint> &points);
2018-03-22 20:00:30 +01:00
Transform(const ReferencePoint &p, const QPointF &scale);
Transform(double m[16]);
2018-01-08 23:47:45 +01:00
2018-03-22 20:00:30 +01:00
QPointF proj2img(const QPointF &p) const {return _proj2img.map(p);}
QPointF img2proj(const QPointF &p) const {return _img2proj.map(p);}
bool isValid() const
{return _proj2img.isInvertible() && _img2proj.isInvertible();}
2018-01-08 23:47:45 +01:00
const QString &errorString() const {return _errorString;}
private:
void simple(const QList<ReferencePoint> &points);
void affine(const QList<ReferencePoint> &points);
2018-03-22 20:00:30 +01:00
QTransform _proj2img, _img2proj;
2018-01-08 23:47:45 +01:00
QString _errorString;
};
#ifndef QT_NO_DEBUG
2018-01-21 00:48:34 +01:00
QDebug operator<<(QDebug dbg, const ReferencePoint &p);
#endif // QT_NO_DEBUG
2018-01-21 00:48:34 +01:00
2018-01-08 23:47:45 +01:00
#endif // TRANSFORM_H