Skip to content
Permalink
Browse files
Fix rubber band bounding box calculation
The icon half-width was incorrectly divided by map units per pixel...
  • Loading branch information
wonder-sk committed Mar 29, 2017
1 parent eeab9a3 commit d4852ca2d464831b74ed3e660f086df80a63822b
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/gui/qgsrubberband.cpp
@@ -544,10 +544,9 @@ void QgsRubberBand::updateRect()

const QgsMapToPixel &m2p = *( mMapCanvas->getCoordinateTransform() );

qreal res = m2p.mapUnitsPerPixel();
qreal w = ( ( mIconSize - 1 ) / 2 + mPen.width() ) / res;
qreal w = ( ( mIconSize - 1 ) / 2 + mPen.width() ); // in canvas units

QgsRectangle r;
QgsRectangle r; // in canvas units
for ( int i = 0; i < mPoints.size(); ++i )
{
QList<QgsPoint>::const_iterator it = mPoints.at( i ).constBegin(),
@@ -572,6 +571,7 @@ void QgsRubberBand::updateRect()

// This is an hack to pass QgsMapCanvasItem::setRect what it
// expects (encoding of position and size of the item)
qreal res = m2p.mapUnitsPerPixel();
QgsPoint topLeft = m2p.toMapPoint( r.xMinimum(), r.yMinimum() );
QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + r.width()*res, topLeft.y() - r.height()*res );

0 comments on commit d4852ca

Please sign in to comment.