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