QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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"
21 #include "qgsrendercontext.h"
22 #include <QtGlobal>
23 
24 class QgsLayout;
25 
32 class CORE_EXPORT QgsLayoutRenderContext : public QObject
33 {
34 
35  Q_OBJECT
36 
37  public:
38 
40  enum Flag
41  {
42  FlagDebug = 1 << 1,
43  FlagOutlineOnly = 1 << 2,
44  FlagAntialiasing = 1 << 3,
45  FlagUseAdvancedEffects = 1 << 4,
46  FlagForceVectorOutput = 1 << 5,
47  FlagHideCoverageLayer = 1 << 6,
48  FlagDrawSelection = 1 << 7,
49  FlagDisableTiledRasterLayerRenders = 1 << 8,
50  FlagRenderLabelsByMapLayer = 1 << 9,
51  FlagLosslessImageRendering = 1 << 10,
52  };
53  Q_DECLARE_FLAGS( Flags, Flag )
54 
55 
59 
66  void setFlags( QgsLayoutRenderContext::Flags flags );
67 
75  void setFlag( QgsLayoutRenderContext::Flag flag, bool on = true );
76 
83  QgsLayoutRenderContext::Flags flags() const;
84 
91  bool testFlag( Flag flag ) const;
92 
96  QgsRenderContext::Flags renderContextFlags() const;
97 
103  void setDpi( double dpi );
104 
109  double dpi() const;
110 
116  void setSelectionColor( const QColor &color ) { mSelectionColor = color; }
117 
123  QColor selectionColor() const { return mSelectionColor; }
124 
129  SIP_SKIP const QgsLayoutMeasurementConverter &measurementConverter() const { return mMeasurementConverter; }
130 
135  QgsLayoutMeasurementConverter &measurementConverter() { return mMeasurementConverter; }
136 
142  bool isPreviewRender() const { return mIsPreviewRender; }
143 
148  bool gridVisible() const;
149 
154  void setGridVisible( bool visible );
155 
160  bool boundingBoxesVisible() const;
161 
166  void setBoundingBoxesVisible( bool visible );
167 
174  void setPagesVisible( bool visible );
175 
182  bool pagesVisible() const { return mPagesVisible; }
183 
194  Q_DECL_DEPRECATED void setCurrentExportLayer( int layer = -1 ) SIP_DEPRECATED { mCurrentExportLayer = layer; }
195 
206  Q_DECL_DEPRECATED int currentExportLayer() const SIP_DEPRECATED { return mCurrentExportLayer; }
207 
215  {
216  return mTextRenderFormat;
217  }
218 
226  {
227  mTextRenderFormat = format;
228  }
229 
247  void setSimplifyMethod( const QgsVectorSimplifyMethod &method ) { mSimplifyMethod = method; }
248 
261  const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
262 
272  QStringList exportThemes() const;
273 
283  void setExportThemes( const QStringList &themes );
284 
291  void setPredefinedScales( const QVector<qreal> &scales );
292 
298  QVector<qreal> predefinedScales() const { return mPredefinedScales; }
299 
308  QgsFeatureFilterProvider *featureFilterProvider() const;
309 
318  void setFeatureFilterProvider( QgsFeatureFilterProvider *featureFilterProvider );
319 
320  signals:
321 
326  void flagsChanged( QgsLayoutRenderContext::Flags flags );
327 
331  void dpiChanged();
332 
339 
340  private:
341 
342  Flags mFlags = Flags();
343 
344  QgsLayout *mLayout = nullptr;
345 
346  int mCurrentExportLayer = -1;
347 
348  QColor mSelectionColor = Qt::yellow;
349 
350  QgsLayoutMeasurementConverter mMeasurementConverter;
351 
352  bool mIsPreviewRender = true;
353  bool mGridVisible = false;
354  bool mBoundingBoxesVisible = true;
355  bool mPagesVisible = true;
356 
358 
359  QStringList mExportThemes;
360 
361  QgsVectorSimplifyMethod mSimplifyMethod;
362 
363  QVector<qreal> mPredefinedScales;
364 
365  QgsFeatureFilterProvider *mFeatureFilterProvider = nullptr;
366 
367  friend class QgsLayoutExporter;
368  friend class TestQgsLayout;
369  friend class LayoutContextPreviewSettingRestorer;
370  friend class TestQgsLayoutMap;
371  friend class TestQgsLayoutLabel;
372 
373 };
374 
375 Q_DECLARE_METATYPE( QgsLayoutRenderContext::Flags )
376 
377 #endif //QGSLAYOUTRENDERCONTEXT_H
378 
379 
380 
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 setTextRenderFormat(QgsRenderContext::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
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.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
void predefinedScalesChanged()
Emitted when the list of predefined scales changes.
bool pagesVisible() const
Returns whether the page items are be visible in the layout.
bool isPreviewRender() const
Returns true if the render current being conducted is a preview render, i.e.
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
void flagsChanged(QgsLayoutRenderContext::Flags flags)
Emitted whenever the context's flags change.
QVector< qreal > predefinedScales() const
Returns the current list of predefined scales for use with the layout.
QgsLayoutMeasurementConverter & measurementConverter()
Returns the layout measurement converter to be used in the layout.
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.
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:50
TextRenderFormat
Options for rendering text.
@ TextFormatAlwaysOutlines
Always render text using path objects (AKA outlines/curves).
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_SKIP
Definition: qgis_sip.h:126
Q_DECLARE_METATYPE(QgsMeshTimeSettings)