QGIS API Documentation  3.0.2-Girona (307d082)
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( QString( "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( QString( "Composition mode %1 mapped to Normal" ).arg( blendMode ) );
136  }
137 }
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
Definition: qgspainting.h:36