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

okular

  • sources
  • kde-4.12
  • kdegraphics
  • okular
  • core
rotationjob.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Tobias Koenig <tokoe@kde.org> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  ***************************************************************************/
9 
10 #include "rotationjob_p.h"
11 
12 #include <QtGui/QTransform>
13 
14 using namespace Okular;
15 
16 RotationJob::RotationJob( const QImage &image, Rotation oldRotation, Rotation newRotation, DocumentObserver *observer )
17  : mImage( image ), mOldRotation( oldRotation ), mNewRotation( newRotation ), mObserver( observer ), m_pd( 0 )
18  , mRect( NormalizedRect() )
19 {
20 }
21 
22 void RotationJob::setPage( PagePrivate * pd )
23 {
24  m_pd = pd;
25 }
26 
27 void RotationJob::setRect( const NormalizedRect &rect )
28 {
29  mRect = rect;
30 }
31 
32 QImage RotationJob::image() const
33 {
34  return mRotatedImage;
35 }
36 
37 Rotation RotationJob::rotation() const
38 {
39  return mNewRotation;
40 }
41 
42 DocumentObserver * RotationJob::observer() const
43 {
44  return mObserver;
45 }
46 
47 PagePrivate * RotationJob::page() const
48 {
49  return m_pd;
50 }
51 
52 NormalizedRect RotationJob::rect() const
53 {
54  return mRect;
55 }
56 
57 void RotationJob::run()
58 {
59  if ( mOldRotation == mNewRotation ) {
60  mRotatedImage = mImage;
61  return;
62  }
63 
64  QTransform matrix = rotationMatrix( mOldRotation, mNewRotation );
65 
66  mRotatedImage = mImage.transformed( matrix );
67 }
68 
69 QTransform RotationJob::rotationMatrix( Rotation from, Rotation to )
70 {
71  QTransform matrix;
72 
73  if ( from == Rotation0 ) {
74  if ( to == Rotation90 )
75  matrix.rotate( 90 );
76  else if ( to == Rotation180 )
77  matrix.rotate( 180 );
78  else if ( to == Rotation270 )
79  matrix.rotate( 270 );
80  } else if ( from == Rotation90 ) {
81  if ( to == Rotation180 )
82  matrix.rotate( 90 );
83  else if ( to == Rotation270 )
84  matrix.rotate( 180 );
85  else if ( to == Rotation0 )
86  matrix.rotate( 270 );
87  } else if ( from == Rotation180 ) {
88  if ( to == Rotation270 )
89  matrix.rotate( 90 );
90  else if ( to == Rotation0 )
91  matrix.rotate( 180 );
92  else if ( to == Rotation90 )
93  matrix.rotate( 270 );
94  } else if ( from == Rotation270 ) {
95  if ( to == Rotation0 )
96  matrix.rotate( 90 );
97  else if ( to == Rotation90 )
98  matrix.rotate( 180 );
99  else if ( to == Rotation180 )
100  matrix.rotate( 270 );
101  }
102 
103  return matrix;
104 }
105 
106 #include "rotationjob_p.moc"
Okular::Rotation
Rotation
A rotation.
Definition: global.h:44
Okular::PagePrivate
Definition: page_p.h:55
Okular::RotationJob::rotationMatrix
static QTransform rotationMatrix(Rotation from, Rotation to)
Definition: rotationjob.cpp:69
Okular::RotationJob::setPage
void setPage(PagePrivate *pd)
Definition: rotationjob.cpp:22
Okular::NormalizedRect
NormalizedRect is a helper class which stores the coordinates of a normalized rect, which is a rectangle of.
Definition: area.h:105
Okular::Rotation180
Rotated 180 degrees clockwise.
Definition: global.h:48
Okular::RotationJob::setRect
void setRect(const NormalizedRect &rect)
Definition: rotationjob.cpp:27
Okular::Rotation0
Not rotated.
Definition: global.h:46
Okular::RotationJob::rect
NormalizedRect rect() const
Definition: rotationjob.cpp:52
Okular::RotationJob::image
QImage image() const
Definition: rotationjob.cpp:32
Okular::RotationJob::rotation
Rotation rotation() const
Definition: rotationjob.cpp:37
Okular::RotationJob::page
PagePrivate * page() const
Definition: rotationjob.cpp:47
Okular::Rotation270
Rotated 2700 degrees clockwise.
Definition: global.h:49
Okular::Rotation90
Rotated 90 degrees clockwise.
Definition: global.h:47
Okular::DocumentObserver
Base class for objects being notified when something changes.
Definition: observer.h:28
rotationjob_p.h
Okular::RotationJob::observer
DocumentObserver * observer() const
Definition: rotationjob.cpp:42
Okular::RotationJob::run
virtual void run()
Definition: rotationjob.cpp:57
Okular::RotationJob::RotationJob
RotationJob(const QImage &image, Rotation oldRotation, Rotation newRotation, DocumentObserver *observer)
Definition: rotationjob.cpp:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:45:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okular

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

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal