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