30 QPainter *painter = context.
painter();
34 painter->setRenderHint( QPainter::Antialiasing,
true );
68 return QSizeF( 2 * settings.
boxContentSpace() + 2 * settings.
pen().width() + textWidth,
72 QString QgsNumericScaleBarRenderer::scaleText(
double scale )
const 74 return "1:" + QStringLiteral(
"%L1" ).arg( scale, 0,
'f', 0 );
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 ...
Use antialiasing while drawing.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
HAlignment
Horizontal alignment.
QSizeF calculateBoxSize(const QgsScaleBarSettings &settings, const QgsScaleBarRenderer::ScaleBarContext &scaleContext) const override
Calculates the required box size (in millimeters) for a scalebar using the specified settings and sca...
double scale
Scale denominator.
QSizeF size
Destination size for scalebar.
QgsTextFormat & textFormat()
Returns the text format used for drawing text in the scalebar.
static void drawText(const QRectF &rect, double rotation, HAlignment alignment, const QStringList &textLines, QgsRenderContext &context, const QgsTextFormat &format, bool drawAsOutlines=true)
Draws text within a rectangle using the specified settings.
double boxContentSpace() const
Returns the spacing (margin) between the scalebar box and content in millimeters. ...
void draw(QgsRenderContext &context, const QgsScaleBarSettings &settings, const QgsScaleBarRenderer::ScaleBarContext &scaleContext) const override
Draws the scalebar using the specified settings and scaleContext to a destination render context...
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
static double fontAscentMM(const QFont &font)
Calculates a font ascent in millimeters, including workarounds for QT font rendering issues...
QPen pen() const
Returns the pen used for drawing outlines in the scalebar.
Flags flags() const
Returns combination of flags used for rendering.
Alignment alignment() const
Returns the scalebar alignment.
QFont toQFont() const
Returns a QFont matching the relevant settings from this text format.
The QgsScaleBarSettings class stores the appearance and layout settings for scalebar drawing with Qgs...
Contains parameters regarding scalebar calculations.