Skip to content

Commit 3ffc255

Browse files
committed
sync QgsRubberBand and QgsMpaCanvasMap antialiasing, this also fixes 1px QgsRubberBand shift with x11 rendering engine if rendered without antialiasing
1 parent 3d41384 commit 3ffc255

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/gui/qgsmapcanvas.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
8282
, mCanvasProperties( new CanvasProperties )
8383
, mNewSize( QSize() )
8484
, mPainting( false )
85+
, mAntiAliasing( false )
8586
{
8687
//disable the update that leads to the resize crash
87-
if( viewport() )
88+
if ( viewport() )
8889
{
8990
viewport()->setAttribute( Qt::WA_PaintOnScreen, true );
9091
}
@@ -163,6 +164,7 @@ QgsMapCanvas::~QgsMapCanvas()
163164

164165
void QgsMapCanvas::enableAntiAliasing( bool theFlag )
165166
{
167+
mAntiAliasing = theFlag;
166168
mMap->enableAntiAliasing( theFlag );
167169
if ( mMapOverview )
168170
mMapOverview->enableAntiAliasing( theFlag );

src/gui/qgsmapcanvas.h

+5
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
244244
//! used to determine if anti-aliasing is enabled or not
245245
void enableAntiAliasing( bool theFlag );
246246

247+
//! true if antialising is enabled
248+
bool antiAliasingEnabled() const { return mAntiAliasing; }
249+
247250
//! Select which Qt class to render with
248251
void useImageToRender( bool theFlag );
249252

@@ -463,6 +466,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
463466
//! currently in paint event
464467
bool mPainting;
465468

469+
//! indicates whether antialiasing will be used for rendering
470+
bool mAntiAliasing;
466471
}; // class QgsMapCanvas
467472

468473

src/gui/qgsmapcanvasitem.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ void QgsMapCanvasItem::paint( QPainter * painter,
4242
const QStyleOptionGraphicsItem * option,
4343
QWidget * widget )
4444
{
45+
if ( mMapCanvas->antiAliasingEnabled() )
46+
{
47+
painter->setRenderHint( QPainter::Antialiasing );
48+
}
4549
paint( painter ); // call the derived item's drawing routines
4650
}
4751

0 commit comments

Comments
 (0)