QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgsblendmodecombobox.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsblendmodecombobox.cpp
3 ------------------------
4 begin : March 21, 2013
5 copyright : (C) 2013 by Nyall Dawson
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgis.h"
20#include "qgspainting.h"
21
22#include <QAbstractItemView>
23#include <QLocale>
24#include <QSettings>
25#include <QLineEdit>
26
28 : QComboBox( parent )
29{
30 setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
32}
33
35{
36 blockSignals( true );
37 clear();
38
39 // This list is designed to emulate GIMP's layer modes, where
40 // blending modes are grouped by their effect (lightening, darkening, etc)
41
42 addItem( tr( "Normal" ), static_cast< int >( Qgis::BlendMode::Normal ) );
43 insertSeparator( count() );
44 addItem( tr( "Lighten" ), static_cast< int >( Qgis::BlendMode::Lighten ) );
45 addItem( tr( "Screen" ), static_cast< int >( Qgis::BlendMode::Screen ) );
46 addItem( tr( "Dodge" ), static_cast< int >( Qgis::BlendMode::Dodge ) );
47 addItem( tr( "Addition" ), static_cast< int >( Qgis::BlendMode::Addition ) );
48 insertSeparator( count() );
49 addItem( tr( "Darken" ), static_cast< int >( Qgis::BlendMode::Darken ) );
50 addItem( tr( "Multiply" ), static_cast< int >( Qgis::BlendMode::Multiply ) );
51 addItem( tr( "Burn" ), static_cast< int >( Qgis::BlendMode::Burn ) );
52 insertSeparator( count() );
53 addItem( tr( "Overlay" ), static_cast< int >( Qgis::BlendMode::Overlay ) );
54 addItem( tr( "Soft Light" ), static_cast< int >( Qgis::BlendMode::SoftLight ) );
55 addItem( tr( "Hard Light" ), static_cast< int >( Qgis::BlendMode::HardLight ) );
56 insertSeparator( count() );
57 addItem( tr( "Difference" ), static_cast< int >( Qgis::BlendMode::Difference ) );
58 addItem( tr( "Subtract" ), static_cast< int >( Qgis::BlendMode::Subtract ) );
59
60 if ( mShowClipModes )
61 {
62 insertSeparator( count() );
63 addItem( tr( "Masked By Below" ), static_cast< int >( Qgis::BlendMode::SourceIn ) );
64 addItem( tr( "Mask Below" ), static_cast< int >( Qgis::BlendMode::DestinationIn ) );
65 addItem( tr( "Inverse Masked By Below" ), static_cast< int >( Qgis::BlendMode::SourceOut ) );
66 addItem( tr( "Inverse Mask Below" ), static_cast< int >( Qgis::BlendMode::DestinationOut ) );
67 addItem( tr( "Paint Inside Below" ), static_cast< int >( Qgis::BlendMode::SourceAtop ) );
68 addItem( tr( "Paint Below Inside" ), static_cast< int >( Qgis::BlendMode::DestinationAtop ) );
69 }
70
71 blockSignals( false );
72}
73
74QPainter::CompositionMode QgsBlendModeComboBox::blendMode()
75{
76 return QgsPainting::getCompositionMode( static_cast< Qgis::BlendMode >( currentData().toInt() ) );
77}
78
79void QgsBlendModeComboBox::setBlendMode( QPainter::CompositionMode blendMode )
80{
81 setCurrentIndex( findData( static_cast< int >( QgsPainting::getBlendModeEnum( blendMode ) ) ) );
82}
83
85{
86 mShowClipModes = show;
87 const QPainter::CompositionMode mode = blendMode();
89
90 setBlendMode( mode );
91}
92
94{
95 return mShowClipModes;
96}
97
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition: qgis.h:2978
void setBlendMode(QPainter::CompositionMode blendMode)
Sets the selected blend mode.
void setShowClippingModes(bool show)
Sets whether composition modes which cause clipping are shown in the combo box.
QgsBlendModeComboBox(QWidget *parent=nullptr)
Constructor for QgsBlendModeComboBox.
void updateModes()
Populates the blend mode combo box, and sets up mapping for blend modes to combo box indexes.
bool showClippingModes() const
Returns true if composition modes which cause clipping are shown in the combo box.
QPainter::CompositionMode blendMode()
Returns the selected blend mode.
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20