extract in an own static function te calculation of a rotation matrix from both source and destination rotations

svn path=/trunk/KDE/kdegraphics/okular/; revision=708049
This commit is contained in:
Pino Toscano 2007-09-03 18:16:27 +00:00
parent 0d7db7513b
commit 4913076ee9
2 changed files with 41 additions and 31 deletions

View file

@ -50,39 +50,46 @@ void RotationJob::run()
return;
}
QMatrix matrix;
if ( mOldRotation == Rotation0 ) {
if ( mNewRotation == Rotation90 )
matrix.rotate( 90 );
else if ( mNewRotation == Rotation180 )
matrix.rotate( 180 );
else if ( mNewRotation == Rotation270 )
matrix.rotate( 270 );
} else if ( mOldRotation == Rotation90 ) {
if ( mNewRotation == Rotation180 )
matrix.rotate( 90 );
else if ( mNewRotation == Rotation270 )
matrix.rotate( 180 );
else if ( mNewRotation == Rotation0 )
matrix.rotate( 270 );
} else if ( mOldRotation == Rotation180 ) {
if ( mNewRotation == Rotation270 )
matrix.rotate( 90 );
else if ( mNewRotation == Rotation0 )
matrix.rotate( 180 );
else if ( mNewRotation == Rotation90 )
matrix.rotate( 270 );
} else if ( mOldRotation == Rotation270 ) {
if ( mNewRotation == Rotation0 )
matrix.rotate( 90 );
else if ( mNewRotation == Rotation90 )
matrix.rotate( 180 );
else if ( mNewRotation == Rotation180 )
matrix.rotate( 270 );
}
QMatrix matrix = rotationMatrix( mOldRotation, mNewRotation );
mRotatedImage = mImage.transformed( matrix );
}
QMatrix RotationJob::rotationMatrix( Rotation from, Rotation to )
{
QMatrix matrix;
if ( from == Rotation0 ) {
if ( to == Rotation90 )
matrix.rotate( 90 );
else if ( to == Rotation180 )
matrix.rotate( 180 );
else if ( to == Rotation270 )
matrix.rotate( 270 );
} else if ( from == Rotation90 ) {
if ( to == Rotation180 )
matrix.rotate( 90 );
else if ( to == Rotation270 )
matrix.rotate( 180 );
else if ( to == Rotation0 )
matrix.rotate( 270 );
} else if ( from == Rotation180 ) {
if ( to == Rotation270 )
matrix.rotate( 90 );
else if ( to == Rotation0 )
matrix.rotate( 180 );
else if ( to == Rotation90 )
matrix.rotate( 270 );
} else if ( from == Rotation270 ) {
if ( to == Rotation0 )
matrix.rotate( 90 );
else if ( to == Rotation90 )
matrix.rotate( 180 );
else if ( to == Rotation180 )
matrix.rotate( 270 );
}
return matrix;
}
#include "rotationjob_p.moc"

View file

@ -11,6 +11,7 @@
#define _OKULAR_ROTATIONJOB_P_H_
#include <QtGui/QImage>
#include <QtGui/QMatrix>
#include <threadweaver/Job.h>
@ -34,6 +35,8 @@ class RotationJob : public ThreadWeaver::Job
int id() const;
PagePrivate * page() const;
static QMatrix rotationMatrix( Rotation from, Rotation to );
protected:
virtual void run();