41   , mEmbeddedInParent( false )
    52   return Qt::ItemIsEnabled;
    71   double itemHeight = std::max( static_cast< double >( settings.
symbolSize().height() ), textHeight );
    87   QIcon symbolIcon = 
data( Qt::DecorationRole ).value<QIcon>();
    88   if ( symbolIcon.isNull() )
    99                           static_cast< int >( ctx->
top + ( itemHeight - settings.
symbolSize().height() ) / 2 ),
   100                           static_cast< int >( settings.
symbolSize().width() ),
   101                           static_cast< int >( settings.
symbolSize().height() ) );
   105         symbolIcon.paint( ctx->
painter,
   107                           static_cast< int >( ctx->
top + ( itemHeight - settings.
symbolSize().height() ) / 2 ),
   108                           static_cast< int >( settings.
symbolSize().width() ),
   109                           static_cast< int >( settings.
symbolSize().height() ) );
   118   const QIcon icon = 
data( Qt::DecorationRole ).value<QIcon>();
   122   const QImage image( icon.pixmap( settings.
symbolSize().width(), settings.
symbolSize().height() ).toImage() );
   123   QByteArray byteArray;
   124   QBuffer buffer( &byteArray );
   125   image.save( &buffer, 
"PNG" );
   126   const QString base64 = QString::fromLatin1( byteArray.toBase64().data() );
   127   json[ 
"icon" ] = base64;
   132   QSizeF labelSize( 0, 0 );
   142   labelSize.rheight() = lines.count() * textHeight + ( lines.count() - 1 ) * ( settings.
lineSpacing() + textDescent );
   144   double labelXMin = 0.0;
   145   double labelXMax = 0.0;
   174     if ( labelSize.height() < symbolSize.height() )
   175       labelY += symbolSize.height() / 2 - labelSize.height() / 2;  
   177     labelY += textHeight;
   180   for ( QStringList::ConstIterator itemPart = lines.constBegin(); itemPart != lines.constEnd(); ++itemPart )
   183     labelSize.rwidth() = std::max( lineWidth, 
double( labelSize.width() ) );
   191           settings.
drawText( ctx->
painter, labelXMin, labelY, *itemPart, symbolLabelFont );
   195           settings.
drawText( ctx->
painter, labelXMax - lineWidth, labelY, *itemPart, symbolLabelFont );
   198         case Qt::AlignHCenter:
   199           settings.
drawText( ctx->
painter, labelXMin + ( labelXMax - labelXMin - lineWidth ) / 2.0, labelY, *itemPart, symbolLabelFont );
   203       if ( itemPart != ( lines.end() - 1 ) )
   204         labelY += textDescent + settings.
lineSpacing() + textHeight;
   213   const QString text = 
data( Qt::DisplayRole ).toString();
   214   json[ 
"title" ] = text;
   222   , mSymbolUsesMapUnits( false )
   225   mIconSize = QSize( iconSize, iconSize );
   229   connect( nodeLayer, &QObject::destroyed, 
this, [ = ]() { 
mLayerNode = 
nullptr; } );
   238     return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
   240     return Qt::ItemIsEnabled;
   254   QSize minSz( iconSize, iconSize );
   272   if ( !mTextOnSymbolLabel.isEmpty() && context )
   276     int wInt = ceil( w ), hInt = ceil( h );
   277     if ( wInt > minSz.width() ) minSz.setWidth( wInt );
   278     if ( hInt > minSz.height() ) minSz.setHeight( hInt );
   282     minSz.setWidth( mItem.
level() * INDENT_SIZE + minSz.width() );
   298     QString layerName = legendlabel.isNull() ? 
mLayerNode->
name() : legendlabel.toString();
   311   std::unique_ptr< QgsSymbol > s( symbol ); 
   313   if ( !vlayer || !vlayer->
renderer() )
   338   if ( !vlayer || !vlayer->
renderer() )
   342   for ( 
const auto &item : symbolList )
   363   std::unique_ptr<QgsRenderContext> context = qgis::make_unique<QgsRenderContext>( );
   364   context->setScaleFactor( dpi / 25.4 );
   365   context->setRendererScale( scale );
   367   return context.release();
   370 void QgsSymbolLegendNode::checkAll( 
bool state )
   373   if ( !vlayer || !vlayer->
renderer() )
   377   for ( 
const auto &item : symbolList )
   388   if ( role == Qt::DisplayRole )
   392   else if ( role == Qt::EditRole )
   396   else if ( role == Qt::DecorationRole )
   398     if ( mPixmap.isNull() || mPixmap.size() != mIconSize )
   406         if ( !mTextOnSymbolLabel.isEmpty() && context )
   408           QPainter painter( &pix );
   409           painter.setRenderHint( QPainter::Antialiasing );
   410           context->setPainter( &painter );
   411           QFontMetricsF fm( mTextOnSymbolTextFormat.
scaledFont( *context ) );
   412           qreal yBaselineVCenter = ( mIconSize.height() + fm.ascent() - fm.descent() ) / 2;
   414                                      QStringList() << mTextOnSymbolLabel, *context, mTextOnSymbolTextFormat );
   419         pix = QPixmap( mIconSize );
   420         pix.fill( Qt::transparent );
   428         QPixmap pix2( pix.width() + mItem.
level() * INDENT_SIZE, pix.height() );
   429         pix2.fill( Qt::transparent );
   431         p.drawPixmap( mItem.
level() * INDENT_SIZE, 0, pix );
   438   else if ( role == Qt::CheckStateRole )
   444     if ( !vlayer || !vlayer->
renderer() )
   463   if ( role != Qt::CheckStateRole )
   470   if ( !vlayer || !vlayer->
renderer() )
   495   std::unique_ptr< QgsRenderContext > tempRenderContext;
   500     tempRenderContext = qgis::make_unique< QgsRenderContext >();
   502     tempRenderContext->setRendererScale( settings.
mapScale() );
   505     tempRenderContext->setForceVectorOutput( 
true );
   506     tempRenderContext->setPainter( ctx ? ctx->
painter : 
nullptr );
   511     tempRenderContext->setExpressionContext( expContext );
   512     context = tempRenderContext.get();
   516   double height = settings.
symbolSize().height();
   520   double widthOffset = 0;
   521   double heightOffset = 0;
   523   if ( 
QgsMarkerSymbol *markerSymbol = dynamic_cast<QgsMarkerSymbol *>( s ) )
   526     double size = markerSymbol->size( *context ) / context->
scaleFactor();
   531       widthOffset = ( settings.
symbolSize().width() - width ) / 2.0;
   533     if ( height < settings.
symbolSize().height() )
   535       heightOffset = ( settings.
symbolSize().height() - height ) / 2.0;
   541     double currentYCoord = ctx->
top + ( itemHeight - settings.
symbolSize().height() ) / 2;
   549       opacity = 
static_cast<int >( std::round( 255 * vectorLayer->opacity() ) );
   552     p->setRenderHint( QPainter::Antialiasing );
   558         p->translate( ctx->
columnLeft + widthOffset, currentYCoord + heightOffset );
   561         p->translate( ctx->
columnRight - widthOffset - width, currentYCoord + heightOffset );
   565     p->scale( 1.0 / dotsPerMM, 1.0 / dotsPerMM );
   572       const QSize symbolSize( static_cast< int >( std::round( width * dotsPerMM ) ), static_cast<int >( std::round( height * dotsPerMM ) ) );
   573       const QSize tempImageSize( symbolSize.width() + maxBleed * 2, symbolSize.height() + maxBleed * 2 );
   574       QImage tempImage = QImage( tempImageSize, QImage::Format_ARGB32 );
   575       tempImage.fill( Qt::transparent );
   576       QPainter imagePainter( &tempImage );
   577       imagePainter.setRenderHint( QPainter::Antialiasing );
   579       imagePainter.translate( maxBleed, maxBleed );
   581       imagePainter.translate( -maxBleed, -maxBleed );
   584       imagePainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
   585       imagePainter.fillRect( tempImage.rect(), QColor( 0, 0, 0, opacity ) );
   588       p->drawImage( -maxBleed, -maxBleed, tempImage );
   592       s->
drawPreviewIcon( p, QSize( static_cast< int >( std::round( width * dotsPerMM ) ), static_cast< int >( std::round( height * dotsPerMM ) ) ), context );
   595     if ( !mTextOnSymbolLabel.isEmpty() )
   597       QFontMetricsF fm( mTextOnSymbolTextFormat.
scaledFont( *context ) );
   598       qreal yBaselineVCenter = ( height * dotsPerMM + fm.ascent() - fm.descent() ) / 2;
   600                                  QStringList() << mTextOnSymbolLabel, *context, mTextOnSymbolTextFormat );
   606   return QSizeF( std::max( width + 2 * widthOffset, static_cast< double >( settings.
symbolSize().width() ) ),
   607                  std::max( height + 2 * heightOffset, static_cast< double >( settings.
symbolSize().height() ) ) );
   630   QImage img( pix.toImage().convertToFormat( QImage::Format_ARGB32_Premultiplied ) );
   634     opacity = ( 255 * vectorLayer->opacity() );
   636   if ( opacity != 255 )
   639     painter.begin( &img );
   640     painter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
   641     painter.fillRect( pix.rect(), QColor( 0, 0, 0, opacity ) );
   645   QByteArray byteArray;
   646   QBuffer buffer( &byteArray );
   647   img.save( &buffer, 
"PNG" );
   648   const QString base64 = QString::fromLatin1( byteArray.toBase64().data() );
   649   json[ 
"icon" ] = base64;
   661   if ( mSymbolUsesMapUnits )
   669 void QgsSymbolLegendNode::updateLabel()
   678   if ( showFeatureCount && vl )
   681     mLabel += QStringLiteral( 
" [%1]" ).arg( count != -1 ? QLocale().toString( count ) : tr( 
"N/A" ) );
   701     if ( label.isEmpty() )
   705       else if ( mLabel.contains( 
"[%" ) )
   717       else if ( label.contains( 
"[%" ) )
   752   if ( role == Qt::DisplayRole || role == Qt::EditRole )
   754   else if ( role == Qt::DecorationRole )
   773   if ( role == Qt::DecorationRole )
   775     return QPixmap::fromImage( mImage );
   777   else if ( role == Qt::SizeHintRole )
   779     return mImage.size();
   786   Q_UNUSED( itemHeight )
   795                                  mImage, QRectF( 0, 0, mImage.width(), mImage.height() ) );
   800                                  mImage, QRectF( 0, 0, mImage.width(), mImage.height() ) );
   809   QByteArray byteArray;
   810   QBuffer buffer( &byteArray );
   811   mImage.save( &buffer, 
"PNG" );
   812   const QString base64 = QString::fromLatin1( byteArray.toBase64().data() );
   813   json[ 
"icon" ] = base64;
   827   if ( role == Qt::DecorationRole )
   830     QPixmap pix( iconSize, iconSize );
   834   else if ( role == Qt::DisplayRole || role == Qt::EditRole )
   845     QColor itemColor = mColor;
   849         itemColor.setAlpha( rasterRenderer->opacity() * 255.0 );
   851     ctx->
painter->setBrush( itemColor );
   858       pen.setJoinStyle( Qt::MiterJoin );
   863       ctx->
painter->setPen( Qt::NoPen );
   885   QImage img = QImage( settings.
symbolSize().toSize(), QImage::Format_ARGB32 );
   886   img.fill( Qt::transparent );
   888   QPainter painter( &img );
   889   painter.setRenderHint( QPainter::Antialiasing );
   891   QColor itemColor = mColor;
   895       itemColor.setAlpha( rasterRenderer->opacity() * 255.0 );
   897   painter.setBrush( itemColor );
   904     pen.setJoinStyle( Qt::MiterJoin );
   905     painter.setPen( pen );
   909     painter.setPen( Qt::NoPen );
   912   painter.drawRect( QRectF( 0, 0, settings.
symbolSize().width(), settings.
symbolSize().height() ) );
   914   QByteArray byteArray;
   915   QBuffer buffer( &byteArray );
   916   img.save( &buffer, 
"PNG" );
   917   const QString base64 = QString::fromLatin1( byteArray.toBase64().data() );
   918   json[ 
"icon" ] = base64;
   929 QImage QgsWmsLegendNode::getLegendGraphic()
 const   931   if ( ! mValid && ! mFetcher )
   946     Q_ASSERT( ! mFetcher );
   965   if ( role == Qt::DecorationRole )
   967     return QPixmap::fromImage( getLegendGraphic() );
   969   else if ( role == Qt::SizeHintRole )
   971     return getLegendGraphic().size();
   978   Q_UNUSED( itemHeight )
   991                                  QRectF( QPointF( 0, 0 ), mImage.size() ) );
  1000                                  QRectF( QPointF( 0, 0 ), mImage.size() ) );
  1009   QByteArray byteArray;
  1010   QBuffer buffer( &byteArray );
  1011   mImage.save( &buffer, 
"PNG" );
  1012   const QString base64 = QString::fromLatin1( byteArray.toBase64().data() );
  1013   json[ 
"icon" ] = base64;
  1017 QImage QgsWmsLegendNode::renderMessage( 
const QString &msg )
 const  1019   const int fontHeight = 10;
  1020   const int margin = fontHeight / 2;
  1021   const int nlines = 1;
  1023   const int w = 512, h = fontHeight * nlines + margin * ( nlines + 1 );
  1024   QImage image( w, h, QImage::Format_ARGB32_Premultiplied );
  1026   painter.begin( &image );
  1027   painter.setPen( QColor( 255, 0, 0 ) );
  1028   painter.setFont( QFont( QStringLiteral( 
"Chicago" ), fontHeight ) );
  1029   painter.fillRect( 0, 0, w, h, QColor( 255, 255, 255 ) );
  1030   painter.drawText( 0, margin + fontHeight, msg );
  1037 void QgsWmsLegendNode::getLegendGraphicProgress( qint64 cur, qint64 tot )
  1039   QString msg = QStringLiteral( 
"Downloading... %1/%2" ).arg( cur ).arg( tot );
  1041   mImage = renderMessage( msg );
  1045 void QgsWmsLegendNode::getLegendGraphicErrored( 
const QString &msg )
  1047   if ( ! mFetcher ) 
return; 
  1049   mImage = renderMessage( msg );
  1061 void QgsWmsLegendNode::getLegendGraphicFinished( 
const QImage &image )
  1063   if ( ! mFetcher ) 
return; 
  1066   if ( ! image.isNull() )
  1068     if ( image != mImage )
  1102   if ( role == Qt::DecorationRole )
  1105     return QPixmap::fromImage( mImage );
  1107   else if ( role == Qt::SizeHintRole )
  1110     return mImage.size();
  1128     ctx->
painter->setRenderHint( QPainter::Antialiasing );
  1138   double labelXOffset;
  1151 void QgsDataDefinedSizeLegendNode::cacheImage()
 const  1153   if ( mImage.isNull() )
  1159       Q_ASSERT( context ); 
  1160       context->setScaleFactor( 96 / 25.4 );
 void exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context, QJsonObject &json) const override
Adds a symbol in base64 string within a JSON object with the key "icon". 
 
Q_NOWARN_DEPRECATED_POP QgsRenderContext * context
Render context, if available. 
 
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
 
void drawText(QPainter *p, double x, double y, const QString &text, const QFont &font) const
Draws Text. 
 
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend. 
 
Single variable definition for use within a QgsExpressionContextScope. 
 
QgsDataDefinedSizeLegendNode(QgsLayerTreeLayer *nodeLayer, const QgsDataDefinedSizeLegend &settings, QObject *parent=nullptr)
Construct the node using QgsDataDefinedSizeLegend as definition of the node's appearance. 
 
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr)
Draws an icon of the symbol that occupies an area given by size using the specified painter...
 
double columnRight
Right side of current legend column. 
 
~QgsDataDefinedSizeLegendNode() override
 
virtual Qt::ItemFlags flags() const
Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled. 
 
double mapScale() const
Returns the legend map scale. 
 
QString labelExpression() const
Returns the expression member of the LayerTreeNode. 
 
QgsRenderContext * createTemporaryRenderContext() const
Returns a temporary context or nullptr if legendMapViewData are not valid. 
 
QList< QgsLegendSymbolItem > QgsLegendSymbolList
 
Text at point of origin draw mode. 
 
QgsSymbol * symbol() const
Returns associated symbol. May be nullptr. 
 
Abstract base class for all rendered symbols. 
 
QString ruleKey() const
Returns unique identifier of the rule for identification of the item within renderer. 
 
bool useAdvancedEffects() const
 
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class. 
 
virtual QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const
Draws symbol on the left side of the item. 
 
void setFont(const QFont &font)
Sets font used for rendering of labels - only valid for collapsed legend. 
 
Use antialiasing while drawing. 
 
QgsImageLegendNode(QgsLayerTreeLayer *nodeLayer, const QImage &img, QObject *parent=nullptr)
Constructor for QgsImageLegendNode. 
 
virtual bool setData(const QVariant &value, int role)
Sets some data associated with the item. Default implementation does nothing and returns false...
 
QStringList evaluateItemText(const QString &text, const QgsExpressionContext &context) const
Splits a string using the wrap char taking into account handling empty wrap char which means no wrapp...
 
Represents a raster layer. 
 
QgsSymbolLegendNode(QgsLayerTreeLayer *nodeLayer, const QgsLegendSymbolItem &item, QObject *parent=nullptr)
Constructor for QgsSymbolLegendNode. 
 
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class. 
 
bool testFlag(Flag f) const
Check whether a flag is enabled. 
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference) 
 
void emitStyleChanged()
Triggers an emission of the styleChanged() signal. 
 
double margin(Side side)
Returns the margin (in mm) for the specified side of the component. 
 
void setRendererScale(double scale)
Sets the renderer map scale. 
 
QFont font() const
Returns the font used for rendering this legend component. 
 
Qt::AlignmentFlag symbolAlignment() const
Returns the alignment for placement of legend symbols. 
 
virtual QgsImageFetcher * getLegendGraphicFetcher(const QgsMapSettings *mapSettings)
Returns a new image downloader for the raster legend. 
 
void invalidateMapBasedData() override
Notification from model that information from associated map view has changed. 
 
void invalidateMapBasedData() override
Notification from model that information from associated map view has changed. 
 
QgsLayerTreeLayer * layerNode() const
Returns pointer to the parent layer node. 
 
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class. 
 
bool drawRasterStroke() const
Returns whether a stroke will be drawn around raster symbol items. 
 
double textWidthMillimeters(const QFont &font, const QString &text) const
Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE...
 
void exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context, QJsonObject &json) const override
Adds a symbol in base64 string within a JSON object with the key "icon". 
 
QgsLayerTreeModelLegendNode(QgsLayerTreeLayer *nodeL, QObject *parent=nullptr)
Construct the node with pointer to its parent layer node. 
 
QString label() const
Returns text label. 
 
QPainter * painter
Painter. 
 
QgsWmsLegendNode(QgsLayerTreeLayer *nodeLayer, QObject *parent=nullptr)
Constructor for QgsWmsLegendNode. 
 
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
Draws symbol on the left side of the item. 
 
A marker symbol type, for rendering Point and MultiPoint geometries. 
 
QColor rasterStrokeColor() const
Returns the stroke color for the stroke drawn around raster symbol items. 
 
void exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context, QJsonObject &json) const override
Adds a symbol in base64 string within a JSON object with the key "icon". 
 
The QgsMapSettings class contains configuration for rendering of the map. 
 
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol. 
 
void toggleAllItems()
Toggle all items belonging to the same layer as this node. 
 
QSize minimumIconSize() const
Calculates the minimum icon size to prevent cropping. 
 
Perform transforms between map coordinates and device coordinates. 
 
The QgsLayerTreeModel class is model implementation for Qt item views framework. 
 
QSizeF wmsLegendSize() const
 
Rule key of the parent legend node - for legends with tree hierarchy (QString). Added in 2...
 
QgsLegendStyle style(QgsLegendStyle::Style s) const
Returns style. 
 
QgsRasterDataProvider * dataProvider() override
Returns the source data provider. 
 
QImage collapsedLegendImage(QgsRenderContext &context, const QColor &backgroundColor=Qt::transparent, double paddingMM=1) const
Returns output image that would be shown in the legend. Returns invalid image if legend is not config...
 
void exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context, QJsonObject &json) const override
Adds a symbol in base64 string within a JSON object with the key "icon". 
 
QString name() const override
Returns the layer's name. 
 
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes. 
 
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
Draws symbol on the left side of the item. 
 
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted...
 
static int scaleIconSize(int standardSize)
Scales an layer tree model icon size to compensate for display pixel density, making the icon size hi...
 
Qt::ItemFlags flags() const override
Returns item flags associated with the item. Default implementation returns Qt::ItemIsEnabled. 
 
Rule key of the node (QString) 
 
void setSymbol(QgsSymbol *s)
Sets the symbol of the item. 
 
QgsRasterSymbolLegendNode(QgsLayerTreeLayer *nodeLayer, const QColor &color, const QString &label, QObject *parent=nullptr)
Constructor for QgsRasterSymbolLegendNode. 
 
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key. 
 
void checkAllItems()
Checks all items belonging to the same layer as this node. 
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
void error(const QString &msg)
Emitted when an error occurs. 
 
QgsLayerTreeLayer * mLayerNode
 
double rasterStrokeWidth() const
Returns the stroke width (in millimeters) for the stroke drawn around raster symbol items...
 
QgsLayerTreeModel * model() const
Returns pointer to model owning this legend node. 
 
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLege...
 
QVariant customProperty(const QString &key, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer. Properties are stored in a map and saved in project file...
 
ItemMetrics draw(const QgsLegendSettings &settings, ItemContext *ctx) override
Entry point called from QgsLegendRenderer to do the rendering. 
 
Symbol icon (excluding label) 
 
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation. 
 
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked 
 
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol. 
 
QgsFeatureRenderer * renderer()
Returns renderer. 
 
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer. 
 
double maxSiblingSymbolWidth
Largest symbol width, considering all other sibling legend components associated with the current com...
 
QString symbolLabel() const
Label of the symbol, user defined label will be used, otherwise will default to the label made by QGI...
 
void drawCollapsedLegend(QgsRenderContext &context, QSizeF *outputSize SIP_OUT=nullptr, double *labelXOffset SIP_OUT=nullptr) const
Draw the legend if using LegendOneNodeForAll and optionally output size of the legend and x offset of...
 
Single scope for storing variables and functions for use within a QgsExpressionContext. 
 
void dataChanged()
Emitted on internal data change so the layer tree model can forward the signal to views...
 
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons. 
 
void symbolFeatureCountMapChanged()
Emitted when the feature count for symbols on this layer has been recalculated. 
 
Qt::Alignment alignment() const
Returns the alignment for the legend component. 
 
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked 
 
virtual void setLegendSymbolItem(const QString &key, QgsSymbol *symbol)
Sets the symbol to be used for a legend symbol item. 
 
bool isCheckable() const
Returns whether the item is user-checkable - whether renderer supports enabling/disabling it...
 
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
Draws symbol on the left side of the item. 
 
QSizeF symbolSize() const
 
static void drawText(const QRectF &rect, double rotation, HAlignment alignment, const QStringList &textLines, QgsRenderContext &context, const QgsTextFormat &format, bool drawAsOutlines=true)
Draws text within a rectangle using the specified settings. 
 
double fontHeightCharacterMM(const QFont &font, QChar c) const
Returns the font height of a character in millimeters. 
 
virtual ItemMetrics draw(const QgsLegendSettings &settings, ItemContext *ctx)
Entry point called from QgsLegendRenderer to do the rendering. 
 
QgsExpressionContext & expressionContext()
Gets the expression context. 
 
void setEmbeddedInParent(bool embedded) override
 
QgsMapLayer * layer() const
Returns the map layer associated with this node. 
 
void setSymbol(QgsSymbol *symbol)
Sets the symbol to be used by the legend node. 
 
double top
Top y-position of legend item. 
 
const QgsSymbol * symbol() const
Returns the symbol used by the legend node. 
 
void exportToJson(const QgsLegendSettings &settings, const QgsRenderContext &context, QJsonObject &json)
Entry point called from QgsLegendRenderer to do the rendering in a JSON object. 
 
QgsSimpleLegendNode(QgsLayerTreeLayer *nodeLayer, const QString &label, const QIcon &icon=QIcon(), QObject *parent=nullptr, const QString &key=QString())
Constructor for QgsSimpleLegendNode. 
 
virtual void setEmbeddedInParent(bool embedded)
 
QFont scaledFont(const QgsRenderContext &context) const
Returns a font with the size scaled to match the format's size settings (including units and map unit...
 
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
 
Contains information about the context of a rendering operation. 
 
QgsExpressionContextScope * createExpressionContextScope() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
 
SymbolType type() const
Returns the symbol's type. 
 
QSizeF drawSymbol(const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight) const override
Draws symbol on the left side of the item. 
 
bool setData(const QVariant &value, int role) override
Sets some data associated with the item. Default implementation does nothing and returns false...
 
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context. 
 
static QPixmap symbolPreviewPixmap(const QgsSymbol *symbol, QSize size, int padding=0, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr)
Returns a pixmap preview for a color ramp. 
 
virtual void exportSymbolToJson(const QgsLegendSettings &settings, const QgsRenderContext &context, QJsonObject &json) const
Adds a symbol in base64 string within a JSON object with the key "icon". 
 
double columnLeft
Left side of current legend column. 
 
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
 
virtual QVariant data(int role) const =0
Returns data associated with the item. Must be implemented in derived class. 
 
void legendMapViewData(double *mapUnitsPerPixel, int *dpi, double *scale) const
Gets hints about map view - to be used in legend nodes. 
 
static QRect nonTransparentImageRect(const QImage &image, QSize minSize=QSize(), bool center=false)
Calculates the non-transparent region of an image. 
 
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
 
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class. 
 
void uncheckAllItems()
Unchecks all items belonging to the same layer as this node. 
 
void appendScopes(const QList< QgsExpressionContextScope *> &scopes)
Appends a list of scopes to the end of the context. 
 
void setTextColor(const QColor &color)
Sets text color for rendering of labels - only valid for collapsed legend. 
 
virtual QSizeF drawSymbolText(const QgsLegendSettings &settings, ItemContext *ctx, QSizeF symbolSize) const
Draws label on the right side of the item. 
 
QString parentRuleKey() const
Key of the parent legend node. 
 
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class. 
 
Symbol label (excluding icon) 
 
double lineSpacing() const
 
For legends that support it, will show them in a tree instead of a list (needs also ShowLegend)...
 
static double textWidth(const QgsRenderContext &context, const QgsTextFormat &format, const QStringList &textLines, QFontMetricsF *fontMetrics=nullptr)
Returns the width of a text based on a given format. 
 
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes. 
 
Represents a vector layer which manages a vector based data sets. 
 
void finish(const QImage &legend)
Emitted when the download completes. 
 
Object that keeps configuration of appearance of marker symbol's data-defined size in legend...
 
QVariant data(int role) const override
Returns data associated with the item. Must be implemented in derived class. 
 
int level() const
Indentation level that tells how deep the item is in a hierarchy of items. For flat lists level is 0...
 
double fontDescentMillimeters(const QFont &font) const
Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCA...
 
QString evaluateLabel(const QgsExpressionContext &context=QgsExpressionContext(), const QString &label=QString())
Evaluates and returns the text label of the current node. 
 
double mmPerMapUnit() const
 
Raster renderer pipe that applies colors to a raster. 
 
void exportSymbolTextToJson(const QgsLegendSettings &settings, QJsonObject &json) const
Adds a label in a JSON object with the key "title". 
 
void progress(qint64 received, qint64 total)
Emitted to report progress. 
 
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context. 
 
Layer tree node points to a map layer. 
 
static QString replaceExpressionText(const QString &action, const QgsExpressionContext *context, const QgsDistanceArea *distanceArea=nullptr)
This function replaces each expression between [% and %] in the string with the result of its evaluat...
 
Base class for raster data providers. 
 
static double textHeight(const QgsRenderContext &context, const QgsTextFormat &format, const QStringList &textLines, DrawMode mode, QFontMetricsF *fontMetrics=nullptr)
Returns the height of a text based on a given format.