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-04-16 20:26:10 +02:00
|
|
|
#include "pointd.h"
|
2018-01-08 23:47:45 +01:00
|
|
|
|
2018-04-15 16:27:47 +02:00
|
|
|
class ReferencePoint
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ReferencePoint() {}
|
|
|
|
ReferencePoint(const PointD &xy, const PointD &pp) : _xy(xy), _pp(pp) {}
|
|
|
|
|
|
|
|
const PointD &xy() const {return _xy;}
|
|
|
|
const PointD &pp() const {return _pp;}
|
|
|
|
void setXY(const PointD &xy) {_xy = xy;}
|
|
|
|
void setPP(const PointD &pp) {_pp = pp;}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PointD _xy, _pp;
|
2018-01-08 23:47:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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-04-15 16:27:47 +02:00
|
|
|
Transform(const ReferencePoint &p1, const ReferencePoint &p2);
|
|
|
|
Transform(const ReferencePoint &p, const PointD &scale);
|
|
|
|
Transform(double matrix[16]);
|
2018-01-08 23:47:45 +01:00
|
|
|
|
2018-04-15 17:32:25 +02:00
|
|
|
QPointF proj2img(const PointD &p) const
|
|
|
|
{return _proj2img.map(p.toPointF());}
|
|
|
|
PointD img2proj(const QPointF &p) const
|
|
|
|
{return _img2proj.map(p);}
|
2018-03-22 20:00:30 +01:00
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{return _proj2img.isInvertible() && _img2proj.isInvertible();}
|
2018-01-08 23:47:45 +01:00
|
|
|
const QString &errorString() const {return _errorString;}
|
|
|
|
|
|
|
|
private:
|
2018-04-15 16:27:47 +02:00
|
|
|
void simple(const ReferencePoint &p1, const ReferencePoint &p2);
|
2018-01-08 23:47:45 +01:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2018-02-13 23:03:18 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
2018-01-21 00:48:34 +01:00
|
|
|
QDebug operator<<(QDebug dbg, const ReferencePoint &p);
|
2018-02-13 23:03:18 +01:00
|
|
|
#endif // QT_NO_DEBUG
|
2018-01-21 00:48:34 +01:00
|
|
|
|
2018-01-08 23:47:45 +01:00
|
|
|
#endif // TRANSFORM_H
|