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 ( !
qgsDoubleNear( 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 );
double scale() const
Scale.
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)
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 void drawText(QPainter *painter, 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...
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
QString name() const override
void setFont(const QFont &font)
~QgsNumericScaleBarStyle()
QgsNumericScaleBarStyle(QgsComposerScaleBar *bar)
Abstraction of composer scale bar style.
Object representing map window.
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 QgsComposerMap * composerMap() const
const QgsComposerScaleBar * mScaleBar
double boxContentSpace() const
Alignment alignment() const
Left / Middle/ Right.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const