Skip to content
Permalink
Browse files

Remove QgsRenderOptions, return filter in separate method

  • Loading branch information
m-kuhn committed Jul 22, 2015
1 parent 7573078 commit e984fb00fd34c4165e60ef3867b7788136c640a6
@@ -49,7 +49,7 @@ class QgsCategorizedSymbolRendererV2 : QgsFeatureRendererV2

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );

virtual void stopRender( QgsRenderContext& context );

@@ -91,7 +91,7 @@ class QgsGraduatedSymbolRendererV2 : QgsFeatureRendererV2

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );

virtual void stopRender( QgsRenderContext& context );

@@ -10,7 +10,7 @@ class QgsHeatmapRenderer : QgsFeatureRendererV2

//reimplemented methods
virtual QgsFeatureRendererV2* clone() const /Factory/;
virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );
virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
virtual void stopRender( QgsRenderContext& context );
virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature );
@@ -14,7 +14,7 @@ class QgsInvertedPolygonRenderer : QgsFeatureRendererV2
/** Used to clone this feature renderer.*/
virtual QgsFeatureRendererV2* clone() const /Factory/;

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );

/** Renders a given feature.
* This will here collect features. The actual rendering will be postponed to stopRender()
@@ -16,7 +16,7 @@ class QgsPointDisplacementRenderer : QgsFeatureRendererV2

QgsSymbolV2* symbolForFeature( QgsFeature& feature );

QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );

void stopRender( QgsRenderContext& context );

@@ -17,15 +17,6 @@ class QgsSymbolV2LevelItem
int layer();
};

class QgsRenderOptions
{
%TypeHeaderCode
#include <qgsrendererv2.h>
%End
public:
void setWhereClause( const QString& whereClause );
QString whereClause();
};

// every level has list of items: symbol + symbol layer num
// typedef QList< QgsSymbolV2LevelItem > QgsSymbolV2Level;
@@ -84,13 +75,15 @@ class QgsFeatureRendererV2
*/
virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields ) = 0;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) = 0;

//! @deprecated since 2.4 - not using QgsVectorLayer directly anymore
virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer ) /Deprecated/;

virtual void stopRender( QgsRenderContext& context ) = 0;

virtual QString filter();

virtual QList<QString> usedAttributes() = 0;

virtual ~QgsFeatureRendererV2();
@@ -175,10 +175,12 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2

virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );

virtual void stopRender( QgsRenderContext& context );

virtual QString filter();

virtual QList<QString> usedAttributes();

virtual QgsFeatureRendererV2* clone() const /Factory/;
@@ -13,7 +13,7 @@ class QgsSingleSymbolRendererV2 : QgsFeatureRendererV2

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields );
virtual void startRender( QgsRenderContext& context, const QgsFields& fields );

virtual void stopRender( QgsRenderContext& context );

@@ -134,19 +134,20 @@ bool QgsVectorLayerRenderer::render()
mContext.painter()->setCompositionMode( mFeatureBlendMode );
}

QgsRenderOptions opts = mRendererV2->startRender( mContext, mFields );
mRendererV2->startRender( mContext, mFields );

QString rendererFilter = mRendererV2->filter();

QgsDebugMsg( opts.whereClause() );
QgsRectangle requestExtent = mContext.extent();
mRendererV2->modifyRequestExtent( requestExtent, mContext );

QgsFeatureRequest featureRequest = QgsFeatureRequest()
.setFilterRect( requestExtent )
.setSubsetOfAttributes( mAttrNames, mFields );

if ( !opts.whereClause().isNull() )
if ( !rendererFilter.isNull() )
{
featureRequest.setFilterExpression( opts.whereClause() );
featureRequest.setFilterExpression( rendererFilter );
}

// enable the simplification of the geometries (Using the current map2pixel context) before send it to renderer engine.
@@ -396,7 +396,7 @@ void QgsCategorizedSymbolRendererV2::sortByLabel( Qt::SortOrder order )
}
}

QgsRenderOptions QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
void QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
{
mCounting = context.rendererScale() == 0.0;

@@ -425,7 +425,7 @@ QgsRenderOptions QgsCategorizedSymbolRendererV2::startRender( QgsRenderContext&
mTempSymbols[ it->symbol()] = tempSymbol;
}
}
return QgsRenderOptions();
return;
}

void QgsCategorizedSymbolRendererV2::stopRender( QgsRenderContext& context )
@@ -79,7 +79,7 @@ class CORE_EXPORT QgsCategorizedSymbolRendererV2 : public QgsFeatureRendererV2

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature ) override;

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;

virtual void stopRender( QgsRenderContext& context ) override;

@@ -369,7 +369,7 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::originalSymbolForFeature( QgsFeature&
return symbolForValue( value.toDouble() );
}

QgsRenderOptions QgsGraduatedSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
void QgsGraduatedSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
{
mCounting = context.rendererScale() == 0.0;

@@ -399,7 +399,7 @@ QgsRenderOptions QgsGraduatedSymbolRendererV2::startRender( QgsRenderContext& co
mTempSymbols[ it->symbol()] = tempSymbol;
}
}
return QgsRenderOptions();
return;
}

void QgsGraduatedSymbolRendererV2::stopRender( QgsRenderContext& context )
@@ -123,7 +123,7 @@ class CORE_EXPORT QgsGraduatedSymbolRendererV2 : public QgsFeatureRendererV2

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature ) override;

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;

virtual void stopRender( QgsRenderContext& context ) override;

@@ -63,12 +63,12 @@ void QgsHeatmapRenderer::initializeValues( QgsRenderContext& context )
mRadiusSquared = mRadiusPixels * mRadiusPixels;
}

QgsRenderOptions QgsHeatmapRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
void QgsHeatmapRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
{
Q_UNUSED( fields );
if ( !context.painter() )
{
return QgsRenderOptions();
return;
}

// find out classification attribute index from name
@@ -80,7 +80,7 @@ QgsRenderOptions QgsHeatmapRenderer::startRender( QgsRenderContext& context, con
}

initializeValues( context );
return QgsRenderOptions();
return;
}

QgsMultiPoint QgsHeatmapRenderer::convertToMultipoint( const QgsGeometry* geom )
@@ -39,7 +39,7 @@ class CORE_EXPORT QgsHeatmapRenderer : public QgsFeatureRendererV2

//reimplemented methods
virtual QgsFeatureRendererV2* clone() const override;
virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;
virtual void stopRender( QgsRenderContext& context ) override;
virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature ) override;
@@ -63,11 +63,11 @@ const QgsFeatureRendererV2* QgsInvertedPolygonRenderer::embeddedRenderer() const
return mSubRenderer.data();
}

QgsRenderOptions QgsInvertedPolygonRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
void QgsInvertedPolygonRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
{
if ( !mSubRenderer )
{
return QgsRenderOptions();
return;
}

// first call start render on the sub renderer
@@ -85,7 +85,7 @@ QgsRenderOptions QgsInvertedPolygonRenderer::startRender( QgsRenderContext& cont

if ( !context.painter() )
{
return QgsRenderOptions();
return;
}

// convert viewport to dest CRS
@@ -120,7 +120,7 @@ QgsRenderOptions QgsInvertedPolygonRenderer::startRender( QgsRenderContext& cont
mExtentPolygon.clear();
mExtentPolygon.append( exteriorRing );

return QgsRenderOptions();
return;
}

bool QgsInvertedPolygonRenderer::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
@@ -50,7 +50,7 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRendererV2
/** Used to clone this feature renderer.*/
virtual QgsFeatureRendererV2* clone() const override;

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;

/** Renders a given feature.
* This will here collect features. The actual rendering will be postponed to stopRender()
@@ -279,7 +279,7 @@ bool QgsPointDisplacementRenderer::willRenderFeature( QgsFeature& feat )
}


QgsRenderOptions QgsPointDisplacementRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
void QgsPointDisplacementRenderer::startRender( QgsRenderContext& context, const QgsFields& fields )
{
mRenderer->startRender( context, fields );

@@ -310,7 +310,7 @@ QgsRenderOptions QgsPointDisplacementRenderer::startRender( QgsRenderContext& co
{
mCenterSymbol->startRender( context, &fields );
}
return QgsRenderOptions();
return;
}

void QgsPointDisplacementRenderer::stopRender( QgsRenderContext& context )
@@ -58,7 +58,7 @@ class CORE_EXPORT QgsPointDisplacementRenderer: public QgsFeatureRendererV2
/** Proxy that will call this method on the embedded renderer. */
virtual bool willRenderFeature( QgsFeature& feat ) override;

QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;

void stopRender( QgsRenderContext& context ) override;

@@ -61,18 +61,6 @@ class CORE_EXPORT QgsSymbolV2LevelItem
int mLayer;
};

class CORE_EXPORT QgsRenderOptions
{
public:
QgsRenderOptions() {}
QgsRenderOptions( const QString& whereClause ) { mWhereClause = whereClause; }

void setWhereClause( const QString& whereClause ) { mWhereClause = whereClause; }
QString whereClause() { return mWhereClause; }
private:
QString mWhereClause;
};

// every level has list of items: symbol + symbol layer num
typedef QList< QgsSymbolV2LevelItem > QgsSymbolV2Level;

@@ -114,13 +102,26 @@ class CORE_EXPORT QgsFeatureRendererV2
* @param fields The fields available for rendering
* @return Information passed back from the renderer that can e.g. be used to reduce the amount of requested features
*/
virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields ) = 0;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) = 0;

//! @deprecated since 2.4 - not using QgsVectorLayer directly anymore
Q_DECL_DEPRECATED virtual void startRender( QgsRenderContext& context, const QgsVectorLayer* vlayer );

virtual void stopRender( QgsRenderContext& context ) = 0;

/**
* If a renderer does not require all the features this method may be overridden
* and return an expression used as where clause.
* This will be called once after {@link startRender()} and before the first call
* to {@link renderFeature()}.
* By default this returns a null string and all features will be requested.
* You do not need to specify the extent in here, this is taken care of separately and
* will be combined with a filter returned from this method.
*
* @return An expresion used as where clause
*/
virtual QString filter() { return QString::null; }

virtual QList<QString> usedAttributes() = 0;

virtual ~QgsFeatureRendererV2();
@@ -807,11 +807,10 @@ bool QgsRuleBasedRendererV2::renderFeature( QgsFeature& feature,
}


QgsRenderOptions QgsRuleBasedRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
void QgsRuleBasedRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
{
QString filter;
// prepare active children
mRootRule->startRender( context, fields, filter );
mRootRule->startRender( context, fields, mFilter );

QSet<int> symbolZLevelsSet = mRootRule->collectZLevels();
QList<int> symbolZLevels = symbolZLevelsSet.toList();
@@ -829,7 +828,6 @@ QgsRenderOptions QgsRuleBasedRendererV2::startRender( QgsRenderContext& context,
}

mRootRule->setNormZLevels( zLevelsToNormLevels );
return QgsRenderOptions( filter );
}

void QgsRuleBasedRendererV2::stopRender( QgsRenderContext& context )
@@ -873,6 +871,11 @@ void QgsRuleBasedRendererV2::stopRender( QgsRenderContext& context )
mRootRule->stopRender( context );
}

QString QgsRuleBasedRendererV2::filter()
{
return mFilter;
}

QList<QString> QgsRuleBasedRendererV2::usedAttributes()
{
QSet<QString> attrs = mRootRule->usedAttributes();
@@ -222,10 +222,12 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2

virtual bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override;

virtual QgsRenderOptions startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;

virtual void stopRender( QgsRenderContext& context ) override;

virtual QString filter() override;

virtual QList<QString> usedAttributes() override;

virtual QgsFeatureRendererV2* clone() const override;
@@ -308,6 +310,8 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
// temporary
RenderQueue mRenderQueue;
QList<FeatureToRender> mCurrentFeatures;

QString mFilter;
};

#endif // QGSRULEBASEDRENDERERV2_H

0 comments on commit e984fb0

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