17 #ifndef QGSLAYOUTUTILS_H
18 #define QGSLAYOUTUTILS_H
20 #include "qgis_core.h"
30 class QStyleOptionGraphicsItem;
47 static void rotate(
double angle,
double &x,
double &y );
54 static double normalizedAngle(
double angle,
bool allowNegative =
false );
60 static double snappedAngle(
double angle );
89 static void relativeResizeRect( QRectF &rectToResize,
const QRectF &boundsBefore,
const QRectF &boundsAfter );
100 static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
107 static QFont scaledFontPixelSize(
const QFont &font );
116 static double fontAscentMM(
const QFont &font );
125 static double fontDescentMM(
const QFont &font );
135 static double fontHeightMM(
const QFont &font );
145 static double fontHeightCharacterMM(
const QFont &font, QChar character );
156 static double textWidthMM(
const QFont &font,
const QString &text );
167 static double textHeightMM(
const QFont &font,
const QString &text,
double multiLineHeight = 1.0 );
176 static void drawText( QPainter *painter, QPointF position,
const QString &text,
const QFont &font,
const QColor &color = QColor() );
190 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 );
200 static QRectF largestRotatedRectWithinBounds(
const QRectF &originalRect,
const QRectF &boundsRect,
double rotation );
212 static double scaleFactorFromItemStyle(
const QStyleOptionGraphicsItem *style );
233 static double calculatePrettySize(
double minimumSize,
double maximumSize );
240 static bool itemIsAClippingSource(
const QgsLayoutItem *item );
251 static double pointsToMM(
double pointSize );
257 static double mmToPoints(
double mmSize );
259 friend class TestQgsLayoutUtils;
262 #endif //QGSLAYOUTUTILS_H