@@ -268,6 +268,11 @@ void QgsHighlight::paintPolygon( QPainter *p, QgsPolygon polygon )
268
268
p->drawPath ( path );
269
269
}
270
270
271
+ void QgsHighlight::updatePosition ( )
272
+ {
273
+ // nothing to do here...
274
+ }
275
+
271
276
/* !
272
277
Draw the shape in response to an update event.
273
278
*/
@@ -357,12 +362,6 @@ void QgsHighlight::paint( QPainter* p )
357
362
QgsFeatureRendererV2 *renderer = getRenderer ( context, tmpColor, tmpFillColor );
358
363
if ( layer && renderer )
359
364
{
360
- QgsRectangle extent = mMapCanvas ->extent ();
361
- if ( extent != rect () ) // catches also canvas resize as it is causing extent change
362
- {
363
- updateRect ();
364
- return ; // it will be repainted after updateRect()
365
- }
366
365
367
366
QSize imageSize ( mMapCanvas ->mapSettings ().outputSize () );
368
367
QImage image = QImage ( imageSize.width (), imageSize.height (), QImage::Format_ARGB32 );
@@ -429,7 +428,16 @@ void QgsHighlight::updateRect()
429
428
// 1) currently there is no method in QgsFeatureRendererV2 to get rendered feature
430
429
// bounding box
431
430
// 2) using different extent would result in shifted fill patterns
432
- setRect ( mMapCanvas ->extent () );
431
+
432
+ // This is an hack to pass QgsMapCanvasItem::setRect what it
433
+ // expects (encoding of position and size of the item)
434
+ const QgsMapToPixel& m2p = mMapCanvas ->mapSettings ().mapToPixel ();
435
+ QgsPoint topLeft = m2p.toMapPoint ( 0 , 0 );
436
+ double res = m2p.mapUnitsPerPixel ();
437
+ QSizeF imageSize = mMapCanvas ->mapSettings ().outputSize ();
438
+ QgsRectangle rect ( topLeft.x (), topLeft.y (), topLeft.x () + imageSize.width ()*res, topLeft.y () - imageSize.height ()*res );
439
+ setRect ( rect );
440
+
433
441
setVisible ( true );
434
442
}
435
443
else
0 commit comments