Skip to content

Commit 7fef39e

Browse files
committedDec 23, 2012
Feature style for simple fill
1 parent d9c7991 commit 7fef39e

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
 

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ void QgsSimpleFillSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
175175
QgsSymbolLayerV2Utils::createDisplacementElement( doc, symbolizerElem, mOffset );
176176
}
177177

178+
QString QgsSimpleFillSymbolLayerV2::ogrFeatureStyle( double widthScaleFactor ) const
179+
{
180+
//brush
181+
QString symbolStyle;
182+
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStyleBrush( mColor ) );
183+
symbolStyle.append( ";" );
184+
//pen
185+
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStylePen( mBorderWidth * widthScaleFactor, mBorderColor ) );
186+
return symbolStyle;
187+
}
188+
178189
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::createFromSld( QDomElement &element )
179190
{
180191
QgsDebugMsg( "Entered." );

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
5757

5858
void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
5959

60+
QString ogrFeatureStyle( double widthScaleFactor ) const;
61+
6062
Qt::BrushStyle brushStyle() const { return mBrushStyle; }
6163
void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; }
6264

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,29 @@ void QgsSymbolLayerV2Utils::labelTextToSld( QDomDocument &doc, QDomElement &elem
20952095
}
20962096
}
20972097

2098+
QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, const QColor& c )
2099+
{
2100+
QString penStyle;
2101+
penStyle.append( "PEN(" );
2102+
penStyle.append( "c:" );
2103+
penStyle.append( c.name() );
2104+
penStyle.append( ",w:" );
2105+
//dxf driver writes ground units as mm? Should probably be changed in ogr
2106+
penStyle.append( QString::number( width ) );
2107+
penStyle.append( "mm" );
2108+
return penStyle;
2109+
}
2110+
2111+
QString QgsSymbolLayerV2Utils::ogrFeatureStyleBrush( const QColor& fillColor )
2112+
{
2113+
QString brushStyle;
2114+
brushStyle.append( "BRUSH(" );
2115+
brushStyle.append( "fc:" );
2116+
brushStyle.append( fillColor.name() );
2117+
brushStyle.append( ")" );
2118+
return brushStyle;
2119+
}
2120+
20982121
void QgsSymbolLayerV2Utils::createGeometryElement( QDomDocument &doc, QDomElement &element, QString geomFunc )
20992122
{
21002123
if ( geomFunc.isEmpty() )

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
164164
static void labelTextToSld( QDomDocument &doc, QDomElement &element, QString label,
165165
QFont font, QColor color = QColor(), double size = -1 );
166166

167+
/**Create ogr feature style string for pen
168+
@param width linewidth in mm
169+
@param c line color*/
170+
static QString ogrFeatureStylePen( double width, const QColor& c );
171+
/**Create ogr feature syle string for brush
172+
@param fillColr fill color*/
173+
static QString ogrFeatureStyleBrush( const QColor& fillColr );
174+
167175
static void createRotationElement( QDomDocument &doc, QDomElement &element, QString rotationFunc );
168176
static bool rotationFromSldElement( QDomElement &element, QString &rotationFunc );
169177

0 commit comments

Comments
 (0)
Please sign in to comment.