25 , mWmsLegendSize( 50, 25 )
26 , mRasterStrokeColor( Qt::black )
128 return mMmPerMapUnit;
138 return mUseAdvancedEffects;
143 mUseAdvancedEffects = use;
158 return 1 / ( mMmPerMapUnit * ( mDpi / 25.4 ) );
184 const QStringList lines = stringToSplit.split(
'\n' );
191 for (
const QString &line : lines )
193 res.append( line.split(
wrapChar() ) );
198#define FONT_WORKAROUND_SCALE 10
206 p->setFont( textFont );
208 p->scale( scaleFactor, scaleFactor );
213void QgsLegendSettings::drawText( QPainter *p,
const QRectF &rect,
const QString &text,
const QFont &font, Qt::AlignmentFlag halignment, Qt::AlignmentFlag valignment,
int flags )
const
221 p->setFont( textFont );
223 p->scale( scaleFactor, scaleFactor );
224 p->drawText( scaledRect, halignment | valignment | flags, text );
230 QFont scaledFont = font;
232 scaledFont.setPixelSize( pixelSize );
238 return ( pointSize * 0.3527 );
244 const QFontMetricsF fontMetrics( metricsFont );
251 const QFontMetricsF fontMetrics( metricsFont );
258 const QFontMetricsF fontMetrics( metricsFont );
265 const QFontMetricsF fontMetrics( metricsFont );
271 return mJsonRenderFlags;
@ Symbol
Symbol icon (excluding label)
@ Group
Legend group title.
@ Subgroup
Legend subgroup title.
@ SymbolLabel
Symbol label (excluding icon)
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size)
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
QFlags< LegendJsonRenderFlag > LegendJsonRenderFlags
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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...
QString wrapChar() const
Returns the string used as a wrapping character.
Q_DECL_DEPRECATED void setFontColor(const QColor &c)
Sets the font color used for legend items.
Q_DECL_DEPRECATED QColor layerFontColor() const
Returns layer font color, defaults to fontColor()
void drawText(QPainter *p, double x, double y, const QString &text, const QFont &font) const
Draws Text.
QgsLegendStyle & rstyle(Qgis::LegendComponent s)
Returns modifiable reference to the style for a legend component.
Q_DECL_DEPRECATED void setMapScale(double scale)
Sets the legend map scale.
Q_DECL_DEPRECATED void setLayerFontColor(const QColor &fontColor)
Sets layer font color to fontColor Overrides fontColor()
Q_DECL_DEPRECATED void setMapUnitsPerPixel(double mapUnitsPerPixel)
Sets the mmPerMapUnit calculated by mapUnitsPerPixel mostly taken from the map settings.
Q_DECL_DEPRECATED void setLineSpacing(double s)
Sets the line spacing to use between lines of legend text.
Q_DECL_DEPRECATED void setMmPerMapUnit(double mmPerMapUnit)
Q_DECL_DEPRECATED void setDpi(int dpi)
void setJsonRenderFlags(const Qgis::LegendJsonRenderFlags &jsonRenderFlags)
Sets the the JSON export flags to jsonRenderFlags.
double fontDescentMillimeters(const QFont &font) const
Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCA...
Q_DECL_DEPRECATED QColor fontColor() const
Returns the font color used for legend items.
double textWidthMillimeters(const QFont &font, const QString &text) const
Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE...
Q_DECL_DEPRECATED bool useAdvancedEffects() const
double pixelFontSize(double pointSize) const
Calculates font to from point size to pixel size.
double fontHeightCharacterMM(const QFont &font, QChar c) const
Returns the font height of a character in millimeters.
Q_DECL_DEPRECATED void setUseAdvancedEffects(bool use)
void updateDataDefinedProperties(QgsRenderContext &context)
Updates any data-defined properties in the settings, using the specified render context.
double fontAscentMillimeters(const QFont &font) const
Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCAL...
QgsLegendStyle style(Qgis::LegendComponent s) const
Returns the style for a legend component.
Q_DECL_DEPRECATED int dpi() const
QFont scaledFontPixelSize(const QFont &font) const
Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE.
Q_DECL_DEPRECATED double mapUnitsPerPixel() const
Returns the factor of map units per pixel for symbols with size given in map units calculated by dpi ...
Q_DECL_DEPRECATED double mmPerMapUnit() const
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...
Qgis::LegendJsonRenderFlags jsonRenderFlags() const
Returns the JSON export flags.
QStringList splitStringForWrapping(const QString &stringToSplt) const
Splits a string using the wrap char taking into account handling empty wrap char which means no wrapp...
Q_DECL_DEPRECATED double mapScale() const
Returns the legend map scale.
void setIndent(double indent)
Sets the indent (in mm) of a group or subgroup.
QgsTextFormat & textFormat()
Returns the text format used for rendering this legend component.
void setMargin(Side side, double margin)
Sets the margin (in mm) for the specified side of the component.
void updateDataDefinedProperties(QgsRenderContext &context)
Updates any data-defined properties in the style, using the specified render context.
void setTextFormat(const QgsTextFormat &format)
Sets the text format used for rendering this legend component.
Contains information about the context of a rendering operation.
Scoped object for saving and restoring a QPainter object's state.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void setSize(double size)
Sets the size for rendered text.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the size of rendered text.
void setLineHeightUnit(Qgis::RenderUnit unit)
Sets the unit for the line height for text.
double size() const
Returns the size for rendered text.
QColor color() const
Returns the color that text will be rendered in.
void setLineHeight(double height)
Sets the line height for text.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define FONT_WORKAROUND_SCALE