Skip to content
Permalink
Browse files
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.


git-svn-id: http://svn.osgeo.org/qgis/trunk@10926 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jun 14, 2009
1 parent 6e1f579 commit a4ac4f8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
@@ -48,5 +48,9 @@ class QgsMapCanvasMap : QGraphicsRectItem

QRectF boundingRect() const;

//! Update contents - can be called while drawing to show the status.
//! Added in version 1.2
void updateContents();

};

@@ -391,7 +391,7 @@ void QgsMapCanvas::updateMap()
{
if ( mMap )
{
mMap->update();
mMap->updateContents();
}
}

@@ -33,10 +33,6 @@ QgsMapCanvasMap::QgsMapCanvasMap( QgsMapCanvas* canvas )
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 @@ void QgsMapCanvasMap::render()
// 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 @@ void QgsMapCanvasMap::render()
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 @@ QPaintDevice& QgsMapCanvasMap::paintDevice()
return mPixmap;
}
}

void QgsMapCanvasMap::updateContents()
{
// make sure we're using current contents
if ( mUseQImageToRender )
mPixmap = QPixmap::fromImage(mImage);

// trigger update of this item
update();
}
@@ -58,6 +58,9 @@ class GUI_EXPORT QgsMapCanvasMap : public QGraphicsRectItem

QRectF boundingRect() const;

//! Update contents - can be called while drawing to show the status.
//! Added in version 1.2
void updateContents();

private:

0 comments on commit a4ac4f8

Please sign in to comment.