mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Fix feature highlight in presence of rotation (#11815)
This commit is contained in:
parent
df49538298
commit
dee9c462e9
@ -268,6 +268,11 @@ void QgsHighlight::paintPolygon( QPainter *p, QgsPolygon polygon )
|
||||
p->drawPath( path );
|
||||
}
|
||||
|
||||
void QgsHighlight::updatePosition( )
|
||||
{
|
||||
// nothing to do here...
|
||||
}
|
||||
|
||||
/*!
|
||||
Draw the shape in response to an update event.
|
||||
*/
|
||||
@ -357,12 +362,6 @@ void QgsHighlight::paint( QPainter* p )
|
||||
QgsFeatureRendererV2 *renderer = getRenderer( context, tmpColor, tmpFillColor );
|
||||
if ( layer && renderer )
|
||||
{
|
||||
QgsRectangle extent = mMapCanvas->extent();
|
||||
if ( extent != rect() ) // catches also canvas resize as it is causing extent change
|
||||
{
|
||||
updateRect();
|
||||
return; // it will be repainted after updateRect()
|
||||
}
|
||||
|
||||
QSize imageSize( mMapCanvas->mapSettings().outputSize() );
|
||||
QImage image = QImage( imageSize.width(), imageSize.height(), QImage::Format_ARGB32 );
|
||||
@ -429,7 +428,16 @@ void QgsHighlight::updateRect()
|
||||
// 1) currently there is no method in QgsFeatureRendererV2 to get rendered feature
|
||||
// bounding box
|
||||
// 2) using different extent would result in shifted fill patterns
|
||||
setRect( mMapCanvas->extent() );
|
||||
|
||||
// This is an hack to pass QgsMapCanvasItem::setRect what it
|
||||
// expects (encoding of position and size of the item)
|
||||
const QgsMapToPixel& m2p = mMapCanvas->mapSettings().mapToPixel();
|
||||
QgsPoint topLeft = m2p.toMapPoint( 0, 0 );
|
||||
double res = m2p.mapUnitsPerPixel();
|
||||
QSizeF imageSize = mMapCanvas->mapSettings().outputSize();
|
||||
QgsRectangle rect( topLeft.x(), topLeft.y(), topLeft.x() + imageSize.width()*res, topLeft.y() - imageSize.height()*res );
|
||||
setRect( rect );
|
||||
|
||||
setVisible( true );
|
||||
}
|
||||
else
|
||||
|
@ -68,6 +68,8 @@ class GUI_EXPORT QgsHighlight: public QgsMapCanvasItem
|
||||
|
||||
const QgsMapLayer *layer() const { return mLayer; }
|
||||
|
||||
virtual void updatePosition();
|
||||
|
||||
protected:
|
||||
virtual void paint( QPainter* p );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user