Skip to content

Commit e98a938

Browse files
committed
Feature #8725: 'AA' disabling uses layer cfg
'AA' disabling for '1-pixel geometries' uses the layer simplification configuration
1 parent fec6baf commit e98a938

6 files changed

+29
-6
lines changed

src/core/qgsvectorlayer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
694694
.setSubsetOfAttributes( attributes );
695695

696696
// Enable the simplification of the geometries before fetch the features using the current map2pixel context.
697-
if ( mSimplifyDrawing && !mEditBuffer && !(featureRequest.flags() & QgsFeatureRequest::NoGeometry) )
697+
if ( simplifyDrawingCanbeApplied() && !(featureRequest.flags() & QgsFeatureRequest::NoGeometry) )
698698
{
699699
QPainter* p = rendererContext.painter();
700700
float dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;

src/core/qgsvectorlayer.h

+3
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
13741374
/** Returns whether is enabled the map2pixel simplification of geometries for fast rendering of features */
13751375
bool simplifyDrawing() const { return mSimplifyDrawing; }
13761376

1377+
/** Returns whether the VectorLayer can apply geometry simplification in FeatureRequests */
1378+
bool simplifyDrawingCanbeApplied() const { return mSimplifyDrawing && !mEditBuffer; }
1379+
13771380
public slots:
13781381
/**
13791382
* Select feature by its ID

src/core/symbology-ng/qgslinesymbollayerv2.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
181181
p->setPen( context.selected() ? mSelPen : mPen );
182182

183183
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
184-
if ( points.size()<=2 && QgsFeatureRequest::canbeGeneralizedByWndBoundingBox( points, context.layer() ? context.layer()->simplifyDrawingTol() : QgsFeatureRequest::MAPTOPIXEL_THRESHOLD_DEFAULT ) && p->renderHints() & QPainter::Antialiasing )
184+
if ( points.size()<=2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied() && QgsFeatureRequest::canbeGeneralizedByWndBoundingBox( points, context.layer()->simplifyDrawingTol() ) && p->renderHints() & QPainter::Antialiasing )
185185
{
186186
p->setRenderHint( QPainter::Antialiasing, false );
187-
p->drawPolyline ( points );
187+
p->drawPolyline( points );
188188
p->setRenderHint( QPainter::Antialiasing, true );
189189
return;
190190
}

src/core/symbology-ng/qgssymbollayerv2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points,
358358
}
359359

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

src/core/symbology-ng/qgssymbolv2.cpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <cmath>
3535

3636
QgsSymbolV2::QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers )
37-
: mType( type ), mLayers( layers ), mAlpha( 1.0 ), mRenderHints( 0 )
37+
: mType( type ), mLayers( layers ), mAlpha( 1.0 ), mRenderHints( 0 ), mLayer( NULL )
3838
{
3939

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

216216
void QgsSymbolV2::startRender( QgsRenderContext& context, const QgsVectorLayer* layer )
217217
{
218+
mLayer = layer;
219+
218220
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints );
219-
symbolContext.setLayer( layer );
221+
symbolContext.setLayer( mLayer );
222+
220223
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
221224
( *it )->startRender( symbolContext );
222225
}
223226

224227
void QgsSymbolV2::stopRender( QgsRenderContext& context )
225228
{
226229
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints );
230+
symbolContext.setLayer( mLayer );
231+
227232
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
228233
( *it )->stopRender( symbolContext );
234+
235+
mLayer = NULL;
229236
}
230237

231238
void QgsSymbolV2::setColor( const QColor& color )
@@ -252,6 +259,8 @@ void QgsSymbolV2::drawPreviewIcon( QPainter* painter, QSize size )
252259
{
253260
QgsRenderContext context = QgsSymbolLayerV2Utils::createRenderContext( painter );
254261
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, false, mRenderHints );
262+
symbolContext.setLayer( mLayer );
263+
255264
for ( QgsSymbolLayerV2List::iterator it = mLayers.begin(); it != mLayers.end(); ++it )
256265
{
257266
if ( mType == Fill && ( *it )->type() == Line )
@@ -532,6 +541,8 @@ QgsSymbolV2::ScaleMethod QgsMarkerSymbolV2::scaleMethod()
532541
void QgsMarkerSymbolV2::renderPoint( const QPointF& point, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
533542
{
534543
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
544+
symbolContext.setLayer( mLayer );
545+
535546
if ( layer != -1 )
536547
{
537548
if ( layer >= 0 && layer < mLayers.count() )
@@ -600,6 +611,8 @@ double QgsLineSymbolV2::width()
600611
void QgsLineSymbolV2::renderPolyline( const QPolygonF& points, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
601612
{
602613
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
614+
symbolContext.setLayer( mLayer );
615+
603616
if ( layer != -1 )
604617
{
605618
if ( layer >= 0 && layer < mLayers.count() )
@@ -635,6 +648,8 @@ QgsFillSymbolV2::QgsFillSymbolV2( QgsSymbolLayerV2List layers )
635648
void QgsFillSymbolV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, const QgsFeature* f, QgsRenderContext& context, int layer, bool selected )
636649
{
637650
QgsSymbolV2RenderContext symbolContext( context, outputUnit(), mAlpha, selected, mRenderHints, f );
651+
symbolContext.setLayer( mLayer );
652+
638653
if ( layer != -1 )
639654
{
640655
if ( layer >= 0 && layer < mLayers.count() )

src/core/symbology-ng/qgssymbolv2.h

+5
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ class CORE_EXPORT QgsSymbolV2
128128

129129
QSet<QString> usedAttributes() const;
130130

131+
void setLayer( const QgsVectorLayer* layer ) { mLayer = layer; }
132+
const QgsVectorLayer* layer() const { return mLayer; }
133+
131134
protected:
132135
QgsSymbolV2( SymbolType type, QgsSymbolLayerV2List layers ); // can't be instantiated
133136

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

147150
int mRenderHints;
151+
152+
const QgsVectorLayer* mLayer; //current vectorlayer
148153
};
149154

150155
///////////////////////

0 commit comments

Comments
 (0)