QGIS API Documentation  3.2.0-Bonn (bc43194)
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  };
49  Q_DECLARE_FLAGS( Flags, Flag )
50 
51 
55 
62  void setFlags( QgsLayoutRenderContext::Flags flags );
63 
71  void setFlag( QgsLayoutRenderContext::Flag flag, bool on = true );
72 
79  QgsLayoutRenderContext::Flags flags() const;
80 
87  bool testFlag( Flag flag ) const;
88 
92  QgsRenderContext::Flags renderContextFlags() const;
93 
99  void setDpi( double dpi );
100 
105  double dpi() const;
106 
111  SIP_SKIP const QgsLayoutMeasurementConverter &measurementConverter() const { return mMeasurementConverter; }
112 
117  QgsLayoutMeasurementConverter &measurementConverter() { return mMeasurementConverter; }
118 
124  bool isPreviewRender() const { return mIsPreviewRender; }
125 
130  bool gridVisible() const;
131 
136  void setGridVisible( bool visible );
137 
142  bool boundingBoxesVisible() const;
143 
148  void setBoundingBoxesVisible( bool visible );
149 
156  void setPagesVisible( bool visible );
157 
164  bool pagesVisible() const { return mPagesVisible; }
165 
175  void setCurrentExportLayer( int layer = -1 ) { mCurrentExportLayer = layer; }
176 
186  int currentExportLayer() const { return mCurrentExportLayer; }
187 
188  signals:
189 
194  void flagsChanged( QgsLayoutRenderContext::Flags flags );
195 
199  void dpiChanged();
200 
201  private:
202 
203  Flags mFlags = nullptr;
204 
205  QgsLayout *mLayout = nullptr;
206 
207  int mCurrentExportLayer = -1;
208 
209  QgsLayoutMeasurementConverter mMeasurementConverter;
210 
211  bool mIsPreviewRender = true;
212  bool mGridVisible = false;
213  bool mBoundingBoxesVisible = true;
214  bool mPagesVisible = true;
215 
216  friend class QgsLayoutExporter;
217  friend class TestQgsLayout;
218  friend class LayoutContextPreviewSettingRestorer;
219 
220 };
221 
222 Q_DECLARE_METATYPE( QgsLayoutRenderContext::Flags )
223 
224 #endif //QGSLAYOUTRENDERCONTEXT_H
225 
226 
227 
#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.
Q_DECLARE_METATYPE(QModelIndex)
#define SIP_SKIP
Definition: qgis_sip.h:119
QgsLayoutMeasurementConverter & measurementConverter()
Returns the layout measurement converter to be used in the layout.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
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.