Skip to content
Permalink
Browse files
Move decodeBlendMode to QgsSymbolLayerV2Utils
  • Loading branch information
nyalldawson committed Jul 4, 2014
1 parent c7175cf commit 3187410e1eb069144a3fac65d386afeee1998fbb
@@ -59,6 +59,8 @@ class QgsSymbolLayerV2Utils

static QString encodeScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
static QgsSymbolV2::ScaleMethod decodeScaleMethod( QString str );

static QPainter::CompositionMode decodeBlendMode( const QString& s );

static QIcon symbolPreviewIcon( QgsSymbolV2* symbol, QSize size );
static QIcon symbolLayerPreviewIcon( QgsSymbolLayerV2* layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale& scale = QgsMapUnitScale() );
@@ -654,23 +654,6 @@ static QgsPalLayerSettings::SizeUnit _decodeUnits( const QString& str )
return QgsPalLayerSettings::MM; // "MM"
}

static QPainter::CompositionMode _decodeBlendMode( const QString& str )
{
if ( str.compare( "Lighten", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Lighten;
if ( str.compare( "Screen", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Screen;
if ( str.compare( "Dodge", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_ColorDodge;
if ( str.compare( "Addition", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Plus;
if ( str.compare( "Darken", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Darken;
if ( str.compare( "Multiply", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Multiply;
if ( str.compare( "Burn", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_ColorBurn;
if ( str.compare( "Overlay", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Overlay;
if ( str.compare( "SoftLight", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_SoftLight;
if ( str.compare( "HardLight", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_HardLight;
if ( str.compare( "Difference", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Difference;
if ( str.compare( "Subtract", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Exclusion;
return QPainter::CompositionMode_SourceOver; // "Normal"
}

static Qt::PenJoinStyle _decodePenJoinStyle( const QString& str )
{
if ( str.compare( "Miter", Qt::CaseInsensitive ) == 0 ) return Qt::MiterJoin;
@@ -2483,7 +2466,7 @@ bool QgsPalLayerSettings::dataDefinedValEval( const QString& valType,

if ( !blendstr.isEmpty() )
{
dataDefinedValues.insert( p, QVariant(( int )_decodeBlendMode( blendstr ) ) );
dataDefinedValues.insert( p, QVariant(( int )QgsSymbolLayerV2Utils::decodeBlendMode( blendstr ) ) );
return true;
}
}
@@ -499,6 +499,23 @@ QgsSymbolV2::ScaleMethod QgsSymbolLayerV2Utils::decodeScaleMethod( QString str )
return scaleMethod;
}

QPainter::CompositionMode QgsSymbolLayerV2Utils::decodeBlendMode( const QString &s )
{
if ( s.compare( "Lighten", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Lighten;
if ( s.compare( "Screen", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Screen;
if ( s.compare( "Dodge", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_ColorDodge;
if ( s.compare( "Addition", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Plus;
if ( s.compare( "Darken", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Darken;
if ( s.compare( "Multiply", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Multiply;
if ( s.compare( "Burn", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_ColorBurn;
if ( s.compare( "Overlay", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Overlay;
if ( s.compare( "SoftLight", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_SoftLight;
if ( s.compare( "HardLight", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_HardLight;
if ( s.compare( "Difference", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Difference;
if ( s.compare( "Subtract", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Exclusion;
return QPainter::CompositionMode_SourceOver; // "Normal"
}

QIcon QgsSymbolLayerV2Utils::symbolPreviewIcon( QgsSymbolV2* symbol, QSize size )
{
return QIcon( symbolPreviewPixmap( symbol, size ) );
@@ -22,6 +22,7 @@
#include <QtCore>
#include <QFont>
#include <QColor>
#include <QPainter>
#include "qgssymbolv2.h"
#include "qgis.h"
#include "qgsmapunitscale.h"
@@ -98,6 +99,8 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
static QString encodeScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
static QgsSymbolV2::ScaleMethod decodeScaleMethod( QString str );

static QPainter::CompositionMode decodeBlendMode( const QString& s );

static QIcon symbolPreviewIcon( QgsSymbolV2* symbol, QSize size );
static QIcon symbolLayerPreviewIcon( QgsSymbolLayerV2* layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale& scale = QgsMapUnitScale() );
static QIcon colorRampPreviewIcon( QgsVectorColorRampV2* ramp, QSize size );

0 comments on commit 3187410

Please sign in to comment.