Skip to content
Permalink
Browse files

Rule-based renderer: enable new labeling

  • Loading branch information
wonder-sk committed Jan 26, 2012
1 parent 75512bc commit ace2844da37a0b2c41817c6e8d2510e6bb3a64ba
@@ -81,7 +81,7 @@ public:

virtual QgsSymbolV2List symbols()=0;

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

bool usingSymbolLevels() const;
void setUsingSymbolLevels(bool usingSymbolLevels);
@@ -438,7 +438,7 @@ class QgsRuleBasedRendererV2 : QgsFeatureRendererV2
//! return symbol for current feature. Should not be used individually: there could be more symbols for a feature
virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature );

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

virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer );

@@ -744,7 +744,7 @@ void QgsVectorLayer::drawRendererV2( QgsRenderContext& rendererContext, bool lab
bool drawMarker = ( mEditable && ( !vertexMarkerOnlyForSelection || sel ) );

// render feature
mRendererV2->renderFeature( fet, rendererContext, -1, sel, drawMarker );
bool rendered = mRendererV2->renderFeature( fet, rendererContext, -1, sel, drawMarker );

if ( mEditable )
{
@@ -753,7 +753,7 @@ void QgsVectorLayer::drawRendererV2( QgsRenderContext& rendererContext, bool lab
}

// labeling - register feature
if ( mRendererV2->symbolForFeature( fet ) != NULL && rendererContext.labelingEngine() )
if ( rendered && rendererContext.labelingEngine() )
{
if ( labeling )
{
@@ -66,7 +66,7 @@ QgsFeatureRendererV2* QgsPointDisplacementRenderer::clone()
return r;
}

void QgsPointDisplacementRenderer::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
bool QgsPointDisplacementRenderer::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
{
Q_UNUSED( drawVertexMarker );
//point position in screen coords
@@ -75,7 +75,7 @@ void QgsPointDisplacementRenderer::renderFeature( QgsFeature& feature, QgsRender
if ( geomType != QGis::WKBPoint && geomType != QGis::WKBPoint25D )
{
//can only render point type
return;
return false;
}
QPointF pt;
_getPoint( pt, context, geom->asWkb() );
@@ -125,7 +125,7 @@ void QgsPointDisplacementRenderer::renderFeature( QgsFeature& feature, QgsRender

if ( symbolList.isEmpty() && labelAttributeList.isEmpty() )
{
return; //display all point symbols for one posi
return true; //display all point symbols for one posi
}


@@ -176,6 +176,7 @@ void QgsPointDisplacementRenderer::renderFeature( QgsFeature& feature, QgsRender
drawSymbols( feature, context, symbolList, symbolPositions, selected );
//and also the labels
drawLabels( pt, symbolContext, labelPositions, labelAttributeList );
return true;
}

void QgsPointDisplacementRenderer::setEmbeddedRenderer( QgsFeatureRendererV2* r )
@@ -37,7 +37,7 @@ class CORE_EXPORT QgsPointDisplacementRenderer: public QgsFeatureRendererV2
QgsFeatureRendererV2* clone();

/**Reimplemented from QgsFeatureRendererV2*/
void renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );
bool renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer = -1, bool selected = false, bool drawVertexMarker = false );

QgsSymbolV2* symbolForFeature( QgsFeature& feature );

@@ -188,13 +188,14 @@ QgsFeatureRendererV2* QgsFeatureRendererV2::defaultRenderer( QGis::GeometryType
}


void QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
bool QgsFeatureRendererV2::renderFeature( QgsFeature& feature, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
{
QgsSymbolV2* symbol = symbolForFeature( feature );
if ( symbol == NULL )
return;
return false;

renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
return true;
}

void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymbolV2* symbol, QgsRenderContext& context, int layer, bool selected, bool drawVertexMarker )
@@ -73,7 +73,7 @@ class CORE_EXPORT QgsFeatureRendererV2

virtual QgsFeatureRendererV2* clone() = 0;

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

//! for debugging
virtual QString dump();
@@ -260,28 +260,32 @@ void QgsRuleBasedRendererV2::Rule::setNormZLevels( const QMap<int, int>& zLevels
}


void QgsRuleBasedRendererV2::Rule::renderFeature( QgsRuleBasedRendererV2::FeatureToRender& featToRender, QgsRenderContext& context, QgsRuleBasedRendererV2::RenderQueue& renderQueue )
bool QgsRuleBasedRendererV2::Rule::renderFeature( QgsRuleBasedRendererV2::FeatureToRender& featToRender, QgsRenderContext& context, QgsRuleBasedRendererV2::RenderQueue& renderQueue )
{
if ( isFilterOK( featToRender.feat ) )
if ( !isFilterOK( featToRender.feat ) )
return false;

bool rendered = false;

// create job for this feature and this symbol, add to list of jobs
if ( mSymbol )
{
// create job for this feature and this symbol, add to list of jobs
if ( mSymbol )
// add job to the queue: each symbol's zLevel must be added
foreach( int normZLevel, mSymbolNormZLevels )
{
// add job to the queue: each symbol's zLevel must be added
foreach( int normZLevel, mSymbolNormZLevels )
{
//QgsDebugMsg(QString("add job at level %1").arg(normZLevel));
renderQueue[normZLevel].jobs.append( new RenderJob( featToRender, mSymbol ) );
}
//QgsDebugMsg(QString("add job at level %1").arg(normZLevel));
renderQueue[normZLevel].jobs.append( new RenderJob( featToRender, mSymbol ) );
}
rendered = true;
}

// process children
for ( QList<Rule*>::iterator it = mActiveChildren.begin(); it != mActiveChildren.end(); ++it )
{
Rule* rule = *it;
rule->renderFeature( featToRender, context, renderQueue );
}
// process children
for ( QList<Rule*>::iterator it = mActiveChildren.begin(); it != mActiveChildren.end(); ++it )
{
Rule* rule = *it;
rendered |= rule->renderFeature( featToRender, context, renderQueue );
}
return rendered;
}


@@ -364,7 +368,7 @@ QgsSymbolV2* QgsRuleBasedRendererV2::symbolForFeature( QgsFeature& )
return 0;
}

void QgsRuleBasedRendererV2::renderFeature( QgsFeature& feature,
bool QgsRuleBasedRendererV2::renderFeature( QgsFeature& feature,
QgsRenderContext& context,
int layer,
bool selected,
@@ -376,7 +380,7 @@ void QgsRuleBasedRendererV2::renderFeature( QgsFeature& feature,
mCurrentFeatures.append( FeatureToRender( feature, flags ) );

// check each active rule
mRootRule->renderFeature( mCurrentFeatures.last(), context, mRenderQueue );
return mRootRule->renderFeature( mCurrentFeatures.last(), context, mRenderQueue );
}


@@ -125,7 +125,7 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
//! assign normalized z-levels [0..N-1] for this rule's symbol for quick access during rendering
void setNormZLevels( const QMap<int, int>& zLevelsToNormLevels );

void renderFeature( FeatureToRender& featToRender, QgsRenderContext& context, RenderQueue& renderQueue );
bool renderFeature( FeatureToRender& featToRender, QgsRenderContext& context, RenderQueue& renderQueue );

void stopRender( QgsRenderContext& context );

@@ -179,7 +179,7 @@ class CORE_EXPORT QgsRuleBasedRendererV2 : public QgsFeatureRendererV2
//! return symbol for current feature. Should not be used individually: there could be more symbols for a feature
virtual QgsSymbolV2* symbolForFeature( QgsFeature& feature );

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

virtual void startRender( QgsRenderContext& context, const QgsVectorLayer *vlayer );

0 comments on commit ace2844

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