QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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 "moc_qgsblendmodecombobox.cpp"
21#include "qgspainting.h"
22
23#include <QAbstractItemView>
24#include <QLocale>
25#include <QSettings>
26#include <QLineEdit>
27
29 : QComboBox( parent )
30{
31 setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
33}
34
36{
37 blockSignals( true );
38 clear();
39
40 // This list is designed to emulate GIMP's layer modes, where
41 // blending modes are grouped by their effect (lightening, darkening, etc)
42
43 addItem( tr( "Normal" ), static_cast< int >( Qgis::BlendMode::Normal ) );
44 insertSeparator( count() );
45 addItem( tr( "Lighten" ), static_cast< int >( Qgis::BlendMode::Lighten ) );
46 addItem( tr( "Screen" ), static_cast< int >( Qgis::BlendMode::Screen ) );
47 addItem( tr( "Dodge" ), static_cast< int >( Qgis::BlendMode::Dodge ) );
48 addItem( tr( "Addition" ), static_cast< int >( Qgis::BlendMode::Addition ) );
49 insertSeparator( count() );
50 addItem( tr( "Darken" ), static_cast< int >( Qgis::BlendMode::Darken ) );
51 addItem( tr( "Multiply" ), static_cast< int >( Qgis::BlendMode::Multiply ) );
52 addItem( tr( "Burn" ), static_cast< int >( Qgis::BlendMode::Burn ) );
53 insertSeparator( count() );
54 addItem( tr( "Overlay" ), static_cast< int >( Qgis::BlendMode::Overlay ) );
55 addItem( tr( "Soft Light" ), static_cast< int >( Qgis::BlendMode::SoftLight ) );
56 addItem( tr( "Hard Light" ), static_cast< int >( Qgis::BlendMode::HardLight ) );
57 insertSeparator( count() );
58 addItem( tr( "Difference" ), static_cast< int >( Qgis::BlendMode::Difference ) );
59 addItem( tr( "Subtract" ), static_cast< int >( Qgis::BlendMode::Subtract ) );
60
61 if ( mShowClipModes )
62 {
63 insertSeparator( count() );
64 addItem( tr( "Masked By Below" ), static_cast< int >( Qgis::BlendMode::SourceIn ) );
65 addItem( tr( "Mask Below" ), static_cast< int >( Qgis::BlendMode::DestinationIn ) );
66 addItem( tr( "Inverse Masked By Below" ), static_cast< int >( Qgis::BlendMode::SourceOut ) );
67 addItem( tr( "Inverse Mask Below" ), static_cast< int >( Qgis::BlendMode::DestinationOut ) );
68 addItem( tr( "Paint Inside Below" ), static_cast< int >( Qgis::BlendMode::SourceAtop ) );
69 addItem( tr( "Paint Below Inside" ), static_cast< int >( Qgis::BlendMode::DestinationAtop ) );
70 }
71
72 blockSignals( false );
73}
74
75QPainter::CompositionMode QgsBlendModeComboBox::blendMode()
76{
77 return QgsPainting::getCompositionMode( static_cast< Qgis::BlendMode >( currentData().toInt() ) );
78}
79
80void QgsBlendModeComboBox::setBlendMode( QPainter::CompositionMode blendMode )
81{
82 setCurrentIndex( findData( static_cast< int >( QgsPainting::getBlendModeEnum( blendMode ) ) ) );
83}
84
86{
87 mShowClipModes = show;
88 const QPainter::CompositionMode mode = blendMode();
90
91 setBlendMode( mode );
92}
93
95{
96 return mShowClipModes;
97}
98
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition qgis.h:4586
@ SoftLight
Soft light.
@ Lighten
Lighten.
@ Subtract
Subtract.
@ Difference
Difference.
@ SourceOut
Source out.
@ DestinationOut
Destination out.
@ DestinationIn
Destination in.
@ Overlay
Overlay.
@ SourceIn
Source in.
@ Addition
Addition.
@ SourceAtop
Source atop.
@ DestinationAtop
Destination atop.
@ HardLight
Hard light.
@ Multiply
Multiple.
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 Qgis::BlendMode corresponding to a QPainter::CompositionMode.
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.