[QGIS Commit] r10926 - in trunk/qgis: python/gui src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Jun 14 17:26:42 EDT 2009


Author: wonder
Date: 2009-06-14 17:26:42 -0400 (Sun, 14 Jun 2009)
New Revision: 10926

Modified:
   trunk/qgis/python/gui/qgsmapcanvasmap.sip
   trunk/qgis/src/gui/qgsmapcanvas.cpp
   trunk/qgis/src/gui/qgsmapcanvasmap.cpp
   trunk/qgis/src/gui/qgsmapcanvasmap.h
Log:
Always use QPixmap when drawing the map in canvas.
This results in faster updates of canvas when rendered map is QImage - e.g. when panning / updating rubber bands.


Modified: trunk/qgis/python/gui/qgsmapcanvasmap.sip
===================================================================
--- trunk/qgis/python/gui/qgsmapcanvasmap.sip	2009-06-14 19:00:28 UTC (rev 10925)
+++ trunk/qgis/python/gui/qgsmapcanvasmap.sip	2009-06-14 21:26:42 UTC (rev 10926)
@@ -48,5 +48,9 @@
 
     QRectF boundingRect() const;
   
+    //! Update contents - can be called while drawing to show the status.
+    //! Added in version 1.2
+    void updateContents();
+
 };
 

Modified: trunk/qgis/src/gui/qgsmapcanvas.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.cpp	2009-06-14 19:00:28 UTC (rev 10925)
+++ trunk/qgis/src/gui/qgsmapcanvas.cpp	2009-06-14 21:26:42 UTC (rev 10926)
@@ -391,7 +391,7 @@
 {
   if ( mMap )
   {
-    mMap->update();
+    mMap->updateContents();
   }
 }
 

Modified: trunk/qgis/src/gui/qgsmapcanvasmap.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvasmap.cpp	2009-06-14 19:00:28 UTC (rev 10925)
+++ trunk/qgis/src/gui/qgsmapcanvasmap.cpp	2009-06-14 21:26:42 UTC (rev 10926)
@@ -33,10 +33,6 @@
 void QgsMapCanvasMap::paint( QPainter* p, const QStyleOptionGraphicsItem*, QWidget* )
 {
   //refreshes the canvas map with the current offscreen image
-  if ( mUseQImageToRender )
-  {
-    mPixmap = QPixmap::fromImage( mImage );
-  }
   p->drawPixmap( 0, 0, mPixmap );
 }
 
@@ -73,6 +69,11 @@
     // use temporary image for rendering
     mImage.fill( mBgColor.rgb() );
 
+    // clear the pixmap so that old map won't be displayed while rendering
+    // TODO: do the canvas updates wisely -> this wouldn't be needed
+    mPixmap = QPixmap(mImage.size());
+    mPixmap.fill( mBgColor.rgb() );
+
     QPainter paint;
     paint.begin( &mImage );
     // Clip drawing to the QImage
@@ -87,7 +88,7 @@
     paint.end();
 
     // convert QImage to QPixmap to acheive faster drawing on screen
-    //mPixmap = QPixmap::fromImage(image);
+    mPixmap = QPixmap::fromImage(mImage);
   }
   else
   {
@@ -113,3 +114,13 @@
     return mPixmap;
   }
 }
+
+void QgsMapCanvasMap::updateContents()
+{
+  // make sure we're using current contents
+  if ( mUseQImageToRender )
+    mPixmap = QPixmap::fromImage(mImage);
+
+  // trigger update of this item
+  update();
+}

Modified: trunk/qgis/src/gui/qgsmapcanvasmap.h
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvasmap.h	2009-06-14 19:00:28 UTC (rev 10925)
+++ trunk/qgis/src/gui/qgsmapcanvasmap.h	2009-06-14 21:26:42 UTC (rev 10926)
@@ -58,6 +58,9 @@
 
     QRectF boundingRect() const;
 
+    //! Update contents - can be called while drawing to show the status.
+    //! Added in version 1.2
+    void updateContents();
 
   private:
 



More information about the QGIS-commit mailing list