16 #ifndef QGSLEGENDRENDERER_H 17 #define QGSLEGENDRENDERER_H 19 #include "qgis_core.h" 87 void drawLegend( QPainter *painter );
101 void exportLegendToJson(
const QgsRenderContext &context, QJsonObject &json );
128 class LegendComponent
132 LegendComponent() =
default;
134 QObject *item =
nullptr;
151 double labelXOffset = 0.0;
157 double maxSiblingSymbolWidth = 0.0;
174 class LegendComponentGroup
179 QList<LegendComponent> components;
182 QSizeF size = QSizeF( 0, 0 );
212 QSizeF paintAndDetermineSize( QPainter *painter =
nullptr );
223 void setColumns( QList<LegendComponentGroup> &groupList );
232 QSizeF drawTitle( QPainter *painter =
nullptr,
double top = 0, Qt::AlignmentFlag halignment = Qt::AlignLeft,
double legendWidth = 0 );
237 double spaceAboveGroup(
const LegendComponentGroup &group );
245 QSizeF drawGroup(
const LegendComponentGroup &group, ColumnContext columnContext, QPainter *painter =
nullptr,
double top = 0 );
250 LegendComponent drawSymbolItem(
QgsLayerTreeModelLegendNode *symbolItem, ColumnContext columnContext = ColumnContext(), QPainter *painter =
nullptr,
double top = 0,
double maxSiblingSymbolWidth = 0 );
259 QSizeF drawLayerTitle(
QgsLayerTreeLayer *nodeLayer, ColumnContext columnContext = ColumnContext(), QPainter *painter =
nullptr,
double top = 0 );
265 QSizeF drawGroupTitle(
QgsLayerTreeGroup *nodeGroup, ColumnContext columnContext = ColumnContext(), QPainter *painter =
nullptr,
double top = 0 );
289 QSizeF drawTitle(
QgsRenderContext *context,
double top, Qt::AlignmentFlag halignment = Qt::AlignLeft,
double legendWidth = 0 );
299 QSizeF drawGroup(
const LegendComponentGroup &group,
QgsRenderContext *rendercontext, ColumnContext columnContext,
double top = 0 );
334 QSizeF drawTitleInternal(
QgsRenderContext *context, QPainter *painter,
double top, Qt::AlignmentFlag halignment,
double legendWidth );
335 QSizeF drawGroupInternal(
const LegendComponentGroup &group,
QgsRenderContext *context, ColumnContext columnContext, QPainter *painter,
double top );
336 QgsLegendRenderer::LegendComponent drawSymbolItemInternal(
QgsLayerTreeModelLegendNode *symbolItem, ColumnContext columnContext,
QgsRenderContext *context, QPainter *painter,
double top,
double maxSiblingSymbolWidth );
339 QSizeF paintAndDetermineSizeInternal(
QgsRenderContext *context, QPainter *painter );
341 void widthAndOffsetForTitleText(
const Qt::AlignmentFlag halignment,
double legendWidth,
double &width,
double &offset );
344 #endif // QGSLEGENDRENDERER_H Layer tree group node serves as a container for layers and further groups.
void setLegendSize(QSizeF s)
Sets the preferred resulting legend size.
Abstract base class for all rendered symbols.
The QgsLayerTreeModel class is model implementation for Qt item views framework.
QSizeF legendSize() const
Returns the preferred legend size set by the client.
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
This class is a base class for nodes in a layer tree.
Style
Component of legends which can be styled.
Contains information about the context of a rendering operation.
QgsLayerTreeModel * legendModel(const QgsWmsRenderContext &context, QgsLayerTree &tree)
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
Layer tree node points to a map layer.
The QgsLegendRenderer class handles automatic layout and rendering of legend.