QgsLayoutRenderContext class
Stores information relating to the current rendering settings for a layout.
Contents
Public types
- enum Flag { FlagDebug = 1 << 1, FlagOutlineOnly = 1 << 2, FlagAntialiasing = 1 << 3, FlagUseAdvancedEffects = 1 << 4, FlagForceVectorOutput = 1 << 5, FlagHideCoverageLayer = 1 << 6, FlagDrawSelection = 1 << 7 }
- Flags for controlling how a layout is rendered.
Constructors, destructors, conversion operators
- QgsLayoutRenderContext(QgsLayout* layout)
- Constructor for QgsLayoutRenderContext.
Public functions
- auto boundingBoxesVisible() const -> bool
- Returns true if the item bounding boxes should be drawn.
- auto currentExportLayer() const -> int
- Returns the current item layer to draw while exporting.
- auto dpi() const -> double
- Returns the dpi for outputting the layout.
- auto flags() const -> QgsLayoutRenderContext::Flags
- Returns the current combination of flags used for rendering the layout.
- auto gridVisible() const -> bool
- Returns true if the page grid should be drawn.
- auto isPreviewRender() const -> bool
- Returns true if the render current being conducted is a preview render, i.e.
- auto measurementConverter() const -> const QgsLayoutMeasurementConverter&
- Returns the layout measurement converter to be used in the layout.
- auto measurementConverter() -> QgsLayoutMeasurementConverter&
- Returns the layout measurement converter to be used in the layout.
- auto pagesVisible() const -> bool
- Returns whether the page items are be visible in the layout.
- auto renderContextFlags() const -> QgsRenderContext::Flags
- Returns the combination of render context flags matched to the layout context's settings.
- auto selectionColor() const -> QColor
- Gets color that is used for drawing of selected vector features.
- void setBoundingBoxesVisible(bool visible)
- Sets whether the item bounding boxes should be visible.
- void setCurrentExportLayer(int layer = -1)
- Sets the current item layer to draw while exporting.
- void setDpi(double dpi)
- Sets the dpi for outputting the layout.
-
void setFlag(QgsLayoutRenderContext::
Flag flag, bool on = true) - Enables or disables a particular rendering flag for the layout.
- void setFlags(QgsLayoutRenderContext::Flags flags)
- Sets the combination of flags that will be used for rendering the layout.
- void setGridVisible(bool visible)
- Sets whether the page grid should be visible.
- void setPagesVisible(bool visible)
- Sets whether the page items should be visible in the layout.
- void setSelectionColor(const QColor& color)
- Sets color that is used for drawing of selected vector features.
-
void setTextRenderFormat(QgsRenderContext::
TextRenderFormat format) - Sets the text render format, which dictates how text is rendered (e.g.
- auto testFlag(Flag flag) const -> bool
- Check whether a particular rendering flag is enabled for the layout.
-
auto textRenderFormat() const -> QgsRenderContext::
TextRenderFormat - Returns the text render format, which dictates how text is rendered (e.g.
Signals
- void dpiChanged()
- Emitted when the context's DPI is changed.
- void flagsChanged(QgsLayoutRenderContext::Flags flags)
- Emitted whenever the context's flags change.
Enum documentation
enum QgsLayoutRenderContext:: Flag
Flags for controlling how a layout is rendered.
| Enumerators | |
|---|---|
| FlagDebug |
Debug/testing mode, items are drawn as solid rectangles. |
| FlagOutlineOnly |
Render items as outlines only. |
| FlagAntialiasing |
Use antialiasing when drawing items. |
| FlagUseAdvancedEffects |
Enable advanced effects such as blend modes. |
| FlagForceVectorOutput |
Force output in vector format where possible, even if items require rasterization to keep their correct appearance. |
| FlagHideCoverageLayer |
Hide coverage layer in outputs. |
| FlagDrawSelection |
Draw selection. |
Function documentation
bool QgsLayoutRenderContext:: boundingBoxesVisible() const
Returns true if the item bounding boxes should be drawn.
int QgsLayoutRenderContext:: currentExportLayer() const
Returns the current item layer to draw while exporting.
QgsLayoutItem subclasses which support multi-layer SVG exports must check this and customize their rendering based on the layer.
If layer is -1, all item layers should be rendered.
double QgsLayoutRenderContext:: dpi() const
Returns the dpi for outputting the layout.
QgsLayoutRenderContext::Flags QgsLayoutRenderContext:: flags() const
Returns the current combination of flags used for rendering the layout.
bool QgsLayoutRenderContext:: gridVisible() const
Returns true if the page grid should be drawn.
bool QgsLayoutRenderContext:: isPreviewRender() const
Returns true if the render current being conducted is a preview render, i.e.
it is being rendered inside a QGraphicsView widget as opposed to a destination device (such as an image).
const QgsLayoutMeasurementConverter& QgsLayoutRenderContext:: measurementConverter() const
Returns the layout measurement converter to be used in the layout.
This converter is used for translating between other measurement units and the layout's native unit.
QgsLayoutMeasurementConverter& QgsLayoutRenderContext:: measurementConverter()
Returns the layout measurement converter to be used in the layout.
This converter is used for translating between other measurement units and the layout's native unit.
bool QgsLayoutRenderContext:: pagesVisible() const
Returns whether the page items are be visible in the layout.
This setting effects both display of the page boundaries in layout views and whether they will be rendered in layout exports.
QColor QgsLayoutRenderContext:: selectionColor() const
Gets color that is used for drawing of selected vector features.
void QgsLayoutRenderContext:: setBoundingBoxesVisible(bool visible)
Sets whether the item bounding boxes should be visible.
void QgsLayoutRenderContext:: setCurrentExportLayer(int layer = -1)
Sets the current item layer to draw while exporting.
QgsLayoutItem subclasses which support multi-layer SVG exports must check the currentExportLayer() and customize their rendering based on the layer.
If layer is -1, all item layers will be rendered.
void QgsLayoutRenderContext:: setDpi(double dpi)
Sets the dpi for outputting the layout.
This also sets the corresponding DPI for the context's measurementConverter().
void QgsLayoutRenderContext:: setFlag(QgsLayoutRenderContext:: Flag flag,
bool on = true)
Enables or disables a particular rendering flag for the layout.
Other existing flags are not affected.
void QgsLayoutRenderContext:: setFlags(QgsLayoutRenderContext::Flags flags)
Sets the combination of flags that will be used for rendering the layout.
void QgsLayoutRenderContext:: setGridVisible(bool visible)
Sets whether the page grid should be visible.
void QgsLayoutRenderContext:: setPagesVisible(bool visible)
Sets whether the page items should be visible in the layout.
Removing them will prevent both display of the page boundaries in layout views and will also prevent them from being rendered in layout exports.
void QgsLayoutRenderContext:: setSelectionColor(const QColor& color)
Sets color that is used for drawing of selected vector features.
void QgsLayoutRenderContext:: setTextRenderFormat(QgsRenderContext:: TextRenderFormat format)
Sets the text render format, which dictates how text is rendered (e.g.
as paths or real text objects).
QgsRenderContext:: TextRenderFormat QgsLayoutRenderContext:: textRenderFormat() const
Returns the text render format, which dictates how text is rendered (e.g.
as paths or real text objects).
void QgsLayoutRenderContext:: flagsChanged(QgsLayoutRenderContext::Flags flags) signal
Emitted whenever the context's flags change.