Skip to content

Commit

Permalink
Add blendmodes
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 21, 2024
1 parent e9112ba commit e8b3d1c
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 1 deletion.
16 changes: 16 additions & 0 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8554,6 +8554,18 @@
QgsPainting.BlendMode.BlendXor = Qgis.BlendMode.Xor
QgsPainting.BlendXor.is_monkey_patched = True
QgsPainting.BlendXor.__doc__ = "XOR"
QgsPainting.Nonseparable_Hue = Qgis.BlendMode.Nonseparable_Hue
QgsPainting.Nonseparable_Hue.is_monkey_patched = True
QgsPainting.Nonseparable_Hue.__doc__ = "Nonseparable Hue"
QgsPainting.Nonseparable_Saturation = Qgis.BlendMode.Nonseparable_Saturation
QgsPainting.Nonseparable_Saturation.is_monkey_patched = True
QgsPainting.Nonseparable_Saturation.__doc__ = "Nonseparable Saturation"
QgsPainting.Nonseparable_Color = Qgis.BlendMode.Nonseparable_Color
QgsPainting.Nonseparable_Color.is_monkey_patched = True
QgsPainting.Nonseparable_Color.__doc__ = "Nonseparable Color"
QgsPainting.Nonseparable_Luminosity = Qgis.BlendMode.Nonseparable_Luminosity
QgsPainting.Nonseparable_Luminosity.is_monkey_patched = True
QgsPainting.Nonseparable_Luminosity.__doc__ = "Nonseparable Luminosity"
Qgis.BlendMode.__doc__ = """Blending modes defining the available composition modes that can
be used when painting.

Expand Down Expand Up @@ -8659,6 +8671,10 @@

Available as ``QgsPainting.BlendXor`` in older QGIS releases.

* ``Nonseparable_Hue``: Nonseparable Hue
* ``Nonseparable_Saturation``: Nonseparable Saturation
* ``Nonseparable_Color``: Nonseparable Color
* ``Nonseparable_Luminosity``: Nonseparable Luminosity

"""
# --
Expand Down
4 changes: 4 additions & 0 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -2635,6 +2635,10 @@ The development version
SourceAtop,
DestinationAtop,
Xor,
Nonseparable_Hue,
Nonseparable_Saturation,
Nonseparable_Color,
Nonseparable_Luminosity
};

enum class SystemOfMeasurement /BaseType=IntEnum/
Expand Down
16 changes: 16 additions & 0 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8476,6 +8476,18 @@
QgsPainting.BlendMode.BlendXor = Qgis.BlendMode.Xor
QgsPainting.BlendXor.is_monkey_patched = True
QgsPainting.BlendXor.__doc__ = "XOR"
QgsPainting.Nonseparable_Hue = Qgis.BlendMode.Nonseparable_Hue
QgsPainting.Nonseparable_Hue.is_monkey_patched = True
QgsPainting.Nonseparable_Hue.__doc__ = "Nonseparable Hue"
QgsPainting.Nonseparable_Saturation = Qgis.BlendMode.Nonseparable_Saturation
QgsPainting.Nonseparable_Saturation.is_monkey_patched = True
QgsPainting.Nonseparable_Saturation.__doc__ = "Nonseparable Saturation"
QgsPainting.Nonseparable_Color = Qgis.BlendMode.Nonseparable_Color
QgsPainting.Nonseparable_Color.is_monkey_patched = True
QgsPainting.Nonseparable_Color.__doc__ = "Nonseparable Color"
QgsPainting.Nonseparable_Luminosity = Qgis.BlendMode.Nonseparable_Luminosity
QgsPainting.Nonseparable_Luminosity.is_monkey_patched = True
QgsPainting.Nonseparable_Luminosity.__doc__ = "Nonseparable Luminosity"
Qgis.BlendMode.__doc__ = """Blending modes defining the available composition modes that can
be used when painting.

Expand Down Expand Up @@ -8581,6 +8593,10 @@

Available as ``QgsPainting.BlendXor`` in older QGIS releases.

* ``Nonseparable_Hue``: Nonseparable Hue
* ``Nonseparable_Saturation``: Nonseparable Saturation
* ``Nonseparable_Color``: Nonseparable Color
* ``Nonseparable_Luminosity``: Nonseparable Luminosity

"""
# --
Expand Down
4 changes: 4 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -2635,6 +2635,10 @@ The development version
SourceAtop,
DestinationAtop,
Xor,
Nonseparable_Hue,
Nonseparable_Saturation,
Nonseparable_Color,
Nonseparable_Luminosity
};

enum class SystemOfMeasurement
Expand Down
20 changes: 20 additions & 0 deletions src/core/painting/qgspainting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ QPainter::CompositionMode QgsPainting::getCompositionMode( Qgis::BlendMode blend
return QPainter::CompositionMode_DestinationAtop;
case Qgis::BlendMode::Xor:
return QPainter::CompositionMode_Xor;
case Qgis::BlendMode::Nonseparable_Hue:
return QPainter::CompositionMode_Nonseparable_Hue;
case Qgis::BlendMode::Nonseparable_Saturation:
return QPainter::CompositionMode_Nonseparable_Saturation;
case Qgis::BlendMode::Nonseparable_Color:
return QPainter::CompositionMode_Nonseparable_Color;
case Qgis::BlendMode::Nonseparable_Luminosity:
return QPainter::CompositionMode_Nonseparable_Luminosity;
default:
QgsDebugError( QStringLiteral( "Blend mode %1 mapped to SourceOver" ).arg( qgsEnumValueToKey( blendMode ) ) );
return QPainter::CompositionMode_SourceOver;
Expand Down Expand Up @@ -134,6 +142,14 @@ Qgis::BlendMode QgsPainting::getBlendModeEnum( QPainter::CompositionMode blendMo
return Qgis::BlendMode::DestinationAtop;
case QPainter::CompositionMode_Xor:
return Qgis::BlendMode::Xor;
case QPainter::CompositionMode_Nonseparable_Hue:
return Qgis::BlendMode::Nonseparable_Hue;
case QPainter::CompositionMode_Nonseparable_Saturation:
return Qgis::BlendMode::Nonseparable_Saturation;
case QPainter::CompositionMode_Nonseparable_Color:
return Qgis::BlendMode::Nonseparable_Color;
case QPainter::CompositionMode_Nonseparable_Luminosity:
return Qgis::BlendMode::Nonseparable_Luminosity;
default:
QgsDebugError( QStringLiteral( "Composition mode %1 mapped to Normal" ).arg( blendMode ) );
return Qgis::BlendMode::Normal;
Expand Down Expand Up @@ -161,6 +177,10 @@ bool QgsPainting::isClippingMode( Qgis::BlendMode mode )
case Qgis::BlendMode::DestinationOver:
case Qgis::BlendMode::Clear:
case Qgis::BlendMode::Destination:
case Qgis::BlendMode::Nonseparable_Hue:
case Qgis::BlendMode::Nonseparable_Saturation:
case Qgis::BlendMode::Nonseparable_Color:
case Qgis::BlendMode::Nonseparable_Luminosity;
return false;

case Qgis::BlendMode::SourceIn:
Expand Down
4 changes: 4 additions & 0 deletions src/core/qgis.h
Original file line number Diff line number Diff line change
Expand Up @@ -4679,6 +4679,10 @@ class CORE_EXPORT Qgis
SourceAtop SIP_MONKEYPATCH_COMPAT_NAME( BlendSourceAtop ), //!< Source atop
DestinationAtop SIP_MONKEYPATCH_COMPAT_NAME( BlendDestinationAtop ), //!< Destination atop
Xor SIP_MONKEYPATCH_COMPAT_NAME( BlendXor ), //!< XOR
Nonseparable_Hue, //!< Nonseparable Hue
Nonseparable_Saturation, //!< Nonseparable Saturation
Nonseparable_Color, //!< Nonseparable Color
Nonseparable_Luminosity //!< Nonseparable Luminosity
};
Q_ENUM( BlendMode )

Expand Down
3 changes: 2 additions & 1 deletion src/core/qgsproperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString
mTypes = DataTypeString;
mHelpText = trString() + QStringLiteral( "[<b>Normal</b>|<b>Lighten</b>|<b>Screen</b>|<b>Dodge</b>|<br>"
"<b>Addition</b>|<b>Darken</b>|<b>Multiply</b>|<b>Burn</b>|<b>Overlay</b>|<br>"
"<b>SoftLight</b>|<b>HardLight</b>|<b>Difference</b>|<b>Subtract</b>]" );
"<b>SoftLight</b>|<b>HardLight</b>|<b>Difference</b>|<b>Subtract</b><br>]"
"<b>Nonseparable_Hue</b>|<b>Nonseparable_Saturation</b>|<b>Nonseparable_Color</b>|<b>Nonseparable_Luminosity</b>]" );
break;

case Point:
Expand Down
4 changes: 4 additions & 0 deletions src/core/symbology/qgssymbollayerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,10 @@ QPainter::CompositionMode QgsSymbolLayerUtils::decodeBlendMode( const QString &s
if ( s.compare( QLatin1String( "HardLight" ), Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_HardLight;
if ( s.compare( QLatin1String( "Difference" ), Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Difference;
if ( s.compare( QLatin1String( "Subtract" ), Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Exclusion;
if ( s.compare( QLatin1String( "Nonseparable_Hue" ), Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Nonseparable_Hue;
if ( s.compare( QLatin1String( "Nonseparable_Saturation" ), Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Nonseparable_Saturation;
if ( s.compare( QLatin1String( "Nonseparable_Color" ), Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Nonseparable_Color;
if ( s.compare( QLatin1String( "Nonseparable_Luminosity" ), Qt::CaseInsensitive ) == 0 ) return QPainter::CompositionMode_Nonseparable_Luminosity;
return QPainter::CompositionMode_SourceOver; // "Normal"
}

Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsblendmodecombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ void QgsBlendModeComboBox::updateModes()
insertSeparator( count() );
addItem( tr( "Difference" ), static_cast<int>( Qgis::BlendMode::Difference ) );
addItem( tr( "Subtract" ), static_cast<int>( Qgis::BlendMode::Subtract ) );
insertSeparator( count() );
addItem( tr( "Nonseparable Hue" ), static_cast<int>( Qgis::BlendMode::Nonseparable_Hue ) );
addItem( tr( "Nonseparable Saturation" ), static_cast<int>( Qgis::BlendMode::Nonseparable_Saturation ) );
addItem( tr( "Nonseparable Color" ), static_cast<int>( Qgis::BlendMode::Nonseparable_Color ) );
addItem( tr( "Nonseparable Luminosity" ), static_cast<int>( Qgis::BlendMode::Nonseparable_Luminosity ) );

if ( mShowClipModes )
{
Expand Down

0 comments on commit e8b3d1c

Please sign in to comment.