Skip to content
Permalink
Browse files

Fix dash pattern for line width < 1 pixels in Qt 4.8

  • Loading branch information
mhugent committed Jun 26, 2013
1 parent 2d6c92b commit a597823c6d9ed132ac677f675cb5518b0c26775c
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/core/symbology-ng/qgslinesymbollayerv2.cpp
@@ -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 );
}

0 comments on commit a597823

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