@@ -173,6 +173,9 @@ QgsMarkerSymbolLayerV2::QgsMarkerSymbolLayerV2( bool locked )
173
173
: QgsSymbolLayerV2( QgsSymbolV2::Marker, locked ), mSizeUnit( QgsSymbolV2::MM ), mOffsetUnit( QgsSymbolV2::MM ),
174
174
mHorizontalAnchorPoint( HCenter ), mVerticalAnchorPoint( VCenter )
175
175
{
176
+ mOffsetExpression = NULL ;
177
+ mHorizontalAnchorExpression = NULL ;
178
+ mVerticalAnchorExpression = NULL ;
176
179
}
177
180
178
181
QgsLineSymbolLayerV2::QgsLineSymbolLayerV2 ( bool locked )
@@ -185,6 +188,13 @@ QgsFillSymbolLayerV2::QgsFillSymbolLayerV2( bool locked )
185
188
{
186
189
}
187
190
191
+ void QgsMarkerSymbolLayerV2::startRender ( QgsSymbolV2RenderContext& context )
192
+ {
193
+ mOffsetExpression = expression ( " offset" );
194
+ mHorizontalAnchorExpression = expression ( " horizontal_anchor_point" );
195
+ mVerticalAnchorExpression = expression ( " vertical_anchor_point" );
196
+ }
197
+
188
198
void QgsMarkerSymbolLayerV2::drawPreviewIcon ( QgsSymbolV2RenderContext& context, QSize size )
189
199
{
190
200
startRender ( context );
@@ -210,10 +220,9 @@ void QgsMarkerSymbolLayerV2::markerOffset( const QgsSymbolV2RenderContext& conte
210
220
offsetX = mOffset .x ();
211
221
offsetY = mOffset .y ();
212
222
213
- QgsExpression* offsetExpression = expression ( " offset" );
214
- if ( offsetExpression )
223
+ if ( mOffsetExpression )
215
224
{
216
- QPointF offset = QgsSymbolLayerV2Utils::decodePoint ( offsetExpression ->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toString () );
225
+ QPointF offset = QgsSymbolLayerV2Utils::decodePoint ( mOffsetExpression ->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toString () );
217
226
offsetX = offset.x ();
218
227
offsetY = offset.y ();
219
228
}
@@ -223,15 +232,13 @@ void QgsMarkerSymbolLayerV2::markerOffset( const QgsSymbolV2RenderContext& conte
223
232
224
233
HorizontalAnchorPoint horizontalAnchorPoint = mHorizontalAnchorPoint ;
225
234
VerticalAnchorPoint verticalAnchorPoint = mVerticalAnchorPoint ;
226
- QgsExpression* horizontalAnchorExpression = expression ( " horizontal_anchor_point" );
227
- if ( horizontalAnchorExpression )
235
+ if ( mHorizontalAnchorExpression )
228
236
{
229
- horizontalAnchorPoint = decodeHorizontalAnchorPoint ( horizontalAnchorExpression ->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toString () );
237
+ horizontalAnchorPoint = decodeHorizontalAnchorPoint ( mHorizontalAnchorExpression ->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toString () );
230
238
}
231
- QgsExpression* verticalAnchorExpression = expression ( " vertical_anchor_point" );
232
- if ( verticalAnchorExpression )
239
+ if ( mVerticalAnchorExpression )
233
240
{
234
- verticalAnchorPoint = decodeVerticalAnchorPoint ( verticalAnchorExpression ->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toString () );
241
+ verticalAnchorPoint = decodeVerticalAnchorPoint ( mVerticalAnchorExpression ->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toString () );
235
242
}
236
243
237
244
// correct horizontal position according to anchor point
0 commit comments