• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdegraphics
  • Sitemap
  • Contact Us
 

okular

rotationjob.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006 by Tobias Koenig <tokoe@kde.org>                   *
00003  *                                                                         *
00004  *   This program is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU General Public License as published by  *
00006  *   the Free Software Foundation; either version 2 of the License, or     *
00007  *   (at your option) any later version.                                   *
00008  ***************************************************************************/
00009 
00010 #include "rotationjob_p.h"
00011 
00012 #include <QtGui/QMatrix>
00013 
00014 using namespace Okular;
00015 
00016 RotationJob::RotationJob( const QImage &image, Rotation oldRotation, Rotation newRotation, int id )
00017     : mImage( image ), mOldRotation( oldRotation ), mNewRotation( newRotation ), mId( id ), m_pd( 0 )
00018 {
00019 }
00020 
00021 void RotationJob::setPage( PagePrivate * pd )
00022 {
00023     m_pd = pd;
00024 }
00025 
00026 QImage RotationJob::image() const
00027 {
00028     return mRotatedImage;
00029 }
00030 
00031 Rotation RotationJob::rotation() const
00032 {
00033     return mNewRotation;
00034 }
00035 
00036 int RotationJob::id() const
00037 {
00038     return mId;
00039 }
00040 
00041 PagePrivate * RotationJob::page() const
00042 {
00043     return m_pd;
00044 }
00045 
00046 void RotationJob::run()
00047 {
00048     if ( mOldRotation == mNewRotation ) {
00049         mRotatedImage = mImage;
00050         return;
00051     }
00052 
00053     QMatrix matrix = rotationMatrix( mOldRotation, mNewRotation );
00054 
00055     mRotatedImage = mImage.transformed( matrix );
00056 }
00057 
00058 QMatrix RotationJob::rotationMatrix( Rotation from, Rotation to )
00059 {
00060     QMatrix matrix;
00061 
00062     if ( from == Rotation0 ) {
00063         if ( to == Rotation90 )
00064             matrix.rotate( 90 );
00065         else if ( to == Rotation180 )
00066             matrix.rotate( 180 );
00067         else if ( to == Rotation270 )
00068             matrix.rotate( 270 );
00069     } else if ( from == Rotation90 ) {
00070         if ( to == Rotation180 )
00071             matrix.rotate( 90 );
00072         else if ( to == Rotation270 )
00073             matrix.rotate( 180 );
00074         else if ( to == Rotation0 )
00075             matrix.rotate( 270 );
00076     } else if ( from == Rotation180 ) {
00077         if ( to == Rotation270 )
00078             matrix.rotate( 90 );
00079         else if ( to == Rotation0 )
00080             matrix.rotate( 180 );
00081         else if ( to == Rotation90 )
00082             matrix.rotate( 270 );
00083     } else if ( from == Rotation270 ) {
00084         if ( to == Rotation0 )
00085             matrix.rotate( 90 );
00086         else if ( to == Rotation90 )
00087             matrix.rotate( 180 );
00088         else if ( to == Rotation180 )
00089             matrix.rotate( 270 );
00090     }
00091 
00092     return matrix;
00093 }
00094 
00095 #include "rotationjob_p.moc"

okular

Skip menu "okular"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdegraphics

Skip menu "kdegraphics"
  • okular
Generated for kdegraphics by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal