[QGIS Commit] r15208 - in trunk/qgis: python/gui src/gui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Feb 19 08:21:34 EST 2011
Author: jef
Date: 2011-02-19 05:21:34 -0800 (Sat, 19 Feb 2011)
New Revision: 15208
Modified:
trunk/qgis/python/gui/qgsmapcanvas.sip
trunk/qgis/python/gui/qgsmapcanvasmap.sip
trunk/qgis/src/gui/qgsmapcanvas.cpp
trunk/qgis/src/gui/qgsmapcanvas.h
Log:
deprecate QgsMapCanvas::pixmap() following QgsMapCanvasMap::pixmap()
Modified: trunk/qgis/python/gui/qgsmapcanvas.sip
===================================================================
--- trunk/qgis/python/gui/qgsmapcanvas.sip 2011-02-19 09:47:27 UTC (rev 15207)
+++ trunk/qgis/python/gui/qgsmapcanvas.sip 2011-02-19 13:21:34 UTC (rev 15208)
@@ -65,8 +65,12 @@
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();
Modified: trunk/qgis/python/gui/qgsmapcanvasmap.sip
===================================================================
--- trunk/qgis/python/gui/qgsmapcanvasmap.sip 2011-02-19 09:47:27 UTC (rev 15207)
+++ trunk/qgis/python/gui/qgsmapcanvasmap.sip 2011-02-19 13:21:34 UTC (rev 15208)
@@ -42,7 +42,8 @@
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*);
Modified: trunk/qgis/src/gui/qgsmapcanvas.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.cpp 2011-02-19 09:47:27 UTC (rev 15207)
+++ trunk/qgis/src/gui/qgsmapcanvas.cpp 2011-02-19 13:21:34 UTC (rev 15208)
@@ -422,7 +422,11 @@
}
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,11 +1236,34 @@
QPixmap& QgsMapCanvas::canvasPixmap()
{
- return mMap->pixmap();
+ 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
{
return mMapRenderer->mapUnitsPerPixel();
Modified: trunk/qgis/src/gui/qgsmapcanvas.h
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.h 2011-02-19 09:47:27 UTC (rev 15207)
+++ trunk/qgis/src/gui/qgsmapcanvas.h 2011-02-19 13:21:34 UTC (rev 15208)
@@ -119,8 +119,12 @@
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();
More information about the QGIS-commit
mailing list