From 07085345e90e2452a3ee6c061b59e5bee5fd9bcf Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 1 Aug 2020 21:32:21 +0100 Subject: [PATCH] Flip chamfer corners. Fixes https://gitlab.com/kicad/code/kicad/issues/5038 --- pcbnew/class_pad.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index a846d01970..13a4a568e0 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -510,6 +510,32 @@ void D_PAD::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) SetOrientation( -GetOrientation() ); + auto mirrorBitFlags = []( int& aBitfield, int a, int b ) + { + bool temp = aBitfield & a; + + if( aBitfield & b ) + aBitfield |= a; + else + aBitfield &= ~a; + + if( temp ) + aBitfield |= b; + else + aBitfield &= ~b; + }; + + if( aFlipLeftRight ) + { + mirrorBitFlags( m_chamferPositions, RECT_CHAMFER_TOP_LEFT, RECT_CHAMFER_TOP_RIGHT ); + mirrorBitFlags( m_chamferPositions, RECT_CHAMFER_BOTTOM_LEFT, RECT_CHAMFER_BOTTOM_RIGHT ); + } + else + { + mirrorBitFlags( m_chamferPositions, RECT_CHAMFER_TOP_LEFT, RECT_CHAMFER_BOTTOM_LEFT ); + mirrorBitFlags( m_chamferPositions, RECT_CHAMFER_TOP_RIGHT, RECT_CHAMFER_BOTTOM_RIGHT ); + } + // flip pads layers // PADS items are currently on all copper layers, or // currently, only on Front or Back layers.