Skip to content

Commit 031596c

Browse files
committed
#8725R: define simplifyDrawingCanbeApplied better
1 parent 653af3a commit 031596c

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

python/core/qgsvectorlayer.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ class QgsVectorLayer : QgsMapLayer
10131013
const QgsVectorSimplifyMethod& simplifyMethod() const;
10141014

10151015
/** Returns whether the VectorLayer can apply the specified simplification hint */
1016-
bool simplifyDrawingCanbeApplied( int simplifyHint ) const;
1016+
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const;
10171017

10181018
public slots:
10191019
/**

src/core/qgsvectorlayer.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
702702
.setSubsetOfAttributes( attributes );
703703

704704
// enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
705-
mCurrentRendererContext = &rendererContext;
706-
if ( simplifyDrawingCanbeApplied( QgsVectorLayer::GeometrySimplification ) )
705+
if ( simplifyDrawingCanbeApplied( rendererContext, QgsVectorLayer::GeometrySimplification ) )
707706
{
708707
QPainter* p = rendererContext.painter();
709708
double dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
@@ -749,7 +748,6 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
749748
else
750749
drawRendererV2( fit, rendererContext, labeling );
751750

752-
mCurrentRendererContext = NULL;
753751
return true;
754752
}
755753

@@ -1259,14 +1257,14 @@ bool QgsVectorLayer::setSubsetString( QString subset )
12591257
return res;
12601258
}
12611259

1262-
bool QgsVectorLayer::simplifyDrawingCanbeApplied( int simplifyHint ) const
1260+
bool QgsVectorLayer::simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const
12631261
{
1264-
if ( mDataProvider && !mEditBuffer && ( hasGeometryType() && geometryType() != QGis::Point ) && ( mSimplifyMethod.simplifyHints() & simplifyHint ) && ( !mCurrentRendererContext || mCurrentRendererContext->useRenderingOptimization() ) )
1262+
if ( mDataProvider && !mEditBuffer && ( hasGeometryType() && geometryType() != QGis::Point ) && ( mSimplifyMethod.simplifyHints() & simplifyHint ) && renderContext.useRenderingOptimization() )
12651263
{
12661264
double maximumSimplificationScale = mSimplifyMethod.maximumScale();
12671265

12681266
// check maximum scale at which generalisation should be carried out
1269-
if ( mCurrentRendererContext && maximumSimplificationScale > 1 && mCurrentRendererContext->rendererScale() <= maximumSimplificationScale )
1267+
if ( maximumSimplificationScale > 1 && renderContext.rendererScale() <= maximumSimplificationScale )
12701268
return false;
12711269

12721270
return true;

src/core/qgsvectorlayer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
13871387
inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
13881388

13891389
/** Returns whether the VectorLayer can apply the specified simplification hint */
1390-
bool simplifyDrawingCanbeApplied( int simplifyHint ) const;
1390+
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const;
13911391

13921392
public slots:
13931393
/**

src/core/symbology-ng/qgslinesymbollayerv2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
183183
p->setPen( context.selected() ? mSelPen : mPen );
184184

185185
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
186-
if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
186+
if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
187187
{
188188
p->setRenderHint( QPainter::Antialiasing, false );
189189
p->drawPolyline( points );

src/core/symbology-ng/qgssymbollayerv2.cpp

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

390390
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
391-
if ( points.size() <= 5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
391+
if ( points.size() <= 5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
392392
{
393393
p->setRenderHint( QPainter::Antialiasing, false );
394394
p->drawRect( points.boundingRect() );

0 commit comments

Comments
 (0)