Skip to content
Permalink
Browse files
Fix for placement of map items in composer
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15843 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 28, 2011
1 parent b3e33fa commit 967f966e65c3f584508bdd06c418803c78fae55d
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/core/composer/qgscomposermap.cpp
@@ -1568,10 +1568,11 @@ QPointF QgsComposerMap::composerMapPosForItem( const QGraphicsItem* item ) const
return QPointF( 0, 0 );
}

double mapX = item->scenePos().x() / mMapCanvas->width() * mMapRenderer->extent().width() + mMapRenderer->extent().xMinimum();
double mapY = mMapRenderer->extent().yMaximum() - item->scenePos().y() / mMapCanvas->height() * mMapRenderer->extent().height();
QRectF graphicsSceneRect = mMapCanvas->sceneRect();
QPointF itemScenePos = item->scenePos();
QgsRectangle mapRendererExtent = mMapRenderer->extent();

double itemX = rect().width() * ( mapX - mExtent.xMinimum() ) / mExtent.width() + mXOffset;
double itemY = rect().height() * ( mExtent.yMaximum() - mapY ) / mExtent.height() + mYOffset;
return QPointF( itemX, itemY );
double mapX = itemScenePos.x() / graphicsSceneRect.width() * mapRendererExtent.width() + mapRendererExtent.xMinimum();
double mapY = mapRendererExtent.yMaximum() - itemScenePos.y() / graphicsSceneRect.height() * mapRendererExtent.height();
return mapToItemCoords( QPointF( mapX, mapY ) );
}

0 comments on commit 967f966

Please sign in to comment.