Skip to content
Permalink
Browse files

Feature #8725: Disable simplification in composer

Disable the simplification of geometries when the render request comes
from a print composition to avoid rendering quality issues
  • Loading branch information
ahuarte47 committed Nov 4, 2013
1 parent f30f229 commit 5441a1ebff651e09b9e060b68a14a03ed5b077df
@@ -191,13 +191,14 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const
{
theRendererContext->setDrawEditingInformation( false );
theRendererContext->setRenderingStopped( false );
}
theRendererContext->setRenderingPrintComposition( true );

// force vector output (no caching of marker images etc.)
theRendererContext->setForceVectorOutput( true );
// force vector output (no caching of marker images etc.)
theRendererContext->setForceVectorOutput( true );

// make the renderer respect the composition's useAdvancedEffects flag
theRendererContext->setUseAdvancedEffects( mComposition->useAdvancedEffects() );
// make the renderer respect the composition's useAdvancedEffects flag
theRendererContext->setUseAdvancedEffects( mComposition->useAdvancedEffects() );
}

//force composer map scale for scale dependent visibility
double bk_scale = theMapRenderer.scale();
@@ -28,7 +28,8 @@ QgsRenderContext::QgsRenderContext()
mScaleFactor( 1.0 ),
mRasterScaleFactor( 1.0 ),
mRendererScale( 1.0 ),
mLabelingEngine( NULL )
mLabelingEngine( NULL ),
mRenderingPrintComposition( false )
{

}
@@ -95,6 +95,10 @@ class CORE_EXPORT QgsRenderContext
//! Added in QGIS v2.0
void setSelectionColor( const QColor& color ) { mSelectionColor = color; }

/**True if the rendering request comes from a print composition, false it comes from a normal window request */
void setRenderingPrintComposition( bool renderingPrintComposition ) { mRenderingPrintComposition = renderingPrintComposition; }
bool renderingPrintComposition( ) const { return mRenderingPrintComposition; }

private:

/**Painter for rendering operations*/
@@ -133,6 +137,9 @@ class CORE_EXPORT QgsRenderContext

/** Color used for features that are marked as selected */
QColor mSelectionColor;

/**True if the rendering request comes from a print composition, false it comes from a normal window request */
bool mRenderingPrintComposition;
};

#endif
@@ -694,15 +694,15 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
.setSubsetOfAttributes( attributes );

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

featureRequest.setFlags( featureRequest.flags() | QgsFeatureRequest::SimplifyGeometries );
featureRequest.setCoordinateTransform( rendererContext.coordinateTransform() );
featureRequest.setMapToPixel( &rendererContext.mapToPixel() );
featureRequest.setMapToPixelTol( mSimplifyDrawingTol * 72.0f/dpi );
featureRequest.setMapToPixelTol( mSimplifyDrawingTol * 96.0f/dpi );
}

QgsFeatureIterator fit = getFeatures( featureRequest );
@@ -1373,7 +1373,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
bool simplifyDrawing() const { return mSimplifyDrawing; }

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

public slots:
/**

0 comments on commit 5441a1e

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