Skip to content

Commit 04dc5d8

Browse files
committedMay 30, 2014
Merge remote-tracking branch 'alvaro/Simplification_MTR'
Conflicts: python/core/qgsmapsettings.sip
2 parents ecdb6de + 83eec4a commit 04dc5d8

File tree

10 files changed

+33
-12
lines changed

10 files changed

+33
-12
lines changed
 

‎python/core/qgsmapsettings.sip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class QgsMapSettings
4545
DrawEditingInfo = 0x02,
4646
ForceVectorOutput = 0x04,
4747
UseAdvancedEffects = 0x08,
48-
DrawLabeling = 0x10
48+
DrawLabeling = 0x10,
49+
UseRenderingOptimization = 0x20
4950
// TODO: ignore scale-based visibility (overview)
5051
};
5152
typedef QFlags<QgsMapSettings::Flag> Flags;

‎python/core/qgsrendercontext.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ class QgsRenderContext
7272
/**Returns true if the rendering optimization (geometry simplification) can be executed*/
7373
bool useRenderingOptimization() const;
7474
void setUseRenderingOptimization( bool enabled );
75+
76+
//! Added in QGIS v2.4
77+
const QgsVectorSimplifyMethod& vectorSimplifyMethod() const;
78+
void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod );
7579
};

‎src/core/composer/qgscomposermap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const
201201
jobMapSettings.setDestinationCrs( ms.destinationCrs() );
202202
jobMapSettings.setCrsTransformEnabled( ms.hasCrsTransformEnabled() );
203203
jobMapSettings.setFlags( ms.flags() );
204-
/* TODO[MD] fix after merge
204+
205205
if ( mComposition->plotStyle() == QgsComposition::Print ||
206206
mComposition->plotStyle() == QgsComposition::Postscript )
207207
{
208208
//if outputing composer, disable optimisations like layer simplification
209-
theRendererContext->setUseRenderingOptimization( false );
210-
}*/
209+
jobMapSettings.setFlag( QgsMapSettings::UseRenderingOptimization, false );
210+
}
211211

212212
//update $map variable. Use QgsComposerItem's id since that is user-definable
213213
QgsExpression::setSpecialColumn( "$map", QgsComposerItem::id() );

‎src/core/qgsmapsettings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class CORE_EXPORT QgsMapSettings
6060
DrawEditingInfo = 0x02,
6161
ForceVectorOutput = 0x04,
6262
UseAdvancedEffects = 0x08,
63-
DrawLabeling = 0x10
63+
DrawLabeling = 0x10,
64+
UseRenderingOptimization = 0x20,
6465
// TODO: ignore scale-based visibility (overview)
6566
};
6667
Q_DECLARE_FLAGS( Flags, Flag )

‎src/core/qgsrendercontext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ QgsRenderContext::QgsRenderContext()
3333
mLabelingEngine( NULL ),
3434
mUseRenderingOptimization( true )
3535
{
36-
36+
mVectorSimplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
3737
}
3838

3939
QgsRenderContext::~QgsRenderContext()
@@ -48,6 +48,7 @@ QgsRenderContext QgsRenderContext::fromMapSettings( const QgsMapSettings& mapSet
4848
ctx.setDrawEditingInformation( mapSettings.testFlag( QgsMapSettings::DrawEditingInfo ) );
4949
ctx.setForceVectorOutput( mapSettings.testFlag( QgsMapSettings::ForceVectorOutput ) );
5050
ctx.setUseAdvancedEffects( mapSettings.testFlag( QgsMapSettings::UseAdvancedEffects ) );
51+
ctx.setUseRenderingOptimization( mapSettings.testFlag( QgsMapSettings::UseRenderingOptimization ) );
5152
ctx.setCoordinateTransform( 0 );
5253
ctx.setSelectionColor( mapSettings.selectionColor() );
5354
ctx.setRasterScaleFactor( 1.0 );

‎src/core/qgsrendercontext.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "qgscoordinatetransform.h"
2424
#include "qgsmaptopixel.h"
2525
#include "qgsrectangle.h"
26+
#include "qgsvectorsimplifymethod.h"
2627

2728
class QPainter;
2829

@@ -104,6 +105,10 @@ class CORE_EXPORT QgsRenderContext
104105
bool useRenderingOptimization() const { return mUseRenderingOptimization; }
105106
void setUseRenderingOptimization( bool enabled ) { mUseRenderingOptimization = enabled; }
106107

108+
//! Added in QGIS v2.4
109+
const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
110+
void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
111+
107112
private:
108113

109114
/**Painter for rendering operations*/
@@ -145,6 +150,9 @@ class CORE_EXPORT QgsRenderContext
145150

146151
/**True if the rendering optimization (geometry simplification) can be executed*/
147152
bool mUseRenderingOptimization;
153+
154+
/**Simplification object which holds the information about how to simplify the features for fast rendering */
155+
QgsVectorSimplifyMethod mVectorSimplifyMethod;
148156
};
149157

150158
#endif

‎src/core/qgsvectorlayerrenderer.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ bool QgsVectorLayerRenderer::render()
169169
simplifyMethod.setForceLocalOptimization( mSimplifyMethod.forceLocalOptimization() );
170170

171171
featureRequest.setSimplifyMethod( simplifyMethod );
172+
173+
QgsVectorSimplifyMethod vectorMethod = mSimplifyMethod;
174+
mContext.setVectorSimplifyMethod( vectorMethod );
175+
}
176+
else
177+
{
178+
QgsVectorSimplifyMethod vectorMethod;
179+
vectorMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
180+
mContext.setVectorSimplifyMethod( vectorMethod );
172181
}
173182

174183
QgsFeatureIterator fit = mSource->getFeatures( featureRequest );

‎src/core/symbology-ng/qgslinesymbollayerv2.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,13 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
258258
p->setPen( context.selected() ? mSelPen : mPen );
259259

260260
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
261-
#if 0 // TODO[MD]: after merge
262-
if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
261+
if ( points.size() <= 2 && ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
263262
{
264263
p->setRenderHint( QPainter::Antialiasing, false );
265264
p->drawPolyline( points );
266265
p->setRenderHint( QPainter::Antialiasing, true );
267266
return;
268267
}
269-
#endif
270268

271269
if ( offset == 0 )
272270
{

‎src/core/symbology-ng/qgssymbollayerv2.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,13 @@ void QgsFillSymbolLayerV2::_renderPolygon( QPainter* p, const QPolygonF& points,
427427
}
428428

429429
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
430-
#if 0 // TODO[MD]: after merge
431-
if ( points.size() <= 5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
430+
if ( points.size() <= 5 && ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
432431
{
433432
p->setRenderHint( QPainter::Antialiasing, false );
434433
p->drawRect( points.boundingRect() );
435434
p->setRenderHint( QPainter::Antialiasing, true );
436435
return;
437436
}
438-
#endif
439437

440438
if ( rings == NULL )
441439
{

‎src/gui/qgsmapcanvas.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
206206
this, SLOT( writeProject( QDomDocument & ) ) );
207207

208208
mSettings.setFlag( QgsMapSettings::DrawEditingInfo );
209+
mSettings.setFlag( QgsMapSettings::UseRenderingOptimization );
209210

210211
// class that will sync most of the changes between canvas and (legacy) map renderer
211212
// it is parented to map canvas, will be deleted automatically

0 commit comments

Comments
 (0)
Please sign in to comment.