31 return QPainter::CompositionMode_SourceOver;
33 return QPainter::CompositionMode_Lighten;
35 return QPainter::CompositionMode_Screen;
37 return QPainter::CompositionMode_ColorDodge;
39 return QPainter::CompositionMode_Plus;
41 return QPainter::CompositionMode_Darken;
43 return QPainter::CompositionMode_Multiply;
45 return QPainter::CompositionMode_ColorBurn;
47 return QPainter::CompositionMode_Overlay;
49 return QPainter::CompositionMode_SoftLight;
51 return QPainter::CompositionMode_HardLight;
53 return QPainter::CompositionMode_Difference;
55 return QPainter::CompositionMode_Exclusion;
57 return QPainter::CompositionMode_Source;
59 return QPainter::CompositionMode_DestinationOver;
61 return QPainter::CompositionMode_Clear;
63 return QPainter::CompositionMode_Destination;
65 return QPainter::CompositionMode_SourceIn;
67 return QPainter::CompositionMode_DestinationIn;
69 return QPainter::CompositionMode_SourceOut;
71 return QPainter::CompositionMode_DestinationOut;
73 return QPainter::CompositionMode_SourceAtop;
75 return QPainter::CompositionMode_DestinationAtop;
77 return QPainter::CompositionMode_Xor;
80 return QPainter::CompositionMode_SourceOver;
90 case QPainter::CompositionMode_SourceOver:
92 case QPainter::CompositionMode_Lighten:
94 case QPainter::CompositionMode_Screen:
96 case QPainter::CompositionMode_ColorDodge:
98 case QPainter::CompositionMode_Plus:
100 case QPainter::CompositionMode_Darken:
102 case QPainter::CompositionMode_Multiply:
104 case QPainter::CompositionMode_ColorBurn:
106 case QPainter::CompositionMode_Overlay:
108 case QPainter::CompositionMode_SoftLight:
110 case QPainter::CompositionMode_HardLight:
112 case QPainter::CompositionMode_Difference:
114 case QPainter::CompositionMode_Exclusion:
116 case QPainter::CompositionMode_Source:
118 case QPainter::CompositionMode_DestinationOver:
120 case QPainter::CompositionMode_Clear:
122 case QPainter::CompositionMode_Destination:
124 case QPainter::CompositionMode_SourceIn:
126 case QPainter::CompositionMode_DestinationIn:
128 case QPainter::CompositionMode_SourceOut:
130 case QPainter::CompositionMode_DestinationOut:
132 case QPainter::CompositionMode_SourceAtop:
134 case QPainter::CompositionMode_DestinationAtop:
136 case QPainter::CompositionMode_Xor:
139 QgsDebugError( QStringLiteral(
"Composition mode %1 mapped to Normal" ).arg( blendMode ) );
179QTransform
QgsPainting::triangleToTriangleTransform(
double inX1,
double inY1,
double inX2,
double inY2,
double inX3,
double inY3,
double outX1,
double outY1,
double outX2,
double outY2,
double outX3,
double outY3,
bool &ok )
196 return ( U.inverted( &ok ) ) * V;
199bool QgsPainting::drawTriangleUsingTexture( QPainter *painter,
const QPolygonF &triangle,
const QImage &textureImage,
float textureX1,
float textureY1,
float textureX2,
float textureY2,
float textureX3,
float textureY3 )
203 textureX1 * ( textureImage.width() - 1 ), textureY1 * ( textureImage.height() - 1 ),
204 textureX2 * ( textureImage.width() - 1 ), textureY2 * ( textureImage.height() - 1 ),
205 textureX3 * ( textureImage.width() - 1 ), textureY3 * ( textureImage.height() - 1 ),
206 triangle.at( 0 ).x(), triangle.at( 0 ).y(),
207 triangle.at( 1 ).x(), triangle.at( 1 ).y(),
208 triangle.at( 2 ).x(), triangle.at( 2 ).y(),
215 const QBrush previousBrush = painter->brush();
217 QBrush textureBrush( textureImage );
218 textureBrush.setTransform( brushTransform );
220 painter->setBrush( textureBrush );
221 painter->drawPolygon( triangle );
222 painter->setBrush( previousBrush );
255 painter->scale( xScale, yScale );
256 painter->drawPicture( QPointF( point.x() / xScale, point.y() / yScale ), picture );
257 painter->scale( 1 / xScale, 1 / yScale );
BlendMode
Blending modes defining the available composition modes that can be used when painting.
@ Destination
Destination.
@ DestinationOut
Destination out.
@ DestinationIn
Destination in.
@ DestinationOver
Destination over.
@ DestinationAtop
Destination atop.
static bool drawTriangleUsingTexture(QPainter *painter, const QPolygonF &triangle, const QImage &textureImage, float textureX1, float textureY1, float textureX2, float textureY2, float textureX3, float textureY3)
Draws a triangle onto a painter using a mapped texture image.
static int qtDefaultDpiY()
Returns the default Qt vertical DPI.
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a Qgis::BlendMode corresponding to a QPainter::CompositionMode.
static bool isClippingMode(Qgis::BlendMode mode)
Returns true if mode is a clipping blend mode.
static int qtDefaultDpiX()
Returns the default Qt horizontal DPI.
static QTransform triangleToTriangleTransform(double inX1, double inY1, double inX2, double inY2, double inX3, double inY3, double outX1, double outY1, double outX2, double outY2, double outX3, double outY3, bool &ok)
Calculates the QTransform which maps the triangle defined by the points (inX1, inY1),...
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.
static void applyScaleFixForQPictureDpi(QPainter *painter)
Applies a workaround to a painter to avoid an issue with incorrect scaling when drawing QPictures.
static void drawPicture(QPainter *painter, const QPointF &point, const QPicture &picture)
Draws a picture onto a painter, correctly applying workarounds to avoid issues with incorrect scaling...
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
#define QgsDebugError(str)
Q_GUI_EXPORT int qt_defaultDpiX()
Q_GUI_EXPORT int qt_defaultDpiY()