29 QgsNumericScaleBarStyle::QgsNumericScaleBarStyle():
QgsScaleBarStyle( 0 ), mLastScaleBarWidth( 0 )
61 double penWidth =
mScaleBar->QgsComposerItem::pen().widthF() / 2.0;
64 Qt::AlignmentFlag hAlign;
68 hAlign = Qt::AlignLeft;
71 hAlign = Qt::AlignHCenter;
74 hAlign = Qt::AlignRight;
77 hAlign = Qt::AlignLeft;
103 if ( mLastScaleBarWidth != rect.width() && mLastScaleBarWidth > 0 && rect.width() > 0 )
108 mLastScaleBarWidth = rect.width();
112 QString QgsNumericScaleBarStyle::scaleText()
const
118 double scaleDenominator = 1;
122 scaleDenominator = composerMap->
scale();
123 scaleBarText =
"1:" +
QString(
"%L1" ).
arg( scaleDenominator, 0,
'f', 0 );
125 scaleBarText =
"1:" +
QString(
"%L1" ).
arg( scaleDenominator, 0,
'f', 0 );
A scale bar item that can be added to a map composition.
QRectF calculateBoxSize() const override
void draw(QPainter *p, double xOffset=0) const override
Draws the style.
void setRenderHint(RenderHint hint, bool on)
double boxContentSpace() const
Alignment alignment() const
Left / Middle/ Right.
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 ...
static double fontAscentMM(const QFont &font)
Calculate font ascent in millimeters, including workarounds for QT font rendering issues...
QString name() const override
void setFont(const QFont &font)
double scale() const
Scale.
~QgsNumericScaleBarStyle()
QgsNumericScaleBarStyle(QgsComposerScaleBar *bar)
Abstraction of composer scale bar style.
const QgsComposerMap * composerMap() const
Object representing map window.
QPen pen() const
Returns the pen used for drawing the scalebar.
QColor fontColor() const
Returns the color used for drawing text in the scalebar.
static double textWidthMM(const QFont &font, const QString &text)
Calculate font width in millimeters for a string, including workarounds for QT font rendering issues...
const QgsComposerScaleBar * mScaleBar
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const