Navigation Menu

Skip to content

Commit

Permalink
Fix dash pattern for line width < 1 pixels in Qt 4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 26, 2013
1 parent 2d6c92b commit a597823
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/symbology-ng/qgslinesymbollayerv2.cpp
Expand Up @@ -127,12 +127,21 @@ void QgsSimpleLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context
mPen.setStyle( Qt::CustomDashLine );

//scale pattern vector
double dashWidthDiv = scaledWidth;
//fix dash pattern width in Qt 4.8
QStringList versionSplit = QString( qVersion() ).split( "." );
if ( versionSplit.size() > 1
&& versionSplit.at( 1 ).toInt() >= 8
&& ( scaledWidth * context.renderContext().rasterScaleFactor() ) < 1.0 )
{
dashWidthDiv = 1.0;
}
QVector<qreal> scaledVector;
QVector<qreal>::const_iterator it = mCustomDashVector.constBegin();
for ( ; it != mCustomDashVector.constEnd(); ++it )
{
//the dash is specified in terms of pen widths, therefore the division
scaledVector << ( *it ) * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit ) / scaledWidth;
scaledVector << ( *it ) * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit ) / dashWidthDiv;
}
mPen.setDashPattern( scaledVector );
}
Expand Down

0 comments on commit a597823

Please sign in to comment.