Skip to content
Permalink
Browse files

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 622aaa157ea6fb91feb2a2c6fd77673c7fb40125
Showing with 16 additions and 1 deletion.
  1. +1 −1 src/app/qgsmaptoolcircularstringcurvepoint.cpp
  2. +15 −0 src/core/geometry/qgscircularstringv2.cpp
@@ -46,7 +46,7 @@ void QgsMapToolCircularStringCurvePoint::canvasMapReleaseEvent( QgsMapMouseEvent
createCenterPointRubberBand();
}

if ( mPoints.size() > 1 )
if ( mPoints.size() >= 1 )
{
if ( !mRubberBand )
{
@@ -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;
}

@@ -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 )

0 comments on commit 622aaa1

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