Skip to content
Permalink
Browse files

#9060: use QGis::fromUnitToUnitFactor in QgsDecorationScaleBar

  • Loading branch information
ahuarte47 committed Jan 14, 2014
1 parent 23f6a23 commit 2bffa19fc0d161ef532a13b6976ed3b2ed04a157
Showing with 4 additions and 13 deletions.
  1. +4 −13 src/app/qgsdecorationscalebar.cpp
@@ -139,19 +139,10 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
QGis::UnitType myPreferredUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );
QGis::UnitType myMapUnits = canvas->mapUnits();

// Adjust units meter/feet or vice versa
if ( myMapUnits == QGis::Meters && myPreferredUnits == QGis::Feet )
{
// From meter to feet
myMapUnits = QGis::Feet;
myMapUnitsPerPixelDouble /= 0.3084;
}
else if ( myMapUnits == QGis::Feet && myPreferredUnits == QGis::Meters )
{
// From feet to meter
myMapUnits = QGis::Meters;
myMapUnitsPerPixelDouble *= 0.3084;
}
// Adjust units meter/feet/... or vice versa
myMapUnitsPerPixelDouble *= QGis::fromUnitToUnitFactor( myMapUnits, myPreferredUnits );
myMapUnits = myPreferredUnits;

//Calculate size of scale bar for preferred number of map units
double myScaleBarWidth = mPreferredSize / myMapUnitsPerPixelDouble;

0 comments on commit 2bffa19

Please sign in to comment.
You can’t perform that action at this time.