Don't allow degenerate arcs when dragging editing handles.

Fixes: lp:1839536
* https://bugs.launchpad.net/kicad/+bug/1839536
This commit is contained in:
Jeff Young 2019-08-08 21:22:13 +01:00
parent ab283174df
commit 885497ec1f
1 changed files with 11 additions and 3 deletions

View File

@ -468,15 +468,23 @@ void LIB_ARC::CalcEdit( const wxPoint& aPosition )
double chordAfter = sq( v.x ) + sq( v.y );
double ratio = chordAfter / chordBefore;
m_Radius = KiROUND( sqrt( m_Radius * m_Radius * ratio ) );
if( ratio > 0 )
{
m_Radius = int( sqrt( m_Radius * m_Radius * ratio ) ) + 1;
m_Radius = std::max( m_Radius, int( sqrt( chordAfter ) / 2 ) + 1 );
}
break;
}
case 4:
m_Radius = KiROUND( ( GetLineLength( m_ArcStart, aPosition )
+ GetLineLength( m_ArcEnd, aPosition ) ) / 2.0 );
{
double chordA = GetLineLength( m_ArcStart, aPosition );
double chordB = GetLineLength( m_ArcEnd, aPosition );
m_Radius = int( ( chordA + chordB ) / 2.0 ) + 1;
break;
}
}
// Calculate center based on start, end, and radius
//