QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgspainting.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgspainting.cpp
3  ---------------------
4  begin : July 2016
5  copyright : (C) 2016 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgspainting.h"
17 
18 #include "qgslogger.h"
19 
20 QPainter::CompositionMode QgsPainting::getCompositionMode( QgsPainting::BlendMode blendMode )
21 {
22  // Map QgsPainting::BlendNormal to QPainter::CompositionMode
23  switch ( blendMode )
24  {
26  return QPainter::CompositionMode_SourceOver;
28  return QPainter::CompositionMode_Lighten;
30  return QPainter::CompositionMode_Screen;
32  return QPainter::CompositionMode_ColorDodge;
34  return QPainter::CompositionMode_Plus;
36  return QPainter::CompositionMode_Darken;
38  return QPainter::CompositionMode_Multiply;
40  return QPainter::CompositionMode_ColorBurn;
42  return QPainter::CompositionMode_Overlay;
44  return QPainter::CompositionMode_SoftLight;
46  return QPainter::CompositionMode_HardLight;
48  return QPainter::CompositionMode_Difference;
50  return QPainter::CompositionMode_Exclusion;
52  return QPainter::CompositionMode_Source;
54  return QPainter::CompositionMode_DestinationOver;
56  return QPainter::CompositionMode_Clear;
58  return QPainter::CompositionMode_Destination;
60  return QPainter::CompositionMode_SourceIn;
62  return QPainter::CompositionMode_DestinationIn;
64  return QPainter::CompositionMode_SourceOut;
66  return QPainter::CompositionMode_DestinationOut;
68  return QPainter::CompositionMode_SourceAtop;
70  return QPainter::CompositionMode_DestinationAtop;
72  return QPainter::CompositionMode_Xor;
73  default:
74  QgsDebugMsg( QStringLiteral( "Blend mode %1 mapped to SourceOver" ).arg( blendMode ) );
75  return QPainter::CompositionMode_SourceOver;
76  }
77 }
78 
79 
80 QgsPainting::BlendMode QgsPainting::getBlendModeEnum( QPainter::CompositionMode blendMode )
81 {
82  // Map QPainter::CompositionMode to QgsPainting::BlendNormal
83  switch ( blendMode )
84  {
85  case QPainter::CompositionMode_SourceOver:
87  case QPainter::CompositionMode_Lighten:
89  case QPainter::CompositionMode_Screen:
91  case QPainter::CompositionMode_ColorDodge:
93  case QPainter::CompositionMode_Plus:
95  case QPainter::CompositionMode_Darken:
97  case QPainter::CompositionMode_Multiply:
99  case QPainter::CompositionMode_ColorBurn:
100  return QgsPainting::BlendBurn;
101  case QPainter::CompositionMode_Overlay:
103  case QPainter::CompositionMode_SoftLight:
105  case QPainter::CompositionMode_HardLight:
107  case QPainter::CompositionMode_Difference:
109  case QPainter::CompositionMode_Exclusion:
111  case QPainter::CompositionMode_Source:
113  case QPainter::CompositionMode_DestinationOver:
115  case QPainter::CompositionMode_Clear:
117  case QPainter::CompositionMode_Destination:
119  case QPainter::CompositionMode_SourceIn:
121  case QPainter::CompositionMode_DestinationIn:
123  case QPainter::CompositionMode_SourceOut:
125  case QPainter::CompositionMode_DestinationOut:
127  case QPainter::CompositionMode_SourceAtop:
129  case QPainter::CompositionMode_DestinationAtop:
131  case QPainter::CompositionMode_Xor:
132  return QgsPainting::BlendXor;
133  default:
134  QgsDebugMsg( QStringLiteral( "Composition mode %1 mapped to Normal" ).arg( blendMode ) );
136  }
137 }
QgsPainting::BlendNormal
@ BlendNormal
Definition: qgspainting.h:64
QgsPainting::BlendHardLight
@ BlendHardLight
Definition: qgspainting.h:74
QgsPainting::BlendXor
@ BlendXor
Definition: qgspainting.h:87
QgsPainting::BlendMode
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
Definition: qgspainting.h:49
QgsPainting::BlendSource
@ BlendSource
Definition: qgspainting.h:77
QgsPainting::BlendDestinationOut
@ BlendDestinationOut
Definition: qgspainting.h:84
QgsPainting::BlendDodge
@ BlendDodge
Definition: qgspainting.h:67
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsPainting::BlendLighten
@ BlendLighten
Definition: qgspainting.h:65
QgsPainting::BlendSoftLight
@ BlendSoftLight
Definition: qgspainting.h:73
QgsPainting::getBlendModeEnum
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
QgsPainting::BlendDestinationAtop
@ BlendDestinationAtop
Definition: qgspainting.h:86
QgsPainting::BlendSourceAtop
@ BlendSourceAtop
Definition: qgspainting.h:85
QgsPainting::BlendDarken
@ BlendDarken
Definition: qgspainting.h:69
QgsPainting::BlendBurn
@ BlendBurn
Definition: qgspainting.h:71
QgsPainting::getCompositionMode
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
qgspainting.h
QgsPainting::BlendDifference
@ BlendDifference
Definition: qgspainting.h:75
QgsPainting::BlendDestinationIn
@ BlendDestinationIn
Definition: qgspainting.h:82
QgsPainting::BlendSourceIn
@ BlendSourceIn
Definition: qgspainting.h:81
QgsPainting::BlendOverlay
@ BlendOverlay
Definition: qgspainting.h:72
QgsPainting::BlendDestinationOver
@ BlendDestinationOver
Definition: qgspainting.h:78
QgsPainting::BlendDestination
@ BlendDestination
Definition: qgspainting.h:80
QgsPainting::BlendAddition
@ BlendAddition
Definition: qgspainting.h:68
QgsPainting::BlendClear
@ BlendClear
Definition: qgspainting.h:79
qgslogger.h
QgsPainting::BlendMultiply
@ BlendMultiply
Definition: qgspainting.h:70
QgsPainting::BlendSubtract
@ BlendSubtract
Definition: qgspainting.h:76
QgsPainting::BlendSourceOut
@ BlendSourceOut
Definition: qgspainting.h:83
QgsPainting::BlendScreen
@ BlendScreen
Definition: qgspainting.h:66