QGIS API Documentation
3.8.0-Zanzibar (11aff65)
|
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLegendRenderer. More...
#include <qgslegendsettings.h>
Public Member Functions | |
QgsLegendSettings () | |
double | boxSpace () const |
int | columnCount () const |
double | columnSpace () const |
int | dpi () const |
bool | drawRasterStroke () const |
Returns whether a stroke will be drawn around raster symbol items. More... | |
void | drawText (QPainter *p, double x, double y, const QString &text, const QFont &font) const |
Draws Text. More... | |
void | drawText (QPainter *p, const QRectF &rect, const QString &text, const QFont &font, Qt::AlignmentFlag halignment=Qt::AlignLeft, Qt::AlignmentFlag valignment=Qt::AlignTop, int flags=Qt::TextWordWrap) const |
Like the above, but with a rectangle for multiline text. More... | |
bool | equalColumnWidth () 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 wrapping. More... | |
double | fontAscentMillimeters (const QFont &font) const |
Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE. More... | |
QColor | fontColor () const |
double | fontDescentMillimeters (const QFont &font) const |
Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE. More... | |
double | fontHeightCharacterMM (const QFont &font, QChar c) const |
Returns the font height of a character in millimeters. More... | |
QColor | layerFontColor () const |
Returns layer font color, defaults to fontColor() More... | |
double | lineSpacing () const |
double | mapScale () const |
Returns the legend map scale. More... | |
double | mapUnitsPerPixel () const |
Returns the factor of map units per pixel for symbols with size given in map units calculated by dpi and mmPerMapUnit. More... | |
double | mmPerMapUnit () const |
double | pixelFontSize (double pointSize) const |
Calculates font to from point size to pixel size. More... | |
QColor | rasterStrokeColor () const |
Returns the stroke color for the stroke drawn around raster symbol items. More... | |
double | rasterStrokeWidth () const |
Returns the stroke width (in millimeters) for the stroke drawn around raster symbol items. More... | |
QgsLegendStyle & | rstyle (QgsLegendStyle::Style s) |
Returns reference to modifiable style. More... | |
QFont | scaledFontPixelSize (const QFont &font) const |
Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE. More... | |
void | setBoxSpace (double s) |
void | setColumnCount (int c) |
void | setColumnSpace (double s) |
void | setDpi (int dpi) |
void | setDrawRasterStroke (bool enabled) |
Sets whether a stroke will be drawn around raster symbol items. More... | |
void | setEqualColumnWidth (bool s) |
void | setFontColor (const QColor &c) |
void | setLayerFontColor (const QColor &fontColor) |
Sets layer font color to fontColor Overrides fontColor() More... | |
void | setLineSpacing (double s) |
void | setMapScale (double scale) |
Sets the legend map scale. More... | |
void | setMapUnitsPerPixel (double mapUnitsPerPixel) |
Sets the mmPerMapUnit calculated by mapUnitsPerPixel mostly taken from the map settings. More... | |
void | setMmPerMapUnit (double mmPerMapUnit) |
void | setRasterStrokeColor (const QColor &color) |
Sets the stroke color for the stroke drawn around raster symbol items. More... | |
void | setRasterStrokeWidth (double width) |
Sets the stroke width for the stroke drawn around raster symbol items. More... | |
void | setSplitLayer (bool s) |
void | setStyle (QgsLegendStyle::Style s, const QgsLegendStyle &style) |
void | setSymbolSize (QSizeF s) |
void | setTitle (const QString &t) |
void | setTitleAlignment (Qt::AlignmentFlag alignment) |
Sets the alignment of the legend title. More... | |
void | setUseAdvancedEffects (bool use) |
void | setWmsLegendSize (QSizeF s) |
void | setWrapChar (const QString &t) |
bool | splitLayer () const |
QStringList | splitStringForWrapping (const QString &stringToSplt) const |
Splits a string using the wrap char taking into account handling empty wrap char which means no wrapping. More... | |
QgsLegendStyle | style (QgsLegendStyle::Style s) const |
Returns style. More... | |
QSizeF | symbolSize () const |
double | textWidthMillimeters (const QFont &font, const QString &text) const |
Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE. More... | |
QString | title () const |
Qt::AlignmentFlag | titleAlignment () const |
Returns the alignment of the legend title. More... | |
bool | useAdvancedEffects () const |
QSizeF | wmsLegendSize () const |
QString | wrapChar () const |
The QgsLegendSettings class stores the appearance and layout settings for legend drawing with QgsLegendRenderer.
The content of the legend is given in QgsLegendModel class.
Definition at line 38 of file qgslegendsettings.h.
QgsLegendSettings::QgsLegendSettings | ( | ) |
Definition at line 22 of file qgslegendsettings.cpp.
|
inline |
Definition at line 70 of file qgslegendsettings.h.
|
inline |
Definition at line 79 of file qgslegendsettings.h.
|
inline |
Definition at line 76 of file qgslegendsettings.h.
|
inline |
Definition at line 213 of file qgslegendsettings.h.
|
inline |
Returns whether a stroke will be drawn around raster symbol items.
Definition at line 119 of file qgslegendsettings.h.
void QgsLegendSettings::drawText | ( | QPainter * | p, |
double | x, | ||
double | y, | ||
const QString & | text, | ||
const QFont & | font | ||
) | const |
Draws Text.
Takes care about all the composer specific issues (calculation to pixel, scaling of font and painter to work around the Qt font bug)
Definition at line 70 of file qgslegendsettings.cpp.
void QgsLegendSettings::drawText | ( | QPainter * | p, |
const QRectF & | rect, | ||
const QString & | text, | ||
const QFont & | font, | ||
Qt::AlignmentFlag | halignment = Qt::AlignLeft , |
||
Qt::AlignmentFlag | valignment = Qt::AlignTop , |
||
int | flags = Qt::TextWordWrap |
||
) | const |
Like the above, but with a rectangle for multiline text.
p | painter to use |
rect | rectangle to draw into |
text | text to draw |
font | font to use |
halignment | optional horizontal alignment |
valignment | optional vertical alignment |
flags | allows for passing Qt::TextFlags to control appearance of rendered text |
Definition at line 83 of file qgslegendsettings.cpp.
|
inline |
Definition at line 85 of file qgslegendsettings.h.
QStringList QgsLegendSettings::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 wrapping.
Returns the actual text to render for a legend item, split into separate lines.
The expression context argument is used to correctly evaluated expressions contained within legend item text.
Definition at line 50 of file qgslegendsettings.cpp.
double QgsLegendSettings::fontAscentMillimeters | ( | const QFont & | font | ) | const |
Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
Definition at line 126 of file qgslegendsettings.cpp.
|
inline |
Definition at line 88 of file qgslegendsettings.h.
double QgsLegendSettings::fontDescentMillimeters | ( | const QFont & | font | ) | const |
Returns the font descent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
Definition at line 133 of file qgslegendsettings.cpp.
double QgsLegendSettings::fontHeightCharacterMM | ( | const QFont & | font, |
QChar | c | ||
) | const |
Returns the font height of a character in millimeters.
Definition at line 119 of file qgslegendsettings.cpp.
|
inline |
Returns layer font color, defaults to fontColor()
Definition at line 97 of file qgslegendsettings.h.
|
inline |
Definition at line 176 of file qgslegendsettings.h.
|
inline |
Returns the legend map scale.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
Definition at line 190 of file qgslegendsettings.h.
double QgsLegendSettings::mapUnitsPerPixel | ( | ) | const |
Returns the factor of map units per pixel for symbols with size given in map units calculated by dpi and mmPerMapUnit.
Definition at line 40 of file qgslegendsettings.cpp.
|
inline |
Definition at line 179 of file qgslegendsettings.h.
double QgsLegendSettings::pixelFontSize | ( | double | pointSize | ) | const |
Calculates font to from point size to pixel size.
Definition at line 107 of file qgslegendsettings.cpp.
|
inline |
Returns the stroke color for the stroke drawn around raster symbol items.
The stroke is only drawn if drawRasterStroke() is true
.
Definition at line 139 of file qgslegendsettings.h.
|
inline |
Returns the stroke width (in millimeters) for the stroke drawn around raster symbol items.
The stroke is only drawn if drawRasterStroke() is true
.
Definition at line 160 of file qgslegendsettings.h.
|
inline |
Returns reference to modifiable style.
Definition at line 65 of file qgslegendsettings.h.
QFont QgsLegendSettings::scaledFontPixelSize | ( | const QFont & | font | ) | const |
Returns a font where size is in pixel and font size is upscaled with FONT_WORKAROUND_SCALE.
Definition at line 99 of file qgslegendsettings.cpp.
|
inline |
Definition at line 71 of file qgslegendsettings.h.
|
inline |
Definition at line 80 of file qgslegendsettings.h.
|
inline |
Definition at line 77 of file qgslegendsettings.h.
|
inline |
Definition at line 214 of file qgslegendsettings.h.
|
inline |
Sets whether a stroke will be drawn around raster symbol items.
enabled | set to true to draw borders |
Definition at line 129 of file qgslegendsettings.h.
|
inline |
Definition at line 86 of file qgslegendsettings.h.
|
inline |
Definition at line 89 of file qgslegendsettings.h.
|
inline |
Sets layer font color to fontColor Overrides fontColor()
Definition at line 106 of file qgslegendsettings.h.
|
inline |
Definition at line 177 of file qgslegendsettings.h.
|
inline |
Sets the legend map scale.
The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
Definition at line 197 of file qgslegendsettings.h.
void QgsLegendSettings::setMapUnitsPerPixel | ( | double | mapUnitsPerPixel | ) |
Sets the mmPerMapUnit calculated by mapUnitsPerPixel mostly taken from the map settings.
Definition at line 45 of file qgslegendsettings.cpp.
|
inline |
Definition at line 180 of file qgslegendsettings.h.
|
inline |
Sets the stroke color for the stroke drawn around raster symbol items.
The stroke is only drawn if drawRasterStroke() is true
.
color | stroke color |
Definition at line 150 of file qgslegendsettings.h.
|
inline |
Sets the stroke width for the stroke drawn around raster symbol items.
The stroke is only drawn if drawRasterStroke() is true
.
width | stroke width in millimeters |
Definition at line 171 of file qgslegendsettings.h.
|
inline |
Definition at line 83 of file qgslegendsettings.h.
|
inline |
Definition at line 68 of file qgslegendsettings.h.
|
inline |
Definition at line 110 of file qgslegendsettings.h.
|
inline |
Definition at line 43 of file qgslegendsettings.h.
|
inline |
Sets the alignment of the legend title.
alignment | Text alignment for drawing the legend title |
Definition at line 58 of file qgslegendsettings.h.
|
inline |
Definition at line 183 of file qgslegendsettings.h.
|
inline |
Definition at line 174 of file qgslegendsettings.h.
|
inline |
Definition at line 73 of file qgslegendsettings.h.
|
inline |
Definition at line 82 of file qgslegendsettings.h.
QStringList QgsLegendSettings::splitStringForWrapping | ( | const QString & | stringToSplt | ) | const |
Splits a string using the wrap char taking into account handling empty wrap char which means no wrapping.
Definition at line 56 of file qgslegendsettings.cpp.
|
inline |
Returns style.
Definition at line 67 of file qgslegendsettings.h.
|
inline |
Definition at line 109 of file qgslegendsettings.h.
double QgsLegendSettings::textWidthMillimeters | ( | const QFont & | font, |
const QString & | text | ||
) | const |
Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE.
Definition at line 112 of file qgslegendsettings.cpp.
|
inline |
Definition at line 44 of file qgslegendsettings.h.
|
inline |
Returns the alignment of the legend title.
Definition at line 51 of file qgslegendsettings.h.
|
inline |
Definition at line 182 of file qgslegendsettings.h.
|
inline |
Definition at line 173 of file qgslegendsettings.h.
|
inline |
Definition at line 74 of file qgslegendsettings.h.