Skip to content

Commit 3187410

Browse files
committed
Move decodeBlendMode to QgsSymbolLayerV2Utils
1 parent c7175cf commit 3187410

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

python/core/symbology-ng/qgssymbollayerv2utils.sip

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class QgsSymbolLayerV2Utils
5959

6060
static QString encodeScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
6161
static QgsSymbolV2::ScaleMethod decodeScaleMethod( QString str );
62+
63+
static QPainter::CompositionMode decodeBlendMode( const QString& s );
6264

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

src/core/qgspallabeling.cpp

+1-18
Original file line numberDiff line numberDiff line change
@@ -654,23 +654,6 @@ static QgsPalLayerSettings::SizeUnit _decodeUnits( const QString& str )
654654
return QgsPalLayerSettings::MM; // "MM"
655655
}
656656

657-
static QPainter::CompositionMode _decodeBlendMode( const QString& str )
658-
{
659-
if ( str.compare( "Lighten", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Lighten;
660-
if ( str.compare( "Screen", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Screen;
661-
if ( str.compare( "Dodge", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_ColorDodge;
662-
if ( str.compare( "Addition", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Plus;
663-
if ( str.compare( "Darken", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Darken;
664-
if ( str.compare( "Multiply", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Multiply;
665-
if ( str.compare( "Burn", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_ColorBurn;
666-
if ( str.compare( "Overlay", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Overlay;
667-
if ( str.compare( "SoftLight", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_SoftLight;
668-
if ( str.compare( "HardLight", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_HardLight;
669-
if ( str.compare( "Difference", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Difference;
670-
if ( str.compare( "Subtract", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Exclusion;
671-
return QPainter::CompositionMode_SourceOver; // "Normal"
672-
}
673-
674657
static Qt::PenJoinStyle _decodePenJoinStyle( const QString& str )
675658
{
676659
if ( str.compare( "Miter", Qt::CaseInsensitive ) == 0 ) return Qt::MiterJoin;
@@ -2483,7 +2466,7 @@ bool QgsPalLayerSettings::dataDefinedValEval( const QString& valType,
24832466

24842467
if ( !blendstr.isEmpty() )
24852468
{
2486-
dataDefinedValues.insert( p, QVariant(( int )_decodeBlendMode( blendstr ) ) );
2469+
dataDefinedValues.insert( p, QVariant(( int )QgsSymbolLayerV2Utils::decodeBlendMode( blendstr ) ) );
24872470
return true;
24882471
}
24892472
}

src/core/symbology-ng/qgssymbollayerv2utils.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,23 @@ QgsSymbolV2::ScaleMethod QgsSymbolLayerV2Utils::decodeScaleMethod( QString str )
499499
return scaleMethod;
500500
}
501501

502+
QPainter::CompositionMode QgsSymbolLayerV2Utils::decodeBlendMode( const QString &s )
503+
{
504+
if ( s.compare( "Lighten", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Lighten;
505+
if ( s.compare( "Screen", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Screen;
506+
if ( s.compare( "Dodge", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_ColorDodge;
507+
if ( s.compare( "Addition", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Plus;
508+
if ( s.compare( "Darken", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Darken;
509+
if ( s.compare( "Multiply", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Multiply;
510+
if ( s.compare( "Burn", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_ColorBurn;
511+
if ( s.compare( "Overlay", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Overlay;
512+
if ( s.compare( "SoftLight", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_SoftLight;
513+
if ( s.compare( "HardLight", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_HardLight;
514+
if ( s.compare( "Difference", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Difference;
515+
if ( s.compare( "Subtract", Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Exclusion;
516+
return QPainter::CompositionMode_SourceOver; // "Normal"
517+
}
518+
502519
QIcon QgsSymbolLayerV2Utils::symbolPreviewIcon( QgsSymbolV2* symbol, QSize size )
503520
{
504521
return QIcon( symbolPreviewPixmap( symbol, size ) );

src/core/symbology-ng/qgssymbollayerv2utils.h

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <QtCore>
2323
#include <QFont>
2424
#include <QColor>
25+
#include <QPainter>
2526
#include "qgssymbolv2.h"
2627
#include "qgis.h"
2728
#include "qgsmapunitscale.h"
@@ -98,6 +99,8 @@ class CORE_EXPORT QgsSymbolLayerV2Utils
9899
static QString encodeScaleMethod( QgsSymbolV2::ScaleMethod scaleMethod );
99100
static QgsSymbolV2::ScaleMethod decodeScaleMethod( QString str );
100101

102+
static QPainter::CompositionMode decodeBlendMode( const QString& s );
103+
101104
static QIcon symbolPreviewIcon( QgsSymbolV2* symbol, QSize size );
102105
static QIcon symbolLayerPreviewIcon( QgsSymbolLayerV2* layer, QgsSymbolV2::OutputUnit u, QSize size, const QgsMapUnitScale& scale = QgsMapUnitScale() );
103106
static QIcon colorRampPreviewIcon( QgsVectorColorRampV2* ramp, QSize size );

0 commit comments

Comments
 (0)