QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
#include <qgslayoututils.h>
Static Public Member Functions | |
static double | calculatePrettySize (double minimumSize, double maximumSize) |
Calculates a "pretty" size which falls between the range [minimumSize, maximumSize]. More... | |
static QgsRenderContext | createRenderContextForLayout (QgsLayout *layout, QPainter *painter, double dpi=-1) |
Creates a render context suitable for the specified layout and painter destination. More... | |
static QgsRenderContext | createRenderContextForMap (QgsLayoutItemMap *map, QPainter *painter, double dpi=-1) |
Creates a render context suitable for the specified layout map and painter destination. More... | |
static QgsLayoutItemPage::Orientation | decodePaperOrientation (const QString &string, bool &ok) |
Decodes a string representing a paper orientation and returns the decoded orientation. More... | |
static void | drawText (QPainter *painter, const QRectF &rectangle, const QString &text, const QFont &font, const QColor &color=QColor(), Qt::AlignmentFlag halignment=Qt::AlignLeft, Qt::AlignmentFlag valignment=Qt::AlignTop, int flags=Qt::TextWordWrap) |
Draws text on a painter within a rectangle, taking care of layout specific issues (calculation to pixel, scaling of font and painter to work around Qt font bugs). More... | |
static void | drawText (QPainter *painter, QPointF position, const QString &text, const QFont &font, const QColor &color=QColor()) |
Draws text on a painter at a specific position, taking care of layout specific issues (calculation to pixel, scaling of font and painter to work around Qt font bugs). More... | |
static double | fontAscentMM (const QFont &font) |
Calculates a font ascent in millimeters, including workarounds for QT font rendering issues. More... | |
static double | fontDescentMM (const QFont &font) |
Calculate a font descent in millimeters, including workarounds for QT font rendering issues. More... | |
static double | fontHeightCharacterMM (const QFont &font, QChar character) |
Calculate a font height in millimeters of a single character, including workarounds for QT font rendering issues. More... | |
static double | fontHeightMM (const QFont &font) |
Calculate a font height in millimeters, including workarounds for QT font rendering issues. More... | |
static QRectF | largestRotatedRectWithinBounds (const QRectF &originalRect, const QRectF &boundsRect, double rotation) |
Calculates the largest scaled version of originalRect which fits within boundsRect, when it is rotated by the a specified rotation amount. More... | |
static QgsMapLayer * | mapLayerFromString (const QString &string, QgsProject *project) |
Resolves a string into a map layer from a given project. More... | |
static double | normalizedAngle (double angle, bool allowNegative=false) |
Ensures that an angle (in degrees) is in the range 0 <= angle < 360. More... | |
static double | relativePosition (double position, double beforeMin, double beforeMax, double afterMin, double afterMax) |
Returns a scaled position given a before and after range. More... | |
static void | relativeResizeRect (QRectF &rectToResize, const QRectF &boundsBefore, const QRectF &boundsAfter) |
Resizes a QRectF relative to a resized bounding rectangle. More... | |
static void | rotate (double angle, double &x, double &y) |
Rotates a point / vector around the origin. More... | |
static QFont | scaledFontPixelSize (const QFont &font) |
Returns a font where size is set in points and the size has been upscaled with FONT_WORKAROUND_SCALE to workaround QT font rendering bugs. More... | |
static double | scaleFactorFromItemStyle (const QStyleOptionGraphicsItem *style) |
Extracts the scale factor from an item style. More... | |
static double | snappedAngle (double angle) |
Snaps an angle (in degrees) to its closest 45 degree angle. More... | |
static double | textHeightMM (const QFont &font, const QString &text, double multiLineHeight=1.0) |
Calculate a font height in millimeters for a text string, including workarounds for QT font rendering issues. More... | |
static double | textWidthMM (const QFont &font, const QString &text) |
Calculate a font width in millimeters for a text string, including workarounds for QT font rendering issues. More... | |
Friends | |
class | TestQgsLayoutUtils |
|
static |
Calculates a "pretty" size which falls between the range [minimumSize, maximumSize].
This method will return an optimal round number which falls within the given range, finding the largest "pretty" number possible.
Definition at line 438 of file qgslayoututils.cpp.
|
static |
Creates a render context suitable for the specified layout and painter destination.
This method returns a new QgsRenderContext which matches the scale and settings from the layout's QgsLayout::referenceMap(). If the dpi argument is not specified then the dpi will be taken from the destination painter device.
Definition at line 138 of file qgslayoututils.cpp.
|
static |
Creates a render context suitable for the specified layout map and painter destination.
This method returns a new QgsRenderContext which matches the scale and settings of the target map. If the dpi argument is not specified then the dpi will be taken from the destination painter device.
Definition at line 94 of file qgslayoututils.cpp.
|
static |
Decodes a string representing a paper orientation and returns the decoded orientation.
If the string was correctly decoded, ok will be set to true
.
Definition at line 373 of file qgslayoututils.cpp.
|
static |
Draws text on a painter within a rectangle, taking care of layout specific issues (calculation to pixel, scaling of font and painter to work around Qt font bugs).
If color is specified, text will be rendered in that color. If not specified, the current painter pen color will be used instead.
The text alignment within rectangle can be set via the halignment and valignment arguments.
The flags parameter allows for passing Qt::TextFlags to control appearance of rendered text.
Definition at line 267 of file qgslayoututils.cpp.
|
static |
Draws text on a painter at a specific position, taking care of layout specific issues (calculation to pixel, scaling of font and painter to work around Qt font bugs).
If color is specified, text will be rendered in that color. If not specified, the current painter pen color will be used instead.
Definition at line 244 of file qgslayoututils.cpp.
|
static |
Calculates a font ascent in millimeters, including workarounds for QT font rendering issues.
Definition at line 181 of file qgslayoututils.cpp.
|
static |
Calculate a font descent in millimeters, including workarounds for QT font rendering issues.
Definition at line 190 of file qgslayoututils.cpp.
|
static |
Calculate a font height in millimeters of a single character, including workarounds for QT font rendering issues.
Definition at line 210 of file qgslayoututils.cpp.
|
static |
Calculate a font height in millimeters, including workarounds for QT font rendering issues.
The font height is the font ascent + descent + 1 (for the baseline).
Definition at line 200 of file qgslayoututils.cpp.
|
static |
Calculates the largest scaled version of originalRect which fits within boundsRect, when it is rotated by the a specified rotation amount.
originalRect | QRectF to be rotated and scaled |
boundsRect | QRectF specifying the bounds which the rotated and scaled rectangle must fit within |
rotation | the rotation in degrees to be applied to the rectangle |
Definition at line 293 of file qgslayoututils.cpp.
|
static |
Resolves a string into a map layer from a given project.
Attempts different forms of layer matching such as matching by layer id or layer name.
Layer names are matched using a case-insensitive check, ONLY if an exact case match was not found.
Definition at line 403 of file qgslayoututils.cpp.
|
static |
Ensures that an angle (in degrees) is in the range 0 <= angle < 360.
If allowNegative is true
then angles between (-360, 360) are allowed. If false
, angles are converted to positive angles in the range [0, 360).
Definition at line 40 of file qgslayoututils.cpp.
|
static |
Returns a scaled position given a before and after range.
position | initial position within before range to scale |
beforeMin | minimum value in before range |
beforeMax | maximum value in before range |
afterMin | minimum value in after range |
afterMax | maximum value in after range |
Definition at line 162 of file qgslayoututils.cpp.
|
static |
Resizes a QRectF relative to a resized bounding rectangle.
rectToResize | QRectF to resize, contained within boundsBefore. The rectangle is linearly scaled to retain its relative position and size within boundsAfter. |
boundsBefore | QRectF of bounds before resize |
boundsAfter | QRectF of bounds after resize |
Definition at line 151 of file qgslayoututils.cpp.
|
static |
Rotates a point / vector around the origin.
angle | rotation angle in degrees, counterclockwise |
x | in/out: x coordinate before / after the rotation |
y | in/out: y coordinate before / after the rotation |
Definition at line 30 of file qgslayoututils.cpp.
|
static |
Returns a font where size is set in points and the size has been upscaled with FONT_WORKAROUND_SCALE to workaround QT font rendering bugs.
Returns a font with size set in pixels.
Definition at line 171 of file qgslayoututils.cpp.
|
static |
Extracts the scale factor from an item style.
Definition at line 390 of file qgslayoututils.cpp.
|
static |
Snaps an angle (in degrees) to its closest 45 degree angle.
Definition at line 54 of file qgslayoututils.cpp.
|
static |
Calculate a font height in millimeters for a text string, including workarounds for QT font rendering issues.
Note that this method uses a non-standard measure of text height, where only the font ascent is considered for the first line of text.
The multiLineHeight parameter specifies the line spacing factor.
Definition at line 228 of file qgslayoututils.cpp.
|
static |
Calculate a font width in millimeters for a text string, including workarounds for QT font rendering issues.
Definition at line 219 of file qgslayoututils.cpp.
|
friend |
Definition at line 252 of file qgslayoututils.h.