mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
Re-enable geometry simplification while rendering
This commit is contained in:
parent
a3af93394e
commit
bc07486982
@ -62,9 +62,6 @@ QgsVectorLayerFeatureSource::QgsVectorLayerFeatureSource(QgsVectorLayer *layer)
|
||||
mChangedAttributeValues = QgsChangedAttributesMap( layer->editBuffer()->changedAttributeValues() );
|
||||
mAddedAttributes = QList<QgsField>( layer->editBuffer()->addedAttributes() );
|
||||
mDeletedAttributeIds = QgsAttributeList( layer->editBuffer()->deletedAttributeIds() );
|
||||
|
||||
// TODO[MD]: after merge
|
||||
//mChangedFeaturesRequest.setFilterFids( L->editBuffer()->changedAttributeValues().keys().toSet() );
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ QgsVectorLayerRenderer::QgsVectorLayerRenderer( QgsVectorLayer* layer, QgsRender
|
||||
mLayerTransparency = layer->layerTransparency();
|
||||
mFeatureBlendMode = layer->featureBlendMode();
|
||||
|
||||
mSimplifyMethod = layer->simplifyMethod();
|
||||
mSimplifyGeometry = layer->simplifyDrawingCanbeApplied( mContext, QgsVectorLayer::GeometrySimplification );
|
||||
|
||||
QSettings settings;
|
||||
mVertexMarkerOnlyForSelection = settings.value( "/qgis/digitizing/marker_only_for_selected", false ).toBool();
|
||||
|
||||
@ -114,21 +117,20 @@ bool QgsVectorLayerRenderer::render()
|
||||
.setSubsetOfAttributes( mAttrNames, mFields );
|
||||
|
||||
// enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
|
||||
#if 0 //TODO[MD]: after merge
|
||||
if ( simplifyDrawingCanbeApplied( mContext, QgsVectorLayer::GeometrySimplification ) )
|
||||
if ( mSimplifyGeometry )
|
||||
{
|
||||
QPainter* p = rendererContext.painter();
|
||||
QPainter* p = mContext.painter();
|
||||
double dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
|
||||
double map2pixelTol = mSimplifyMethod.threshold() * 96.0f / dpi;
|
||||
|
||||
const QgsMapToPixel& mtp = rendererContext.mapToPixel();
|
||||
const QgsMapToPixel& mtp = mContext.mapToPixel();
|
||||
map2pixelTol *= mtp.mapUnitsPerPixel();
|
||||
const QgsCoordinateTransform* ct = rendererContext.coordinateTransform();
|
||||
const QgsCoordinateTransform* ct = mContext.coordinateTransform();
|
||||
|
||||
// resize the tolerance using the change of size of an 1-BBOX from the source CoordinateSystem to the target CoordinateSystem
|
||||
if ( ct && !(( QgsCoordinateTransform* )ct )->isShortCircuited() )
|
||||
{
|
||||
QgsPoint center = rendererContext.extent().center();
|
||||
QgsPoint center = mContext.extent().center();
|
||||
double rectSize = ct->sourceCrs().geographicFlag() ? 0.0008983 /* ~100/(40075014/360=111319.4833) */ : 100;
|
||||
|
||||
QgsRectangle sourceRect = QgsRectangle( center.x(), center.y(), center.x() + rectSize, center.y() + rectSize );
|
||||
@ -153,7 +155,6 @@ bool QgsVectorLayerRenderer::render()
|
||||
|
||||
featureRequest.setSimplifyMethod( simplifyMethod );
|
||||
}
|
||||
#endif
|
||||
|
||||
QgsFeatureIterator fit = mSource->getFeatures( featureRequest );
|
||||
|
||||
|
@ -22,6 +22,7 @@ typedef QList<int> QgsAttributeList;
|
||||
#include "qgsfield.h" // QgsFields
|
||||
#include "qgsfeature.h" // QgsFeatureIds
|
||||
#include "qgsfeatureiterator.h"
|
||||
#include "qgsvectorsimplifymethod.h"
|
||||
|
||||
#include "qgsmaplayerrenderer.h"
|
||||
|
||||
@ -86,6 +87,9 @@ protected:
|
||||
|
||||
int mLayerTransparency;
|
||||
QPainter::CompositionMode mFeatureBlendMode;
|
||||
|
||||
QgsVectorSimplifyMethod mSimplifyMethod;
|
||||
bool mSimplifyGeometry;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user