Commit 4266ec1f authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix scaling multiple rotated shapes

When applying the scaling transform we should first uncover the
selection transform and only then apply our scaling.
parent 6910da3f
......@@ -79,7 +79,9 @@ QPointF KoFlake::toAbsolute(const QPointF &relative, const QSizeF &size)
#include "kis_debug.h"
#include "kis_algebra_2d.h"
void KoFlake::resizeShape(KoShape *shape, qreal scaleX, qreal scaleY, const QPointF &absoluteStillPoint, bool usePostScaling)
void KoFlake::resizeShape(KoShape *shape, qreal scaleX, qreal scaleY,
const QPointF &absoluteStillPoint,
bool usePostScaling, const QTransform &postScalingCoveringTransform)
{
QPointF localStillPoint = shape->absoluteTransformation(0).inverted().map(absoluteStillPoint);
......@@ -88,7 +90,9 @@ void KoFlake::resizeShape(KoShape *shape, qreal scaleX, qreal scaleY, const QPoi
if (usePostScaling) {
const QTransform scale = QTransform::fromScale(scaleX, scaleY);
shape->setTransformation(shape->transformation() * scale);
shape->setTransformation(shape->transformation() *
postScalingCoveringTransform.inverted() *
scale * postScalingCoveringTransform);
} else {
using namespace KisAlgebra2D;
......
......@@ -108,7 +108,7 @@ namespace KoFlake
KRITAFLAKE_EXPORT QPointF toAbsolute(const QPointF &relative, const QSizeF &size);
KRITAFLAKE_EXPORT void resizeShape(KoShape *shape, qreal scaleX, qreal scaleY,
const QPointF &absoluteStillPoint, bool usePostScaling = true);
const QPointF &absoluteStillPoint, bool usePostScaling, const QTransform &postScalingCoveringTransform);
}
#endif
......@@ -204,7 +204,7 @@ void KisShapeCommandsTest::testResizeShape(bool normalizeGroup)
const QPointF stillPoint = group->absolutePosition(KoFlake::BottomRightCorner);
KoFlake::resizeShape(group, 1.2, 1.4, stillPoint);
KoFlake::resizeShape(group, 1.2, 1.4, stillPoint, true, QTransform());
qDebug() << "After:";
qDebug() << ppVar(group->absolutePosition(KoFlake::TopLeftCorner));
......
......@@ -57,7 +57,7 @@ ShapeMoveStrategy::ShapeMoveStrategy(KoToolBase *tool, const QPointF &clicked)
m_initialOffset = selection->absolutePosition(SelectionDecorator::hotPosition()) - m_start;
m_canvas->snapGuide()->setIgnoredShapes(KoShape::linearizeSubtree(selection->selectedShapes()));
tool->setStatusText(i18n("Press ALT to hold x- or y-position."));
tool->setStatusText(i18n("Press Shift to hold x- or y-position."));
}
void ShapeMoveStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardModifiers modifiers)
......
......@@ -111,9 +111,9 @@ ShapeResizeStrategy::ShapeResizeStrategy(KoToolBase *tool, const QPointF &clicke
m_globalStillPoint = shape->absoluteTransformation(0).map(p0 + m_globalStillPoint);
m_globalCenterPoint = shape->absolutePosition(KoFlake::CenteredPosition);
// TODO: deprecate
m_unwindMatrix = shape->absoluteTransformation(0).inverted();
m_initialSelectionSize = shape->size();
m_postScalingCoveringTransform = shape->transformation();
}
tool->setStatusText(i18n("Press CTRL to resize from center."));
......@@ -213,7 +213,9 @@ void ShapeResizeStrategy::resizeBy(const QPointF &stillPoint, qreal zoomX, qreal
shape->setTransformation(m_initialTransforms[i]);
shape->setSize(m_initialSizes[i]);
KoFlake::resizeShape(shape, zoomX, zoomY, stillPoint, usePostScaling);
KoFlake::resizeShape(shape, zoomX, zoomY,
stillPoint,
usePostScaling, m_postScalingCoveringTransform);
shape->update();
i++;
......
......@@ -56,6 +56,7 @@ private:
QList<QSizeF> m_initialSizes;
QList<QTransform> m_initialTransforms;
QTransform m_postScalingCoveringTransform;
QSizeF m_initialSelectionSize;
QTransform m_unwindMatrix;
bool m_top, m_left, m_bottom, m_right;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment