From 0a660c23644ed622945b6c3d59f9caf347676d4b Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 18 Mar 2021 22:09:45 +0100 Subject: [PATCH] Pcbnew: Remove 180 deg rotation when flipping PCB_TEXT in some cases --- pcbnew/pcb_text.cpp | 55 ++++----------------------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 3d3e6f3a47..bae5344c61 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -150,64 +150,17 @@ void PCB_TEXT::Rotate( const wxPoint& aRotCentre, double aAngle ) void PCB_TEXT::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) { - double angle = GetTextAngle(); - bool vertical = KiROUND( angle ) % 1800 == 900; - - if( KiROUND( angle ) != 0 ) - { - Rotate( aCentre, -angle ); - - if( vertical ) - aFlipLeftRight = !aFlipLeftRight; - } - - // Flip the bounding box - EDA_RECT box = GetTextBox(); - int left = box.GetLeft(); - int right = box.GetRight(); - int top = box.GetTop(); - int bottom = box.GetBottom(); - wxPoint pos = GetTextPos(); - if( aFlipLeftRight ) { - MIRROR( left, aCentre.x ); - MIRROR( right, aCentre.x ); - std::swap( left, right ); - - MIRROR( pos.x, aCentre.x ); + SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) ); + SetTextAngle( -GetTextAngle() ); } else { - MIRROR( top, aCentre.y ); - MIRROR( bottom, aCentre.y ); - std::swap( top, bottom ); - - MIRROR( pos.y, aCentre.y ); + SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) ); + SetTextAngle( 1800 - GetTextAngle() ); } - // Now put the text back in its bounding box - switch( GetHorizJustify() ) - { - case GR_TEXT_HJUSTIFY_LEFT: SetTextX( IsMirrored() ? left : right ); break; - case GR_TEXT_HJUSTIFY_CENTER: SetTextX( pos.x ); break; - case GR_TEXT_HJUSTIFY_RIGHT: SetTextX( IsMirrored() ? right : left ); break; - } - - if( !aFlipLeftRight ) - { - switch( GetVertJustify() ) - { - case GR_TEXT_VJUSTIFY_TOP: SetTextY( bottom ); break; - case GR_TEXT_VJUSTIFY_CENTER: SetTextY( pos.y ); break; - case GR_TEXT_VJUSTIFY_BOTTOM: SetTextY( top ); break; - } - } - - // And restore orientation - if( KiROUND( angle ) != 0 ) - Rotate( aCentre, angle ); - SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); SetMirrored( !IsMirrored() ); }