[QGIS Commit] r10856 - trunk/qgis/src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu May 28 13:59:36 EDT 2009


Author: mhugent
Date: 2009-05-28 13:59:35 -0400 (Thu, 28 May 2009)
New Revision: 10856

Modified:
   trunk/qgis/src/gui/qgscomposerview.cpp
   trunk/qgis/src/gui/qgscomposerview.h
Log:
Fix for bug #1717

Modified: trunk/qgis/src/gui/qgscomposerview.cpp
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.cpp	2009-05-28 11:18:13 UTC (rev 10855)
+++ trunk/qgis/src/gui/qgscomposerview.cpp	2009-05-28 17:59:35 UTC (rev 10856)
@@ -101,6 +101,7 @@
     {
       QTransform t;
       mRubberBandItem = new QGraphicsRectItem( 0, 0, 0, 0 );
+      mRubberBandStartPos = QPointF(snappedScenePoint.x(), snappedScenePoint.y());
       t.translate( snappedScenePoint.x(), snappedScenePoint.y() );
       mRubberBandItem->setTransform( t );
       mRubberBandItem->setZValue( 100 );
@@ -235,11 +236,44 @@
 
       case AddMap:
         //adjust rubber band item
-        newWidth = scenePoint.x() - mRubberBandItem->transform().dx();
-        newHeight = scenePoint.y() - mRubberBandItem->transform().dy();
-        mRubberBandItem->setRect( 0, 0, newWidth, newHeight );
-        break;
+        {
+          double x = 0;
+          double y = 0;
+          double width = 0;
+          double height = 0;
 
+          double dx = scenePoint.x() - mRubberBandStartPos.x();
+          double dy = scenePoint.y() - mRubberBandStartPos.y();
+
+          if(dx < 0)
+          {
+            x = scenePoint.x();
+            width = -dx;
+          }
+          else
+          {
+            x = mRubberBandStartPos.x();
+            width = dx;
+          }
+
+          if(dy < 0)
+          {
+            y = scenePoint.y();
+            height = -dy;
+          }
+          else
+          {
+            y = mRubberBandStartPos.y();
+            height = dy;
+          }
+
+          mRubberBandItem->setRect( 0, 0, width, height );
+          QTransform t;
+          t.translate(x, y);
+          mRubberBandItem->setTransform(t);
+          break;
+        }
+
       case MoveItemContent:
       {
         //update map preview if composer map

Modified: trunk/qgis/src/gui/qgscomposerview.h
===================================================================
--- trunk/qgis/src/gui/qgscomposerview.h	2009-05-28 11:18:13 UTC (rev 10855)
+++ trunk/qgis/src/gui/qgscomposerview.h	2009-05-28 17:59:35 UTC (rev 10856)
@@ -107,6 +107,8 @@
     QgsComposerItem* mMoveContentItem;
     /**Start position of content move*/
     QPointF mMoveContentStartPos;
+    /**Start of rubber band creation*/
+    QPointF mRubberBandStartPos;
 
   public slots:
     /**For QgsComposerItemGroup to send its signals to QgsComposer (or other classes that keep track of input widgets)*/



More information about the QGIS-commit mailing list