Skip to content

Commit

Permalink
[composer] Don't rasterise svg arrow heads
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 19, 2014
1 parent d74f406 commit 5d10f3c
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions src/core/composer/qgscomposerarrow.cpp
Expand Up @@ -229,29 +229,12 @@ void QgsComposerArrow::drawSVGMarker( QPainter* p, MarkerType type, const QStrin
{
arrowHeadHeight = mStopArrowHeadHeight;
}

//prepare paint device
int dpi = ( p->device()->logicalDpiX() + p->device()->logicalDpiY() ) / 2;
double viewScaleFactor = horizontalViewScaleFactor();
int imageWidth = mArrowHeadWidth / 25.4 * dpi;
int imageHeight = arrowHeadHeight / 25.4 * dpi;

//make nicer preview
if ( mComposition && mComposition->plotStyle() == QgsComposition::Preview )
{
imageWidth *= qMin( viewScaleFactor, 10.0 );
imageHeight *= qMin( viewScaleFactor, 10.0 );
}
if ( imageWidth <= 0 || imageHeight <= 0 )
if ( mArrowHeadWidth <= 0 || arrowHeadHeight <= 0 )
{
//bad image size
return;
}

QImage markerImage( imageWidth, imageHeight, QImage::Format_ARGB32 );
QColor markerBG( 255, 255, 255, 0 ); //transparent white background
markerImage.fill( markerBG.rgba() );

QPointF imageFixPoint;
imageFixPoint.setX( mArrowHeadWidth / 2.0 );
QPointF canvasPoint;
Expand Down Expand Up @@ -283,10 +266,8 @@ void QgsComposerArrow::drawSVGMarker( QPainter* p, MarkerType type, const QStrin
}
}

QPainter imagePainter( &markerImage );
r.render( &imagePainter );

p->save();
p->setRenderHint( QPainter::Antialiasing );
if ( mBoundsBehaviour == 22 )
{
//if arrow was created in versions prior to 2.4, use the old rendering style
Expand All @@ -313,8 +294,7 @@ void QgsComposerArrow::drawSVGMarker( QPainter* p, MarkerType type, const QStrin

p->rotate( ang );
p->translate( -mArrowHeadWidth / 2.0, -arrowHeadHeight / 2.0 );

p->drawImage( QRectF( 0, 0, mArrowHeadWidth, arrowHeadHeight ), markerImage, QRectF( 0, 0, imageWidth, imageHeight ) );
r.render( p, QRectF( 0, 0, mArrowHeadWidth, arrowHeadHeight ) );
p->restore();

return;
Expand Down

0 comments on commit 5d10f3c

Please sign in to comment.