Skip to content

Commit 25e79f9

Browse files
committedAug 15, 2013
Merge pull request #811 from 3nids/fixrubber
fix appearance of point rubber bands at small scales
2 parents 58b7910 + 93a5879 commit 25e79f9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
 

‎src/gui/qgsrubberband.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ void QgsRubberBand::removePoint( int index, bool doUpdate/* = true*/, int geomet
190190
}
191191
}
192192

193-
void QgsRubberBand::removeLastPoint( int geometryIndex )
193+
void QgsRubberBand::removeLastPoint( int geometryIndex, bool doUpdate/* = true*/ )
194194
{
195-
removePoint( -1, true, geometryIndex );
195+
removePoint( -1, doUpdate, geometryIndex );
196196
}
197197

198198
/*!
@@ -272,6 +272,7 @@ void QgsRubberBand::addGeometry( QgsGeometry* geom, QgsVectorLayer* layer )
272272
pt = geom->asPoint();
273273
}
274274
addPoint( pt, false, idx );
275+
removeLastPoint( idx , false );
275276
}
276277
break;
277278

@@ -285,10 +286,12 @@ void QgsRubberBand::addGeometry( QgsGeometry* geom, QgsVectorLayer* layer )
285286
if ( layer )
286287
{
287288
addPoint( mr->layerToMapCoordinates( layer, pt ), false, idx );
289+
removeLastPoint( idx , false );
288290
}
289291
else
290292
{
291293
addPoint( pt, false, idx );
294+
removeLastPoint( idx , false );
292295
}
293296
}
294297
}
@@ -499,8 +502,10 @@ void QgsRubberBand::updateRect()
499502
{
500503
return;
501504
}
502-
qreal s = ( mIconSize - 1 ) / 2;
503-
qreal p = mPen.width();
505+
506+
qreal scale = mMapCanvas->mapUnitsPerPixel();
507+
qreal s = ( mIconSize - 1 ) / 2 * scale;
508+
qreal p = mPen.width() * scale;
504509

505510
QgsRectangle r( it->x() + mTranslationOffsetX - s - p, it->y() + mTranslationOffsetY - s - p,
506511
it->x() + mTranslationOffsetX + s + p, it->y() + mTranslationOffsetY + s + p );

‎src/gui/qgsrubberband.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
149149
/**
150150
* Removes the last point. Most useful in connection with undo operations
151151
*/
152-
void removeLastPoint( int geometryIndex = 0 );
152+
void removeLastPoint( int geometryIndex = 0 , bool doUpdate = true );
153153

154154
/**
155155
* Moves the rubber band point specified by index. Note that if the rubber band is

0 commit comments

Comments
 (0)
Please sign in to comment.