Skip to content
Permalink
Browse files

Add return type QgsRenderOptions to QgsRendererV2::startRender

This allows to specify additional filter constraints for the feature request to
be specified.
  • Loading branch information
m-kuhn committed Jul 14, 2015
1 parent 9752c46 commit b47b9a54b75af1cb1ff875bef0ae845cec217113
@@ -1,4 +1,5 @@
*.*~
*.autosave
*.aux
*.diff
*.log*
@@ -49,7 +49,7 @@ class QgsCategorizedSymbolRendererV2 : QgsFeatureRendererV2

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );

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

virtual void stopRender( QgsRenderContext& context );

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

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );

virtual void startRender( QgsRenderContext& context, const QgsFields& fields );
virtual QgsRenderOptions 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 void startRender( QgsRenderContext& context, const QgsFields& fields );
virtual QgsRenderOptions 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 void startRender( QgsRenderContext& context, const QgsFields& fields );
virtual QgsRenderOptions 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 );

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

void stopRender( QgsRenderContext& context );

@@ -17,6 +17,16 @@ 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;

@@ -74,7 +84,7 @@ class QgsFeatureRendererV2
*/
virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );

virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) = 0;
virtual QgsRenderOptions 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/;
@@ -173,7 +173,7 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2

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

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

virtual void stopRender( QgsRenderContext& context );

@@ -13,7 +13,7 @@ class QgsSingleSymbolRendererV2 : QgsFeatureRendererV2

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature );

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

virtual void stopRender( QgsRenderContext& context );

@@ -396,7 +396,7 @@ void QgsCategorizedSymbolRendererV2::sortByLabel( Qt::SortOrder order )
}
}

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

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

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

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature ) override;

virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual QgsRenderOptions 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() );
}

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

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

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

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature ) override;

virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual QgsRenderOptions 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;
}

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

// find out classification attribute index from name
@@ -80,6 +80,7 @@ void QgsHeatmapRenderer::startRender( QgsRenderContext& context, const QgsFields
}

initializeValues( context );
return QgsRenderOptions();
}

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

//reimplemented methods
virtual QgsFeatureRendererV2* clone() const override;
virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual QgsRenderOptions 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();
}

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

// first call start render on the sub renderer
@@ -85,7 +85,7 @@ void QgsInvertedPolygonRenderer::startRender( QgsRenderContext& context, const Q

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

// convert viewport to dest CRS
@@ -119,6 +119,8 @@ void QgsInvertedPolygonRenderer::startRender( QgsRenderContext& context, const Q

mExtentPolygon.clear();
mExtentPolygon.append( exteriorRing );

return QgsRenderOptions();
}

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 void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
virtual QgsRenderOptions 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 )
}


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

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

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;

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

void stopRender( QgsRenderContext& context ) override;

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

class CORE_EXPORT QgsRenderOptions
{
public:
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;

@@ -95,7 +104,14 @@ class CORE_EXPORT QgsFeatureRendererV2
*/
virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature ) { return symbolForFeature( feature ); }

virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) = 0;
/**
* Needs to be called when a new render cycle is started
*
* @param context Additional information passed to the renderer about the job which will be rendered
* @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;

//! @deprecated since 2.4 - not using QgsVectorLayer directly anymore
Q_DECL_DEPRECATED virtual void startRender( QgsRenderContext& context, const QgsVectorLayer* vlayer );
@@ -779,7 +779,7 @@ bool QgsRuleBasedRendererV2::renderFeature( QgsFeature& feature,
}


void QgsRuleBasedRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
QgsRenderOptions QgsRuleBasedRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
{
// prepare active children
mRootRule->startRender( context, fields );
@@ -800,6 +800,7 @@ void QgsRuleBasedRendererV2::startRender( QgsRenderContext& context, const QgsFi
}

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

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

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

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

virtual void stopRender( QgsRenderContext& context ) override;

@@ -79,9 +79,10 @@ QgsSymbolV2* QgsSingleSymbolRendererV2::originalSymbolForFeature( QgsFeature& fe
return mSymbol.data();
}

void QgsSingleSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
QgsRenderOptions QgsSingleSymbolRendererV2::startRender( QgsRenderContext& context, const QgsFields& fields )
{
if ( !mSymbol.data() ) return;
if ( !mSymbol.data() )
return QgsRenderOptions();

mSymbol->startRender( context, &fields );

@@ -112,6 +113,8 @@ void QgsSingleSymbolRendererV2::startRender( QgsRenderContext& context, const Qg
mOrigSize = 0;
}
}

return QgsRenderOptions();
}

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

virtual QgsSymbolV2* originalSymbolForFeature( QgsFeature& feature ) override;

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

virtual void stopRender( QgsRenderContext& context ) override;

0 comments on commit b47b9a5

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