Skip to content
Permalink
Browse files
Add custom dash dot pattern to symbol layer utils function
  • Loading branch information
mhugent committed Dec 25, 2012
1 parent 5327da9 commit 22731aa826b6c39e4bf7f3a622731dcd5d14333b
@@ -182,7 +182,7 @@ QString QgsSimpleFillSymbolLayerV2::ogrFeatureStyle( double widthScaleFactor ) c
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStyleBrush( mColor ) );
symbolStyle.append( ";" );
//pen
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStylePen( mBorderWidth * widthScaleFactor, mBorderColor ) );
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStylePen( mBorderWidth, widthScaleFactor, mBorderColor ) );
return symbolStyle;
}

@@ -197,36 +197,14 @@ void QgsSimpleLineSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,

QString QgsSimpleLineSymbolLayerV2::ogrFeatureStyle( double widthScaleFactor ) const
{
QString symbolStyle;

//pen
symbolStyle.append( "PEN(" );
symbolStyle.append( "c:" );
symbolStyle.append( mPen.color().name() );
symbolStyle.append( ",w:" );
//dxf driver writes ground units as mm? Should probably be changed in ogr
symbolStyle.append( QString::number( mWidth * widthScaleFactor ) );
symbolStyle.append( "mm" );

//dash dot vector
if ( mUseCustomDashPattern && mCustomDashVector.size() > 0 )
{
symbolStyle.append( ",p:\"" );
QVector<qreal>::const_iterator pIt = mCustomDashVector.constBegin();
for ( ; pIt != mCustomDashVector.constEnd(); ++pIt )
if( mUseCustomDashPattern )
{
if ( pIt != mCustomDashVector.constBegin() )
{
symbolStyle.append( " " );
}
symbolStyle.append( QString::number( *pIt * widthScaleFactor ) );
symbolStyle.append( "mm" );
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor, mPen.color(), &mCustomDashVector );
}
else
{
return QgsSymbolLayerV2Utils::ogrFeatureStylePen( mWidth, widthScaleFactor, mPen.color() );
}
symbolStyle.append( "\"" );
}
symbolStyle.append( ")" );

return symbolStyle;
}

QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::createFromSld( QDomElement &element )
@@ -2095,16 +2095,35 @@ void QgsSymbolLayerV2Utils::labelTextToSld( QDomDocument &doc, QDomElement &elem
}
}

QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, const QColor& c )
QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c, const QVector<qreal>* dashPattern )
{
QString penStyle;
penStyle.append( "PEN(" );
penStyle.append( "c:" );
penStyle.append( c.name() );
penStyle.append( ",w:" );
//dxf driver writes ground units as mm? Should probably be changed in ogr
penStyle.append( QString::number( width ) );
penStyle.append( QString::number( width * widthScaleFactor ) );
penStyle.append( "mm" );

//dash dot vector
if ( dashPattern && dashPattern->size() > 0 )
{
penStyle.append( ",p:\"" );
QVector<qreal>::const_iterator pIt = dashPattern->constBegin();
for ( ; pIt != dashPattern->constEnd(); ++pIt )
{
if ( pIt != dashPattern->constBegin() )
{
penStyle.append( " " );
}
penStyle.append( QString::number( *pIt * widthScaleFactor ) );
penStyle.append( "mm" );
}
penStyle.append( "\"" );
}

penStyle.append( ")" );
return penStyle;
}

@@ -167,7 +167,7 @@ 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, const QColor& c );
static QString ogrFeatureStylePen( double width, double widthScaleFactor, const QColor& c, 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 22731aa

Please sign in to comment.