Smarten textbox conversion back to cardinal rectangle.

Fixes https://gitlab.com/kicad/code/kicad/issues/11302
This commit is contained in:
Jeff Young 2022-04-05 14:54:16 +01:00
parent ed361925ba
commit c591e19e9f
1 changed files with 12 additions and 1 deletions

View File

@ -263,10 +263,21 @@ void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
{
std::vector<VECTOR2I> corners = GetCorners();
VECTOR2I diag = corners[2] - corners[0];
EDA_ANGLE angle = GetTextAngle();
SetShape( SHAPE_T::RECT );
SetStart( corners[0] );
SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y + abs( diag.y ) ) );
angle.Normalize();
if( angle == ANGLE_90 )
SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y - abs( diag.y ) ) );
else if( angle == ANGLE_180 )
SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y - abs( diag.y ) ) );
else if( angle == ANGLE_270 )
SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y + abs( diag.y ) ) );
else
SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y + abs( diag.y ) ) );
}
}