59 double penWidth =
mScaleBar->QgsComposerItem::pen().widthF() / 2.0;
62 Qt::AlignmentFlag hAlign;
66 hAlign = Qt::AlignLeft;
69 hAlign = Qt::AlignHCenter;
72 hAlign = Qt::AlignRight;
75 hAlign = Qt::AlignLeft;
80 QRectF painterRect( penWidth + margin, penWidth + margin,
mScaleBar->rect().width() - 2 * penWidth - 2 * margin,
mScaleBar->rect().
height() - 2 * penWidth - 2 * margin );
112 QString scaleBarText;
116 double scaleDenominator = 1;
120 scaleDenominator = composerMap->
scale();
121 scaleBarText =
"1:" + QString(
"%L1" ).arg( scaleDenominator, 0,
'f', 0 );
123 scaleBarText =
"1:" + QString(
"%L1" ).arg( scaleDenominator, 0,
'f', 0 );
A scale bar item that can be added to a map composition.
double boxContentSpace() const
double mLastScaleBarWidth
Store last width (in mm) to keep alignment to left/middle/right side.
Alignment alignment() const
Left / Middle/ Right.
QString scaleText() const
Returns the text for the scale bar or an empty string in case of error.
double scale() const
Scale.
double textWidthMillimeters(const QFont &font, const QString &text) const
Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE...
~QgsNumericScaleBarStyle()
QRectF calculateBoxSize() const
void drawText(QPainter *p, double x, double y, const QString &text, const QFont &font) const
Draws Text.
Abstraction of composer scale bar style.
const QgsComposerMap * composerMap() const
Object representing map window.
const QgsComposerScaleBar * mScaleBar
void draw(QPainter *p, double xOffset=0) const
Draws the style.
double fontAscentMillimeters(const QFont &font) const
Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCAL...
QgsNumericScaleBarStyle()