Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Write pen cap and join style to ogr pen
  • Loading branch information
mhugent committed Dec 25, 2012
1 parent 22731aa commit faf0abb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/core/symbology-ng/qgslinesymbollayerv2.cpp
Expand Up @@ -197,14 +197,16 @@ void QgsSimpleLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,

QString QgsSimpleLineSymbolLayerV2::ogrFeatureStyle( double widthScaleFactor ) const
{
if( mUseCustomDashPattern )
{
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor, mPen.color(), &mCustomDashVector );
}
else
{
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor, mPen.color() );
}
if ( mUseCustomDashPattern )
{
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor,
mPen.color(), mPenJoinStyle,
mPenCapStyle, &mCustomDashVector );
}
else
{
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor, mPen.color() );
}
}

QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::createFromSld( QDomElement &element )
Expand Down
35 changes: 34 additions & 1 deletion src/core/symbology-ng/qgssymbollayerv2utils.cpp
Expand Up @@ -2095,7 +2095,10 @@ void QgsSymbolLayerV2Utils::labelTextToSld( QDomDocument &doc, QDomElement &elem
}
}

QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c, const QVector<qreal>* dashPattern )
QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c,
Qt::PenJoinStyle joinStyle,
Qt::PenCapStyle capStyle,
const QVector<qreal>* dashPattern )
{
QString penStyle;
penStyle.append( "PEN(" );
Expand Down Expand Up @@ -2123,6 +2126,36 @@ QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, double widthSca
penStyle.append( "\"" );
}

//cap
penStyle.append( ",cap=" );
switch ( capStyle )
{
case Qt::SquareCap:
penStyle.append( "p" );
break;
case Qt::RoundCap:
penStyle.append( "r" );
break;
case Qt::FlatCap:
default:
penStyle.append( "b" );
}

//join
penStyle.append( ",j=" );
switch ( joinStyle )
{
case Qt::BevelJoin:
penStyle.append( "b" );
break;
case Qt::RoundJoin:
penStyle.append( "r" );
break;
case Qt::MiterJoin:
default:
penStyle.append( "m" );
}

penStyle.append( ")" );
return penStyle;
}
Expand Down
5 changes: 4 additions & 1 deletion src/core/symbology-ng/qgssymbollayerv2utils.h
Expand Up @@ -167,7 +167,10 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
/**Create ogr feature style string for pen
@param width linewidth in mm
@param c line color*/
static QString ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c, const QVector<qreal>* dashPattern = 0 );
static QString ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c,
Qt::PenJoinStyle joinStyle = Qt::MiterJoin,
Qt::PenCapStyle capStyle = Qt::FlatCap,
const QVector<qreal>* dashPattern = 0 );
/**Create ogr feature syle string for brush
@param fillColr fill color*/
static QString ogrFeatureStyleBrush( const QColor& fillColr );
Expand Down

0 comments on commit faf0abb

Please sign in to comment.