20 #include <QFontMetricsF>
28 QgsScaleBarStyle::QgsScaleBarStyle(): mScaleBar( 0 )
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.
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
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...
double numMapUnitsPerScaleBarUnit() const
void setFont(const QFont &font)
virtual ~QgsScaleBarStyle()
QString number(int n, int base)
int numSegmentsLeft() const
void setPen(const QColor &color)
double labelBarSpace() const
QString unitLabeling() const
double segmentMillimeters() const
QgsScaleBarStyle(const QgsComposerScaleBar *bar)
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
double numUnitsPerSegment() const
const_iterator constEnd() const
const_iterator constBegin() const
QString firstLabelString() const
Returns string of first label (important for drawing, labeling, size calculation. ...