QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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 "moc_qgslayoutrendercontext.cpp"
19#include "qgslayout.h"
20
22 : QObject( layout )
23 , mFlags( FlagAntialiasing | FlagUseAdvancedEffects )
24 , mLayout( layout )
25{
27}
28
30{
31 if ( flags == mFlags )
32 return;
33
34 mFlags = flags;
35 emit flagsChanged( mFlags );
36}
37
39{
40 Flags newFlags = mFlags;
41 if ( on )
42 newFlags |= flag;
43 else
44 newFlags &= ~flag;
45
46 if ( newFlags == mFlags )
47 return;
48
49 mFlags = newFlags;
50 emit flagsChanged( mFlags );
51}
52
57
59{
60 return mFlags.testFlag( flag );
61}
62
80
82{
83 if ( qgsDoubleNear( dpi, mMeasurementConverter.dpi() ) )
84 return;
85
86 mMeasurementConverter.setDpi( dpi );
87 emit dpiChanged();
88}
89
91{
92 return mMeasurementConverter.dpi();
93}
94
96{
97 return mGridVisible;
98}
99
101{
102 mGridVisible = visible;
103}
104
106{
107 return mBoundingBoxesVisible;
108}
109
111{
112 mBoundingBoxesVisible = visible;
113}
114
116{
117 mPagesVisible = visible;
118}
119
121{
122 mMaskRenderSettings = settings;
123}
124
126{
127 return mExportThemes;
128}
129
130void QgsLayoutRenderContext::setExportThemes( const QStringList &exportThemes )
131{
132 mExportThemes = exportThemes;
133}
134
135void QgsLayoutRenderContext::setPredefinedScales( const QVector<qreal> &scales )
136{
137 if ( scales == mPredefinedScales )
138 return;
139
140 mPredefinedScales = scales;
141 // make sure the list is sorted
142 std::sort( mPredefinedScales.begin(), mPredefinedScales.end() ); // clazy:exclude=detaching-member
144}
145
147{
148 return mFeatureFilterProvider;
149}
150
152{
153 mFeatureFilterProvider = featureFilterProvider;
154}
@ NoSimplification
No simplification can be applied.
QFlags< RenderContextFlag > RenderContextFlags
Render context flags.
Definition qgis.h:2591
@ 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 nullptr) 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 setMaskSettings(const QgsMaskRenderSettings &settings)
Sets the mask render settings, which control how masks are drawn and behave during map renders.
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:49
Contains settings regarding how masks are calculated and handled during a map render.
void setSimplifyHints(Qgis::VectorRenderingSimplificationFlags simplifyHints)
Sets the simplification hints of the vector layer managed.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition qgis.h:5958