Skip to content

Commit faf0abb

Browse files
committedDec 25, 2012
Write pen cap and join style to ogr pen
1 parent 22731aa commit faf0abb

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed
 

‎src/core/symbology-ng/qgslinesymbollayerv2.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,16 @@ void QgsSimpleLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
197197

198198
QString QgsSimpleLineSymbolLayerV2::ogrFeatureStyle( double widthScaleFactor ) const
199199
{
200-
if( mUseCustomDashPattern )
201-
{
202-
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor, mPen.color(), &mCustomDashVector );
203-
}
204-
else
205-
{
206-
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor, mPen.color() );
207-
}
200+
if ( mUseCustomDashPattern )
201+
{
202+
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor,
203+
mPen.color(), mPenJoinStyle,
204+
mPenCapStyle, &mCustomDashVector );
205+
}
206+
else
207+
{
208+
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor, mPen.color() );
209+
}
208210
}
209211

210212
QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::createFromSld( QDomElement &element )

‎src/core/symbology-ng/qgssymbollayerv2utils.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,10 @@ void QgsSymbolLayerV2Utils::labelTextToSld( QDomDocument &doc, QDomElement &elem
20952095
}
20962096
}
20972097

2098-
QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c, const QVector<qreal>* dashPattern )
2098+
QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c,
2099+
Qt::PenJoinStyle joinStyle,
2100+
Qt::PenCapStyle capStyle,
2101+
const QVector<qreal>* dashPattern )
20992102
{
21002103
QString penStyle;
21012104
penStyle.append( "PEN(" );
@@ -2123,6 +2126,36 @@ QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, double widthSca
21232126
penStyle.append( "\"" );
21242127
}
21252128

2129+
//cap
2130+
penStyle.append( ",cap=" );
2131+
switch ( capStyle )
2132+
{
2133+
case Qt::SquareCap:
2134+
penStyle.append( "p" );
2135+
break;
2136+
case Qt::RoundCap:
2137+
penStyle.append( "r" );
2138+
break;
2139+
case Qt::FlatCap:
2140+
default:
2141+
penStyle.append( "b" );
2142+
}
2143+
2144+
//join
2145+
penStyle.append( ",j=" );
2146+
switch ( joinStyle )
2147+
{
2148+
case Qt::BevelJoin:
2149+
penStyle.append( "b" );
2150+
break;
2151+
case Qt::RoundJoin:
2152+
penStyle.append( "r" );
2153+
break;
2154+
case Qt::MiterJoin:
2155+
default:
2156+
penStyle.append( "m" );
2157+
}
2158+
21262159
penStyle.append( ")" );
21272160
return penStyle;
21282161
}

‎src/core/symbology-ng/qgssymbollayerv2utils.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
167167
/**Create ogr feature style string for pen
168168
@param width linewidth in mm
169169
@param c line color*/
170-
static QString ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c, const QVector<qreal>* dashPattern = 0 );
170+
static QString ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c,
171+
Qt::PenJoinStyle joinStyle = Qt::MiterJoin,
172+
Qt::PenCapStyle capStyle = Qt::FlatCap,
173+
const QVector<qreal>* dashPattern = 0 );
171174
/**Create ogr feature syle string for brush
172175
@param fillColr fill color*/
173176
static QString ogrFeatureStyleBrush( const QColor& fillColr );

0 commit comments

Comments
 (0)
Please sign in to comment.