Skip to content

Commit

Permalink
Feature style for simple fill
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Dec 23, 2012
1 parent d9c7991 commit 7fef39e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/symbology-ng/qgsfillsymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ void QgsSimpleFillSymbolLayerV2::toSld( QDomDocument &doc, QDomElement &element,
QgsSymbolLayerV2Utils::createDisplacementElement( doc, symbolizerElem, mOffset );
}

QString QgsSimpleFillSymbolLayerV2::ogrFeatureStyle( double widthScaleFactor ) const
{
//brush
QString symbolStyle;
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStyleBrush( mColor ) );
symbolStyle.append( ";" );
//pen
symbolStyle.append( QgsSymbolLayerV2Utils::ogrFeatureStylePen( mBorderWidth * widthScaleFactor, mBorderColor ) );
return symbolStyle;
}

QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::createFromSld( QDomElement &element )
{
QgsDebugMsg( "Entered." );
Expand Down
2 changes: 2 additions & 0 deletions src/core/symbology-ng/qgsfillsymbollayerv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2

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

QString ogrFeatureStyle( double widthScaleFactor ) const;

Qt::BrushStyle brushStyle() const { return mBrushStyle; }
void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; }

Expand Down
23 changes: 23 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,29 @@ void QgsSymbolLayerV2Utils::labelTextToSld( QDomDocument &doc, QDomElement &elem
}
}

QString QgsSymbolLayerV2Utils::ogrFeatureStylePen( double width, const QColor& c )
{
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( "mm" );
return penStyle;
}

QString QgsSymbolLayerV2Utils::ogrFeatureStyleBrush( const QColor& fillColor )
{
QString brushStyle;
brushStyle.append( "BRUSH(" );
brushStyle.append( "fc:" );
brushStyle.append( fillColor.name() );
brushStyle.append( ")" );
return brushStyle;
}

void QgsSymbolLayerV2Utils::createGeometryElement( QDomDocument &doc, QDomElement &element, QString geomFunc )
{
if ( geomFunc.isEmpty() )
Expand Down
8 changes: 8 additions & 0 deletions src/core/symbology-ng/qgssymbollayerv2utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
static void labelTextToSld( QDomDocument &doc, QDomElement &element, QString label,
QFont font, QColor color = QColor(), double size = -1 );

/**Create ogr feature style string for pen
@param width linewidth in mm
@param c line color*/
static QString ogrFeatureStylePen( double width, const QColor& c );
/**Create ogr feature syle string for brush
@param fillColr fill color*/
static QString ogrFeatureStyleBrush( const QColor& fillColr );

static void createRotationElement( QDomDocument &doc, QDomElement &element, QString rotationFunc );
static bool rotationFromSldElement( QDomElement &element, QString &rotationFunc );

Expand Down

0 comments on commit 7fef39e

Please sign in to comment.