Apply only default size (not all other default settings) when adding scalebar to composer view

git-svn-id: http://svn.osgeo.org/qgis/trunk@15016 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
mhugent 2011-01-11 14:52:17 +00:00
parent 5aed037fdc
commit 2065e89bdd
4 changed files with 13 additions and 3 deletions

View File

@ -58,8 +58,11 @@ class QgsComposerScaleBar: QgsComposerItem
double segmentMillimeters() const;
/**Apply default settings (scale bar 1/5 of map item width)*/
/**Apply default settings*/
void applyDefaultSettings();
/**Apply default size (scale bar 1/5 of map item width)
@note this method was added in version 1.7*/
void applyDefaultSize();
/**Sets style by name
@param styleName (untranslated) style name. Possibilities are: 'Single Box', 'Double Box', 'Line Ticks Middle', 'Line Ticks Down', 'Line Ticks Up', 'Numeric'*/

View File

@ -31,6 +31,7 @@
QgsComposerScaleBar::QgsComposerScaleBar( QgsComposition* composition ): QgsComposerItem( composition ), mComposerMap( 0 ), mStyle( 0 ), mSegmentMillimeters( 0.0 )
{
applyDefaultSettings();
applyDefaultSize();
}
QgsComposerScaleBar::~QgsComposerScaleBar()
@ -130,7 +131,10 @@ void QgsComposerScaleBar::applyDefaultSettings()
mLabelBarSpace = 3.0;
mBoxContentSpace = 1.0;
}
void QgsComposerScaleBar::applyDefaultSize()
{
if ( mComposerMap )
{
//calculate mNumUnitsPerSegment

View File

@ -81,8 +81,11 @@ class CORE_EXPORT QgsComposerScaleBar: public QgsComposerItem
double segmentMillimeters() const {return mSegmentMillimeters;}
/**Apply default settings (scale bar 1/5 of map item width)*/
/**Apply default settings*/
void applyDefaultSettings();
/**Apply default size (scale bar 1/5 of map item width)
@note this method was added in version 1.7*/
void applyDefaultSize();
/**Sets style by name
@param styleName (untranslated) style name. Possibilities are: 'Single Box', 'Double Box', 'Line Ticks Middle', 'Line Ticks Down', 'Line Ticks Up', 'Numeric'*/

View File

@ -550,7 +550,7 @@ void QgsComposerView::addComposerScaleBar( QgsComposerScaleBar* scaleBar )
{
scaleBar->setComposerMap( mapItemList.at( 0 ) );
}
scaleBar->applyDefaultSettings(); //4 segments, 1/5 of composer map width
scaleBar->applyDefaultSize(); //4 segments, 1/5 of composer map width
scene()->addItem( scaleBar );
emit composerScaleBarAdded( scaleBar );
scene()->clearSelection();