QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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  };
51  Q_DECLARE_FLAGS( Flags, Flag )
52 
53 
57 
64  void setFlags( QgsLayoutRenderContext::Flags flags );
65 
73  void setFlag( QgsLayoutRenderContext::Flag flag, bool on = true );
74 
81  QgsLayoutRenderContext::Flags flags() const;
82 
89  bool testFlag( Flag flag ) const;
90 
94  QgsRenderContext::Flags renderContextFlags() const;
95 
101  void setDpi( double dpi );
102 
107  double dpi() const;
108 
114  void setSelectionColor( const QColor &color ) { mSelectionColor = color; }
115 
121  QColor selectionColor() const { return mSelectionColor; }
122 
127  SIP_SKIP const QgsLayoutMeasurementConverter &measurementConverter() const { return mMeasurementConverter; }
128 
133  QgsLayoutMeasurementConverter &measurementConverter() { return mMeasurementConverter; }
134 
140  bool isPreviewRender() const { return mIsPreviewRender; }
141 
146  bool gridVisible() const;
147 
152  void setGridVisible( bool visible );
153 
158  bool boundingBoxesVisible() const;
159 
164  void setBoundingBoxesVisible( bool visible );
165 
172  void setPagesVisible( bool visible );
173 
180  bool pagesVisible() const { return mPagesVisible; }
181 
191  void setCurrentExportLayer( int layer = -1 ) { mCurrentExportLayer = layer; }
192 
202  int currentExportLayer() const { return mCurrentExportLayer; }
203 
211  {
212  return mTextRenderFormat;
213  }
214 
222  {
223  mTextRenderFormat = format;
224  }
225 
226  signals:
227 
232  void flagsChanged( QgsLayoutRenderContext::Flags flags );
233 
237  void dpiChanged();
238 
239  private:
240 
241  Flags mFlags = nullptr;
242 
243  QgsLayout *mLayout = nullptr;
244 
245  int mCurrentExportLayer = -1;
246 
247  QColor mSelectionColor = Qt::yellow;
248 
249  QgsLayoutMeasurementConverter mMeasurementConverter;
250 
251  bool mIsPreviewRender = true;
252  bool mGridVisible = false;
253  bool mBoundingBoxesVisible = true;
254  bool mPagesVisible = true;
255 
257 
258  friend class QgsLayoutExporter;
259  friend class TestQgsLayout;
260  friend class LayoutContextPreviewSettingRestorer;
261 
262 };
263 
264 Q_DECLARE_METATYPE( QgsLayoutRenderContext::Flags )
265 
266 #endif //QGSLAYOUTRENDERCONTEXT_H
267 
268 
269 
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Flag
Flags for controlling how a layout is rendered.
int currentExportLayer() const
Returns the current item layer to draw while exporting.
void setTextRenderFormat(QgsRenderContext::TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
#define SIP_SKIP
Definition: qgis_sip.h:119
Always render text using path objects (AKA outlines/curves).
QgsLayoutMeasurementConverter & measurementConverter()
Returns the layout measurement converter to be used in the layout.
void setSelectionColor(const QColor &color)
Sets color that is used for drawing of selected vector features.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
TextRenderFormat
Options for rendering text.
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
Handles rendering and exports of layouts to various formats.
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
This class provides a method of converting QgsLayoutMeasurements from one unit to another...
void setCurrentExportLayer(int layer=-1)
Sets the current item layer to draw while exporting.
Stores information relating to the current rendering settings for a layout.
bool isPreviewRender() const
Returns true if the render current being conducted is a preview render, i.e.
bool pagesVisible() const
Returns whether the page items are be visible in the layout.