Skip to content
Permalink
Browse files
deprecate QgsMapCanvas::pixmap() following QgsMapCanvasMap::pixmap()
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15208 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 19, 2011
1 parent 65c3543 commit 4d0aaf03afdf913b33125dbf2f5c0c863f4b25f0
Showing with 42 additions and 6 deletions.
  1. +5 −1 python/gui/qgsmapcanvas.sip
  2. +2 −1 python/gui/qgsmapcanvasmap.sip
  3. +30 −3 src/gui/qgsmapcanvas.cpp
  4. +5 −1 src/gui/qgsmapcanvas.h
@@ -65,7 +65,11 @@ class QgsMapCanvas : QGraphicsView
QgsMapRenderer* mapRenderer();

//! Accessor for the canvas pixmap
QPixmap& canvasPixmap();
// @deprecated use canvasPaintDevice()
QPixmap& canvasPixmap() /Deprecated/;

//! Accessor for the canvas paint device
QPaintDevice &canvasPaintDevice();

//! Get the last reported scale of the canvas
double scale();
@@ -42,7 +42,8 @@ class QgsMapCanvasMap : QGraphicsRectItem

void setPanningOffset(const QPoint& point);

QPixmap& pixmap();
//! @deprecated Please use paintDevice() function which is also save in case QImage is used
QPixmap& pixmap() /Deprecated/;

void paint(QPainter* p, const QStyleOptionGraphicsItem*, QWidget*);

@@ -422,7 +422,11 @@ void QgsMapCanvas::saveAsImage( QString theFileName, QPixmap * theQPixmap, QStri
}
else //use the map view
{
mMap->pixmap().save( theFileName, theFormat.toLocal8Bit().data() );
QPixmap *pixmap = dynamic_cast<QPixmap *>( &mMap->paintDevice() );
if( !pixmap )
return;

pixmap->save( theFileName, theFormat.toLocal8Bit().data() );
}
//create a world file to go with the image...
QgsRectangle myRect = mMapRenderer->extent();
@@ -1232,10 +1236,33 @@ bool QgsMapCanvas::isFrozen()

QPixmap& QgsMapCanvas::canvasPixmap()
{
return mMap->pixmap();
} // canvasPixmap
QPixmap *pixmap = dynamic_cast<QPixmap *>( &canvasPaintDevice() );
if( pixmap )
{
return *pixmap;
}

qWarning( "QgsMapCanvas::canvasPixmap() deprecated - returning static pixmap instance - use QgsMapCanvas::paintDevice()" );

static QPixmap staticPixmap;

QImage *image = dynamic_cast<QImage *>( &mMap->paintDevice() );
if( image )
{
staticPixmap = QPixmap::fromImage( *image );
}
else
{
staticPixmap = QPixmap( canvasPaintDevice().width(), canvasPaintDevice().height() );
}

return staticPixmap;
} // canvasPixmap

QPaintDevice &QgsMapCanvas::canvasPaintDevice()
{
return mMap->paintDevice();
}

double QgsMapCanvas::mapUnitsPerPixel() const
{
@@ -119,7 +119,11 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
QgsMapRenderer* mapRenderer();

//! Accessor for the canvas pixmap
QPixmap& canvasPixmap();
//! @deprecated use canvasPaintDevice()
QGISDEPRECATED QPixmap& canvasPixmap();

//! Accessor for the canvas paint device
QPaintDevice &canvasPaintDevice();

//! Get the last reported scale of the canvas
double scale();

0 comments on commit 4d0aaf0

Please sign in to comment.