Skip to content

Commit b3cbefc

Browse files
committedJun 12, 2014
fixes two symbology bugs
1 parent 37d2144 commit b3cbefc

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed
 

‎python/core/symbology-ng/qgsmarkersymbollayerv2.sip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ class QgsSvgMarkerSymbolLayerV2 : QgsMarkerSymbolLayerV2
9595
public:
9696
QgsSvgMarkerSymbolLayerV2( QString name = DEFAULT_SVGMARKER_NAME,
9797
double size = DEFAULT_SVGMARKER_SIZE,
98-
double angle = DEFAULT_SVGMARKER_ANGLE );
98+
double angle = DEFAULT_SVGMARKER_ANGLE,
99+
QgsSymbolV2::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
99100

100101
// static stuff
101102

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,26 @@ void QgsSimpleLineSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2RenderCon
443443
QgsExpression* dashPatternExpression = expression( "customdash" );
444444
if ( dashPatternExpression )
445445
{
446+
447+
double scaledWidth = mWidth * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mWidthUnit, mWidthMapUnitScale );
448+
449+
double dashWidthDiv = mPen.widthF();
450+
//fix dash pattern width in Qt 4.8
451+
QStringList versionSplit = QString( qVersion() ).split( "." );
452+
if ( versionSplit.size() > 1
453+
&& versionSplit.at( 1 ).toInt() >= 8
454+
&& ( scaledWidth * context.renderContext().rasterScaleFactor() ) < 1.0 )
455+
{
456+
dashWidthDiv = 1.0;
457+
}
458+
459+
446460
QVector<qreal> dashVector;
447461
QStringList dashList = dashPatternExpression->evaluate( const_cast<QgsFeature*>( context.feature() ) ).toString().split( ";" );
448462
QStringList::const_iterator dashIt = dashList.constBegin();
449463
for ( ; dashIt != dashList.constEnd(); ++dashIt )
450464
{
451-
dashVector.push_back( dashIt->toDouble() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit, mCustomDashPatternMapUnitScale ) / mPen.widthF() );
465+
dashVector.push_back( dashIt->toDouble() * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mCustomDashPatternUnit, mCustomDashPatternMapUnitScale ) / dashWidthDiv );
452466
}
453467
pen.setDashPattern( dashVector );
454468
}

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,12 +976,13 @@ QgsMapUnitScale QgsSimpleMarkerSymbolLayerV2::mapUnitScale() const
976976
//////////
977977

978978

979-
QgsSvgMarkerSymbolLayerV2::QgsSvgMarkerSymbolLayerV2( QString name, double size, double angle )
979+
QgsSvgMarkerSymbolLayerV2::QgsSvgMarkerSymbolLayerV2( QString name, double size, double angle, QgsSymbolV2::ScaleMethod scaleMethod )
980980
{
981981
mPath = QgsSymbolLayerV2Utils::symbolNameToPath( name );
982982
mSize = size;
983983
mAngle = angle;
984984
mOffset = QPointF( 0, 0 );
985+
mScaleMethod = scaleMethod;
985986
mOutlineWidth = 1.0;
986987
mOutlineWidthUnit = QgsSymbolV2::MM;
987988
mFillColor = QColor( Qt::black );
@@ -994,15 +995,18 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create( const QgsStringMap& props )
994995
QString name = DEFAULT_SVGMARKER_NAME;
995996
double size = DEFAULT_SVGMARKER_SIZE;
996997
double angle = DEFAULT_SVGMARKER_ANGLE;
997-
998+
QgsSymbolV2::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD;
999+
9981000
if ( props.contains( "name" ) )
9991001
name = props["name"];
10001002
if ( props.contains( "size" ) )
10011003
size = props["size"].toDouble();
10021004
if ( props.contains( "angle" ) )
10031005
angle = props["angle"].toDouble();
1004-
1005-
QgsSvgMarkerSymbolLayerV2* m = new QgsSvgMarkerSymbolLayerV2( name, size, angle );
1006+
if ( props.contains( "scale_method" ) )
1007+
scaleMethod = QgsSymbolLayerV2Utils::decodeScaleMethod( props["scale_method"] );
1008+
1009+
QgsSvgMarkerSymbolLayerV2* m = new QgsSvgMarkerSymbolLayerV2( name, size, angle, scaleMethod );
10061010

10071011
//we only check the svg default parameters if necessary, since it could be expensive
10081012
if ( !props.contains( "fill" ) && !props.contains( "outline" ) && !props.contains( "outline-width" ) )
@@ -1143,6 +1147,7 @@ void QgsSvgMarkerSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Re
11431147

11441148
double scaledSize = mSize;
11451149
QgsExpression* sizeExpression = expression( "size" );
1150+
11461151
bool hasDataDefinedSize = context.renderHints() & QgsSymbolV2::DataDefinedSizeScale || sizeExpression;
11471152

11481153
if ( sizeExpression )
@@ -1297,6 +1302,7 @@ QgsStringMap QgsSvgMarkerSymbolLayerV2::properties() const
12971302
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
12981303
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
12991304
map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale );
1305+
map["scale_method"] = QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod );
13001306
map["fill"] = mFillColor.name();
13011307
map["outline"] = mOutlineColor.name();
13021308
map["outline-width"] = QString::number( mOutlineWidth );

‎src/core/symbology-ng/qgsmarkersymbollayerv2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ class CORE_EXPORT QgsSvgMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
149149
public:
150150
QgsSvgMarkerSymbolLayerV2( QString name = DEFAULT_SVGMARKER_NAME,
151151
double size = DEFAULT_SVGMARKER_SIZE,
152-
double angle = DEFAULT_SVGMARKER_ANGLE );
152+
double angle = DEFAULT_SVGMARKER_ANGLE,
153+
QgsSymbolV2::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
153154

154155
// static stuff
155156

0 commit comments

Comments
 (0)
Please sign in to comment.