Skip to content

Commit e1dd79d

Browse files
committed
Complete data defined symbology for simple line symbol layer
1 parent f11eeeb commit e1dd79d

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

src/core/symbology-ng/qgslinesymbollayerv2.cpp

+36-2
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,48 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
342342
mPen.setColor( QColor( mStrokeColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
343343
}
344344

345+
//offset
346+
double offset = mOffset;
347+
if ( mLineOffsetExpression )
348+
{
349+
offset = mLineOffsetExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
350+
}
351+
352+
//dash dot vector
353+
if ( mDashPatternExpression )
354+
{
355+
QVector<qreal> dashVector;
356+
QStringList dashList = mDashPatternExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString().split( ";" );
357+
QStringList::const_iterator dashIt = dashList.constBegin();
358+
for ( ; dashIt != dashList.constEnd(); ++dashIt )
359+
{
360+
dashVector.push_back( dashIt->toDouble() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit ) / mPen.widthF() );
361+
}
362+
mPen.setDashPattern( dashVector );
363+
}
364+
365+
//join style
366+
if ( mJoinStyleExpression )
367+
{
368+
QString joinStyleString = mJoinStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
369+
mPen.setJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( joinStyleString ) );
370+
}
371+
372+
//cap style
373+
if ( mCapStyleExpression )
374+
{
375+
QString capStyleString = mCapStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
376+
mPen.setCapStyle( QgsSymbolLayerV2Utils::decodePenCapStyle( capStyleString ) );
377+
}
345378
p->setPen( context.selected() ? mSelPen : mPen );
346-
if ( mOffset == 0 )
379+
380+
if ( offset == 0 )
347381
{
348382
p->drawPolyline( points );
349383
}
350384
else
351385
{
352-
double scaledOffset = mOffset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
386+
double scaledOffset = offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
353387
p->drawPolyline( ::offsetLine( points, scaledOffset ) );
354388
}
355389
}

0 commit comments

Comments
 (0)