QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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
6
email : nyall.dawson@gmail.com
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 "
qgsblendmodecombobox.h
"
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
30
QgsBlendModeComboBox::QgsBlendModeComboBox
( QWidget *parent )
31
: QComboBox( parent )
32
{
33
setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
34
updateModes
();
35
}
36
37
void
QgsBlendModeComboBox::updateModes
()
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
77
QPainter::CompositionMode
QgsBlendModeComboBox::blendMode
()
78
{
79
return
QgsPainting::getCompositionMode
(
static_cast<
Qgis::BlendMode
>
( currentData().toInt() ) );
80
}
81
82
void
QgsBlendModeComboBox::setBlendMode
( QPainter::CompositionMode
blendMode
)
83
{
84
setCurrentIndex( findData(
static_cast<
int
>
(
QgsPainting::getBlendModeEnum
(
blendMode
) ) ) );
85
}
86
87
void
QgsBlendModeComboBox::setShowClippingModes
(
bool
show )
88
{
89
mShowClipModes = show;
90
const
QPainter::CompositionMode mode =
blendMode
();
91
updateModes
();
92
93
setBlendMode
( mode );
94
}
95
96
bool
QgsBlendModeComboBox::showClippingModes
()
const
97
{
98
return
mShowClipModes;
99
}
Qgis::BlendMode
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition
qgis.h:5485
Qgis::BlendMode::SoftLight
@ SoftLight
Soft light.
Definition
qgis.h:5495
Qgis::BlendMode::Burn
@ Burn
Burn.
Definition
qgis.h:5493
Qgis::BlendMode::Lighten
@ Lighten
Lighten.
Definition
qgis.h:5487
Qgis::BlendMode::Subtract
@ Subtract
Subtract.
Definition
qgis.h:5498
Qgis::BlendMode::Difference
@ Difference
Difference.
Definition
qgis.h:5497
Qgis::BlendMode::Screen
@ Screen
Screen.
Definition
qgis.h:5488
Qgis::BlendMode::SourceOut
@ SourceOut
Source out.
Definition
qgis.h:5505
Qgis::BlendMode::DestinationOut
@ DestinationOut
Destination out.
Definition
qgis.h:5506
Qgis::BlendMode::DestinationIn
@ DestinationIn
Destination in.
Definition
qgis.h:5504
Qgis::BlendMode::Overlay
@ Overlay
Overlay.
Definition
qgis.h:5494
Qgis::BlendMode::SourceIn
@ SourceIn
Source in.
Definition
qgis.h:5503
Qgis::BlendMode::Addition
@ Addition
Addition.
Definition
qgis.h:5490
Qgis::BlendMode::SourceAtop
@ SourceAtop
Source atop.
Definition
qgis.h:5507
Qgis::BlendMode::DestinationAtop
@ DestinationAtop
Destination atop.
Definition
qgis.h:5508
Qgis::BlendMode::Normal
@ Normal
Normal.
Definition
qgis.h:5486
Qgis::BlendMode::Dodge
@ Dodge
Dodge.
Definition
qgis.h:5489
Qgis::BlendMode::HardLight
@ HardLight
Hard light.
Definition
qgis.h:5496
Qgis::BlendMode::Multiply
@ Multiply
Multiple.
Definition
qgis.h:5492
Qgis::BlendMode::Darken
@ Darken
Darken.
Definition
qgis.h:5491
QgsBlendModeComboBox::setBlendMode
void setBlendMode(QPainter::CompositionMode blendMode)
Sets the selected blend mode.
Definition
qgsblendmodecombobox.cpp:82
QgsBlendModeComboBox::setShowClippingModes
void setShowClippingModes(bool show)
Sets whether composition modes which cause clipping are shown in the combo box.
Definition
qgsblendmodecombobox.cpp:87
QgsBlendModeComboBox::QgsBlendModeComboBox
QgsBlendModeComboBox(QWidget *parent=nullptr)
Constructor for QgsBlendModeComboBox.
Definition
qgsblendmodecombobox.cpp:30
QgsBlendModeComboBox::updateModes
void updateModes()
Populates the blend mode combo box, and sets up mapping for blend modes to combo box indexes.
Definition
qgsblendmodecombobox.cpp:37
QgsBlendModeComboBox::showClippingModes
bool showClippingModes() const
Returns true if composition modes which cause clipping are shown in the combo box.
Definition
qgsblendmodecombobox.cpp:96
QgsBlendModeComboBox::blendMode
QPainter::CompositionMode blendMode()
Returns the selected blend mode.
Definition
qgsblendmodecombobox.cpp:77
QgsPainting::getBlendModeEnum
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a Qgis::BlendMode corresponding to a QPainter::CompositionMode.
Definition
qgspainting.cpp:88
QgsPainting::getCompositionMode
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.
Definition
qgspainting.cpp:28
qgis.h
qgsblendmodecombobox.h
qgspainting.h
Generated on
for QGIS API Documentation by
1.17.0