PDF Tiles "ruler" is fine when Unit is "Inch" or "Cm". It is bad when Unit is "Mm" or "Pixel".

This commit is contained in:
Roman Telezhynskyi 2021-09-28 16:43:36 +03:00
parent 05b884a632
commit 74090f7ffd

View File

@ -446,8 +446,11 @@ void VPTileFactory::DrawRuler(QPainter *painter)
const qreal notchHeight = UnitConvertor(3, Unit::Mm, Unit::Px); const qreal notchHeight = UnitConvertor(3, Unit::Mm, Unit::Px);
const qreal shortNotchHeight = UnitConvertor(1.1, Unit::Mm, Unit::Px); const qreal shortNotchHeight = UnitConvertor(1.1, Unit::Mm, Unit::Px);
Unit layoutUnits = layout->LayoutSettings().GetUnit(); Unit layoutUnits = layout->LayoutSettings().GetUnit();
const qreal step = UnitConvertor(1, layoutUnits, Unit::Px); Unit rulerUnits = layoutUnits == Unit::Inch ? layoutUnits : Unit::Cm;
const qreal step = UnitConvertor(1, rulerUnits, Unit::Px);
double marksCount = (m_drawingAreaWidth-tileStripeWidth) / step; double marksCount = (m_drawingAreaWidth-tileStripeWidth) / step;
int i = 0; int i = 0;
while (i < marksCount) while (i < marksCount)
@ -464,7 +467,7 @@ void VPTileFactory::DrawRuler(QPainter *painter)
} }
else else
{ {
QString units = layoutUnits == Unit::Cm || layoutUnits == Unit::Mm ? tr("cm", "unit") : tr("in", "unit"); QString units = rulerUnits != Unit::Inch ? tr("cm", "unit") : tr("in", "unit");
QFont fnt = painter->font(); QFont fnt = painter->font();
fnt.setPointSize(10); fnt.setPointSize(10);