Commit c0983937 authored by Jan Hambrecht's avatar Jan Hambrecht

Changed api for transformation related methods in KoShape.

When doing shape transformations one has to know that there
are two coordinate systems involved. The first one is the
global (absolute) coordinates system, the one that corresponds
to the document. The second is the local coordinates system
that is only relevant to a single shape. To distinguish on
which coordinate system a methods works, there is the
"absolute" prefix for the methods dealing with the global,
document based coordinate system.

methods working relative to the globale coordinate system:

absolutePosition()
setAbsolutePsotion()
absoluteTransformation() -> was transformationMatrix before
applyAbsoluteTransformation() -> was applyTransformation()

methods working relative to the shape coordinate system:

position()
setPosition()
rotate()
setShear()
setScale()
transformation()
setTransformation()
applyTransformation()

Additionally i removed the moveBy methods which used to
be relative to the global coordinate system. I removed
that one as one can simply type
setAbsolutePosition( absolutePosition() + QPoinF(dx,dy) )
to have the same effect as before.

I hope that makes it easier to use transformation of
shapes.


svn path=/trunk/koffice/; revision=700574
parent 244e9ffd
......@@ -75,7 +75,7 @@ QPainterPath KisShapeSelection::selectionOutline()
{
pathShape = dynamic_cast<KoPathShape*>( shape );
if(pathShape) {
QMatrix shapeMatrix = shape->transformationMatrix(0);
QMatrix shapeMatrix = shape->absoluteTransformation(0);
outline = outline.united(shapeMatrix.map(shape->outline()));
}
......
......@@ -52,7 +52,7 @@ void KoCreatePathTool::paint( QPainter &painter, const KoViewConverter &converte
{
//qDebug() << "KoCreatePathTool::paint" << m_shape;
painter.save();
painter.setMatrix( m_shape->transformationMatrix( &converter ) * painter.matrix() );
painter.setMatrix( m_shape->absoluteTransformation( &converter ) * painter.matrix() );
painter.save();
m_shape->paint( painter, converter );
......
......@@ -569,13 +569,13 @@ void KoInteractionTool::recalcSelectionBox() {
if(koSelection()->count()>1)
{
QMatrix matrix = koSelection()->transformationMatrix(0);
QMatrix matrix = koSelection()->absoluteTransformation(0);
d->selectionOutline = matrix.map(QPolygonF(QRectF(QPointF(0, 0), koSelection()->size())));
d->angle = 0.0; //koSelection()->rotation();
}
else
{
QMatrix matrix = koSelection()->firstSelectedShape()->transformationMatrix(0);
QMatrix matrix = koSelection()->firstSelectedShape()->absoluteTransformation(0);
d->selectionOutline = matrix.map(QPolygonF(QRectF(QPointF(0, 0), koSelection()->firstSelectedShape()->size())));
d->angle = 0.0; //koSelection()->firstSelectedShape()->rotation();
}
......@@ -650,7 +650,7 @@ void SelectionDecorator::paint(QPainter &painter, const KoViewConverter &convert
foreach(KoShape *shape, m_selection->selectedShapes(KoFlake::StrippedSelection)) {
QMatrix matrix = shape->transformationMatrix(0);
QMatrix matrix = shape->absoluteTransformation(0);
outline = matrix.map(QPolygonF(QRectF(QPointF(0, 0), shape->size())));
for(int i =0; i<outline.count(); i++)
outline[i] = converter.documentToView(outline.value(i));
......@@ -668,7 +668,7 @@ void SelectionDecorator::paint(QPainter &painter, const KoViewConverter &convert
if(m_selection->count()>1)
{
QMatrix matrix = m_selection->transformationMatrix(0);
QMatrix matrix = m_selection->absoluteTransformation(0);
outline = matrix.map(QPolygonF(QRectF(QPointF(0, 0), m_selection->size())));
for(int i =0; i<outline.count(); i++)
outline[i] = converter.documentToView(outline.value(i));
......@@ -678,7 +678,7 @@ void SelectionDecorator::paint(QPainter &painter, const KoViewConverter &convert
}
else if( m_selection->firstSelectedShape() )
{
QMatrix matrix = m_selection->firstSelectedShape()->transformationMatrix(0);
QMatrix matrix = m_selection->firstSelectedShape()->absoluteTransformation(0);
outline = matrix.map(QPolygonF(QRectF(QPointF(0, 0), m_selection->firstSelectedShape()->size())));
for(int i =0; i<outline.count(); i++)
outline[i] = converter.documentToView(outline.value(i));
......
......@@ -314,22 +314,22 @@ void KoPathShape::debugPath()
QPointF KoPathShape::shapeToDocument( const QPointF &point ) const
{
return transformationMatrix(0).map( point );
return absoluteTransformation(0).map( point );
}
QRectF KoPathShape::shapeToDocument( const QRectF &rect ) const
{
return transformationMatrix(0).mapRect( rect );
return absoluteTransformation(0).mapRect( rect );
}
QPointF KoPathShape::documentToShape( const QPointF &point ) const
{
return transformationMatrix(0).inverted().map( point );
return absoluteTransformation(0).inverted().map( point );
}
QRectF KoPathShape::documentToShape( const QRectF &rect ) const
{
return transformationMatrix(0).inverted().mapRect( rect );
return absoluteTransformation(0).inverted().mapRect( rect );
}
......@@ -432,13 +432,13 @@ QRectF KoPathShape::boundingRect() const
bb.adjust( -inset.left, -inset.top, inset.right, inset.bottom );
}
//qDebug() << "KoPathShape::boundingRect = " << bb;
return transformationMatrix( 0 ).mapRect( bb );
return absoluteTransformation( 0 ).mapRect( bb );
}
QSizeF KoPathShape::size() const
{
// don't call boundingRect here as it uses transformationMatrix which leads to infinite reccursion
// don't call boundingRect here as it uses absoluteTransformation which leads to infinite reccursion
return outline().boundingRect().size();
}
......@@ -610,7 +610,7 @@ void KoPathShape::update()
QPointF KoPathShape::normalize()
{
QPointF oldTL( boundingRect().topLeft() );
QPointF tl( outline().boundingRect().topLeft() );
QMatrix matrix;
matrix.translate( -tl.x(), -tl.y() );
......@@ -619,7 +619,7 @@ QPointF KoPathShape::normalize()
// keep the top left point of the object
QPointF newTL( boundingRect().topLeft() );
QPointF diff( oldTL - newTL );
moveBy( diff.x(), diff.y() );
setAbsolutePosition( absolutePosition() + diff );
return tl;
}
......@@ -1027,8 +1027,8 @@ bool KoPathShape::combine( KoPathShape *path )
if( ! path )
return false;
QMatrix pathMatrix = path->transformationMatrix(0);
QMatrix myMatrix = transformationMatrix(0).inverted();
QMatrix pathMatrix = path->absoluteTransformation(0);
QMatrix myMatrix = absoluteTransformation(0).inverted();
foreach( KoSubpath* subpath, path->m_subpaths )
{
......@@ -1053,7 +1053,7 @@ bool KoPathShape::separate( QList<KoPathShape*> & separatedPaths )
if( ! m_subpaths.size() )
return false;
QMatrix myMatrix = transformationMatrix(0);
QMatrix myMatrix = absoluteTransformation(0);
foreach( KoSubpath* subpath, m_subpaths )
{
......
......@@ -279,7 +279,7 @@ void KoPathTool::paint( QPainter &painter, const KoViewConverter &converter) {
foreach( KoPathShape *shape, m_selectedShapes )
{
painter.save();
painter.setMatrix( shape->transformationMatrix( &converter ) * painter.matrix() );
painter.setMatrix( shape->absoluteTransformation( &converter ) * painter.matrix() );
KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>( shape );
if ( parameterShape && parameterShape->isParametricShape() )
......@@ -616,7 +616,7 @@ void KoPathTool::resourceChanged( int key, const QVariant & res )
int maxRadius = qMax( m_handleRadius, oldHandleRadius );
foreach(KoPathShape *shape, m_selectedShapes)
{
QRectF controlPointRect = shape->transformationMatrix(0).map( shape->outline() ).controlPointRect();
QRectF controlPointRect = shape->absoluteTransformation(0).map( shape->outline() ).controlPointRect();
repaint( controlPointRect.adjusted(-maxRadius,-maxRadius,maxRadius,maxRadius) );
}
}
......@@ -651,7 +651,7 @@ QRectF KoPathTool::handleRect( const QPointF &p ) {
void KoPathTool::ActivePointHandle::paint( QPainter &painter, const KoViewConverter &converter )
{
painter.save();
painter.setMatrix( m_activePoint->parent()->transformationMatrix(&converter) * painter.matrix() );
painter.setMatrix( m_activePoint->parent()->absoluteTransformation(&converter) * painter.matrix() );
KoShape::applyConversion( painter, converter );
QRectF handle = converter.viewToDocument( m_tool->handleRect( QPoint(0,0) ) );
......@@ -734,7 +734,7 @@ bool KoPathTool::ActivePointHandle::check()
void KoPathTool::ActiveParameterHandle::paint( QPainter &painter, const KoViewConverter &converter )
{
painter.save();
painter.setMatrix( m_parameterShape->transformationMatrix(&converter) * painter.matrix() );
painter.setMatrix( m_parameterShape->absoluteTransformation(&converter) * painter.matrix() );
m_parameterShape->paintHandle( painter, converter, m_handleId, m_tool->m_handleRadius );
painter.restore();
......@@ -767,7 +767,7 @@ void KoPathTool::KoPathPointSelection::paint( QPainter &painter, const KoViewCon
{
painter.save();
painter.setMatrix( it.key()->transformationMatrix(&converter) * painter.matrix() );
painter.setMatrix( it.key()->absoluteTransformation(&converter) * painter.matrix() );
KoShape::applyConversion( painter, converter );
QRectF handle = converter.viewToDocument( m_tool->handleRect( QPoint(0,0) ) );
......
......@@ -97,7 +97,7 @@ void KoSelection::select(KoShape * object)
}
if(d->selectedShapes.count() == 1)
setTransformation( object->transformationMatrix(0) );
setTransformation( object->absoluteTransformation(0) );
else
setTransformation( QMatrix() );
......@@ -120,7 +120,7 @@ void KoSelection::deselect(KoShape * object)
d->selectedShapes.removeAll( object );
if(d->selectedShapes.count() == 1)
setTransformation( firstSelectedShape()->transformationMatrix(0) );
setTransformation( firstSelectedShape()->absoluteTransformation(0) );
requestSelectionChangedEvent();
}
......@@ -171,7 +171,7 @@ bool KoSelection::hitTest( const QPointF &position ) const
void KoSelection::updateSizeAndPosition()
{
QRectF bb = sizeRect();
QMatrix matrix = transformationMatrix(0);
QMatrix matrix = absoluteTransformation(0);
setSize( bb.size() );
QPointF p = matrix.map(bb.topLeft() + matrix.inverted().map( position()) );
setPosition( p );
......@@ -182,7 +182,7 @@ QRectF KoSelection::sizeRect() const
bool first=true;
QRectF bb;
QMatrix itmat = transformationMatrix(0).inverted();
QMatrix itmat = absoluteTransformation(0).inverted();
if ( !d->selectedShapes.isEmpty() )
{
......@@ -191,11 +191,11 @@ QRectF KoSelection::sizeRect() const
if( dynamic_cast<KoShapeGroup*>( *it ))
continue;
if(first) {
bb = ((*it)->transformationMatrix(0) * itmat).mapRect(QRectF(QPointF(),(*it)->size()));
bb = ((*it)->absoluteTransformation(0) * itmat).mapRect(QRectF(QPointF(),(*it)->size()));
first = false;
}
else
bb = bb.unite( ((*it)->transformationMatrix(0) * itmat).mapRect(QRectF(QPointF(),(*it)->size())) );
bb = bb.unite( ((*it)->absoluteTransformation(0) * itmat).mapRect(QRectF(QPointF(),(*it)->size())) );
}
}
......@@ -204,7 +204,7 @@ QRectF KoSelection::sizeRect() const
QRectF KoSelection::boundingRect() const
{
return transformationMatrix(0).mapRect( sizeRect() );
return absoluteTransformation(0).mapRect( sizeRect() );
}
const QList<KoShape*> KoSelection::selectedShapes(KoFlake::SelectionType strip) const {
......
......@@ -230,7 +230,7 @@ bool KoShape::hitTest( const QPointF &position ) const
if(d->parent && d->parent->childClipped(this) && !d->parent->hitTest(position))
return false;
QPointF point = transformationMatrix(0).inverted().map( position );
QPointF point = absoluteTransformation(0).inverted().map( position );
KoInsets insets(0, 0, 0, 0);
if(d->border)
d->border->borderInsets(this, insets);
......@@ -248,16 +248,16 @@ QRectF KoShape::boundingRect() const
d->border->borderInsets(this, insets);
bb.adjust(-insets.left, -insets.top, insets.right, insets.bottom);
}
return transformationMatrix(0).mapRect( bb );
return absoluteTransformation(0).mapRect( bb );
}
QMatrix KoShape::transformationMatrix(const KoViewConverter *converter) const {
QMatrix KoShape::absoluteTransformation(const KoViewConverter *converter) const {
QMatrix matrix;
// apply parents matrix to inherit any transformations done there.
KoShapeContainer * container = d->parent;
if( container ) {
if( container->childClipped(this) )
matrix = container->transformationMatrix(0);
matrix = container->absoluteTransformation(0);
else {
QSizeF containerSize = container->size();
QPointF containerPos = container->absolutePosition() - QPointF( 0.5*containerSize.width(), 0.5*containerSize.height() );
......@@ -276,14 +276,19 @@ QMatrix KoShape::transformationMatrix(const KoViewConverter *converter) const {
return d->localMatrix * matrix;
}
void KoShape::applyTransformation( const QMatrix &matrix )
void KoShape::applyAbsoluteTransformation( const QMatrix &matrix )
{
QMatrix globalMatrix = transformationMatrix(0);
QMatrix globalMatrix = absoluteTransformation(0);
// the transformation is relative to the global coordinate system
// but we want to change the local matrix, so convert the matrix
// to be relative to the local coordinate system
QMatrix transformMatrix = globalMatrix * matrix * globalMatrix.inverted();
d->localMatrix = transformMatrix * d->localMatrix;
applyTransformation( transformMatrix );
}
void KoShape::applyTransformation( const QMatrix &matrix )
{
d->localMatrix = matrix * d->localMatrix;
notifyChanged();
d->shapeChanged(GenericMatrixChange);
}
......@@ -295,7 +300,7 @@ void KoShape::setTransformation( const QMatrix &matrix )
d->shapeChanged(GenericMatrixChange);
}
QMatrix KoShape::localTransformation() const
QMatrix KoShape::transformation() const
{
return d->localMatrix;
}
......@@ -347,7 +352,7 @@ void KoShape::repaint() const {
d->border->borderInsets(this, insets);
rect.adjust(-insets.left, -insets.top, insets.right, insets.bottom);
}
rect = transformationMatrix(0).mapRect(rect);
rect = absoluteTransformation(0).mapRect(rect);
foreach( KoShapeManager * manager, d->shapeManagers )
manager->repaint( rect, this, true );
}
......@@ -356,7 +361,7 @@ void KoShape::repaint() const {
void KoShape::repaint(const QRectF &shape) const {
if ( !d->shapeManagers.empty() && isVisible() )
{
QRectF rect(transformationMatrix(0).mapRect(shape));
QRectF rect(absoluteTransformation(0).mapRect(shape));
foreach( KoShapeManager * manager, d->shapeManagers )
{
manager->repaint(rect);
......@@ -379,7 +384,7 @@ QPointF KoShape::absolutePosition(KoFlake::Position anchor) const {
case KoFlake::BottomRightCorner: point = QPointF(size().width(), size().height()); break;
case KoFlake::CenteredPositon: point = QPointF(size().width() / 2.0, size().height() / 2.0); break;
}
return transformationMatrix(0).map(point);
return absoluteTransformation(0).map(point);
}
void KoShape::setAbsolutePosition(QPointF newPosition, KoFlake::Position anchor) {
......@@ -387,7 +392,7 @@ void KoShape::setAbsolutePosition(QPointF newPosition, KoFlake::Position anchor)
QPointF translate = newPosition - currentAbsPosition;
QMatrix translateMatrix;
translateMatrix.translate( translate.x(), translate.y() );
applyTransformation( translateMatrix );
applyAbsoluteTransformation( translateMatrix );
notifyChanged();
d->shapeChanged(PositionChanged);
}
......@@ -405,11 +410,6 @@ void KoShape::copySettings(const KoShape *shape) {
d->localMatrix = shape->d->localMatrix;
}
void KoShape::moveBy(double distanceX, double distanceY) {
QPointF p = absolutePosition();
setAbsolutePosition(QPointF(p.x() + distanceX, p.y() + distanceY));
}
void KoShape::notifyChanged()
{
foreach( KoShapeManager * manager, d->shapeManagers )
......@@ -696,7 +696,7 @@ bool KoShape::loadOdfAttributes( const KoXmlElement & element, KoShapeLoadingCon
{
QString transform = element.attributeNS( KoXmlNS::draw, "transform", QString() );
if( ! transform.isEmpty() )
applyTransformation( parseOdfTransform( transform ) );
applyAbsoluteTransformation( parseOdfTransform( transform ) );
}
return true;
......@@ -895,7 +895,7 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
bool scale = qAbs(d->scaleX - 1) > 1E-6 || qAbs(d->scaleY -1) > 1E-6;
if(rotate && (skew || scale)) {
QMatrix matrix; // can't use transformationMatrix() as that includes transformation of the container as well.
QMatrix matrix; // can't use absoluteTransformation() as that includes transformation of the container as well.
QSizeF size(this->size());
if ( d->angle != 0 )
{
......@@ -929,7 +929,7 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
context.xmlWriter().addAttribute( "draw:transform", transform );
}
*/
QMatrix matrix = transformationMatrix(0);
QMatrix matrix = absoluteTransformation(0);
if( ! matrix.isIdentity() )
{
QString m = QString( "matrix(%1 %2 %3 %4 %5pt %6pt)" )
......
......@@ -477,16 +477,6 @@ public:
*/
void setAbsolutePosition(QPointF newPosition, KoFlake::Position anchor = KoFlake::CenteredPositon);
/**
* Move this shape from its current (absolute) position over a specified distance.
* This takes the position of the shape, and moves it in the normal plain. This takes
* into account the rotation of the object so distanceX really will be the resulting
* horizontal distance.
* @param distanceX the horizontal distance to move
* @param distanceY the vertical distance to move
*/
void moveBy(double distanceX, double distanceY);
/**
* Set a data object on the shape to be used by an application.
* This is specifically useful when a shape is created in a plugin and that data from that
......@@ -527,19 +517,25 @@ public:
/**
* Create a matrix that describes all the transformations done on this shape.
*
* The absolute transformation is the combined transformation of this shape
* and all its parents and grandparents.
*
* @param converter if not null, this method uses the converter to mark the right
* offsets in the current view.
*/
QMatrix transformationMatrix(const KoViewConverter *converter) const;
QMatrix absoluteTransformation(const KoViewConverter *converter) const;
/**
* Applies a transformation to this shape.
*
* The transformation given is relative to the global coordinate system, i.e. the document.
* This is a convenience function to apply a global transformation to this shape.
* @see applyTransformation
*
* @param matrix the transformation matrix to apply
*/
void applyTransformation(const QMatrix &matrix );
void applyAbsoluteTransformation(const QMatrix &matrix );
/**
* Sets a new transformation matrix describing the local transformations on this shape.
......@@ -548,7 +544,16 @@ public:
void setTransformation( const QMatrix &matrix );
/// Returns the shapes local transformation matrix
QMatrix localTransformation() const;
QMatrix transformation() const;
/**
* Applies a transformation to this shape.
*
* The transformation given is relative to the shape coordinate system.
*
* @param matrix the transformation matrix to apply
*/
void applyTransformation( const QMatrix &matrix );
/**
* Copy all the settings from the parameter shape and apply them to this shape.
......
......@@ -85,12 +85,12 @@ KoShapeConnection::~KoShapeConnection() {
void KoShapeConnection::paint(QPainter &painter, const KoViewConverter &converter) {
double x, y;
converter.zoom(&x, &y);
QMatrix matrix = d->shape1->transformationMatrix(&converter);
QMatrix matrix = d->shape1->absoluteTransformation(&converter);
matrix.scale(x, y);
QPointF a = matrix.map(d->shape1->connectors()[d->gluePointIndex1]);
QPointF b;
if(d->shape2) {
matrix = d->shape2->transformationMatrix(&converter);
matrix = d->shape2->absoluteTransformation(&converter);
matrix.scale(x, y);
b = matrix.map(d->shape2->connectors()[d->gluePointIndex2]);
}
......@@ -137,12 +137,12 @@ int KoShapeConnection::gluePointIndex2() const {
}
QPointF KoShapeConnection::startPoint() const {
return d->shape1->transformationMatrix(0).map(d->shape1->connectors()[d->gluePointIndex1]);
return d->shape1->absoluteTransformation(0).map(d->shape1->connectors()[d->gluePointIndex1]);
}
QPointF KoShapeConnection::endPoint() const {
if(d->shape2)
return d->shape2->transformationMatrix(0).map(d->shape2->connectors()[d->gluePointIndex2]);
return d->shape2->absoluteTransformation(0).map(d->shape2->connectors()[d->gluePointIndex2]);
return d->endPoint;
}
......
......@@ -184,7 +184,7 @@ void KoShapeContainer::paint(QPainter &painter, const KoViewConverter &converter
QList<KoShape*> sortedObjects = d->children->iterator();
qSort(sortedObjects.begin(), sortedObjects.end(), KoShape::compareShapeZIndex);
QMatrix baseMatrix = transformationMatrix(0).inverted() * painter.matrix();
QMatrix baseMatrix = absoluteTransformation(0).inverted() * painter.matrix();
// clip the children to the parent outline.
QMatrix m;
......@@ -208,12 +208,12 @@ void KoShapeContainer::paint(QPainter &painter, const KoViewConverter &converter
}
painter.save();
painter.setMatrix( shape->transformationMatrix(&converter) * baseMatrix );
painter.setMatrix( shape->absoluteTransformation(&converter) * baseMatrix );
shape->paint(painter, converter);
painter.restore();
if(shape->border()) {
painter.save();
painter.setMatrix( shape->transformationMatrix(&converter) * baseMatrix );
painter.setMatrix( shape->absoluteTransformation(&converter) * baseMatrix );
shape->border()->paintBorder(shape, painter, converter);
painter.restore();
}
......
......@@ -91,7 +91,7 @@ bool KoShapeGroup::loadOdf( const KoXmlElement & element, KoShapeLoadingContext
setPosition( bound.topLeft() );
foreach( KoShape * shape, iterator() )
shape->moveBy( -bound.topLeft().x(), -bound.topLeft().y() );
shape->setAbsolutePosition( shape->absolutePosition() - bound.topLeft() );
return true;
}
......@@ -47,7 +47,7 @@ KoShapeManagerPaintingStrategy::~KoShapeManagerPaintingStrategy()
void KoShapeManagerPaintingStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool forPrint )
{
painter.save();
painter.setMatrix( shape->transformationMatrix(&converter) * painter.matrix() );
painter.setMatrix( shape->absoluteTransformation(&converter) * painter.matrix() );
d->shapeManager->paintShape( shape, painter, converter, forPrint );
......
......@@ -39,7 +39,7 @@ KoShapeResizeStrategy::KoShapeResizeStrategy( KoTool *tool, KoCanvasBase *canvas
continue;
m_selectedShapes << shape;
m_startPositions << shape->position();
m_oldTransforms << shape->localTransformation();
m_oldTransforms << shape->transformation();
m_transformations << QMatrix();
m_startSizes << shape->size();
}
......@@ -53,7 +53,7 @@ KoShapeResizeStrategy::KoShapeResizeStrategy( KoTool *tool, KoCanvasBase *canvas
if( shp )
{
m_windMatrix = shp->transformationMatrix(0);
m_windMatrix = shp->absoluteTransformation(0);
m_unwindMatrix = m_windMatrix.inverted();
m_initialSize = shp->size();
m_initialPosition = m_windMatrix.map(QPointF());
......@@ -146,7 +146,7 @@ void KoShapeResizeStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardMo
shape->repaint();
// this uses resize for the zooming part
shape->applyTransformation( m_unwindMatrix );
shape->applyAbsoluteTransformation( m_unwindMatrix );
/*
normally we would just apply the resizeMatrix now and be done with it, but
......@@ -155,10 +155,10 @@ void KoShapeResizeStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardMo
*/
// undo the last resize transformation
shape->applyTransformation( m_transformations[i].inverted() );
shape->applyAbsoluteTransformation( m_transformations[i].inverted() );
// save the shapes transformation matrix
QMatrix shapeMatrix = shape->transformationMatrix(0);
QMatrix shapeMatrix = shape->absoluteTransformation(0);
// calculate the matrix we would apply to the local shape matrix
// that tells us the effective scale values we have to use for the resizing
......@@ -177,18 +177,18 @@ void KoShapeResizeStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardMo
// apply the transformation
shape->setSize( size );
// apply the rest of the transformation without the resizing part
shape->applyTransformation( scaleMatrix.inverted() * resizeMatrix );
shape->applyTransformation( mirrorMatrix );
shape->applyAbsoluteTransformation( scaleMatrix.inverted() * resizeMatrix );
shape->applyAbsoluteTransformation( mirrorMatrix );
// and remember the applied transformation later for later undoing
m_transformations[i] = shapeMatrix.inverted() * shape->transformationMatrix(0);
m_transformations[i] = shapeMatrix.inverted() * shape->absoluteTransformation(0);
shape->applyTransformation( m_windMatrix );
shape->applyAbsoluteTransformation( m_windMatrix );
shape->repaint();
i++;
}
m_canvas->shapeManager()->selection()->applyTransformation( matrix * m_scaleMatrix.inverted() );
m_canvas->shapeManager()->selection()->applyAbsoluteTransformation( matrix * m_scaleMatrix.inverted() );
m_scaleMatrix = matrix;
}
......@@ -199,7 +199,7 @@ QUndoCommand* KoShapeResizeStrategy::createCommand() {
for( int i = 0; i < shapeCount; ++i )
{
newSizes << m_selectedShapes[i]->size();
transformations << m_selectedShapes[i]->localTransformation();
transformations << m_selectedShapes[i]->transformation();
}
QUndoCommand * cmd = new QUndoCommand(i18n("Resize"));
new KoShapeSizeCommand(m_selectedShapes, m_startSizes, newSizes, cmd );
......
......@@ -44,7 +44,7 @@ KoShapeRotateStrategy::KoShapeRotateStrategy( KoTool *tool, KoCanvasBase *canvas
m_initialBoundingRect = shape->boundingRect();
else
m_initialBoundingRect = m_initialBoundingRect.united( shape->boundingRect() );
m_oldTransforms << shape->localTransformation();
m_oldTransforms << shape->transformation();
}
}
......@@ -72,10 +72,10 @@ void KoShapeRotateStrategy::handleMouseMove(const QPointF &point, Qt::KeyboardMo
m_rotationMatrix = matrix;
foreach( KoShape * shape, m_selectedShapes ) {
shape->repaint();
shape->applyTransformation( applyMatrix );
shape->applyAbsoluteTransformation( applyMatrix );
shape->repaint();
}
m_canvas->shapeManager()->selection()->applyTransformation( applyMatrix );
m_canvas->shapeManager()->selection()->applyAbsoluteTransformation( applyMatrix );
}
void KoShapeRotateStrategy::paint( QPainter &painter, const KoViewConverter &converter) {
......@@ -96,7 +96,7 @@ void KoShapeRotateStrategy::paint( QPainter &painter, const KoViewConverter &con
QUndoCommand* KoShapeRotateStrategy::createCommand() {
QList<QMatrix> newTransforms;
foreach( KoShape* shape, m_selectedShapes )
newTransforms << shape->localTransformation();
newTransforms << shape->transformation();
KoShapeTransformCommand * cmd = new KoShapeTransformCommand( m_selectedShapes, m_oldTransforms, newTransforms );
cmd->setText( i18n("Rotate") );
......
......@@ -45,7 +45,7 @@ KoShapeShearStrategy::KoShapeShearStrategy( KoTool *tool, KoCanvasBase *canvas,
if( ! isEditable( shape ) )
continue;
m_selectedShapes << shape;
m_oldTransforms << shape->localTransformation();
m_oldTransforms << shape->transformation();
}
// Eventhoug we aren't currently activated by the corner handles we might as well code like it
......@@ -107,7 +107,7 @@ KoShapeShearStrategy::KoShapeShearStrategy( KoTool *tool, KoCanvasBase *canvas,
m_initialSelectionAngle = currentAngle - angle;
kDebug(30006) <<" PREsol.x=" << m_solidPoint.x() <<" sol.y=" << m_solidPoint.y();
m_solidPoint = canvas->shapeManager()->selection()->transformationMatrix(0).map( m_solidPoint );
m_solidPoint = canvas->shapeManager()->selection()->absoluteTransformation(0).map( m_solidPoint );