mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
#8725R: define simplifyDrawingCanbeApplied better
This commit is contained in:
parent
653af3a459
commit
031596c4e4
@ -1013,7 +1013,7 @@ class QgsVectorLayer : QgsMapLayer
|
||||
const QgsVectorSimplifyMethod& simplifyMethod() const;
|
||||
|
||||
/** Returns whether the VectorLayer can apply the specified simplification hint */
|
||||
bool simplifyDrawingCanbeApplied( int simplifyHint ) const;
|
||||
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
|
@ -702,8 +702,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
|
||||
.setSubsetOfAttributes( attributes );
|
||||
|
||||
// enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
|
||||
mCurrentRendererContext = &rendererContext;
|
||||
if ( simplifyDrawingCanbeApplied( QgsVectorLayer::GeometrySimplification ) )
|
||||
if ( simplifyDrawingCanbeApplied( rendererContext, QgsVectorLayer::GeometrySimplification ) )
|
||||
{
|
||||
QPainter* p = rendererContext.painter();
|
||||
double dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
|
||||
@ -749,7 +748,6 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
|
||||
else
|
||||
drawRendererV2( fit, rendererContext, labeling );
|
||||
|
||||
mCurrentRendererContext = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1259,14 +1257,14 @@ bool QgsVectorLayer::setSubsetString( QString subset )
|
||||
return res;
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::simplifyDrawingCanbeApplied( int simplifyHint ) const
|
||||
bool QgsVectorLayer::simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const
|
||||
{
|
||||
if ( mDataProvider && !mEditBuffer && ( hasGeometryType() && geometryType() != QGis::Point ) && ( mSimplifyMethod.simplifyHints() & simplifyHint ) && ( !mCurrentRendererContext || mCurrentRendererContext->useRenderingOptimization() ) )
|
||||
if ( mDataProvider && !mEditBuffer && ( hasGeometryType() && geometryType() != QGis::Point ) && ( mSimplifyMethod.simplifyHints() & simplifyHint ) && renderContext.useRenderingOptimization() )
|
||||
{
|
||||
double maximumSimplificationScale = mSimplifyMethod.maximumScale();
|
||||
|
||||
// check maximum scale at which generalisation should be carried out
|
||||
if ( mCurrentRendererContext && maximumSimplificationScale > 1 && mCurrentRendererContext->rendererScale() <= maximumSimplificationScale )
|
||||
if ( maximumSimplificationScale > 1 && renderContext.rendererScale() <= maximumSimplificationScale )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -1387,7 +1387,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
|
||||
inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
|
||||
|
||||
/** Returns whether the VectorLayer can apply the specified simplification hint */
|
||||
bool simplifyDrawingCanbeApplied( int simplifyHint ) const;
|
||||
bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, int simplifyHint ) const;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
|
@ -183,7 +183,7 @@ 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 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||
if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||
{
|
||||
p->setRenderHint( QPainter::Antialiasing, false );
|
||||
p->drawPolyline( points );
|
||||
|
@ -388,7 +388,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 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||
if ( points.size() <= 5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorLayer::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||
{
|
||||
p->setRenderHint( QPainter::Antialiasing, false );
|
||||
p->drawRect( points.boundingRect() );
|
||||
|
Loading…
x
Reference in New Issue
Block a user