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 49 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 51 of file kis_free_transform_strategy.cpp.

55 : q(_q),
56 converter(_converter),
57 currentArgs(_currentArgs),
58 transaction(_transaction),
59 imageTooBig(false),
60 isTransforming(false)
61 {
70
71 shearCursorPixmap = QIcon(":/shear_cursor.svg").pixmap(22, 22);
72 rotateHandlesCursor = QCursor(QIcon(":/rotate_cursor_handles.svg").pixmap(32, 32));
73 }
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 269 of file kis_free_transform_strategy.cpp.

270{
271 QPointF handlePtInWidget = converter->imageToWidget(handlePt);
272 QPointF centerPtInWidget = converter->imageToWidget(currentArgs.transformedCenter());
273
274 QPointF direction = handlePtInWidget - centerPtInWidget;
275 qreal angle = atan2(direction.y(), direction.x());
276 angle = normalizeAngle(angle);
277
278 int octant = qRound(angle * 4. / M_PI) % 8;
279 return scaleCursors[octant];
280}
_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 282 of file kis_free_transform_strategy.cpp.

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

◆ recalculateBounds()

void KisFreeTransformStrategy::Private::recalculateBounds ( )

Definition at line 170 of file kis_free_transform_strategy.cpp.

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

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 848 of file kis_free_transform_strategy.cpp.

849{
851 QTransform sanityCheckMatrix = m.TS * m.SC * m.S * m.projectedP;
852
857 KIS_ASSERT_RECOVER_NOOP(sanityCheckMatrix.map(currentArgs.originalCenter()).manhattanLength() < 1e-4);
858
859 transform = m.finalTransform();
860 boundsTransform = m.BRI.inverted();
862
863 QTransform viewScaleTransform = converter->imageToDocumentTransform() * converter->documentToFlakeTransform();
864 handlesTransform = boundsTransform * transform * viewScaleTransform;
865
866 QTransform tl = QTransform::fromTranslate(transaction.originalTopLeft().x(), transaction.originalTopLeft().y());
867 paintingTransform = tl.inverted() * q->thumbToImageTransform() * tl * transform * viewScaleTransform;
869
870 // check whether image is too big to be displayed or not
872
873 // recalculate cached handles position
875
878}
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 181 of file kis_free_transform_strategy.cpp.

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

References bounds.

Member Data Documentation

◆ bounds

QRectF KisFreeTransformStrategy::Private::bounds

Definition at line 114 of file kis_free_transform_strategy.cpp.

◆ boundsTransform

QTransform KisFreeTransformStrategy::Private::boundsTransform

Definition at line 115 of file kis_free_transform_strategy.cpp.

◆ clickArgs

ToolTransformArgs KisFreeTransformStrategy::Private::clickArgs

Definition at line 125 of file kis_free_transform_strategy.cpp.

◆ clickPos

QPointF KisFreeTransformStrategy::Private::clickPos

Definition at line 126 of file kis_free_transform_strategy.cpp.

◆ clickTransform

QTransform KisFreeTransformStrategy::Private::clickTransform

Definition at line 127 of file kis_free_transform_strategy.cpp.

◆ converter

const KisCoordinatesConverter* KisFreeTransformStrategy::Private::converter

standard members ///

Definition at line 79 of file kis_free_transform_strategy.cpp.

◆ currentArgs

ToolTransformArgs& KisFreeTransformStrategy::Private::currentArgs

Definition at line 82 of file kis_free_transform_strategy.cpp.

◆ function

StrokeFunction KisFreeTransformStrategy::Private::function {MOVE}

custom members ///

Definition at line 97 of file kis_free_transform_strategy.cpp.

97{MOVE};

◆ handlesTransform

QTransform KisFreeTransformStrategy::Private::handlesTransform

Definition at line 93 of file kis_free_transform_strategy.cpp.

◆ imageTooBig

bool KisFreeTransformStrategy::Private::imageTooBig {false}

Definition at line 123 of file kis_free_transform_strategy.cpp.

123{false};

◆ isTransforming

bool KisFreeTransformStrategy::Private::isTransforming {false}

Definition at line 129 of file kis_free_transform_strategy.cpp.

129{false};

◆ originalImage

QImage KisFreeTransformStrategy::Private::originalImage

Definition at line 88 of file kis_free_transform_strategy.cpp.

◆ paintingOffset

QPointF KisFreeTransformStrategy::Private::paintingOffset

Definition at line 91 of file kis_free_transform_strategy.cpp.

◆ paintingTransform

QTransform KisFreeTransformStrategy::Private::paintingTransform

Definition at line 90 of file kis_free_transform_strategy.cpp.

◆ q

KisFreeTransformStrategy* KisFreeTransformStrategy::Private::q

Definition at line 75 of file kis_free_transform_strategy.cpp.

◆ rotateHandlesCursor

QCursor KisFreeTransformStrategy::Private::rotateHandlesCursor

Definition at line 121 of file kis_free_transform_strategy.cpp.

◆ scaleCursors

QCursor KisFreeTransformStrategy::Private::scaleCursors[8]

Definition at line 119 of file kis_free_transform_strategy.cpp.

◆ shearCursorPixmap

QPixmap KisFreeTransformStrategy::Private::shearCursorPixmap

Definition at line 120 of file kis_free_transform_strategy.cpp.

◆ thumbToImageTransform

QTransform KisFreeTransformStrategy::Private::thumbToImageTransform

Definition at line 87 of file kis_free_transform_strategy.cpp.

◆ transaction

TransformTransactionProperties& KisFreeTransformStrategy::Private::transaction

Definition at line 84 of file kis_free_transform_strategy.cpp.

◆ transform

QTransform KisFreeTransformStrategy::Private::transform

Definition at line 117 of file kis_free_transform_strategy.cpp.

◆ transformedHandles

HandlePoints KisFreeTransformStrategy::Private::transformedHandles

Definition at line 112 of file kis_free_transform_strategy.cpp.


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