Skip to content
Permalink
Browse files
Write pen cap and join style to ogr pen
  • Loading branch information
mhugent committed Dec 25, 2012
1 parent 22731aa commit faf0abbb3bdd1e41f67b1e8360ecff59868b3630
Showing with 48 additions and 10 deletions.
  1. +10 −8 src/core/symbology-ng/qgslinesymbollayerv2.cpp
  2. +34 −1 src/core/symbology-ng/qgssymbollayerv2utils.cpp
  3. +4 −1 src/core/symbology-ng/qgssymbollayerv2utils.h
@@ -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 )
@@ -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(" );
@@ -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;
}
@@ -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 );

0 comments on commit faf0abb

Please sign in to comment.