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 471 of file kis_perspective_transform_strategy.cpp.

471 {
472 return QVector4D(pt.x(), pt.y(), 0, 1.0);
473}

◆ fromQTransform()

Eigen::Matrix3f fromQTransform ( const QTransform & t)

Definition at line 368 of file kis_perspective_transform_strategy.cpp.

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

◆ fromScale()

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

Definition at line 390 of file kis_perspective_transform_strategy.cpp.

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

◆ fromShear()

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

Definition at line 401 of file kis_perspective_transform_strategy.cpp.

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

◆ fromTranslate()

Eigen::Matrix3f fromTranslate ( const QPointF & pt)

Definition at line 379 of file kis_perspective_transform_strategy.cpp.

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

◆ getTransitionMatrix()

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

Definition at line 341 of file kis_perspective_transform_strategy.cpp.

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

References A.

◆ toQPointF()

QPointF toQPointF ( const QVector4D & v)

Definition at line 475 of file kis_perspective_transform_strategy.cpp.

475 {
476 return v.toVector2DAffine().toPointF();
477}
qreal v

References v.

◆ toQTransform()

QTransform toQTransform ( const Eigen::Matrix3f & m)

Definition at line 361 of file kis_perspective_transform_strategy.cpp.

362{
363 return QTransform(m(0,0), m(1,0), m(2,0),
364 m(0,1), m(1,1), m(2,1),
365 m(0,2), m(1,2), m(2,2));
366}