QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgslayouteffect.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayouteffect.cpp
3 -------------------
4 begin : October 2017
5 copyright : (C) 2017 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
18#include <QPainter>
19
20#include "qgslayouteffect.h"
21#include "moc_qgslayouteffect.cpp"
22
23void QgsLayoutEffect::draw( QPainter *painter )
24{
25 QPoint offset;
26 QPixmap pixmap;
27
28 // Set desired composition mode then draw source
29 painter->setCompositionMode( mCompositionMode );
30
31 if ( mCompositionMode == QPainter::CompositionMode_SourceOver )
32 {
33 // Normal (sourceover) blending, do faster drawSource operation
34 drawSource( painter );
35 return;
36 }
37
38 // Otherwise, draw using pixmap so QPrinter output works as expected
39 if ( sourceIsPixmap() )
40 {
41 // No point in drawing in device coordinates (pixmap will be scaled anyways).
42 pixmap = sourcePixmap( Qt::LogicalCoordinates, &offset );
43 }
44 else
45 {
46 // Draw pixmap in device coordinates to avoid pixmap scaling;
47 pixmap = sourcePixmap( Qt::DeviceCoordinates, &offset );
48 painter->setWorldTransform( QTransform() );
49 }
50
51 painter->drawPixmap( offset, pixmap );
52}
53
54void QgsLayoutEffect::setCompositionMode( QPainter::CompositionMode compositionMode )
55{
56 mCompositionMode = compositionMode;
57
58 // force redraw with new composition mode
59 update();
60}
61
62
63
Q_DECL_DEPRECATED QPainter::CompositionMode compositionMode() const
Returns the composition (blending) mode used for rendering the item.
void draw(QPainter *painter) override
Q_DECL_DEPRECATED void setCompositionMode(QPainter::CompositionMode mode)
Sets the composition (blending) mode used for rendering the item.