mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Made the scale bar units intelligently switch between m and km as appropriate.
Made the scale bar max lenght 1/3 screen rather than 1/2 git-svn-id: http://svn.osgeo.org/qgis/trunk@1688 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
db6cfda517
commit
093db91552
@ -84,7 +84,7 @@ qgisMainWindowPointer(theQGisApp),
|
||||
qGisInterface(theQgisInterFace),
|
||||
QgisPlugin(name_,description_,version_,type_)
|
||||
{
|
||||
mPreferredSize = 100;
|
||||
mPreferredSize = 30;
|
||||
mPlacement = "Top Left";
|
||||
mStyle = "Tick Down";
|
||||
mEnabled = true;
|
||||
@ -153,7 +153,7 @@ void Plugin::run()
|
||||
int myUnits=qGisInterface->getMapCanvas()->mapUnits();
|
||||
switch (myUnits)
|
||||
{
|
||||
case 0: myPluginGui->spnSize->setSuffix(tr(" metres")); break;
|
||||
case 0: myPluginGui->spnSize->setSuffix(tr(" metres/km")); break;
|
||||
case 1: myPluginGui->spnSize->setSuffix(tr(" feet")); break;
|
||||
case 2: myPluginGui->spnSize->setSuffix(tr(" degrees")); break;
|
||||
default: std::cout << "Error: not picked up map units - actual value = " << myUnits << std::endl;
|
||||
@ -205,9 +205,9 @@ void Plugin::renderScaleBar(QPainter * theQPainter)
|
||||
};
|
||||
|
||||
//if scale bar is more than half the canvas wide keep halving until not
|
||||
while (myScaleBarWidth > myCanvasWidth/2)
|
||||
while (myScaleBarWidth > myCanvasWidth/3)
|
||||
{
|
||||
myScaleBarWidth = myScaleBarWidth /2;
|
||||
myScaleBarWidth = myScaleBarWidth /3;
|
||||
};
|
||||
myActualSize = myScaleBarWidth * myMuppDouble;
|
||||
|
||||
@ -236,7 +236,13 @@ void Plugin::renderScaleBar(QPainter * theQPainter)
|
||||
case 2: myScaleBarUnitLabel=tr(" degrees"); break;
|
||||
default: std::cout << "Error: not picked up map units - actual value = " << myMapUnits << std::endl;
|
||||
};
|
||||
//use km if units are larget and scale bar width is larger then 1000
|
||||
if (myMapUnits==0 && myActualSize > 1000)
|
||||
{
|
||||
myScaleBarUnitLabel=tr(" km");
|
||||
myActualSize = myActualSize/1000;
|
||||
|
||||
}
|
||||
//Set font and calculate width of unit label
|
||||
int myFontSize = 10; //we use this later for buffering
|
||||
QFont myFont( "helvetica", myFontSize );
|
||||
|
Loading…
x
Reference in New Issue
Block a user