20 #include <QFontMetricsF> 57 double currentLabelNumber = 0.0;
60 int segmentCounter = 0;
64 for ( ; segmentIt != segmentInfo.
constEnd(); ++segmentIt )
66 if ( segmentCounter == 0 && nSegmentsLeft > 0 )
69 currentNumericLabel = firstLabel;
71 else if ( segmentCounter != 0 && segmentCounter == nSegmentsLeft )
73 currentLabelNumber = 0;
76 if ( segmentCounter >= nSegmentsLeft )
81 if ( segmentCounter == 0 || segmentCounter >= nSegmentsLeft )
87 if ( segmentCounter >= nSegmentsLeft )
95 if ( !segmentInfo.isEmpty() )
122 double totalBarLength = 0.0;
128 for ( ; segmentIt != segmentList.
constEnd(); ++segmentIt )
130 totalBarLength += segmentIt->second;
A scale bar item that can be added to a map composition.
double numUnitsPerSegment() const
virtual QRectF calculateBoxSize() const
double numMapUnitsPerScaleBarUnit() const
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...
int numSegmentsLeft() const
void setFont(const QFont &font)
virtual ~QgsScaleBarStyle()
QString number(int n, int base)
QString firstLabelString() const
Returns string of first label (important for drawing, labeling, size calculation. ...
void setPen(const QColor &color)
double labelBarSpace() const
QgsScaleBarStyle(const QgsComposerScaleBar *bar)
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
double segmentMillimeters() const
QString unitLabeling() const
double boxContentSpace() const
const_iterator constEnd() const
void segmentPositions(QList< QPair< double, double > > &posWidthList) const
Returns the x - positions of the segment borders (in item coordinates) and the width of the segment...
const_iterator constBegin() const
virtual void drawLabels(QPainter *p) const