Skip to content
Permalink
Browse files

Simplify the change by not modifing interfaces

.. I've found a link from gsMapCanvasMap and the QgsMapToPixel class
  • Loading branch information
Sandro Santilli
Sandro Santilli committed Dec 13, 2014
1 parent 05d0306 commit 90db597e7bce6cf7d3f16c941669966540d9657b
Showing with 6 additions and 25 deletions.
  1. +1 −1 src/gui/qgsmapcanvas.cpp
  2. +4 −20 src/gui/qgsmapcanvasmap.cpp
  3. +1 −4 src/gui/qgsmapcanvasmap.h
@@ -724,7 +724,7 @@ void QgsMapCanvas::rendererJobFinished()
p.end();

QgsRectangle rect = mSettings.visibleExtent();
mMap->setContent( img, rect, mSettings.rotation() );
mMap->setContent( img, rect );
}

// now we are in a slot called from mJob - do not delete it immediately
@@ -23,7 +23,7 @@
#include <QPainter>

QgsMapCanvasMap::QgsMapCanvasMap( QgsMapCanvas* canvas )
: QgsMapCanvasItem( canvas ), mRotation(0.0)
: QgsMapCanvasItem( canvas )
{
setZValue( -10 );
}
@@ -32,9 +32,8 @@ QgsMapCanvasMap::~QgsMapCanvasMap()
{
}

void QgsMapCanvasMap::setContent( const QImage& image, const QgsRectangle& rect, double rotation )
void QgsMapCanvasMap::setContent( const QImage& image, const QgsRectangle& rect )
{
mRotation = rotation;
mImage = image;

// For true retro fans: this is approximately how the graphics looked like in 1990
@@ -48,27 +47,12 @@ void QgsMapCanvasMap::setContent( const QImage& image, const QgsRectangle& rect,
void QgsMapCanvasMap::paint( QPainter* painter )
{
int w = qRound( boundingRect().width() ) - 2, h = qRound( boundingRect().height() ) - 2; // setRect() makes the size +2 :-(
int wi = mImage.width();
int hi = mImage.height();

double ar = h ? double(w)/h : 0.0; // aspect ratio of bounding rect
double ari = hi ? double(wi)/hi : 0.0; // aspect ratio of image
double ard = fabs(ari-ar); // aspect ratio difference

#if 0
QgsDebugMsg( QString( "XXXX img %1,%2 (%3) item %4,%5 (%6) ardiff %7" )
.arg( wi ).arg( hi ).arg( ari )
.arg( w ).arg( h ).arg( ar )
.arg ( ard )
);
#endif

if ( mImage.size() != QSize( w, h ) )
{
QgsDebugMsg( QString( "map paint DIFFERENT SIZE: img %1,%2 item %3,%4" ).arg( wi ).arg( hi ).arg( w ).arg( h ) );
QgsDebugMsg( QString( "map paint DIFFERENT SIZE: img %1,%2 item %3,%4" ).arg( mImage.width() ).arg( mImage.height() ).arg( w ).arg( h ) );
}

if ( mRotation )
if ( mMapCanvas->getCoordinateTransform()->mapRotation() )
{
int tX = ( w - mImage.width() ) / 2.0;
int tY = ( h - mImage.height() ) / 2.0;
@@ -41,8 +41,7 @@ class GUI_EXPORT QgsMapCanvasMap : public QgsMapCanvasItem // public QObject, p
~QgsMapCanvasMap();

//! @note added in 2.4
//! @note rotation parameter added in 2.8
void setContent( const QImage& image, const QgsRectangle& rect, double rotation=0.0 );
void setContent( const QImage& image, const QgsRectangle& rect );

//! @note added in 2.4
QImage contentImage() const { return mImage; }
@@ -76,8 +75,6 @@ class GUI_EXPORT QgsMapCanvasMap : public QgsMapCanvasItem // public QObject, p
private:

QImage mImage;

double mRotation;
};

#endif

0 comments on commit 90db597

Please sign in to comment.
You can’t perform that action at this time.