Skip to content

Commit 03d4f63

Browse files
committedSep 2, 2015
Use expression contexts when rendering symbols in composer items
(eg shape fills, arrow line styles, overview frames, grid lines)
1 parent caa3c34 commit 03d4f63

File tree

5 files changed

+19
-27
lines changed

5 files changed

+19
-27
lines changed
 

‎src/core/composer/qgscomposerarrow.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ void QgsComposerArrow::drawLine( QPainter *painter )
186186
QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
187187
context.setForceVectorOutput( true );
188188
context.setPainter( painter );
189+
QgsExpressionContext* expressionContext = createExpressionContext();
190+
context.setExpressionContext( *expressionContext );
191+
delete expressionContext;
189192

190193
//line scaled to dots
191194
QPolygonF line;

‎src/core/composer/qgscomposermapgrid.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,9 @@ void QgsComposerMapGrid::draw( QPainter* p )
656656
QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
657657
context.setForceVectorOutput( true );
658658
context.setPainter( p );
659+
QgsExpressionContext* expressionContext = createExpressionContext();
660+
context.setExpressionContext( *expressionContext );
661+
delete expressionContext;
659662

660663
QList< QPair< double, QLineF > > verticalLines;
661664
QList< QPair< double, QLineF > > horizontalLines;

‎src/core/composer/qgscomposermapoverview.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ void QgsComposerMapOverview::draw( QPainter *painter )
9797
QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
9898
context.setForceVectorOutput( true );
9999
context.setPainter( painter );
100+
QgsExpressionContext* expressionContext = createExpressionContext();
101+
context.setExpressionContext( *expressionContext );
102+
delete expressionContext;
100103

101104
painter->save();
102105
painter->setCompositionMode( mBlendMode );

‎src/core/composer/qgscomposershape.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ void QgsComposerShape::drawShapeUsingSymbol( QPainter* p )
182182
QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
183183
context.setPainter( p );
184184
context.setForceVectorOutput( true );
185+
QgsExpressionContext* expressionContext = createExpressionContext();
186+
context.setExpressionContext( *expressionContext );
187+
delete expressionContext;
188+
185189
p->scale( 1 / dotsPerMM, 1 / dotsPerMM ); // scale painter from mm to dots
186190

187191
//generate polygon to draw
@@ -232,21 +236,9 @@ void QgsComposerShape::drawShapeUsingSymbol( QPainter* p )
232236
}
233237

234238
mShapeStyleSymbol->startRender( context );
235-
236-
//need to render using atlas feature properties?
237-
if ( mComposition->atlasComposition().enabled() && mComposition->atlasMode() != QgsComposition::AtlasOff )
238-
{
239-
//using an atlas, so render using current atlas feature
240-
//since there may be data defined symbols using atlas feature properties
241-
QgsFeature atlasFeature = mComposition->atlasComposition().feature();
242-
mShapeStyleSymbol->renderPolygon( shapePolygon, &rings, &atlasFeature, context );
243-
}
244-
else
245-
{
246-
mShapeStyleSymbol->renderPolygon( shapePolygon, &rings, 0, context );
247-
}
248-
239+
mShapeStyleSymbol->renderPolygon( shapePolygon, &rings, 0, context );
249240
mShapeStyleSymbol->stopRender( context );
241+
250242
p->restore();
251243
}
252244

‎src/core/composer/qgspaperitem.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ void QgsPaperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* ite
164164
QgsRenderContext context = QgsRenderContext::fromMapSettings( ms );
165165
context.setPainter( painter );
166166
context.setForceVectorOutput( true );
167+
QgsExpressionContext* expressionContext = createExpressionContext();
168+
context.setExpressionContext( *expressionContext );
169+
delete expressionContext;
167170

168171
painter->save();
169172

@@ -194,19 +197,7 @@ void QgsPaperItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* ite
194197
( rect().width() - 2 * mPageMargin ) * dotsPerMM, ( rect().height() - 2 * mPageMargin ) * dotsPerMM ) );
195198
QList<QPolygonF> rings; //empty list
196199

197-
//need to render using atlas feature properties?
198-
if ( mComposition->atlasComposition().enabled() && mComposition->atlasMode() != QgsComposition::AtlasOff )
199-
{
200-
//using an atlas, so render using current atlas feature
201-
//since there may be data defined symbols using atlas feature properties
202-
QgsFeature atlasFeature = mComposition->atlasComposition().feature();
203-
mComposition->pageStyleSymbol()->renderPolygon( pagePolygon, &rings, &atlasFeature, context );
204-
}
205-
else
206-
{
207-
mComposition->pageStyleSymbol()->renderPolygon( pagePolygon, &rings, 0, context );
208-
}
209-
200+
mComposition->pageStyleSymbol()->renderPolygon( pagePolygon, &rings, 0, context );
210201
mComposition->pageStyleSymbol()->stopRender( context );
211202
painter->restore();
212203
}

0 commit comments

Comments
 (0)
Please sign in to comment.