Skip to content
Permalink
Browse files

Feature #8725: 'AA' disabling uses layer cfg

'AA' disabling for '1-pixel geometries' uses the layer simplification
configuration
  • Loading branch information
ahuarte47 committed Nov 4, 2013
1 parent 709781a commit f30f229852fd5f95c85ed9be5598a8f4911c818d
@@ -694,7 +694,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
.setSubsetOfAttributes( attributes );

// Enable the simplification of the geometries before fetch the features using the current map2pixel context.
if ( mSimplifyDrawing && !mEditBuffer && !(featureRequest.flags() & QgsFeatureRequest::NoGeometry) )
if ( simplifyDrawingCanbeApplied() && !(featureRequest.flags() & QgsFeatureRequest::NoGeometry) )
{
QPainter* p = rendererContext.painter();
float dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
@@ -1372,6 +1372,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/** Returns whether is enabled the map2pixel simplification of geometries for fast rendering of features */
bool simplifyDrawing() const { return mSimplifyDrawing; }

/** Returns whether the VectorLayer can apply geometry simplification in FeatureRequests */
bool simplifyDrawingCanbeApplied() const { return mSimplifyDrawing && !mEditBuffer; }

public slots:
/**
* Select feature by its ID
@@ -181,10 +181,10 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
p->setPen( context.selected() ? mSelPen : mPen );

// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
if ( points.size()<=2 && QgsFeatureRequest::canbeGeneralizedByWndBoundingBox( points, context.layer() ? context.layer()->simplifyDrawingTol() : QgsFeatureRequest::MAPTOPIXEL_THRESHOLD_DEFAULT ) && p->renderHints() & QPainter::Antialiasing )
if ( points.size()<=2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied() && QgsFeatureRequest::canbeGeneralizedByWndBoundingBox( points, context.layer()->simplifyDrawingTol() ) && p->renderHints() & QPainter::Antialiasing )
{
p->setRenderHint( QPainter::Antialiasing, false );
p->drawPolyline ( points );
p->drawPolyline( points );
p->setRenderHint( QPainter::Antialiasing, true );
return;
}
@@ -332,7 +332,7 @@ void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points,
}

// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
if ( points.size()<=5 && QgsFeatureRequest::canbeGeneralizedByWndBoundingBox( points, context.layer() ? context.layer()->simplifyDrawingTol() : QgsFeatureRequest::MAPTOPIXEL_THRESHOLD_DEFAULT ) && p->renderHints() & QPainter::Antialiasing )
if ( points.size()<=5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied() && QgsFeatureRequest::canbeGeneralizedByWndBoundingBox( points, context.layer()->simplifyDrawingTol() ) && p->renderHints() & QPainter::Antialiasing )
{
p->setRenderHint( QPainter::Antialiasing, false );
p->drawConvexPolygon( points );
@@ -34,7 +34,7 @@
#include <cmath>

QgsSymbolV2::QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers )
: mType( type ), mLayers( layers ), mAlpha( 1.0 ), mRenderHints( 0 )
: mType( type ), mLayers( layers ), mAlpha( 1.0 ), mRenderHints( 0 ), mLayer( NULL )
{

// check they're all correct symbol layers
@@ -215,17 +215,24 @@ bool QgsSymbolV2::changeSymbolLayer( int index, QgsSymbolLayerV2* layer )

void QgsSymbolV2::startRender( QgsRenderContext& context, const QgsVectorLayer* layer )
{
mLayer = layer;

QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints );
symbolContext.setLayer( layer );
symbolContext.setLayer( mLayer );

for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
( *it )->startRender( symbolContext );
}

void QgsSymbolV2::stopRender( QgsRenderContext& context )
{
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints );
symbolContext.setLayer( mLayer );

for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
( *it )->stopRender( symbolContext );

mLayer = NULL;
}

void QgsSymbolV2::setColor( const QColor& color )
@@ -252,6 +259,8 @@ void QgsSymbolV2::drawPreviewIcon( QPainter* painter, QSize size )
{
QgsRenderContext context = QgsSymbolLayerV2Utils::createRenderContext( painter );
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints );
symbolContext.setLayer( mLayer );

for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
{
if ( mType == Fill && ( *it )->type() == Line )
@@ -532,6 +541,8 @@ QgsSymbolV2::ScaleMethod QgsMarkerSymbolV2::scaleMethod()
void QgsMarkerSymbolV2::renderPoint( const QPointF& point, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
{
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
symbolContext.setLayer( mLayer );

if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
@@ -600,6 +611,8 @@ double QgsLineSymbolV2::width()
void QgsLineSymbolV2::renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
{
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
symbolContext.setLayer( mLayer );

if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
@@ -635,6 +648,8 @@ QgsFillSymbolV2::QgsFillSymbolV2( QgsSymbolLayerV2List layers )
void QgsFillSymbolV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
{
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
symbolContext.setLayer( mLayer );

if ( layer != -1 )
{
if ( layer >= 0 && layer < mLayers.count() )
@@ -128,6 +128,9 @@ class CORE_EXPORT QgsSymbolV2

QSet<QString> usedAttributes() const;

void setLayer( const QgsVectorLayer* layer ) { mLayer = layer; }
const QgsVectorLayer* layer() const { return mLayer; }

protected:
QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers ); // can't be instantiated

@@ -145,6 +148,8 @@ class CORE_EXPORT QgsSymbolV2
qreal mAlpha;

int mRenderHints;

const QgsVectorLayer* mLayer; //current vectorlayer
};

///////////////////////

0 comments on commit f30f229

Please sign in to comment.
You can’t perform that action at this time.