Skip to content

Commit 83eec4a

Browse files
committedMay 27, 2014
Enable disabled simplification code after merge MTR (2-2)
Enable AntialiasingSimplification
1 parent 4ab24a4 commit 83eec4a

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed
 

‎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/qgsrendercontext.cpp

Lines changed: 1 addition & 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()

‎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
{

0 commit comments

Comments
 (0)