19 #include <QFontMetricsF>
53 QList<QPair<double, double> > segmentInfo;
56 double currentLabelNumber = 0.0;
59 int segmentCounter = 0;
60 QString currentNumericLabel;
62 QList<QPair<double, double> >::const_iterator segmentIt = segmentInfo.constBegin();
63 for ( ; segmentIt != segmentInfo.constEnd(); ++segmentIt )
65 if ( segmentCounter == 0 && nSegmentsLeft > 0 )
68 currentNumericLabel = firstLabel;
70 else if ( segmentCounter != 0 && segmentCounter == nSegmentsLeft )
72 currentLabelNumber = 0;
75 if ( segmentCounter >= nSegmentsLeft )
80 if ( segmentCounter == 0 || segmentCounter >= nSegmentsLeft )
85 if ( segmentCounter >= nSegmentsLeft )
93 if ( !segmentInfo.isEmpty() )
115 QString largestNumberLabel = QString::number( largestLabelNumber );
119 double totalBarLength = 0.0;
121 QList< QPair<double, double> > segmentList;
124 QList< QPair<double, double> >::const_iterator segmentIt = segmentList.constBegin();
125 for ( ; segmentIt != segmentList.constEnd(); ++segmentIt )
127 totalBarLength += segmentIt->second;
A scale bar item that can be added to a map composition.
virtual void drawLabels(QPainter *p) const
double boxContentSpace() 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...
virtual QRectF calculateBoxSize() const
double numMapUnitsPerScaleBarUnit() const
virtual ~QgsScaleBarStyle()
int numSegmentsLeft() const
double textWidthMillimeters(const QFont &font, const QString &text) const
Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE...
double labelBarSpace() const
QString unitLabeling() const
double segmentMillimeters() const
void drawText(QPainter *p, double x, double y, const QString &text, const QFont &font) const
Draws Text.
const QgsComposerScaleBar * mScaleBar
double numUnitsPerSegment() const
double fontAscentMillimeters(const QFont &font) const
Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCAL...
QString firstLabelString() const
Returns string of first label (important for drawing, labeling, size calculation. ...