QGIS API Documentation 3.43.0-Master (a93bf8b6462)
qgslayoutrendercontext.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutrendercontext.h
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#ifndef QGSLAYOUTRENDERCONTEXT_H
17#define QGSLAYOUTRENDERCONTEXT_H
18
19#include "qgis_core.h"
23#include "qgis.h"
24#include <QtGlobal>
25#include <QColor>
26#include <QVector>
27
28class QgsLayout;
30
36class CORE_EXPORT QgsLayoutRenderContext : public QObject
37{
38
39 Q_OBJECT
40
41 public:
42
47
54 void setFlags( Qgis::LayoutRenderFlags flags );
55
63 void setFlag( Qgis::LayoutRenderFlag flag, bool on = true );
64
71 Qgis::LayoutRenderFlags flags() const;
72
79 bool testFlag( Qgis::LayoutRenderFlag flag ) const;
80
84 Qgis::RenderContextFlags renderContextFlags() const;
85
92 Qgis::RasterizedRenderingPolicy rasterizedRenderingPolicy() const;
93
100 void setRasterizedRenderingPolicy( Qgis::RasterizedRenderingPolicy policy );
101
107 void setDpi( double dpi );
108
113 double dpi() const;
114
120 void setSelectionColor( const QColor &color ) { mSelectionColor = color; }
121
127 QColor selectionColor() const { return mSelectionColor; }
128
133 SIP_SKIP const QgsLayoutMeasurementConverter &measurementConverter() const { return mMeasurementConverter; }
134
139 QgsLayoutMeasurementConverter &measurementConverter() { return mMeasurementConverter; }
140
146 bool isPreviewRender() const { return mIsPreviewRender; }
147
152 bool gridVisible() const;
153
158 void setGridVisible( bool visible );
159
164 bool boundingBoxesVisible() const;
165
170 void setBoundingBoxesVisible( bool visible );
171
178 void setPagesVisible( bool visible );
179
186 bool pagesVisible() const { return mPagesVisible; }
187
198 Q_DECL_DEPRECATED void setCurrentExportLayer( int layer = -1 ) SIP_DEPRECATED { mCurrentExportLayer = layer; }
199
210 Q_DECL_DEPRECATED int currentExportLayer() const SIP_DEPRECATED { return mCurrentExportLayer; }
211
219 {
220 return mTextRenderFormat;
221 }
222
230 {
231 mTextRenderFormat = format;
232 }
233
251 void setSimplifyMethod( const QgsVectorSimplifyMethod &method ) { mSimplifyMethod = method; }
252
265 const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
266
274 const QgsMaskRenderSettings &maskSettings() const SIP_SKIP { return mMaskRenderSettings; }
275
283 QgsMaskRenderSettings &maskSettings() { return mMaskRenderSettings; }
284
292 void setMaskSettings( const QgsMaskRenderSettings &settings );
293
303 QStringList exportThemes() const;
304
314 void setExportThemes( const QStringList &themes );
315
322 void setPredefinedScales( const QVector<qreal> &scales );
323
329 QVector<qreal> predefinedScales() const { return mPredefinedScales; }
330
339 QgsFeatureFilterProvider *featureFilterProvider() const;
340
349 void setFeatureFilterProvider( QgsFeatureFilterProvider *featureFilterProvider );
350
351 signals:
352
358
363
370
371 private:
372
373 void matchRasterizedRenderingPolicyToFlags();
374
377
378 QgsLayout *mLayout = nullptr;
379
380 int mCurrentExportLayer = -1;
381
382 QColor mSelectionColor = Qt::yellow;
383
384 QgsLayoutMeasurementConverter mMeasurementConverter;
385
386 bool mIsPreviewRender = true;
387 bool mGridVisible = false;
388 bool mBoundingBoxesVisible = true;
389 bool mPagesVisible = true;
390
392
393 QStringList mExportThemes;
394
395 QgsVectorSimplifyMethod mSimplifyMethod;
396
397 QVector<qreal> mPredefinedScales;
398
399 QgsFeatureFilterProvider *mFeatureFilterProvider = nullptr;
400
401 QgsMaskRenderSettings mMaskRenderSettings;
402
403 friend class QgsLayoutExporter;
404 friend class TestQgsLayout;
405 friend class LayoutContextPreviewSettingRestorer;
406 friend class TestQgsLayoutMap;
407 friend class TestQgsLayoutLabel;
408
409};
410
411
412#endif //QGSLAYOUTRENDERCONTEXT_H
413
414
415
RasterizedRenderingPolicy
Policies controlling when rasterisation of content during renders is permitted.
Definition qgis.h:2653
@ PreferVector
Prefer vector-based rendering, when the result will still be visually near-identical to a raster-base...
QFlags< RenderContextFlag > RenderContextFlags
Render context flags.
Definition qgis.h:2724
QFlags< LayoutRenderFlag > LayoutRenderFlags
Flags for controlling how a layout is rendered.
Definition qgis.h:5122
TextRenderFormat
Options for rendering text.
Definition qgis.h:2757
@ AlwaysOutlines
Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality...
LayoutRenderFlag
Flags for controlling how a layout is rendered.
Definition qgis.h:5099
Abstract interface for use by classes that filter the features or attributes of a layer.
Handles rendering and exports of layouts to various formats.
Provides a method of converting QgsLayoutMeasurements from one unit to another.
Stores information relating to the current rendering settings for a layout.
void setSimplifyMethod(const QgsVectorSimplifyMethod &method)
Sets the simplification setting to use when rendering vector layers.
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features.
void dpiChanged()
Emitted when the context's DPI is changed.
void setTextRenderFormat(Qgis::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
void predefinedScalesChanged()
Emitted when the list of predefined scales changes.
bool pagesVisible() const
Returns whether the page items are be visible in the layout.
Qgis::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
bool isPreviewRender() const
Returns true if the render current being conducted is a preview render, i.e.
QgsMaskRenderSettings & maskSettings()
Returns a reference to the mask render settings, which control how masks are drawn and behave during ...
QVector< qreal > predefinedScales() const
Returns the current list of predefined scales for use with the layout.
void flagsChanged(Qgis::LayoutRenderFlags flags)
Emitted whenever the context's flags change.
QgsLayoutMeasurementConverter & measurementConverter()
Returns the layout measurement converter to be used in the layout.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
Q_DECL_DEPRECATED void setCurrentExportLayer(int layer=-1)
Sets the current item layer to draw while exporting.
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
const QgsMaskRenderSettings & maskSettings() const
Returns a reference to the mask render settings, which control how masks are drawn and behave during ...
Q_DECL_DEPRECATED int currentExportLayer() const
Returns the current item layer to draw while exporting.
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.
Contains settings for simplifying geometries fetched from a vector layer.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126