QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Handles automatic layout and rendering of legends. More...
#include <qgslegendrenderer.h>
Public Member Functions | |
QgsLegendRenderer (const QgsLegendRenderer &other)=delete | |
QgsLegendRenderer (QgsLayerTreeModel *legendModel, const QgsLegendSettings &settings) | |
Constructor for QgsLegendRenderer. | |
QgsLegendRenderer (QgsLegendRenderer &&other) | |
~QgsLegendRenderer () | |
void | drawLegend (QgsRenderContext &context) |
Draws the legend using a given render context. | |
Q_DECL_DEPRECATED void | drawLegend (QPainter *painter) |
Draws the legend with given painter. | |
QJsonObject | exportLegendToJson (const QgsRenderContext &context) |
Renders the legend in a json object. | |
QSizeF | legendSize () const |
Returns the preferred legend size set by the client. | |
QSizeF | minimumSize (QgsRenderContext *renderContext=nullptr) |
Runs the layout algorithm and returns the minimum size required for the legend. | |
QgsLegendRenderer & | operator= (const QgsLegendRenderer &other)=delete |
QgsLayerTreeFilterProxyModel * | proxyModel () |
Returns the filter proxy model used for filtering the legend model content during rendering. | |
void | setLegendSize (QSizeF s) |
Sets the preferred resulting legend size. | |
Static Public Member Functions | |
static QgsLegendStyle::Style | nodeLegendStyle (QgsLayerTreeNode *node, QgsLayerTreeModel *model) |
Returns the style for the given node, within the specified model. | |
static void | setNodeLegendStyle (QgsLayerTreeNode *node, QgsLegendStyle::Style style) |
Sets the style of a node. | |
Handles automatic layout and rendering of legends.
The content is given by QgsLayerTreeModel instance. Various layout properties can be configured within QgsLegendRenderer.
All spacing and sizes are in millimeters.
Definition at line 47 of file qgslegendrenderer.h.
QgsLegendRenderer::QgsLegendRenderer | ( | QgsLayerTreeModel * | legendModel, |
const QgsLegendSettings & | settings | ||
) |
Constructor for QgsLegendRenderer.
The ownership of the legend model is not changed, and the model must exist for the lifetime of this renderer.
Definition at line 32 of file qgslegendrenderer.cpp.
|
default |
|
delete |
QgsLegendRenderer::QgsLegendRenderer | ( | QgsLegendRenderer && | other | ) |
Definition at line 40 of file qgslegendrenderer.cpp.
void QgsLegendRenderer::drawLegend | ( | QgsRenderContext & | context | ) |
Draws the legend using a given render context.
The legend will occupy the area reported in legendSize().
Definition at line 1140 of file qgslegendrenderer.cpp.
void QgsLegendRenderer::drawLegend | ( | QPainter * | painter | ) |
Draws the legend with given painter.
The legend will occupy the area reported in legendSize(). The painter should be scaled beforehand so that units correspond to millimeters.
Definition at line 71 of file qgslegendrenderer.cpp.
QJsonObject QgsLegendRenderer::exportLegendToJson | ( | const QgsRenderContext & | context | ) |
Renders the legend in a json object.
Definition at line 84 of file qgslegendrenderer.cpp.
|
inline |
Returns the preferred legend size set by the client.
If the returned size is null, the legend will be drawn with the minimum possible size to fit its content.
Definition at line 99 of file qgslegendrenderer.h.
QSizeF QgsLegendRenderer::minimumSize | ( | QgsRenderContext * | renderContext = nullptr | ) |
Runs the layout algorithm and returns the minimum size required for the legend.
Definition at line 51 of file qgslegendrenderer.cpp.
|
static |
Returns the style for the given node, within the specified model.
Definition at line 1083 of file qgslegendrenderer.cpp.
|
delete |
QgsLayerTreeFilterProxyModel * QgsLegendRenderer::proxyModel | ( | ) |
Returns the filter proxy model used for filtering the legend model content during rendering.
Filters can be set on the proxy model to filter rendered legend content.
Definition at line 1111 of file qgslegendrenderer.cpp.
|
inline |
Sets the preferred resulting legend size.
If the size is null, the legend will be drawn with the minimum possible size to fit its content.
Definition at line 89 of file qgslegendrenderer.h.
|
static |
Sets the style of a node.
Definition at line 1116 of file qgslegendrenderer.cpp.