Krita Source Code Documentation
Loading...
Searching...
No Matches
KisFreeTransformStrategy::Private Struct Reference

Classes

struct  HandlePoints
 

Public Member Functions

QCursor getScaleCursor (const QPointF &handlePt)
 
QCursor getShearCursor (const QPointF &start, const QPointF &end)
 
 Private (KisFreeTransformStrategy *_q, const KisCoordinatesConverter *_converter, ToolTransformArgs &_currentArgs, TransformTransactionProperties &_transaction)
 
void recalculateBounds ()
 
void recalculateTransformations ()
 
void recalculateTransformedHandles ()
 

Public Attributes

QRectF bounds
 
QTransform boundsTransform
 
ToolTransformArgs clickArgs
 
QPointF clickPos
 
QTransform clickTransform
 
const KisCoordinatesConverterconverter
 standard members ///
 
ToolTransformArgscurrentArgs
 
StrokeFunction function {MOVE}
 custom members ///
 
QTransform handlesTransform
 
bool imageTooBig {false}
 
bool isTransforming {false}
 
QImage originalImage
 
QPointF paintingOffset
 
QTransform paintingTransform
 
KisFreeTransformStrategyq
 
QCursor rotateHandlesCursor
 
QCursor scaleCursors [8]
 
QPixmap shearCursorPixmap
 
QTransform thumbToImageTransform
 
TransformTransactionPropertiestransaction
 
QTransform transform
 
HandlePoints transformedHandles
 

Detailed Description

Definition at line 48 of file kis_free_transform_strategy.cpp.

Constructor & Destructor Documentation

◆ Private()

KisFreeTransformStrategy::Private::Private ( KisFreeTransformStrategy * _q,
const KisCoordinatesConverter * _converter,
ToolTransformArgs & _currentArgs,
TransformTransactionProperties & _transaction )
inline

Definition at line 50 of file kis_free_transform_strategy.cpp.

54 : q(_q),
55 converter(_converter),
56 currentArgs(_currentArgs),
57 transaction(_transaction),
58 imageTooBig(false),
59 isTransforming(false)
60 {
69
70 shearCursorPixmap.load(":/shear_cursor.png");
71 rotateHandlesCursor = QCursor(QPixmap(":/rotate_cursor_handles.xpm"));
72 }
static QCursor sizeBDiagCursor()
Definition kis_cursor.cc:74
static QCursor sizeHorCursor()
Definition kis_cursor.cc:69
static QCursor sizeFDiagCursor()
Definition kis_cursor.cc:79
static QCursor sizeVerCursor()
Definition kis_cursor.cc:64
TransformTransactionProperties & transaction
const KisCoordinatesConverter * converter
standard members ///

References rotateHandlesCursor, scaleCursors, shearCursorPixmap, KisCursor::sizeBDiagCursor(), KisCursor::sizeFDiagCursor(), KisCursor::sizeHorCursor(), and KisCursor::sizeVerCursor().

Member Function Documentation

◆ getScaleCursor()

QCursor KisFreeTransformStrategy::Private::getScaleCursor ( const QPointF & handlePt)

Definition at line 268 of file kis_free_transform_strategy.cpp.

269{
270 QPointF handlePtInWidget = converter->imageToWidget(handlePt);
271 QPointF centerPtInWidget = converter->imageToWidget(currentArgs.transformedCenter());
272
273 QPointF direction = handlePtInWidget - centerPtInWidget;
274 qreal angle = atan2(direction.y(), direction.x());
275 angle = normalizeAngle(angle);
276
277 int octant = qRound(angle * 4. / M_PI) % 8;
278 return scaleCursors[octant];
279}
_Private::Traits< T >::Result imageToWidget(const T &obj) const
QPointF transformedCenter() const
std::enable_if< std::is_floating_point< T >::value, T >::type normalizeAngle(T a)
Definition kis_global.h:121
#define M_PI
Definition kis_global.h:111
KRITAIMAGE_EXPORT qreal atan2(qreal y, qreal x)
atan2 replacement

References M_PI, and normalizeAngle().

◆ getShearCursor()

QCursor KisFreeTransformStrategy::Private::getShearCursor ( const QPointF & start,
const QPointF & end )

Definition at line 281 of file kis_free_transform_strategy.cpp.

282{
283 QPointF startPtInWidget = converter->imageToWidget(start);
284 QPointF endPtInWidget = converter->imageToWidget(end);
285 QPointF direction = endPtInWidget - startPtInWidget;
286
287 qreal angle = atan2(-direction.y(), direction.x());
288 return QCursor(shearCursorPixmap.transformed(QTransform().rotateRadians(-angle)));
289}

◆ recalculateBounds()

void KisFreeTransformStrategy::Private::recalculateBounds ( )

Definition at line 169 of file kis_free_transform_strategy.cpp.

170{
171 const QPolygonF &convexHull = transaction.convexHull();
172 if (!convexHull.isEmpty()) {
173 bounds = boundsTransform.inverted().map(convexHull).boundingRect();
174 } else {
175 bounds = boundsTransform.inverted().mapRect(transaction.originalRect());
176 }
177}

References bounds, boundsTransform, TransformTransactionProperties::convexHull(), TransformTransactionProperties::originalRect(), and transaction.

◆ recalculateTransformations()

void KisFreeTransformStrategy::Private::recalculateTransformations ( )

The center of the original image should still stay the origin of CS

Definition at line 847 of file kis_free_transform_strategy.cpp.

848{
850 QTransform sanityCheckMatrix = m.TS * m.SC * m.S * m.projectedP;
851
856 KIS_ASSERT_RECOVER_NOOP(sanityCheckMatrix.map(currentArgs.originalCenter()).manhattanLength() < 1e-4);
857
858 transform = m.finalTransform();
859 boundsTransform = m.BRI.inverted();
861
862 QTransform viewScaleTransform = converter->imageToDocumentTransform() * converter->documentToFlakeTransform();
863 handlesTransform = boundsTransform * transform * viewScaleTransform;
864
865 QTransform tl = QTransform::fromTranslate(transaction.originalTopLeft().x(), transaction.originalTopLeft().y());
866 paintingTransform = tl.inverted() * q->thumbToImageTransform() * tl * transform * viewScaleTransform;
868
869 // check whether image is too big to be displayed or not
871
872 // recalculate cached handles position
874
877}
void requestShowImageTooBig(bool value)
static bool checkImageTooBig(const QRectF &bounds, const MatricesPack &m, qreal cameraHeight)
QPointF originalCenter() const
QVector3D cameraPos() const
#define KIS_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:97

References KisTransformUtils::MatricesPack::BRI, KisTransformUtils::checkImageTooBig(), KisTransformUtils::MatricesPack::finalTransform(), KIS_ASSERT_RECOVER_NOOP, KisTransformUtils::MatricesPack::projectedP, KisTransformUtils::MatricesPack::S, KisTransformUtils::MatricesPack::SC, and KisTransformUtils::MatricesPack::TS.

◆ recalculateTransformedHandles()

void KisFreeTransformStrategy::Private::recalculateTransformedHandles ( )

Definition at line 180 of file kis_free_transform_strategy.cpp.

181{
182 QTransform boundsFullTransform = boundsTransform * transform;
183 transformedHandles.topLeft = boundsFullTransform.map(bounds.topLeft());
184 transformedHandles.topMiddle = boundsFullTransform.map(topMiddle(bounds));
185 transformedHandles.topRight = boundsFullTransform.map(bounds.topRight());
186
187 transformedHandles.middleLeft = boundsFullTransform.map(middleLeft(bounds));
188 transformedHandles.middleRight = boundsFullTransform.map(middleRight(bounds));
189
190 transformedHandles.bottomLeft = boundsFullTransform.map(bounds.bottomLeft());
191 transformedHandles.bottomMiddle = boundsFullTransform.map(bottomMiddle(bounds));
192 transformedHandles.bottomRight = boundsFullTransform.map(bounds.bottomRight());
193
195}
QPointF rotationCenterOffset() const

References bounds.

Member Data Documentation

◆ bounds

QRectF KisFreeTransformStrategy::Private::bounds

Definition at line 113 of file kis_free_transform_strategy.cpp.

◆ boundsTransform

QTransform KisFreeTransformStrategy::Private::boundsTransform

Definition at line 114 of file kis_free_transform_strategy.cpp.

◆ clickArgs

ToolTransformArgs KisFreeTransformStrategy::Private::clickArgs

Definition at line 124 of file kis_free_transform_strategy.cpp.

◆ clickPos

QPointF KisFreeTransformStrategy::Private::clickPos

Definition at line 125 of file kis_free_transform_strategy.cpp.

◆ clickTransform

QTransform KisFreeTransformStrategy::Private::clickTransform

Definition at line 126 of file kis_free_transform_strategy.cpp.

◆ converter

const KisCoordinatesConverter* KisFreeTransformStrategy::Private::converter

standard members ///

Definition at line 78 of file kis_free_transform_strategy.cpp.

◆ currentArgs

ToolTransformArgs& KisFreeTransformStrategy::Private::currentArgs

Definition at line 81 of file kis_free_transform_strategy.cpp.

◆ function

StrokeFunction KisFreeTransformStrategy::Private::function {MOVE}

custom members ///

Definition at line 96 of file kis_free_transform_strategy.cpp.

96{MOVE};

◆ handlesTransform

QTransform KisFreeTransformStrategy::Private::handlesTransform

Definition at line 92 of file kis_free_transform_strategy.cpp.

◆ imageTooBig

bool KisFreeTransformStrategy::Private::imageTooBig {false}

Definition at line 122 of file kis_free_transform_strategy.cpp.

122{false};

◆ isTransforming

bool KisFreeTransformStrategy::Private::isTransforming {false}

Definition at line 128 of file kis_free_transform_strategy.cpp.

128{false};

◆ originalImage

QImage KisFreeTransformStrategy::Private::originalImage

Definition at line 87 of file kis_free_transform_strategy.cpp.

◆ paintingOffset

QPointF KisFreeTransformStrategy::Private::paintingOffset

Definition at line 90 of file kis_free_transform_strategy.cpp.

◆ paintingTransform

QTransform KisFreeTransformStrategy::Private::paintingTransform

Definition at line 89 of file kis_free_transform_strategy.cpp.

◆ q

KisFreeTransformStrategy* KisFreeTransformStrategy::Private::q

Definition at line 74 of file kis_free_transform_strategy.cpp.

◆ rotateHandlesCursor

QCursor KisFreeTransformStrategy::Private::rotateHandlesCursor

Definition at line 120 of file kis_free_transform_strategy.cpp.

◆ scaleCursors

QCursor KisFreeTransformStrategy::Private::scaleCursors[8]

Definition at line 118 of file kis_free_transform_strategy.cpp.

◆ shearCursorPixmap

QPixmap KisFreeTransformStrategy::Private::shearCursorPixmap

Definition at line 119 of file kis_free_transform_strategy.cpp.

◆ thumbToImageTransform

QTransform KisFreeTransformStrategy::Private::thumbToImageTransform

Definition at line 86 of file kis_free_transform_strategy.cpp.

◆ transaction

TransformTransactionProperties& KisFreeTransformStrategy::Private::transaction

Definition at line 83 of file kis_free_transform_strategy.cpp.

◆ transform

QTransform KisFreeTransformStrategy::Private::transform

Definition at line 116 of file kis_free_transform_strategy.cpp.

◆ transformedHandles

HandlePoints KisFreeTransformStrategy::Private::transformedHandles

Definition at line 111 of file kis_free_transform_strategy.cpp.


The documentation for this struct was generated from the following file: