Skip to content

Commit a597823

Browse files
committedJun 26, 2013
Fix dash pattern for line width < 1 pixels in Qt 4.8
1 parent 2d6c92b commit a597823

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎src/core/symbology-ng/qgslinesymbollayerv2.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,21 @@ void QgsSimpleLineSymbolLayerV2::startRender( QgsSymbolV2RenderContext& context
127127
mPen.setStyle( Qt::CustomDashLine );
128128

129129
//scale pattern vector
130+
double dashWidthDiv = scaledWidth;
131+
//fix dash pattern width in Qt 4.8
132+
QStringList versionSplit = QString( qVersion() ).split( "." );
133+
if ( versionSplit.size() > 1
134+
&& versionSplit.at( 1 ).toInt() >= 8
135+
&& ( scaledWidth * context.renderContext().rasterScaleFactor() ) < 1.0 )
136+
{
137+
dashWidthDiv = 1.0;
138+
}
130139
QVector<qreal> scaledVector;
131140
QVector<qreal>::const_iterator it = mCustomDashVector.constBegin();
132141
for ( ; it != mCustomDashVector.constEnd(); ++it )
133142
{
134143
//the dash is specified in terms of pen widths, therefore the division
135-
scaledVector << ( *it ) * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit ) / scaledWidth;
144+
scaledVector << ( *it ) * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit ) / dashWidthDiv;
136145
}
137146
mPen.setDashPattern( scaledVector );
138147
}

0 commit comments

Comments
 (0)
Please sign in to comment.