QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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  };
52  Q_DECLARE_FLAGS( Flags, Flag )
53 
54 
58 
65  void setFlags( QgsLayoutRenderContext::Flags flags );
66 
74  void setFlag( QgsLayoutRenderContext::Flag flag, bool on = true );
75 
82  QgsLayoutRenderContext::Flags flags() const;
83 
90  bool testFlag( Flag flag ) const;
91 
95  QgsRenderContext::Flags renderContextFlags() const;
96 
102  void setDpi( double dpi );
103 
108  double dpi() const;
109 
115  void setSelectionColor( const QColor &color ) { mSelectionColor = color; }
116 
122  QColor selectionColor() const { return mSelectionColor; }
123 
128  SIP_SKIP const QgsLayoutMeasurementConverter &measurementConverter() const { return mMeasurementConverter; }
129 
134  QgsLayoutMeasurementConverter &measurementConverter() { return mMeasurementConverter; }
135 
141  bool isPreviewRender() const { return mIsPreviewRender; }
142 
147  bool gridVisible() const;
148 
153  void setGridVisible( bool visible );
154 
159  bool boundingBoxesVisible() const;
160 
165  void setBoundingBoxesVisible( bool visible );
166 
173  void setPagesVisible( bool visible );
174 
181  bool pagesVisible() const { return mPagesVisible; }
182 
193  Q_DECL_DEPRECATED void setCurrentExportLayer( int layer = -1 ) SIP_DEPRECATED { mCurrentExportLayer = layer; }
194 
205  Q_DECL_DEPRECATED int currentExportLayer() const SIP_DEPRECATED { return mCurrentExportLayer; }
206 
214  {
215  return mTextRenderFormat;
216  }
217 
225  {
226  mTextRenderFormat = format;
227  }
228 
246  void setSimplifyMethod( const QgsVectorSimplifyMethod &method ) { mSimplifyMethod = method; }
247 
260  const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
261 
271  QStringList exportThemes() const;
272 
282  void setExportThemes( const QStringList &themes );
283 
290  void setPredefinedScales( const QVector<qreal> &scales );
291 
297  QVector<qreal> predefinedScales() const { return mPredefinedScales; }
298 
299  signals:
300 
305  void flagsChanged( QgsLayoutRenderContext::Flags flags );
306 
310  void dpiChanged();
311 
317  void predefinedScalesChanged();
318 
319  private:
320 
321  Flags mFlags = Flags();
322 
323  QgsLayout *mLayout = nullptr;
324 
325  int mCurrentExportLayer = -1;
326 
327  QColor mSelectionColor = Qt::yellow;
328 
329  QgsLayoutMeasurementConverter mMeasurementConverter;
330 
331  bool mIsPreviewRender = true;
332  bool mGridVisible = false;
333  bool mBoundingBoxesVisible = true;
334  bool mPagesVisible = true;
335 
337 
338  QStringList mExportThemes;
339 
340  QgsVectorSimplifyMethod mSimplifyMethod;
341 
342  QVector<qreal> mPredefinedScales;
343 
344  friend class QgsLayoutExporter;
345  friend class TestQgsLayout;
346  friend class LayoutContextPreviewSettingRestorer;
347  friend class TestQgsLayoutMap;
348  friend class TestQgsLayoutLabel;
349 
350 };
351 
352 Q_DECLARE_METATYPE( QgsLayoutRenderContext::Flags )
353 
354 #endif //QGSLAYOUTRENDERCONTEXT_H
355 
356 
357 
QgsVectorSimplifyMethod
Definition: qgsvectorsimplifymethod.h:29
QgsLayoutRenderContext::measurementConverter
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
Definition: qgslayoutrendercontext.h:128
QgsLayoutRenderContext::currentExportLayer
Q_DECL_DEPRECATED int currentExportLayer() const
Returns the current item layer to draw while exporting.
Definition: qgslayoutrendercontext.h:205
QgsLayoutRenderContext::isPreviewRender
bool isPreviewRender() const
Returns true if the render current being conducted is a preview render, i.e.
Definition: qgslayoutrendercontext.h:141
QgsLayoutRenderContext::simplifyMethod
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
Definition: qgslayoutrendercontext.h:260
QgsLayoutRenderContext::textRenderFormat
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
Definition: qgslayoutrendercontext.h:213
QgsRenderContext::TextRenderFormat
TextRenderFormat
Options for rendering text.
Definition: qgsrendercontext.h:90
QgsLayoutRenderContext
Stores information relating to the current rendering settings for a layout.
Definition: qgslayoutrendercontext.h:32
QgsLayoutRenderContext::setSimplifyMethod
void setSimplifyMethod(const QgsVectorSimplifyMethod &method)
Sets the simplification setting to use when rendering vector layers.
Definition: qgslayoutrendercontext.h:246
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:122
qgsrendercontext.h
QgsLayoutExporter
Handles rendering and exports of layouts to various formats.
Definition: qgslayoutexporter.h:44
QgsLayoutRenderContext::pagesVisible
bool pagesVisible() const
Returns whether the page items are be visible in the layout.
Definition: qgslayoutrendercontext.h:181
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:297
QgsLayoutRenderContext::Flag
Flag
Flags for controlling how a layout is rendered.
Definition: qgslayoutrendercontext.h:40
QgsLayout
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
QgsLayoutRenderContext::setTextRenderFormat
void setTextRenderFormat(QgsRenderContext::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
Definition: qgslayoutrendercontext.h:224
QgsLayoutRenderContext::measurementConverter
QgsLayoutMeasurementConverter & measurementConverter()
Returns the layout measurement converter to be used in the layout.
Definition: qgslayoutrendercontext.h:134
QgsRenderContext::TextFormatAlwaysOutlines
@ TextFormatAlwaysOutlines
Always render text using path objects (AKA outlines/curves).
Definition: qgsrendercontext.h:111
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:193
QgsLayoutRenderContext::setSelectionColor
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features.
Definition: qgslayoutrendercontext.h:115