Skip to content

Commit

Permalink
also flip pennants
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and nyalldawson committed May 15, 2024
1 parent 0bef68f commit d1937f0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core/mesh/qgsmeshvectorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,9 @@ void QgsMeshVectorWindBarbRenderer::drawVector( const QgsPointXY &lineStart, dou
const double centerRadius = d;
const double zeroCircleRadius = 2 * d;
const double barbLength = 8 * d + pen.widthF();
const double barbAngle = isNorthHemisphere ? 135 : -135;
const double barbAngle = 135;
const double barbOffset = 2 * d + pen.widthF();
const int sign = isNorthHemisphere ? 1 : -1;

// Determine the angle of the vector, counter-clockwise, from east
// (and associated trigs)
Expand Down Expand Up @@ -627,7 +628,7 @@ void QgsMeshVectorWindBarbRenderer::drawVector( const QgsPointXY &lineStart, dou
// When first barb is a '10', we want to draw the shaft and barb as a single polyline for a proper join
const QVector< QPointF > pts{ lineStart.toQPointF(),
lineEnd.toQPointF(),
nextLineOrigin.project( barbLength, azimuth + barbAngle ).toQPointF() };
nextLineOrigin.project( barbLength, azimuth + barbAngle * sign ).toQPointF() };
mContext.painter()->drawPolyline( pts );
nextLineOrigin = nextLineOrigin.project( barbOffset, azimuth );
knots -= 10;
Expand All @@ -645,7 +646,7 @@ void QgsMeshVectorWindBarbRenderer::drawVector( const QgsPointXY &lineStart, dou
while ( knots > 47.5 )
{
const QVector< QPointF > pts{ nextLineOrigin.toQPointF(),
nextLineOrigin.project( barbLength / 1.414, azimuth + 90 ).toQPointF(),
nextLineOrigin.project( barbLength / 1.414, azimuth + 90 * sign ).toQPointF(),
nextLineOrigin.project( barbLength / 1.414, azimuth ).toQPointF() };
mContext.painter()->drawPolygon( pts );
knots -= 50;
Expand All @@ -660,7 +661,7 @@ void QgsMeshVectorWindBarbRenderer::drawVector( const QgsPointXY &lineStart, dou
// draw large barbs (10)
while ( knots > 7.5 )
{
mContext.painter()->drawLine( nextLineOrigin.toQPointF(), nextLineOrigin.project( barbLength, azimuth + barbAngle ).toQPointF() );
mContext.painter()->drawLine( nextLineOrigin.toQPointF(), nextLineOrigin.project( barbLength, azimuth + barbAngle * sign ).toQPointF() );
nextLineOrigin = nextLineOrigin.project( barbOffset, azimuth );
knots -= 10;
}
Expand All @@ -672,7 +673,7 @@ void QgsMeshVectorWindBarbRenderer::drawVector( const QgsPointXY &lineStart, dou
if ( nextLineOrigin == lineEnd )
nextLineOrigin = nextLineOrigin.project( barbLength / 2, azimuth );

mContext.painter()->drawLine( nextLineOrigin.toQPointF(), nextLineOrigin.project( barbLength / 2, azimuth + barbAngle ).toQPointF() );
mContext.painter()->drawLine( nextLineOrigin.toQPointF(), nextLineOrigin.project( barbLength / 2, azimuth + barbAngle * sign ).toQPointF() );
}
}
///@endcond

0 comments on commit d1937f0

Please sign in to comment.