Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_perspective_transform_strategy.cpp File Reference
#include "kis_perspective_transform_strategy.h"
#include <QPointF>
#include <QPainter>
#include <QPainterPath>
#include <QMatrix4x4>
#include <QVector2D>
#include <Eigen/Dense>
#include "KoColorDisplayRendererInterface.h"
#include "kis_coordinates_converter.h"
#include "tool_transform_args.h"
#include "transform_transaction_properties.h"
#include "krita_utils.h"
#include "kis_cursor.h"
#include "kis_transform_utils.h"
#include "kis_free_transform_strategy_gsl_helpers.h"

Go to the source code of this file.

Classes

struct  KisPerspectiveTransformStrategy::Private::HandlePoints
 
struct  KisPerspectiveTransformStrategy::Private
 

Functions

QVector4D fromQPointF (const QPointF &pt)
 
Eigen::Matrix3f fromQTransform (const QTransform &t)
 
Eigen::Matrix3f fromScale (qreal sx, qreal sy)
 
Eigen::Matrix3f fromShear (qreal sx, qreal sy)
 
Eigen::Matrix3f fromTranslate (const QPointF &pt)
 
Eigen::Matrix3f getTransitionMatrix (const QVector< QPointF > &sp)
 
QPointF toQPointF (const QVector4D &v)
 
QTransform toQTransform (const Eigen::Matrix3f &m)
 

Function Documentation

◆ fromQPointF()

QVector4D fromQPointF ( const QPointF & pt)

Definition at line 469 of file kis_perspective_transform_strategy.cpp.

469 {
470 return QVector4D(pt.x(), pt.y(), 0, 1.0);
471}

◆ fromQTransform()

Eigen::Matrix3f fromQTransform ( const QTransform & t)

Definition at line 366 of file kis_perspective_transform_strategy.cpp.

367{
368 Eigen::Matrix3f m;
369
370 m << t.m11() , t.m21() , t.m31()
371 ,t.m12() , t.m22() , t.m32()
372 ,t.m13() , t.m23() , t.m33();
373
374 return m;
375}

◆ fromScale()

Eigen::Matrix3f fromScale ( qreal sx,
qreal sy )

Definition at line 388 of file kis_perspective_transform_strategy.cpp.

389{
390 Eigen::Matrix3f m;
391
392 m << sx , 0 , 0
393 ,0 , sy , 0
394 ,0 , 0 , 1;
395
396 return m;
397}

◆ fromShear()

Eigen::Matrix3f fromShear ( qreal sx,
qreal sy )

Definition at line 399 of file kis_perspective_transform_strategy.cpp.

400{
401 Eigen::Matrix3f m;
402
403 m << 1 , sx , 0
404 ,sy , sx*sy + 1, 0
405 ,0 , 0 , 1;
406
407 return m;
408}

◆ fromTranslate()

Eigen::Matrix3f fromTranslate ( const QPointF & pt)

Definition at line 377 of file kis_perspective_transform_strategy.cpp.

378{
379 Eigen::Matrix3f m;
380
381 m << 1 , 0 , pt.x()
382 ,0 , 1 , pt.y()
383 ,0 , 0 , 1;
384
385 return m;
386}

◆ getTransitionMatrix()

Eigen::Matrix3f getTransitionMatrix ( const QVector< QPointF > & sp)

Definition at line 339 of file kis_perspective_transform_strategy.cpp.

340{
341 Eigen::Matrix3f A;
342 Eigen::Vector3f v3;
343
344 A << sp[HANDLE_TOP_LEFT].x() , sp[HANDLE_TOP_RIGHT].x() , sp[HANDLE_BOTTOM_LEFT].x()
345 ,sp[HANDLE_TOP_LEFT].y() , sp[HANDLE_TOP_RIGHT].y() , sp[HANDLE_BOTTOM_LEFT].y()
346 , 1 , 1 , 1;
347
348 v3 << sp[HANDLE_BOTTOM_RIGHT].x() , sp[HANDLE_BOTTOM_RIGHT].y() , 1;
349
350 Eigen::Vector3f coeffs = A.colPivHouseholderQr().solve(v3);
351
352 A.col(0) *= coeffs(0);
353 A.col(1) *= coeffs(1);
354 A.col(2) *= coeffs(2);
355
356 return A;
357}

References A.

◆ toQPointF()

QPointF toQPointF ( const QVector4D & v)

Definition at line 473 of file kis_perspective_transform_strategy.cpp.

473 {
474 return v.toVector2DAffine().toPointF();
475}
qreal v

References v.

◆ toQTransform()

QTransform toQTransform ( const Eigen::Matrix3f & m)

Definition at line 359 of file kis_perspective_transform_strategy.cpp.

360{
361 return QTransform(m(0,0), m(1,0), m(2,0),
362 m(0,1), m(1,1), m(2,1),
363 m(0,2), m(1,2), m(2,2));
364}