[QGIS Commit] r9072 - branches/advanced_printing_branch/src/app/composer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Aug 19 04:12:37 EDT 2008


Author: mhugent
Date: 2008-08-19 04:12:36 -0400 (Tue, 19 Aug 2008)
New Revision: 9072

Modified:
   branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp
Log:
Fix for inverted rectangles

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp	2008-08-18 22:31:52 UTC (rev 9071)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp	2008-08-19 08:12:36 UTC (rev 9072)
@@ -390,12 +390,30 @@
 void QgsComposerItem::setSceneRect(const QRectF& rectangle)
 {
   //setRect in item coordinates
-  QRectF newRect(0, 0, rectangle.width(), rectangle.height());
+  double newWidth = rectangle.width();
+  double newHeight = rectangle.height();
+  double xTranslation = rectangle.x();
+  double yTranslation = rectangle.y();
+
+  //correction if width and/or height are negative
+  if( rectangle.width() < 0 )
+    {
+      newWidth = - rectangle.width();
+      xTranslation -= newWidth;
+    }
+
+  if(rectangle.height() < 0)
+    {
+      newHeight = - rectangle.height();
+      yTranslation -= newHeight;
+    }
+  
+  QRectF newRect(0, 0, newWidth, newHeight);
   QGraphicsRectItem::setRect(newRect);
 
   //set up transformation matrix for item coordinates
   QTransform t;
-  t.translate(rectangle.x(), rectangle.y());
+  t.translate(xTranslation, yTranslation);
   setTransform(t);
 }
 



More information about the QGIS-commit mailing list