Eeschema: Allow 180 deg arcs when editing, enable center point snapping.

This commit is contained in:
Alex Shvartzkop 2023-12-02 17:08:08 +03:00
parent bfcd087751
commit 2a2dc3a508
2 changed files with 12 additions and 17 deletions

View File

@ -1409,7 +1409,7 @@ void EDA_SHAPE::calcEdit( const VECTOR2I& aPosition )
case SHAPE_T::ARC:
{
int radius = GetRadius();
double radius = GetRadius();
EDA_ANGLE lastAngle = GetArcAngle();
// Edit state 0: drawing: place start
@ -1427,7 +1427,7 @@ void EDA_SHAPE::calcEdit( const VECTOR2I& aPosition )
case 1:
m_end = aPosition;
radius = KiROUND( sqrt( sq( GetLineLength( m_start, m_end ) ) / 2.0 ) );
radius = sqrt( sq( GetLineLength( m_start, m_end ) ) / 2.0 );
break;
case 2:
@ -1447,8 +1447,7 @@ void EDA_SHAPE::calcEdit( const VECTOR2I& aPosition )
if( ratio != 0 )
{
radius = std::max( int( sqrt( sq( radius ) * ratio ) ) + 1,
int( sqrt( chordAfter ) / 2 ) + 1 );
radius = std::max( sqrt( sq( radius ) * ratio ), sqrt( chordAfter ) / 2 );
}
}
break;
@ -1457,7 +1456,7 @@ void EDA_SHAPE::calcEdit( const VECTOR2I& aPosition )
{
double radialA = GetLineLength( m_start, aPosition );
double radialB = GetLineLength( m_end, aPosition );
radius = int( ( radialA + radialB ) / 2.0 ) + 1;
radius = ( radialA + radialB ) / 2.0;
}
break;
@ -1470,15 +1469,15 @@ void EDA_SHAPE::calcEdit( const VECTOR2I& aPosition )
//
// Let 'l' be the length of the chord and 'm' the middle point of the chord
double l = GetLineLength( m_start, m_end );
VECTOR2I m = ( m_start + m_end ) / 2;
VECTOR2D m = ( m_start + m_end ) / 2;
// Calculate 'd', the vector from the chord midpoint to the center
VECTOR2I d;
d.x = KiROUND( sqrt( sq( radius ) - sq( l/2 ) ) * ( m_start.y - m_end.y ) / l );
d.y = KiROUND( sqrt( sq( radius ) - sq( l/2 ) ) * ( m_end.x - m_start.x ) / l );
VECTOR2D d;
d.x = sqrt( sq( radius ) - sq( l / 2 ) ) * ( m_start.y - m_end.y ) / l;
d.y = sqrt( sq( radius ) - sq( l / 2 ) ) * ( m_end.x - m_start.x ) / l;
VECTOR2I c1 = m + d;
VECTOR2I c2 = m - d;
VECTOR2I c1 = KiROUND( m + d );
VECTOR2I c2 = KiROUND( m - d );
// Solution gives us 2 centers; we need to pick one:
switch( m_editState )

View File

@ -506,10 +506,6 @@ int EE_POINT_EDITOR::Main( const TOOL_EVENT& aEvent )
}
bool snap = !evt->DisableGridSnapping();
EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( item );
if( shape && shape->GetShape() == SHAPE_T::ARC && getEditedPointIndex() == ARC_CENTER )
snap = false;
m_editedPoint->SetPosition( controls->GetCursorPosition( snap ) );