Skip to content
Permalink
Browse files

#9254: Support for OutlineStyle in SLD files

  • Loading branch information
ahuarte47 committed Jan 2, 2014
1 parent 8a1d769 commit 4f6c9cdee7ddb80cbb2187d58427b0f14a776591
@@ -112,10 +112,10 @@ class QgsSymbolLayerV2Utils
QColor &color, double &size );

static void wellKnownMarkerToSld( QDomDocument &doc, QDomElement &element,
QString name, QColor color, QColor borderColor = QColor(),
QString name, QColor color, QColor borderColor = QColor(), Qt::PenStyle borderStyle = Qt::SolidLine,
double borderWidth = -1, double size = -1 );
static bool wellKnownMarkerFromSld( QDomElement &element,
QString &name, QColor &color, QColor &borderColor,
QString &name, QColor &color, QColor &borderColor, Qt::PenStyle &borderStyle,
double &borderWidth, double &size );

static void externalMarkerToSld( QDomDocument &doc, QDomElement &element,
@@ -301,7 +301,7 @@ void QgsEllipseSymbolLayerV2::writeSldMarker( QDomDocument &doc, QDomElement &el
QDomElement graphicElem = doc.createElement( "se:Graphic" );
element.appendChild( graphicElem );

QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, mSymbolName, mFillColor, mOutlineColor, mOutlineWidth, mSymbolWidth );
QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, mSymbolName, mFillColor, mOutlineColor, mOutlineStyle, mOutlineWidth, mSymbolWidth );

// store w/h factor in a <VendorOption>
double widthHeightFactor = mSymbolWidth / mSymbolHeight;
@@ -356,6 +356,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::createFromSld( QDomElement &element )
QColor fillColor, borderColor;
double borderWidth, size;
double widthHeightFactor = 1.0;
Qt::PenStyle borderStyle;

QgsStringMap vendorOptions = QgsSymbolLayerV2Utils::getVendorOptionList( graphicElem );
for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
@@ -369,7 +370,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::createFromSld( QDomElement &element )
}
}

if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderWidth, size ) )
if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderStyle, borderWidth, size ) )
return NULL;

double angle = 0.0;
@@ -386,6 +387,7 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::createFromSld( QDomElement &element )
m->setSymbolName( name );
m->setFillColor( fillColor );
m->setOutlineColor( borderColor );
m->setOutlineStyle( borderStyle );
m->setOutlineWidth( borderWidth );
m->setSymbolWidth( size );
m->setSymbolHeight( size / widthHeightFactor );
@@ -1597,7 +1597,7 @@ void QgsLinePatternFillSymbolLayer::toSld( QDomDocument &doc, QDomElement &eleme
QDomElement graphicElem = doc.createElement( "se:Graphic" );
graphicFillElem.appendChild( graphicElem );

QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, "horline", QColor(), mColor, mLineWidth, mDistance );
QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, "horline", QColor(), mColor, Qt::SolidLine, mLineWidth, mDistance );

// <Rotation>
QString angleFunc;
@@ -1682,6 +1682,7 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::createFromSld( QDomElement &ele
QString name;
QColor fillColor, lineColor;
double size, lineWidth;
Qt::PenStyle lineStyle;

QDomElement fillElem = element.firstChildElement( "Fill" );
if ( fillElem.isNull() )
@@ -1695,7 +1696,7 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::createFromSld( QDomElement &ele
if ( graphicElem.isNull() )
return NULL;

if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, lineColor, lineWidth, size ) )
if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, fillColor, lineColor, lineStyle, lineWidth, size ) )
return NULL;

if ( name != "horline" )
@@ -605,7 +605,7 @@ void QgsSimpleMarkerSymbolLayerV2::writeSldMarker( QDomDocument &doc, QDomElemen
QDomElement graphicElem = doc.createElement( "se:Graphic" );
element.appendChild( graphicElem );

QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, mName, mColor, mBorderColor, -1, mSize );
QgsSymbolLayerV2Utils::wellKnownMarkerToSld( doc, graphicElem, mName, mColor, mBorderColor, mOutlineStyle, mOutlineWidth, mSize );

// <Rotation>
QString angleFunc;
@@ -698,8 +698,9 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::createFromSld( QDomElement &elem
QString name = "square";
QColor color, borderColor;
double borderWidth, size;
Qt::PenStyle borderStyle;

if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, color, borderColor, borderWidth, size ) )
if ( !QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( graphicElem, name, color, borderColor, borderStyle, borderWidth, size ) )
return NULL;

double angle = 0.0;
@@ -715,9 +716,10 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::createFromSld( QDomElement &elem
QPointF offset;
QgsSymbolLayerV2Utils::displacementFromSldElement( graphicElem, offset );

QgsMarkerSymbolLayerV2 *m = new QgsSimpleMarkerSymbolLayerV2( name, color, borderColor, size );
QgsSimpleMarkerSymbolLayerV2 *m = new QgsSimpleMarkerSymbolLayerV2( name, color, borderColor, size );
m->setAngle( angle );
m->setOffset( offset );
m->setOutlineStyle( borderStyle );
return m;
}

@@ -1180,7 +1180,8 @@ bool QgsSymbolLayerV2Utils::needLinePatternFill( QDomElement &element )
QString name;
QColor fillColor, borderColor;
double size, borderWidth;
if ( !wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderWidth, size ) )
Qt::PenStyle borderStyle;
if ( !wellKnownMarkerFromSld( graphicElem, name, fillColor, borderColor, borderStyle, borderWidth, size ) )
return false;

if ( name != "horline" )
@@ -1561,7 +1562,8 @@ bool QgsSymbolLayerV2Utils::fillFromSld( QDomElement &element, Qt::BrushStyle &b
QString patternName = "square";
QColor fillColor, borderColor;
double borderWidth, size;
if ( !wellKnownMarkerFromSld( graphicElem, patternName, fillColor, borderColor, borderWidth, size ) )
Qt::PenStyle borderStyle;
if ( !wellKnownMarkerFromSld( graphicElem, patternName, fillColor, borderColor, borderStyle, borderWidth, size ) )
return false;

brushStyle = decodeSldBrushStyle( patternName );
@@ -1904,7 +1906,7 @@ bool QgsSymbolLayerV2Utils::externalMarkerFromSld( QDomElement &element,
}

void QgsSymbolLayerV2Utils::wellKnownMarkerToSld( QDomDocument &doc, QDomElement &element,
QString name, QColor color, QColor borderColor,
QString name, QColor color, QColor borderColor, Qt::PenStyle borderStyle,
double borderWidth, double size )
{
QDomElement markElem = doc.createElement( "se:Mark" );
@@ -1926,7 +1928,7 @@ void QgsSymbolLayerV2Utils::wellKnownMarkerToSld( QDomDocument &doc, QDomElement
if ( borderColor.isValid() )
{
QDomElement strokeElem = doc.createElement( "se:Stroke" );
lineToSld( doc, strokeElem, Qt::SolidLine, borderColor, borderWidth );
lineToSld( doc, strokeElem, borderStyle, borderColor, borderWidth );
markElem.appendChild( strokeElem );
}

@@ -1940,7 +1942,7 @@ void QgsSymbolLayerV2Utils::wellKnownMarkerToSld( QDomDocument &doc, QDomElement
}

bool QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( QDomElement &element,
QString &name, QColor &color, QColor &borderColor,
QString &name, QColor &color, QColor &borderColor, Qt::PenStyle &borderStyle,
double &borderWidth, double &size )
{
QgsDebugMsg( "Entered." );
@@ -1970,8 +1972,7 @@ bool QgsSymbolLayerV2Utils::wellKnownMarkerFromSld( QDomElement &element,

// <Stroke>
QDomElement strokeElem = markElem.firstChildElement( "Stroke" );
Qt::PenStyle p = Qt::SolidLine;
lineFromSld( strokeElem, p, borderColor, borderWidth );
lineFromSld( strokeElem, borderStyle, borderColor, borderWidth );
// ignore border style, solid expected

// <Size>
@@ -147,10 +147,10 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
QColor &color, double &size );

static void wellKnownMarkerToSld( QDomDocument &doc, QDomElement &element,
QString name, QColor color, QColor borderColor = QColor(),
QString name, QColor color, QColor borderColor = QColor(), Qt::PenStyle borderStyle = Qt::SolidLine,
double borderWidth = -1, double size = -1 );
static bool wellKnownMarkerFromSld( QDomElement &element,
QString &name, QColor &color, QColor &borderColor,
QString &name, QColor &color, QColor &borderColor, Qt::PenStyle &borderStyle,
double &borderWidth, double &size );

static void externalMarkerToSld( QDomDocument &doc, QDomElement &element,

0 comments on commit 4f6c9cd

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