QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
22 #include "qgis.h"
23 #include <QtGlobal>
24 #include <QColor>
25 #include <QVector>
26 
27 class QgsLayout;
29 
36 class CORE_EXPORT QgsLayoutRenderContext : public QObject
37 {
38 
39  Q_OBJECT
40 
41  public:
42 
44  enum Flag
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  };
57  Q_DECLARE_FLAGS( Flags, Flag )
58 
59 
63 
70  void setFlags( QgsLayoutRenderContext::Flags flags );
71 
79  void setFlag( QgsLayoutRenderContext::Flag flag, bool on = true );
80 
87  QgsLayoutRenderContext::Flags flags() const;
88 
95  bool testFlag( Flag flag ) const;
96 
100  Qgis::RenderContextFlags renderContextFlags() const;
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 
276  QStringList exportThemes() const;
277 
287  void setExportThemes( const QStringList &themes );
288 
295  void setPredefinedScales( const QVector<qreal> &scales );
296 
302  QVector<qreal> predefinedScales() const { return mPredefinedScales; }
303 
312  QgsFeatureFilterProvider *featureFilterProvider() const;
313 
322  void setFeatureFilterProvider( QgsFeatureFilterProvider *featureFilterProvider );
323 
324  signals:
325 
330  void flagsChanged( QgsLayoutRenderContext::Flags flags );
331 
335  void dpiChanged();
336 
342  void predefinedScalesChanged();
343 
344  private:
345 
346  Flags mFlags = Flags();
347 
348  QgsLayout *mLayout = nullptr;
349 
350  int mCurrentExportLayer = -1;
351 
352  QColor mSelectionColor = Qt::yellow;
353 
354  QgsLayoutMeasurementConverter mMeasurementConverter;
355 
356  bool mIsPreviewRender = true;
357  bool mGridVisible = false;
358  bool mBoundingBoxesVisible = true;
359  bool mPagesVisible = true;
360 
361  Qgis::TextRenderFormat mTextRenderFormat = Qgis::TextRenderFormat::AlwaysOutlines;
362 
363  QStringList mExportThemes;
364 
365  QgsVectorSimplifyMethod mSimplifyMethod;
366 
367  QVector<qreal> mPredefinedScales;
368 
369  QgsFeatureFilterProvider *mFeatureFilterProvider = nullptr;
370 
371  friend class QgsLayoutExporter;
372  friend class TestQgsLayout;
373  friend class LayoutContextPreviewSettingRestorer;
374  friend class TestQgsLayoutMap;
375  friend class TestQgsLayoutLabel;
376 
377 };
378 
379 Q_DECLARE_METATYPE( QgsLayoutRenderContext::Flags )
380 
381 #endif //QGSLAYOUTRENDERCONTEXT_H
382 
383 
384 
QgsVectorSimplifyMethod
This class contains information how to simplify geometries fetched from a vector layer.
Definition: qgsvectorsimplifymethod.h:29
QgsLayoutRenderContext::measurementConverter
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
Definition: qgslayoutrendercontext.h:133
QgsLayoutRenderContext::currentExportLayer
Q_DECL_DEPRECATED int currentExportLayer() const
Returns the current item layer to draw while exporting.
Definition: qgslayoutrendercontext.h:210
QgsLayoutRenderContext::setTextRenderFormat
void setTextRenderFormat(Qgis::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
Definition: qgslayoutrendercontext.h:229
Qgis::TextRenderFormat
TextRenderFormat
Options for rendering text.
Definition: qgis.h:1331
QgsLayoutRenderContext::isPreviewRender
bool isPreviewRender() const
Returns true if the render current being conducted is a preview render, i.e.
Definition: qgslayoutrendercontext.h:146
QgsLayoutRenderContext::simplifyMethod
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
Definition: qgslayoutrendercontext.h:265
qgis.h
QgsLayoutRenderContext
Stores information relating to the current rendering settings for a layout.
Definition: qgslayoutrendercontext.h:36
QgsLayoutRenderContext::setSimplifyMethod
void setSimplifyMethod(const QgsVectorSimplifyMethod &method)
Sets the simplification setting to use when rendering vector layers.
Definition: qgslayoutrendercontext.h:251
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
qgslayoutmeasurementconverter.h
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsLayoutRenderContext::selectionColor
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
Definition: qgslayoutrendercontext.h:127
qgsvectorsimplifymethod.h
QgsLayoutExporter
Handles rendering and exports of layouts to various formats.
Definition: qgslayoutexporter.h:46
QgsLayoutRenderContext::pagesVisible
bool pagesVisible() const
Returns whether the page items are be visible in the layout.
Definition: qgslayoutrendercontext.h:186
QgsLayoutMeasurementConverter
This class provides a method of converting QgsLayoutMeasurements from one unit to another....
Definition: qgslayoutmeasurementconverter.h:40
QgsLayoutRenderContext::predefinedScales
QVector< qreal > predefinedScales() const
Returns the current list of predefined scales for use with the layout.
Definition: qgslayoutrendercontext.h:302
QgsLayoutRenderContext::Flag
Flag
Flags for controlling how a layout is rendered.
Definition: qgslayoutrendercontext.h:44
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QgsLayoutRenderContext::textRenderFormat
Qgis::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
Definition: qgslayoutrendercontext.h:218
QgsFeatureFilterProvider
Abstract interface for use by classes that filter the features or attributes of a layer.
Definition: qgsfeaturefilterprovider.h:43
QgsLayoutRenderContext::measurementConverter
QgsLayoutMeasurementConverter & measurementConverter()
Returns the layout measurement converter to be used in the layout.
Definition: qgslayoutrendercontext.h:139
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsLayoutRenderContext::setCurrentExportLayer
Q_DECL_DEPRECATED void setCurrentExportLayer(int layer=-1)
Sets the current item layer to draw while exporting.
Definition: qgslayoutrendercontext.h:198
QgsLayoutRenderContext::setSelectionColor
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features.
Definition: qgslayoutrendercontext.h:120