Skip to content
Permalink
Browse files

Avoid ugly super-narrow annotation balloon callout lines at some angles

  • Loading branch information
nyalldawson committed Apr 30, 2019
1 parent d56b72b commit 1114cdc0a67ed11a5937c1bb5ec4a953e172b143
Showing with 18 additions and 1 deletion.
  1. +18 −1 src/core/annotations/qgsannotation.cpp
@@ -215,7 +215,24 @@ void QgsAnnotation::updateBalloon()
QLineF currentSegment = segmentList.at( i );
QgsPointXY currentMinDistPoint;
double currentMinDist = origin.sqrDistToSegment( currentSegment.x1(), currentSegment.y1(), currentSegment.x2(), currentSegment.y2(), currentMinDistPoint );
if ( currentMinDist < minEdgeDist )
bool isPreferredSegment = false;
if ( qgsDoubleNear( currentMinDist, minEdgeDist ) )
{
// two segments are close - work out which looks nicer
const double angle = fmod( origin.azimuth( currentMinDistPoint ) + 360.0, 360.0 );
if ( angle < 45 || angle > 315 )
isPreferredSegment = i == 0;
else if ( angle < 135 )
isPreferredSegment = i == 3;
else if ( angle < 225 )
isPreferredSegment = i == 2;
else
isPreferredSegment = i == 1;
}
else if ( currentMinDist < minEdgeDist )
isPreferredSegment = true;

if ( isPreferredSegment )
{
minEdgeIndex = i;
minEdgePoint = currentMinDistPoint;

0 comments on commit 1114cdc

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