Commit 5b77883e authored by Jan Hambrecht's avatar Jan Hambrecht

fix transformations for nested shapes

remove old ctor of KoShapeTransformCommand which is not used anymore


svn path=/trunk/koffice/; revision=700088
parent 0b81cb51
......@@ -295,6 +295,11 @@ void KoShape::setTransformation( const QMatrix &matrix )
d->shapeChanged(GenericMatrixChange);
}
QMatrix KoShape::localTransformation() const
{
return d->localMatrix;
}
bool KoShape::compareShapeZIndex(KoShape *s1, KoShape *s2) {
int diff = s1->zIndex() - s2->zIndex();
if(diff == 0) {
......
......@@ -547,6 +547,9 @@ public:
*/
void setTransformation( const QMatrix &matrix );
/// Returns the shapes local transformation matrix
QMatrix localTransformation() const;
/**
* Copy all the settings from the parameter shape and apply them to this shape.
* Settings like the position and rotation to visible and locked. The parent
......
......@@ -39,7 +39,7 @@ KoShapeResizeStrategy::KoShapeResizeStrategy( KoTool *tool, KoCanvasBase *canvas
continue;
m_selectedShapes << shape;
m_startPositions << shape->position();
m_oldTransforms << shape->transformationMatrix(0);
m_oldTransforms << shape->localTransformation();
m_transformations << QMatrix();
m_startSizes << shape->size();
}
......@@ -199,7 +199,7 @@ QUndoCommand* KoShapeResizeStrategy::createCommand() {
for( int i = 0; i < shapeCount; ++i )
{
newSizes << m_selectedShapes[i]->size();
transformations << m_oldTransforms[i] * m_transformations[i];
transformations << m_selectedShapes[i]->localTransformation();
}
QUndoCommand * cmd = new QUndoCommand(i18n("Resize"));
new KoShapeSizeCommand(m_selectedShapes, m_startSizes, newSizes, cmd );
......
......@@ -44,6 +44,7 @@ KoShapeRotateStrategy::KoShapeRotateStrategy( KoTool *tool, KoCanvasBase *canvas
m_initialBoundingRect = shape->boundingRect();
else
m_initialBoundingRect = m_initialBoundingRect.united( shape->boundingRect() );
m_oldTransforms << shape->localTransformation();
}
}
......@@ -93,10 +94,11 @@ void KoShapeRotateStrategy::paint( QPainter &painter, const KoViewConverter &con
}
QUndoCommand* KoShapeRotateStrategy::createCommand() {
KoShapeTransformCommand revert( m_selectedShapes, m_rotationMatrix.inverted() );
revert.redo();
QList<QMatrix> newTransforms;
foreach( KoShape* shape, m_selectedShapes )
newTransforms << shape->localTransformation();
KoShapeTransformCommand * cmd = new KoShapeTransformCommand( m_selectedShapes, m_rotationMatrix );
KoShapeTransformCommand * cmd = new KoShapeTransformCommand( m_selectedShapes, m_oldTransforms, newTransforms );
cmd->setText( i18n("Rotate") );
return cmd;
}
......@@ -53,6 +53,7 @@ private:
QRectF m_initialBoundingRect;
QPointF m_start;
QMatrix m_rotationMatrix;
QList<QMatrix> m_oldTransforms;
};
#endif /* KOSHAPEROTATESTRATEGY_H */
......
......@@ -45,6 +45,7 @@ KoShapeShearStrategy::KoShapeShearStrategy( KoTool *tool, KoCanvasBase *canvas,
if( ! isEditable( shape ) )
continue;
m_selectedShapes << shape;
m_oldTransforms << shape->localTransformation();
}
// Eventhoug we aren't currently activated by the corner handles we might as well code like it
......@@ -167,9 +168,10 @@ void KoShapeShearStrategy::paint( QPainter &painter, const KoViewConverter &conv
}
QUndoCommand* KoShapeShearStrategy::createCommand() {
KoShapeTransformCommand revert( m_selectedShapes, m_shearMatrix.inverted() );
revert.redo();
KoShapeTransformCommand * cmd = new KoShapeTransformCommand( m_selectedShapes, m_shearMatrix );
QList<QMatrix> newTransforms;
foreach( KoShape* shape, m_selectedShapes )
newTransforms << shape->localTransformation();
KoShapeTransformCommand * cmd = new KoShapeTransformCommand( m_selectedShapes, m_oldTransforms, newTransforms );
cmd->setText( i18n("Shear") );
return cmd;
}
......@@ -58,6 +58,7 @@ private:
double m_initialSelectionAngle;
QMatrix m_shearMatrix;
bool m_isMirrored;
QList<QMatrix> m_oldTransforms;
};
#endif /* KOSHAPESHEARSTRATEGY_H */
......
......@@ -34,17 +34,6 @@ public:
QList<QMatrix> newState;
};
KoShapeTransformCommand::KoShapeTransformCommand( const QList<KoShape*> &shapes, const QMatrix &transformation, QUndoCommand *parent )
: QUndoCommand(parent),
d( new Private(shapes))
{
foreach(KoShape *shape, shapes) {
QMatrix current = shape->transformationMatrix(0);
d->oldState.append( current );
d->newState.append( current * transformation );
}
}
KoShapeTransformCommand::KoShapeTransformCommand( const QList<KoShape*> &shapes, const QList<QMatrix> &oldState, const QList<QMatrix> &newState, QUndoCommand * parent )
: QUndoCommand(parent),
d( new Private(shapes))
......
......@@ -33,14 +33,6 @@ class QMatrix;
class FLAKE_EXPORT KoShapeTransformCommand : public QUndoCommand
{
public:
/**
* A command to transform a selection of shapes with the same transformation.
* This command will take the current state of the object as the default state and after re-doing it will
* transform all shapes to the state where the transformation is applied.
* @param shapes all the shapes that should be transformed
* @param transformation the transformation to apply to all shapes
*/
KoShapeTransformCommand( const QList<KoShape*> &shapes, const QMatrix &transformation, QUndoCommand *parent = 0 );
/**
* A command to transform a selection of shapes to the new state.
......
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