Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #811 from 3nids/fixrubber
fix appearance of point rubber bands at small scales
  • Loading branch information
NathanW2 committed Aug 15, 2013
2 parents 58b7910 + 93a5879 commit 25e79f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/gui/qgsrubberband.cpp
Expand Up @@ -190,9 +190,9 @@ void QgsRubberBand::removePoint( int index, bool doUpdate/* = true*/, int geomet
}
}

void QgsRubberBand::removeLastPoint( int geometryIndex )
void QgsRubberBand::removeLastPoint( int geometryIndex, bool doUpdate/* = true*/ )
{
removePoint( -1, true, geometryIndex );
removePoint( -1, doUpdate, geometryIndex );
}

/*!
Expand Down Expand Up @@ -272,6 +272,7 @@ void QgsRubberBand::addGeometry( QgsGeometry* geom, QgsVectorLayer* layer )
pt = geom->asPoint();
}
addPoint( pt, false, idx );
removeLastPoint( idx , false );
}
break;

Expand All @@ -285,10 +286,12 @@ void QgsRubberBand::addGeometry( QgsGeometry* geom, QgsVectorLayer* layer )
if ( layer )
{
addPoint( mr->layerToMapCoordinates( layer, pt ), false, idx );
removeLastPoint( idx , false );
}
else
{
addPoint( pt, false, idx );
removeLastPoint( idx , false );
}
}
}
Expand Down Expand Up @@ -499,8 +502,10 @@ void QgsRubberBand::updateRect()
{
return;
}
qreal s = ( mIconSize - 1 ) / 2;
qreal p = mPen.width();

qreal scale = mMapCanvas->mapUnitsPerPixel();
qreal s = ( mIconSize - 1 ) / 2 * scale;
qreal p = mPen.width() * scale;

QgsRectangle r( it->x() + mTranslationOffsetX - s - p, it->y() + mTranslationOffsetY - s - p,
it->x() + mTranslationOffsetX + s + p, it->y() + mTranslationOffsetY + s + p );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsrubberband.h
Expand Up @@ -149,7 +149,7 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
/**
* Removes the last point. Most useful in connection with undo operations
*/
void removeLastPoint( int geometryIndex = 0 );
void removeLastPoint( int geometryIndex = 0 , bool doUpdate = true );

/**
* Moves the rubber band point specified by index. Note that if the rubber band is
Expand Down

0 comments on commit 25e79f9

Please sign in to comment.