Package: qgis / 2.4.0-1

0001-composer-Fix-calculation-of-rotated-image-size-insid.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 2d427a4ece131af8f9a7ed51aa79de78a4612dc9 Mon Sep 17 00:00:00 2001
From: Nyall Dawson <nyall.dawson@gmail.com>
Date: Sat, 19 Jul 2014 22:05:01 +1000
Subject: [composer] Fix calculation of rotated image size inside picture
 items when rotation is 90 or 270 degrees
Origin: https://github.com/qgis/QGIS/commit/2d427a4ece131af8f9a7ed51aa79de78a4612dc9


--- a/src/core/composer/qgscomposeritem.cpp
+++ b/src/core/composer/qgscomposeritem.cpp
@@ -891,26 +891,35 @@ QRectF QgsComposerItem::largestRotatedRe
   double boundsHeight = boundsRect.height();
   double ratioBoundsRect = boundsWidth / boundsHeight;
 
+  double clippedRotation = fmod( rotation, 360.0 );
+
   //shortcut for some rotation values
-  if ( rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270 )
+  if ( clippedRotation == 0 || clippedRotation == 90 || clippedRotation == 180 || clippedRotation == 270 )
   {
-    double originalRatio = originalWidth / originalHeight;
-    double rectScale = originalRatio > ratioBoundsRect ? boundsWidth / originalWidth : boundsHeight / originalHeight;
+    double rectScale;
+    if ( clippedRotation == 0 || clippedRotation == 180 )
+    {
+      rectScale = (( originalWidth / originalHeight ) > ratioBoundsRect ) ? boundsWidth / originalWidth : boundsHeight / originalHeight;
+    }
+    else
+    {
+      rectScale = (( originalHeight / originalWidth ) > ratioBoundsRect ) ? boundsWidth / originalHeight : boundsHeight / originalWidth;
+    }
     double rectScaledWidth = rectScale * originalWidth;
     double rectScaledHeight = rectScale * originalHeight;
 
-    if ( rotation == 0 || rotation == 180 )
+    if ( clippedRotation == 0 || clippedRotation == 180 )
     {
       return QRectF(( boundsWidth - rectScaledWidth ) / 2.0, ( boundsHeight - rectScaledHeight ) / 2.0, rectScaledWidth, rectScaledHeight );
     }
     else
     {
-      return QRectF(( boundsWidth - rectScaledHeight ) / 2.0, ( boundsHeight - rectScaledWidth ) / 2.0, rectScaledHeight, rectScaledWidth );
+      return QRectF(( boundsWidth - rectScaledHeight ) / 2.0, ( boundsHeight - rectScaledWidth ) / 2.0, rectScaledWidth, rectScaledHeight );
     }
   }
 
   //convert angle to radians and flip
-  double angleRad = -rotation * M_DEG2RAD;
+  double angleRad = -clippedRotation * M_DEG2RAD;
   double cosAngle = cos( angleRad );
   double sinAngle = sin( angleRad );