Skip to content

Commit

Permalink
sync QgsRubberBand and QgsMpaCanvasMap antialiasing, this also fixes …
Browse files Browse the repository at this point in the history
…1px QgsRubberBand shift with x11 rendering engine if rendered without antialiasing
  • Loading branch information
blazek committed May 11, 2011
1 parent a1a0b35 commit aadb7d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
, mCanvasProperties( new CanvasProperties )
, mNewSize( QSize() )
, mPainting( false )
, mAntiAliasing( false )
{
//disable the update that leads to the resize crash
if( viewport() )
if ( viewport() )
{
viewport()->setAttribute( Qt::WA_PaintOnScreen, true );
}
Expand Down Expand Up @@ -163,6 +164,7 @@ QgsMapCanvas::~QgsMapCanvas()

void QgsMapCanvas::enableAntiAliasing( bool theFlag )
{
mAntiAliasing = theFlag;
mMap->enableAntiAliasing( theFlag );
if ( mMapOverview )
mMapOverview->enableAntiAliasing( theFlag );
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmapcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! used to determine if anti-aliasing is enabled or not
void enableAntiAliasing( bool theFlag );

//! true if antialising is enabled
bool antiAliasingEnabled() const { return mAntiAliasing; }

//! Select which Qt class to render with
void useImageToRender( bool theFlag );

Expand Down Expand Up @@ -463,6 +466,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! currently in paint event
bool mPainting;

//! indicates whether antialiasing will be used for rendering
bool mAntiAliasing;
}; // class QgsMapCanvas


Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsmapcanvasitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ void QgsMapCanvasItem::paint( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget )
{
if ( mMapCanvas->antiAliasingEnabled() )
{
painter->setRenderHint( QPainter::Antialiasing );
}
paint( painter ); // call the derived item's drawing routines
}

Expand Down

0 comments on commit aadb7d2

Please sign in to comment.