Skip to content
Permalink
Browse files

[composer] Allow removing svg markers for arrows (fix #11220)

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 9d0b83ab908646db250c810f26263367fe86a1ce
Showing with 22 additions and 14 deletions.
  1. +22 −14 src/core/composer/qgscomposerarrow.cpp
@@ -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() );
@@ -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();
}

0 comments on commit 9d0b83a

Please sign in to comment.
You can’t perform that action at this time.