Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
If circular string has an even number of points, connect the last poi…
…nt with a straight line (for rubberbanding purpose)
  • Loading branch information
mhugent committed Aug 27, 2015
1 parent 632656e commit 622aaa1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolcircularstringcurvepoint.cpp
Expand Up @@ -46,7 +46,7 @@ void QgsMapToolCircularStringCurvePoint::canvasMapReleaseEvent( QgsMapMouseEvent
createCenterPointRubberBand();
}

if ( mPoints.size() > 1 )
if ( mPoints.size() >= 1 )
{
if ( !mRubberBand )
{
Expand Down
15 changes: 15 additions & 0 deletions src/core/geometry/qgscircularstringv2.cpp
Expand Up @@ -66,6 +66,15 @@ QgsRectangle QgsCircularStringV2::calculateBoundingBox() const
bbox.combineExtentWith( &segmentBox );
}
}

if ( nPoints > 0 && nPoints % 2 == 0 )
{
if ( nPoints == 2 )
{
bbox.combineExtentWith( mX[ 0 ], mY[ 0 ] );
}
bbox.combineExtentWith( mX[ nPoints - 1 ], mY[ nPoints - 1 ] );
}
return bbox;
}

Expand Down Expand Up @@ -639,6 +648,12 @@ void QgsCircularStringV2::addToPainterPath( QPainterPath& path ) const
}
//arcTo( path, QPointF( mX[i], mY[i] ), QPointF( mX[i + 1], mY[i + 1] ), QPointF( mX[i + 2], mY[i + 2] ) );
}

//if number of points is even, connect to last point with straight line (even though the circular string is not valid)
if ( nPoints % 2 == 0 )
{
path.lineTo( mX[ nPoints - 1 ], mY[ nPoints - 1 ] );
}
}

void QgsCircularStringV2::arcTo( QPainterPath& path, const QPointF& pt1, const QPointF& pt2, const QPointF& pt3 )
Expand Down

0 comments on commit 622aaa1

Please sign in to comment.