Skip to content
Permalink
Browse files

Address review comments

  • Loading branch information
nyalldawson committed Jan 9, 2020
1 parent 4391fe7 commit 96bbab67ee0f2eede70d6e4ce6ca3da4f0abc772
@@ -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" ) );

@@ -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();
}
@@ -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() );
}
@@ -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;

};

0 comments on commit 96bbab6

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