From c591e19e9f874749876a4aba1088652bad2dd11f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 5 Apr 2022 14:54:16 +0100 Subject: [PATCH] Smarten textbox conversion back to cardinal rectangle. Fixes https://gitlab.com/kicad/code/kicad/issues/11302 --- pcbnew/pcb_textbox.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index 350e8ebe4a..e411900751 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -263,10 +263,21 @@ void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) { std::vector 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 ) ) ); } }