mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
Enable disabled simplification code after merge MTR (2-2)
Enable AntialiasingSimplification
This commit is contained in:
parent
4ab24a4f40
commit
83eec4ac46
@ -72,4 +72,8 @@ class QgsRenderContext
|
|||||||
/**Returns true if the rendering optimization (geometry simplification) can be executed*/
|
/**Returns true if the rendering optimization (geometry simplification) can be executed*/
|
||||||
bool useRenderingOptimization() const;
|
bool useRenderingOptimization() const;
|
||||||
void setUseRenderingOptimization( bool enabled );
|
void setUseRenderingOptimization( bool enabled );
|
||||||
|
|
||||||
|
//! Added in QGIS v2.4
|
||||||
|
const QgsVectorSimplifyMethod& vectorSimplifyMethod() const;
|
||||||
|
void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod );
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ QgsRenderContext::QgsRenderContext()
|
|||||||
mLabelingEngine( NULL ),
|
mLabelingEngine( NULL ),
|
||||||
mUseRenderingOptimization( true )
|
mUseRenderingOptimization( true )
|
||||||
{
|
{
|
||||||
|
mVectorSimplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsRenderContext::~QgsRenderContext()
|
QgsRenderContext::~QgsRenderContext()
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "qgscoordinatetransform.h"
|
#include "qgscoordinatetransform.h"
|
||||||
#include "qgsmaptopixel.h"
|
#include "qgsmaptopixel.h"
|
||||||
#include "qgsrectangle.h"
|
#include "qgsrectangle.h"
|
||||||
|
#include "qgsvectorsimplifymethod.h"
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
@ -104,6 +105,10 @@ class CORE_EXPORT QgsRenderContext
|
|||||||
bool useRenderingOptimization() const { return mUseRenderingOptimization; }
|
bool useRenderingOptimization() const { return mUseRenderingOptimization; }
|
||||||
void setUseRenderingOptimization( bool enabled ) { mUseRenderingOptimization = enabled; }
|
void setUseRenderingOptimization( bool enabled ) { mUseRenderingOptimization = enabled; }
|
||||||
|
|
||||||
|
//! Added in QGIS v2.4
|
||||||
|
const QgsVectorSimplifyMethod& vectorSimplifyMethod() const { return mVectorSimplifyMethod; }
|
||||||
|
void setVectorSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mVectorSimplifyMethod = simplifyMethod; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**Painter for rendering operations*/
|
/**Painter for rendering operations*/
|
||||||
@ -145,6 +150,9 @@ class CORE_EXPORT QgsRenderContext
|
|||||||
|
|
||||||
/**True if the rendering optimization (geometry simplification) can be executed*/
|
/**True if the rendering optimization (geometry simplification) can be executed*/
|
||||||
bool mUseRenderingOptimization;
|
bool mUseRenderingOptimization;
|
||||||
|
|
||||||
|
/**Simplification object which holds the information about how to simplify the features for fast rendering */
|
||||||
|
QgsVectorSimplifyMethod mVectorSimplifyMethod;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -169,6 +169,15 @@ bool QgsVectorLayerRenderer::render()
|
|||||||
simplifyMethod.setForceLocalOptimization( mSimplifyMethod.forceLocalOptimization() );
|
simplifyMethod.setForceLocalOptimization( mSimplifyMethod.forceLocalOptimization() );
|
||||||
|
|
||||||
featureRequest.setSimplifyMethod( simplifyMethod );
|
featureRequest.setSimplifyMethod( simplifyMethod );
|
||||||
|
|
||||||
|
QgsVectorSimplifyMethod vectorMethod = mSimplifyMethod;
|
||||||
|
mContext.setVectorSimplifyMethod( vectorMethod );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QgsVectorSimplifyMethod vectorMethod;
|
||||||
|
vectorMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
|
||||||
|
mContext.setVectorSimplifyMethod( vectorMethod );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
|
QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
|
||||||
|
@ -258,15 +258,13 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
|
|||||||
p->setPen( context.selected() ? mSelPen : mPen );
|
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).
|
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #2 points).
|
||||||
#if 0 // TODO[MD]: after merge
|
if ( points.size() <= 2 && ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||||
if ( points.size() <= 2 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
|
||||||
{
|
{
|
||||||
p->setRenderHint( QPainter::Antialiasing, false );
|
p->setRenderHint( QPainter::Antialiasing, false );
|
||||||
p->drawPolyline( points );
|
p->drawPolyline( points );
|
||||||
p->setRenderHint( QPainter::Antialiasing, true );
|
p->setRenderHint( QPainter::Antialiasing, true );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( offset == 0 )
|
if ( offset == 0 )
|
||||||
{
|
{
|
||||||
|
@ -427,15 +427,13 @@ 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).
|
// Disable 'Antialiasing' if the geometry was generalized in the current RenderContext (We known that it must have least #5 points).
|
||||||
#if 0 // TODO[MD]: after merge
|
if ( points.size() <= 5 && ( context.renderContext().vectorSimplifyMethod().simplifyHints() & QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.renderContext().vectorSimplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
||||||
if ( points.size() <= 5 && context.layer() && context.layer()->simplifyDrawingCanbeApplied( context.renderContext(), QgsVectorSimplifyMethod::AntialiasingSimplification ) && QgsAbstractGeometrySimplifier::canbeGeneralizedByDeviceBoundingBox( points, context.layer()->simplifyMethod().threshold() ) && ( p->renderHints() & QPainter::Antialiasing ) )
|
|
||||||
{
|
{
|
||||||
p->setRenderHint( QPainter::Antialiasing, false );
|
p->setRenderHint( QPainter::Antialiasing, false );
|
||||||
p->drawRect( points.boundingRect() );
|
p->drawRect( points.boundingRect() );
|
||||||
p->setRenderHint( QPainter::Antialiasing, true );
|
p->setRenderHint( QPainter::Antialiasing, true );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( rings == NULL )
|
if ( rings == NULL )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user