Skip to content

Commit

Permalink
Fix ellipse rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Hugentobler committed Jun 10, 2011
1 parent 51ca548 commit 7072290
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Expand Up @@ -117,20 +117,34 @@ void QgsEllipseSymbolLayerV2::renderPoint( const QPointF& point, QgsSymbolV2Rend
return;
}

QPointF off( context.outputLineWidth( mOffset.x() ), context.outputLineWidth( mOffset.y() ) );
//priority for rotation: 1. data defined, 2. symbol layer rotation (mRotation), 3. symbol rotation (mAngle)
double rotation = 0.0;
if( mRotationField.first != -1 )
{
rotation = f->attributeMap()[mRotationField.first].toDouble();
}
else
{
if( !doubleNear( mRotation, 0.0 ) )
{
rotation = mRotation;
}
else if( !doubleNear( mAngle, 0.0 ) )
{
rotation = mAngle;
}
}

QMatrix transform;
transform.translate( point.x() + off.x(), point.y() + off.y() );

p->save();
if( !doubleNear( mRotation, 0.0 ) )
transform.translate( point.x(), point.y() );
if( !doubleNear( rotation, 0.0 ) )
{
p->rotate( mRotation );
transform.rotate( rotation );
}

p->setPen( mPen );
p->setBrush( mBrush );
p->drawPath( transform.map( mPainterPath ) );
p->restore();
}

QString QgsEllipseSymbolLayerV2::layerType() const
Expand Down

0 comments on commit 7072290

Please sign in to comment.