Commit 81a18bcf authored by Jan Hambrecht's avatar Jan Hambrecht

This commit fixes the calculation of absolute transformation matrix

when a view converter is given. This could be seen when rotating a
selection where the painted shapes and the painted selection rect
did not match anymore. This has also the neat sideeffect that
KoShape::applyConversion is not needed anymore. This will get removed
next.

BUG:171969


svn path=/trunk/koffice/; revision=869031
parent c8faf4c3
...@@ -295,21 +295,22 @@ QMatrix KoShape::absoluteTransformation(const KoViewConverter *converter) const ...@@ -295,21 +295,22 @@ QMatrix KoShape::absoluteTransformation(const KoViewConverter *converter) const
if (container->childClipped(this)) if (container->childClipped(this))
matrix = container->absoluteTransformation(0); matrix = container->absoluteTransformation(0);
else { else {
QSizeF containerSize = container->size(); // childs trasformations are relative to the parents position
QPointF containerPos = container->absolutePosition() - QPointF(0.5 * containerSize.width(), 0.5 * containerSize.height()); QRectF containerRect( QPointF(), container->size() );
if (converter) QPointF containerPos = container->absolutePosition() - containerRect.center();
containerPos = converter->documentToView(containerPos);
matrix.translate(containerPos.x(), containerPos.y()); matrix.translate(containerPos.x(), containerPos.y());
} }
} }
QMatrix scaleMatrix;
// calculate the scaling if a view converter is given
if (converter) { if (converter) {
QPointF pos = d->localMatrix.map(QPointF()); qreal zoomX, zoomY;
QPointF trans = converter->documentToView(pos) - pos; converter->zoom(&zoomX, &zoomY);
matrix.translate(trans.x(), trans.y()); scaleMatrix.scale(zoomX, zoomY);
} }
return d->localMatrix * matrix; return d->localMatrix * matrix * scaleMatrix;
} }
void KoShape::applyAbsoluteTransformation(const QMatrix &matrix) void KoShape::applyAbsoluteTransformation(const QMatrix &matrix)
...@@ -1140,9 +1141,11 @@ void KoShape::init(const QMap<QString, KoDataCenter *> & dataCenterMap) ...@@ -1140,9 +1141,11 @@ void KoShape::init(const QMap<QString, KoDataCenter *> & dataCenterMap)
// static // static
void KoShape::applyConversion(QPainter &painter, const KoViewConverter &converter) void KoShape::applyConversion(QPainter &painter, const KoViewConverter &converter)
{ {
/*
qreal zoomX, zoomY; qreal zoomX, zoomY;
converter.zoom(&zoomX, &zoomY); converter.zoom(&zoomX, &zoomY);
painter.scale(zoomX, zoomY); painter.scale(zoomX, zoomY);
*/
} }
QPointF KoShape::shapeToDocument(const QPointF &point) const QPointF KoShape::shapeToDocument(const QPointF &point) const
......
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