Skip to content

Commit

Permalink
[composer] Allow removing svg markers for arrows (fix #11220)
Browse files Browse the repository at this point in the history
Previous behaviour was that if the start or end marker was cleared
than the old marker was drawn. This made it impossible to remove
an svg marker from the start or end of the line after one had been
assigned.

Also fix a Qt warning caused by trying to draw markers if the marker
size is set to 0.
  • Loading branch information
nyalldawson committed Oct 19, 2014
1 parent 6c0155a commit 9d0b83a
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/core/composer/qgscomposerarrow.cpp
Expand Up @@ -242,6 +242,12 @@ void QgsComposerArrow::drawSVGMarker( QPainter* p, MarkerType type, const QStrin
imageWidth *= qMin( viewScaleFactor, 10.0 );
imageHeight *= qMin( viewScaleFactor, 10.0 );
}
if ( imageWidth <= 0 || imageHeight <= 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() );
Expand Down Expand Up @@ -317,32 +323,34 @@ void QgsComposerArrow::drawSVGMarker( QPainter* p, MarkerType type, const QStrin
void QgsComposerArrow::setStartMarker( const QString& svgPath )
{
QSvgRenderer r;
mStartMarkerFile = svgPath;
if ( svgPath.isEmpty() || !r.load( svgPath ) )
{
return;
// mStartArrowHeadHeight = 0;
mStartArrowHeadHeight = 0;
}
else
{
//calculate mArrowHeadHeight from svg file and mArrowHeadWidth
QRect viewBox = r.viewBox();
mStartArrowHeadHeight = mArrowHeadWidth / viewBox.width() * viewBox.height();
}
mStartMarkerFile = svgPath;

//calculate mArrowHeadHeight from svg file and mArrowHeadWidth
QRect viewBox = r.viewBox();
mStartArrowHeadHeight = mArrowHeadWidth / viewBox.width() * viewBox.height();
adaptItemSceneRect();
}

void QgsComposerArrow::setEndMarker( const QString& svgPath )
{
QSvgRenderer r;
mEndMarkerFile = svgPath;
if ( svgPath.isEmpty() || !r.load( svgPath ) )
{
return;
// mStopArrowHeadHeight = 0;
mStopArrowHeadHeight = 0;
}
else
{
//calculate mArrowHeadHeight from svg file and mArrowHeadWidth
QRect viewBox = r.viewBox();
mStopArrowHeadHeight = mArrowHeadWidth / viewBox.width() * viewBox.height();
}
mEndMarkerFile = svgPath;

//calculate mArrowHeadHeight from svg file and mArrowHeadWidth
QRect viewBox = r.viewBox();
mStopArrowHeadHeight = mArrowHeadWidth / viewBox.width() * viewBox.height();
adaptItemSceneRect();
}

Expand Down

0 comments on commit 9d0b83a

Please sign in to comment.