Skip to content

Commit

Permalink
Re-enable geometry simplification while rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Feb 18, 2014
1 parent a3af933 commit bc07486
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/core/qgsvectorlayerfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
//}
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/core/qgsvectorlayerrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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 );
Expand All @@ -153,7 +155,6 @@ bool QgsVectorLayerRenderer::render()

featureRequest.setSimplifyMethod( simplifyMethod );
}
#endif

QgsFeatureIterator fit = mSource->getFeatures( featureRequest );

Expand Down
4 changes: 4 additions & 0 deletions src/core/qgsvectorlayerrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -86,6 +87,9 @@ class QgsVectorLayerRenderer : public QgsMapLayerRenderer

int mLayerTransparency;
QPainter::CompositionMode mFeatureBlendMode;

QgsVectorSimplifyMethod mSimplifyMethod;
bool mSimplifyGeometry;
};


Expand Down

0 comments on commit bc07486

Please sign in to comment.