fp shape, ARC: fix incorrect arc end position after flipping/mirroring.

Add also comments in FP_SHAPE::SetAngle() to avoid a similar issue.
This commit is contained in:
jean-pierre charras 2021-02-08 10:11:04 +01:00
parent 81b83a8f5b
commit 34d7c3e31f
3 changed files with 18 additions and 4 deletions

View File

@ -161,7 +161,9 @@ void FP_SHAPE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
switch( GetShape() )
{
case S_ARC:
SetAngle( -GetAngle() );
// Update arc angle but do not yet update m_ThirdPoint0 and m_thirdPoint,
// arc center and start point must be updated before calculation arc end.
SetAngle( -GetAngle(), false );
KI_FALLTHROUGH;
default:
@ -225,10 +227,13 @@ void FP_SHAPE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis )
{
// Mirror an edge of the footprint. the layer is not modified
// This is a footprint shape modification.
switch( GetShape() )
{
case S_ARC:
SetAngle( -GetAngle() );
// Update arc angle but do not yet update m_ThirdPoint0 and m_thirdPoint,
// arc center and start point must be updated before calculation arc end.
SetAngle( -GetAngle(), false );
KI_FALLTHROUGH;
default:
@ -238,6 +243,7 @@ void FP_SHAPE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis )
{
MIRROR( m_Start0.y, aCentre.y );
MIRROR( m_End0.y, aCentre.y );
MIRROR( m_ThirdPoint0.y, aCentre.y );
MIRROR( m_Bezier0_C1.y, aCentre.y );
MIRROR( m_Bezier0_C2.y, aCentre.y );
}
@ -245,6 +251,7 @@ void FP_SHAPE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis )
{
MIRROR( m_Start0.x, aCentre.x );
MIRROR( m_End0.x, aCentre.x );
MIRROR( m_ThirdPoint0.x, aCentre.x );
MIRROR( m_Bezier0_C1.x, aCentre.x );
MIRROR( m_Bezier0_C2.x, aCentre.x );
}

View File

@ -67,6 +67,12 @@ public:
return false;
}
/**
* Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
* @param aAngle is tenths of degrees, but will soon be degrees.
* @param aUpdateEnd = true to update also arc end coordinates m_thirdPoint and
* m_ThirdPoint0, so must be called after setting m_Start, m_Start0, m_End and m_End0
*/
void SetAngle( double aAngle, bool aUpdateEnd = true ) override;
/**

View File

@ -118,9 +118,10 @@ public:
int GetWidth() const { return m_width; }
/**
* Function SetAngle
* sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
* Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
* @param aAngle is tenths of degrees, but will soon be degrees.
* @param aUpdateEnd = true to update also arc end coordinates m_thirdPoint,
* so must be called after setting m_Start and m_End
*/
virtual void SetAngle( double aAngle, bool aUpdateEnd = true );
double GetAngle() const { return m_angle; }