Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 9, 2020
1 parent 4391fe7 commit 96bbab6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/app/layout/qgslayoutscalebarwidget.cpp
Expand Up @@ -51,6 +51,7 @@ QgsLayoutScaleBarWidget::QgsLayoutScaleBarWidget( QgsLayoutItemScaleBar *scaleBa
connect( mLineJoinStyleCombo, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutScaleBarWidget::mLineJoinStyleCombo_currentIndexChanged );
connect( mLineCapStyleCombo, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutScaleBarWidget::mLineCapStyleCombo_currentIndexChanged );
connect( mMinWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mMinWidthSpinBox_valueChanged );
connect( mMaxWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLayoutScaleBarWidget::mMaxWidthSpinBox_valueChanged );
connect( mNumberFormatPushButton, &QPushButton::clicked, this, &QgsLayoutScaleBarWidget::changeNumberFormat );
setPanelTitle( tr( "Scalebar Properties" ) );

Expand Down
6 changes: 3 additions & 3 deletions src/core/scalebar/qgsnumericscalebarrenderer.cpp
Expand Up @@ -53,7 +53,7 @@ void QgsNumericScaleBarRenderer::draw( QgsRenderContext &context, const QgsScale
//text destination is item's rect, excluding the margin
QRectF painterRect( margin, margin, context.convertToPainterUnits( scaleContext.size.width(), QgsUnitTypes::RenderMillimeters ) - 2 * margin,
context.convertToPainterUnits( scaleContext.size.height(), QgsUnitTypes::RenderMillimeters ) - 2 * margin );
QgsTextRenderer::drawText( painterRect, 0, hAlign, QStringList() << scaleText( settings, scaleContext.scale ), context, settings.textFormat() );
QgsTextRenderer::drawText( painterRect, 0, hAlign, QStringList() << scaleText( scaleContext.scale, settings ), context, settings.textFormat() );

painter->restore();
}
Expand All @@ -63,14 +63,14 @@ QSizeF QgsNumericScaleBarRenderer::calculateBoxSize( const QgsScaleBarSettings &
{
QFont font = settings.textFormat().toQFont();

double textWidth = QgsLayoutUtils::textWidthMM( font, scaleText( settings, scaleContext.scale ) );
double textWidth = QgsLayoutUtils::textWidthMM( font, scaleText( scaleContext.scale, settings ) );
double textHeight = QgsLayoutUtils::fontAscentMM( font );

return QSizeF( 2 * settings.boxContentSpace() + 2 * settings.pen().width() + textWidth,
textHeight + 2 * settings.boxContentSpace() );
}

QString QgsNumericScaleBarRenderer::scaleText( const QgsScaleBarSettings &settings, double scale ) const
QString QgsNumericScaleBarRenderer::scaleText( double scale, const QgsScaleBarSettings &settings ) const
{
return "1:" + settings.numericFormat()->formatDouble( scale, QgsNumericFormatContext() );
}
2 changes: 1 addition & 1 deletion src/core/scalebar/qgsnumericscalebarrenderer.h
Expand Up @@ -48,7 +48,7 @@ class CORE_EXPORT QgsNumericScaleBarRenderer: public QgsScaleBarRenderer
private:

//! Returns the text for the scale bar or an empty string in case of error
QString scaleText( const QgsScaleBarSettings &settings, double scale ) const;
QString scaleText( double scale, const QgsScaleBarSettings &settings ) const;

};

Expand Down

0 comments on commit 96bbab6

Please sign in to comment.