QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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  };
50  Q_DECLARE_FLAGS( Flags, Flag )
51 
52 
56 
63  void setFlags( QgsLayoutRenderContext::Flags flags );
64 
72  void setFlag( QgsLayoutRenderContext::Flag flag, bool on = true );
73 
80  QgsLayoutRenderContext::Flags flags() const;
81 
88  bool testFlag( Flag flag ) const;
89 
93  QgsRenderContext::Flags renderContextFlags() const;
94 
100  void setDpi( double dpi );
101 
106  double dpi() const;
107 
113  void setSelectionColor( const QColor &color ) { mSelectionColor = color; }
114 
120  QColor selectionColor() const { return mSelectionColor; }
121 
126  SIP_SKIP const QgsLayoutMeasurementConverter &measurementConverter() const { return mMeasurementConverter; }
127 
132  QgsLayoutMeasurementConverter &measurementConverter() { return mMeasurementConverter; }
133 
139  bool isPreviewRender() const { return mIsPreviewRender; }
140 
145  bool gridVisible() const;
146 
151  void setGridVisible( bool visible );
152 
157  bool boundingBoxesVisible() const;
158 
163  void setBoundingBoxesVisible( bool visible );
164 
171  void setPagesVisible( bool visible );
172 
179  bool pagesVisible() const { return mPagesVisible; }
180 
190  void setCurrentExportLayer( int layer = -1 ) { mCurrentExportLayer = layer; }
191 
201  int currentExportLayer() const { return mCurrentExportLayer; }
202 
210  {
211  return mTextRenderFormat;
212  }
213 
221  {
222  mTextRenderFormat = format;
223  }
224 
225  signals:
226 
231  void flagsChanged( QgsLayoutRenderContext::Flags flags );
232 
236  void dpiChanged();
237 
238  private:
239 
240  Flags mFlags = nullptr;
241 
242  QgsLayout *mLayout = nullptr;
243 
244  int mCurrentExportLayer = -1;
245 
246  QColor mSelectionColor = Qt::yellow;
247 
248  QgsLayoutMeasurementConverter mMeasurementConverter;
249 
250  bool mIsPreviewRender = true;
251  bool mGridVisible = false;
252  bool mBoundingBoxesVisible = true;
253  bool mPagesVisible = true;
254 
256 
257  friend class QgsLayoutExporter;
258  friend class TestQgsLayout;
259  friend class LayoutContextPreviewSettingRestorer;
260  friend class TestQgsLayoutLabel;
261 };
262 
263 Q_DECLARE_METATYPE( QgsLayoutRenderContext::Flags )
264 
265 #endif //QGSLAYOUTRENDERCONTEXT_H
266 
267 
268 
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
bool pagesVisible() const
Returns whether the page items are be visible in the layout.
Flag
Flags for controlling how a layout is rendered.
QgsRenderContext::TextRenderFormat textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
const QgsLayoutMeasurementConverter & measurementConverter() const
Returns the layout measurement converter to be used in the layout.
Q_DECLARE_METATYPE(QModelIndex)
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.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition: qgslayout.h:49
TextRenderFormat
Options for rendering text.
Handles rendering and exports of layouts to various formats.
QColor selectionColor() const
Gets color that is used for drawing of selected vector features.
Contains information about the context of a rendering operation.
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.
bool isPreviewRender() const
Returns true if the render current being conducted is a preview render, i.e.
Stores information relating to the current rendering settings for a layout.
int currentExportLayer() const
Returns the current item layer to draw while exporting.