Skip to content
Permalink
Browse files

Complete data defined symbology for simple line symbol layer

  • Loading branch information
mhugent committed Mar 27, 2013
1 parent f11eeeb commit e1dd79d7a3fd07b9f9153ec5d110ac3852e2c47b
Showing with 36 additions and 2 deletions.
  1. +36 −2 src/core/symbology-ng/qgslinesymbollayerv2.cpp
@@ -342,14 +342,48 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
mPen.setColor( QColor( mStrokeColorExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString() ) );
}

//offset
double offset = mOffset;
if ( mLineOffsetExpression )
{
offset = mLineOffsetExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toDouble();
}

//dash dot vector
if ( mDashPatternExpression )
{
QVector<qreal> dashVector;
QStringList dashList = mDashPatternExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString().split( ";" );
QStringList::const_iterator dashIt = dashList.constBegin();
for ( ; dashIt != dashList.constEnd(); ++dashIt )
{
dashVector.push_back( dashIt->toDouble() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit ) / mPen.widthF() );
}
mPen.setDashPattern( dashVector );
}

//join style
if ( mJoinStyleExpression )
{
QString joinStyleString = mJoinStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
mPen.setJoinStyle( QgsSymbolLayerV2Utils::decodePenJoinStyle( joinStyleString ) );
}

//cap style
if ( mCapStyleExpression )
{
QString capStyleString = mCapStyleExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString();
mPen.setCapStyle( QgsSymbolLayerV2Utils::decodePenCapStyle( capStyleString ) );
}
p->setPen( context.selected() ? mSelPen : mPen );
if ( mOffset == 0 )

if ( offset == 0 )
{
p->drawPolyline( points );
}
else
{
double scaledOffset = mOffset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
double scaledOffset = offset * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mOffsetUnit );
p->drawPolyline( ::offsetLine( points, scaledOffset ) );
}
}

0 comments on commit e1dd79d

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