QGIS API Documentation 3.39.0-Master (67e056379ed)
Loading...
Searching...
No Matches
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
44 enum Flag SIP_ENUM_BASETYPE( IntFlag )
45 {
46 FlagDebug = 1 << 1,
47 FlagOutlineOnly = 1 << 2,
48 FlagAntialiasing = 1 << 3,
49 FlagUseAdvancedEffects = 1 << 4,
50 FlagForceVectorOutput = 1 << 5,
51 FlagHideCoverageLayer = 1 << 6,
52 FlagDrawSelection = 1 << 7,
53 FlagDisableTiledRasterLayerRenders = 1 << 8,
54 FlagRenderLabelsByMapLayer = 1 << 9,
55 FlagLosslessImageRendering = 1 << 10,
56 FlagSynchronousLegendGraphics = 1 << 11,
57 FlagAlwaysUseGlobalMasks = 1 << 12,
58 };
59 Q_DECLARE_FLAGS( Flags, Flag )
60
61
65
72 void setFlags( QgsLayoutRenderContext::Flags flags );
73
81 void setFlag( QgsLayoutRenderContext::Flag flag, bool on = true );
82
90
97 bool testFlag( Flag flag ) const;
98
102 Qgis::RenderContextFlags renderContextFlags() const;
103
109 void setDpi( double dpi );
110
115 double dpi() const;
116
122 void setSelectionColor( const QColor &color ) { mSelectionColor = color; }
123
129 QColor selectionColor() const { return mSelectionColor; }
130
135 SIP_SKIP const QgsLayoutMeasurementConverter &measurementConverter() const { return mMeasurementConverter; }
136
141 QgsLayoutMeasurementConverter &measurementConverter() { return mMeasurementConverter; }
142
148 bool isPreviewRender() const { return mIsPreviewRender; }
149
154 bool gridVisible() const;
155
160 void setGridVisible( bool visible );
161
166 bool boundingBoxesVisible() const;
167
172 void setBoundingBoxesVisible( bool visible );
173
180 void setPagesVisible( bool visible );
181
188 bool pagesVisible() const { return mPagesVisible; }
189
200 Q_DECL_DEPRECATED void setCurrentExportLayer( int layer = -1 ) SIP_DEPRECATED { mCurrentExportLayer = layer; }
201
212 Q_DECL_DEPRECATED int currentExportLayer() const SIP_DEPRECATED { return mCurrentExportLayer; }
213
221 {
222 return mTextRenderFormat;
223 }
224
232 {
233 mTextRenderFormat = format;
234 }
235
253 void setSimplifyMethod( const QgsVectorSimplifyMethod &method ) { mSimplifyMethod = method; }
254
267 const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
268
276 const QgsMaskRenderSettings &maskSettings() const SIP_SKIP { return mMaskRenderSettings; }
277
285 QgsMaskRenderSettings &maskSettings() { return mMaskRenderSettings; }
286
294 void setMaskSettings( const QgsMaskRenderSettings &settings );
295
305 QStringList exportThemes() const;
306
316 void setExportThemes( const QStringList &themes );
317
324 void setPredefinedScales( const QVector<qreal> &scales );
325
331 QVector<qreal> predefinedScales() const { return mPredefinedScales; }
332
341 QgsFeatureFilterProvider *featureFilterProvider() const;
342
351 void setFeatureFilterProvider( QgsFeatureFilterProvider *featureFilterProvider );
352
353 signals:
354
360
365
372
373 private:
374
375 Flags mFlags = Flags();
376
377 QgsLayout *mLayout = nullptr;
378
379 int mCurrentExportLayer = -1;
380
381 QColor mSelectionColor = Qt::yellow;
382
383 QgsLayoutMeasurementConverter mMeasurementConverter;
384
385 bool mIsPreviewRender = true;
386 bool mGridVisible = false;
387 bool mBoundingBoxesVisible = true;
388 bool mPagesVisible = true;
389
391
392 QStringList mExportThemes;
393
394 QgsVectorSimplifyMethod mSimplifyMethod;
395
396 QVector<qreal> mPredefinedScales;
397
398 QgsFeatureFilterProvider *mFeatureFilterProvider = nullptr;
399
400 QgsMaskRenderSettings mMaskRenderSettings;
401
402 friend class QgsLayoutExporter;
403 friend class TestQgsLayout;
404 friend class LayoutContextPreviewSettingRestorer;
405 friend class TestQgsLayoutMap;
406 friend class TestQgsLayoutLabel;
407
408};
409
411
412#endif //QGSLAYOUTRENDERCONTEXT_H
413
414
415
QFlags< RenderContextFlag > RenderContextFlags
Render context flags.
Definition qgis.h:2377
TextRenderFormat
Options for rendering text.
Definition qgis.h:2409
@ AlwaysOutlines
Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality...
Abstract interface for use by classes that filter the features or attributes of a layer.
Handles rendering and exports of layouts to various formats.
This class 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(QgsLayoutRenderContext::Flags 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.
Flag
Flags for controlling how a layout is rendered.
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.
This class contains information how to simplify geometries fetched from a vector layer.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:278
#define SIP_SKIP
Definition qgis_sip.h:126
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)