QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
300  signals:
301 
306  void flagsChanged( QgsLayoutRenderContext::Flags flags );
307 
311  void dpiChanged();
312 
319 
320  private:
321 
322  Flags mFlags = Flags();
323 
324  QgsLayout *mLayout = nullptr;
325 
326  int mCurrentExportLayer = -1;
327 
328  QColor mSelectionColor = Qt::yellow;
329 
330  QgsLayoutMeasurementConverter mMeasurementConverter;
331 
332  bool mIsPreviewRender = true;
333  bool mGridVisible = false;
334  bool mBoundingBoxesVisible = true;
335  bool mPagesVisible = true;
336 
338 
339  QStringList mExportThemes;
340 
341  QgsVectorSimplifyMethod mSimplifyMethod;
342 
343  QVector<qreal> mPredefinedScales;
344 
345  friend class QgsLayoutExporter;
346  friend class TestQgsLayout;
347  friend class LayoutContextPreviewSettingRestorer;
348  friend class TestQgsLayoutMap;
349  friend class TestQgsLayoutLabel;
350 
351 };
352 
353 Q_DECLARE_METATYPE( QgsLayoutRenderContext::Flags )
354 
355 #endif //QGSLAYOUTRENDERCONTEXT_H
356 
357 
358 
QgsVectorSimplifyMethod
This class contains information how to simplify geometries fetched from a vector layer.
Definition: qgsvectorsimplifymethod.h:30
QgsLayoutRenderContext::measurementConverter
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
Definition: qgslayoutrendercontext.h:129
QgsLayoutRenderContext::currentExportLayer
Q_DECL_DEPRECATED int currentExportLayer() const
Returns the current item layer to draw while exporting.
Definition: qgslayoutrendercontext.h:206
QgsLayoutRenderContext::predefinedScalesChanged
void predefinedScalesChanged()
Emitted when the list of predefined scales changes.
QgsLayoutRenderContext::isPreviewRender
bool isPreviewRender() const
Returns true if the render current being conducted is a preview render, i.e.
Definition: qgslayoutrendercontext.h:142
QgsLayoutRenderContext::simplifyMethod
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
Definition: qgslayoutrendercontext.h:261
QgsLayoutRenderContext::textRenderFormat
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
Definition: qgslayoutrendercontext.h:214
QgsRenderContext::TextRenderFormat
TextRenderFormat
Options for rendering text.
Definition: qgsrendercontext.h:96
QgsLayoutRenderContext
Stores information relating to the current rendering settings for a layout.
Definition: qgslayoutrendercontext.h:33
QgsLayoutRenderContext::setSimplifyMethod
void setSimplifyMethod(const QgsVectorSimplifyMethod &method)
Sets the simplification setting to use when rendering vector layers.
Definition: qgslayoutrendercontext.h:247
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
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:123
qgsrendercontext.h
QgsLayoutRenderContext::flagsChanged
void flagsChanged(QgsLayoutRenderContext::Flags flags)
Emitted whenever the context's flags change.
QgsLayoutExporter
Handles rendering and exports of layouts to various formats.
Definition: qgslayoutexporter.h:45
QgsLayoutRenderContext::pagesVisible
bool pagesVisible() const
Returns whether the page items are be visible in the layout.
Definition: qgslayoutrendercontext.h:182
QgsLayoutMeasurementConverter
This class provides a method of converting QgsLayoutMeasurements from one unit to another.
Definition: qgslayoutmeasurementconverter.h:41
QgsLayoutRenderContext::predefinedScales
QVector< qreal > predefinedScales() const
Returns the current list of predefined scales for use with the layout.
Definition: qgslayoutrendercontext.h:298
QgsLayoutRenderContext::Flag
Flag
Flags for controlling how a layout is rendered.
Definition: qgslayoutrendercontext.h:41
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:50
QgsLayoutRenderContext::setTextRenderFormat
void setTextRenderFormat(QgsRenderContext::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
Definition: qgslayoutrendercontext.h:225
QgsLayoutRenderContext::measurementConverter
QgsLayoutMeasurementConverter & measurementConverter()
Returns the layout measurement converter to be used in the layout.
Definition: qgslayoutrendercontext.h:135
QgsRenderContext::TextFormatAlwaysOutlines
@ TextFormatAlwaysOutlines
Always render text using path objects (AKA outlines/curves).
Definition: qgsrendercontext.h:116
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:194
QgsLayoutRenderContext::setSelectionColor
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features.
Definition: qgslayoutrendercontext.h:116
QgsLayoutRenderContext::dpiChanged
void dpiChanged()
Emitted when the context's DPI is changed.