Skip to content
Permalink
Browse files

Re-enable geometry simplification while rendering

  • Loading branch information
wonder-sk committed Feb 18, 2014
1 parent a3af933 commit bc074869823b67acf76ee3fa5edccc5acb611fd0
@@ -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 @@ class QgsVectorLayerRenderer : public QgsMapLayerRenderer

int mLayerTransparency;
QPainter::CompositionMode mFeatureBlendMode;

QgsVectorSimplifyMethod mSimplifyMethod;
bool mSimplifyGeometry;
};


0 comments on commit bc07486

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