QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgslayoutrendercontext.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutrendercontext.cpp
3 --------------------
4 begin : July 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
18#include "qgslayout.h"
19
21 : QObject( layout )
22 , mFlags( FlagAntialiasing | FlagUseAdvancedEffects )
23 , mLayout( layout )
24{
26}
27
28void QgsLayoutRenderContext::setFlags( const QgsLayoutRenderContext::Flags flags )
29{
30 if ( flags == mFlags )
31 return;
32
33 mFlags = flags;
34 emit flagsChanged( mFlags );
35}
36
38{
39 Flags newFlags = mFlags;
40 if ( on )
41 newFlags |= flag;
42 else
43 newFlags &= ~flag;
44
45 if ( newFlags == mFlags )
46 return;
47
48 mFlags = newFlags;
49 emit flagsChanged( mFlags );
50}
51
52QgsLayoutRenderContext::Flags QgsLayoutRenderContext::flags() const
53{
54 return mFlags;
55}
56
58{
59 return mFlags.testFlag( flag );
60}
61
62Qgis::RenderContextFlags QgsLayoutRenderContext::renderContextFlags() const
63{
64 Qgis::RenderContextFlags flags = Qgis::RenderContextFlags();
65 if ( mFlags & FlagAntialiasing )
66 {
69 }
70 if ( mFlags & FlagUseAdvancedEffects )
72 if ( mFlags & FlagLosslessImageRendering )
74
75 // TODO - expose as layout context flag?
77 return flags;
78}
79
81{
82 if ( qgsDoubleNear( dpi, mMeasurementConverter.dpi() ) )
83 return;
84
85 mMeasurementConverter.setDpi( dpi );
86 emit dpiChanged();
87}
88
90{
91 return mMeasurementConverter.dpi();
92}
93
95{
96 return mGridVisible;
97}
98
100{
101 mGridVisible = visible;
102}
103
105{
106 return mBoundingBoxesVisible;
107}
108
110{
111 mBoundingBoxesVisible = visible;
112}
113
115{
116 mPagesVisible = visible;
117}
118
120{
121 return mExportThemes;
122}
123
124void QgsLayoutRenderContext::setExportThemes( const QStringList &exportThemes )
125{
126 mExportThemes = exportThemes;
127}
128
129void QgsLayoutRenderContext::setPredefinedScales( const QVector<qreal> &scales )
130{
131 if ( scales == mPredefinedScales )
132 return;
133
134 mPredefinedScales = scales;
135 // make sure the list is sorted
136 std::sort( mPredefinedScales.begin(), mPredefinedScales.end() ); // clazy:exclude=detaching-member
138}
139
141{
142 return mFeatureFilterProvider;
143}
144
146{
147 mFeatureFilterProvider = featureFilterProvider;
148}
@ ForceVectorOutput
Vector graphics should not be cached and drawn as raster images.
@ LosslessImageRendering
Render images losslessly whenever possible, instead of the default lossy jpeg rendering used for some...
@ Antialiasing
Use antialiasing while drawing.
@ UseAdvancedEffects
Enable layer opacity and blending effects.
@ HighQualityImageTransforms
Enable high quality image transformations, which results in better appearance of scaled or rotated ra...
Abstract interface for use by classes that filter the features or attributes of a layer.
double dpi() const
Returns the Dots per inch (DPI) of the measurement converter.
void setDpi(const double dpi)
Sets the dots per inch (dpi) for the measurement converter.
void setDpi(double dpi)
Sets the dpi for outputting the layout.
void dpiChanged()
Emitted when the context's DPI is changed.
void setGridVisible(bool visible)
Sets whether the page grid should be visible.
void predefinedScalesChanged()
Emitted when the list of predefined scales changes.
void setFeatureFilterProvider(QgsFeatureFilterProvider *featureFilterProvider)
Sets feature filter provider to featureFilterProvider.
bool boundingBoxesVisible() const
Returns true if the item bounding boxes should be drawn.
QgsLayoutRenderContext::Flags flags() const
Returns the current combination of flags used for rendering the layout.
bool gridVisible() const
Returns true if the page grid should be drawn.
QStringList exportThemes() const
Returns a list of map themes to use during the export.
QgsFeatureFilterProvider * featureFilterProvider() const
Returns the possibly NULL feature filter provider.
void flagsChanged(QgsLayoutRenderContext::Flags flags)
Emitted whenever the context's flags change.
void setFlag(QgsLayoutRenderContext::Flag flag, bool on=true)
Enables or disables a particular rendering flag for the layout.
QgsLayoutRenderContext(QgsLayout *layout)
Constructor for QgsLayoutRenderContext.
double dpi() const
Returns the dpi for outputting the layout.
Flag
Flags for controlling how a layout is rendered.
@ FlagUseAdvancedEffects
Enable advanced effects such as blend modes.
@ FlagLosslessImageRendering
Render images losslessly whenever possible, instead of the default lossy jpeg rendering used for some...
@ FlagAntialiasing
Use antialiasing when drawing items.
void setPredefinedScales(const QVector< qreal > &scales)
Sets the list of predefined scales to use with the layout.
Qgis::RenderContextFlags renderContextFlags() const
Returns the combination of render context flags matched to the layout context's settings.
void setFlags(QgsLayoutRenderContext::Flags flags)
Sets the combination of flags that will be used for rendering the layout.
void setExportThemes(const QStringList &themes)
Sets a list of map themes to use during the export.
bool testFlag(Flag flag) const
Check whether a particular rendering flag is enabled for the layout.
void setPagesVisible(bool visible)
Sets whether the page items should be visible in the layout.
void setBoundingBoxesVisible(bool visible)
Sets whether the item bounding boxes should be visible.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:51
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
@ NoSimplification
No simplification can be applied.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:2527