QGIS API Documentation
2.6.0-Brighton
|
Utilities for compositions. More...
#include <qgscomposerutils.h>
Static Public Member Functions | |
static void | drawArrowHead (QPainter *p, const double x, const double y, const double angle, const double arrowHeadWidth) |
Draws an arrow head on to a QPainter. | |
static double | angle (const QPointF &p1, const QPointF &p2) |
Calculates the angle of the line from p1 to p2 (counter clockwise, starting from a line from north to south) | |
static void | rotate (const double angle, double &x, double &y) |
Rotates a point / vector around the origin. | |
static double | normalizedAngle (const double angle) |
Ensures that an angle is in the range 0 <= angle < 360. | |
static double | snappedAngle (const double angle) |
Snaps an angle to its closest 45 degree angle. | |
static QRectF | largestRotatedRectWithinBounds (const QRectF originalRect, const QRectF boundsRect, const double rotation) |
Calculates the largest scaled version of originalRect which fits within boundsRect, when it is rotated by a specified amount. | |
static double | pointsToMM (const double pointSize) |
Returns the size in mm corresponding to a font point size. | |
static double | mmToPoints (const double mmSize) |
Returns the size in mm corresponding to a font point size. | |
static void | relativeResizeRect (QRectF &rectToResize, const QRectF &boundsBefore, const QRectF &boundsAfter) |
Resizes a QRectF relative to a resized bounding rectangle. | |
static double | relativePosition (const double position, const double beforeMin, const double beforeMax, const double afterMin, const double afterMax) |
Returns a scaled position given a before and after range. | |
static QgsComposition::PaperOrientation | decodePaperOrientation (const QString orientationString, bool &ok) |
Decodes a string representing a paper orientation. | |
static bool | decodePresetPaperSize (const QString presetString, double &width, double &height) |
Decodes a string representing a preset page size. | |
static void | readDataDefinedPropertyMap (const QDomElement &itemElem, QMap< QgsComposerObject::DataDefinedProperty, QString > *dataDefinedNames, QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *dataDefinedProperties) |
Reads all data defined properties from xml. | |
static void | readDataDefinedProperty (const QgsComposerObject::DataDefinedProperty property, const QDomElement &ddElem, QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *dataDefinedProperties) |
Reads a single data defined property from xml DOM element. | |
static void | writeDataDefinedPropertyMap (QDomElement &itemElem, QDomDocument &doc, const QMap< QgsComposerObject::DataDefinedProperty, QString > *dataDefinedNames, const QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *dataDefinedProperties) |
Writes data defined properties to xml. | |
static QFont | scaledFontPixelSize (const QFont &font) |
Returns a font where size is set in pixels and the size has been upscaled with FONT_WORKAROUND_SCALE to workaround QT font rendering bugs. | |
static double | fontAscentMM (const QFont &font) |
Calculate font ascent in millimeters, including workarounds for QT font rendering issues. | |
static double | fontDescentMM (const QFont &font) |
Calculate font descent in millimeters, including workarounds for QT font rendering issues. | |
static double | fontHeightMM (const QFont &font) |
Calculate font height in millimeters, including workarounds for QT font rendering issues The font height is the font ascent + descent + 1 (for the baseline). | |
static double | fontHeightCharacterMM (const QFont &font, const QChar &character) |
Calculate font height in millimeters of a single character, including workarounds for QT font rendering issues. | |
static double | textWidthMM (const QFont &font, const QString &text) |
Calculate font width in millimeters for a string, including workarounds for QT font rendering issues. | |
static void | drawText (QPainter *painter, const QPointF &pos, const QString &text, const QFont &font, const QColor &color=QColor()) |
Draws text on a painter at a specific position, taking care of composer specific issues (calculation to pixel, scaling of font and painter to work around Qt font bugs) | |
static void | drawText (QPainter *painter, const QRectF &rect, const QString &text, const QFont &font, const QColor &color=QColor(), const Qt::AlignmentFlag halignment=Qt::AlignLeft, const Qt::AlignmentFlag valignment=Qt::AlignTop, const int flags=Qt::TextWordWrap) |
Draws text on a painter within a rectangle, taking care of composer specific issues (calculation to pixel, scaling of font and painter to work around Qt font bugs) |
Utilities for compositions.
|
static |
Calculates the angle of the line from p1 to p2 (counter clockwise, starting from a line from north to south)
p1 | start point of line |
p2 | end point of line |
|
static |
Decodes a string representing a paper orientation.
orientationString | string to decode |
ok | will be true if string could be decoded |
|
static |
Decodes a string representing a preset page size.
presetString | string to decode |
width | double for decoded paper width |
height | double for decoded paper height |
|
static |
Draws an arrow head on to a QPainter.
p | destination painter |
x | x-coordinate of arrow center |
y | y-coordinate of arrow center |
angle | angle in degrees which arrow should point toward, measured clockwise from pointing vertical upward |
arrowHeadWidth | size of arrow head |
|
static |
Draws text on a painter at a specific position, taking care of composer specific issues (calculation to pixel, scaling of font and painter to work around Qt font bugs)
painter | destination QPainter |
pos | position to draw text |
text | string to draw |
font | font to use for drawing text |
color | color to draw text |
|
static |
Draws text on a painter within a rectangle, taking care of composer specific issues (calculation to pixel, scaling of font and painter to work around Qt font bugs)
painter | destination QPainter |
rect | rectangle to draw into |
text | string to draw |
font | font to use for drawing text |
color | color to draw text |
halignment | optional horizontal alignment |
valignment | optional vertical alignment |
flags | allows for passing Qt::TextFlags to control appearance of rendered text |
|
static |
Calculate font ascent in millimeters, including workarounds for QT font rendering issues.
font | input font |
|
static |
Calculate font descent in millimeters, including workarounds for QT font rendering issues.
font | input font |
|
static |
Calculate font height in millimeters of a single character, including workarounds for QT font rendering issues.
font | input font |
character | character to calculate height for |
|
static |
Calculate font height in millimeters, including workarounds for QT font rendering issues The font height is the font ascent + descent + 1 (for the baseline).
font | input font |
|
static |
Calculates the largest scaled version of originalRect which fits within boundsRect, when it is rotated by a specified 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 |
|
static |
Returns the size in mm corresponding to a font point size.
mmSize | font size in mm |
|
static |
Ensures that an angle is in the range 0 <= angle < 360.
angle | angle in degrees |
|
static |
Returns the size in mm corresponding to a font point size.
pointSize | font size in points |
|
static |
Reads a single data defined property from xml DOM element.
property | data defined property to read |
ddElem | dom element containing settings for data defined property |
dataDefinedProperties | map of data defined properties to QgsDataDefined in which to store properties from xml |
|
static |
Reads all data defined properties from xml.
itemElem | dom element containing data defined properties |
dataDefinedNames | map of data defined property to name used within xml |
dataDefinedProperties | map of data defined properties to QgsDataDefined in which to store properties from xml |
|
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 |
|
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 |
|
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 cooreinate before / after the rotation |
|
static |
Returns a font where size is set in pixels and the size has been upscaled with FONT_WORKAROUND_SCALE to workaround QT font rendering bugs.
font | source font with size set in points |
|
static |
Snaps an angle to its closest 45 degree angle.
angle | angle in degrees |
|
static |
Calculate font width in millimeters for a string, including workarounds for QT font rendering issues.
font | input font |
text | string to calculate width of |
|
static |
Writes data defined properties to xml.
itemElem | DOM element in which to store data defined properties |
doc | DOM document |
dataDefinedNames | map of data defined property to name used within xml |
dataDefinedProperties | map of data defined properties to QgsDataDefined for storing in xml |