From 4778122aa0441db5bad116db88e712dfd548a209 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 24 Oct 2022 16:22:27 +0100 Subject: [PATCH] Flip anything on a side-specific layer, rather than physical layer. Fixes https://gitlab.com/kicad/code/kicad/issues/12726 --- common/lset.cpp | 6 ++++++ include/layer_ids.h | 6 +++--- pcbnew/fp_text.cpp | 5 ++++- pcbnew/fp_textbox.cpp | 5 ++++- pcbnew/pcb_dimension.cpp | 3 ++- pcbnew/pcb_painter.cpp | 10 +++++----- pcbnew/pcb_text.cpp | 4 +++- pcbnew/pcb_textbox.cpp | 4 +++- 8 files changed, 30 insertions(+), 13 deletions(-) diff --git a/common/lset.cpp b/common/lset.cpp index 67301fac59..bc692a9e61 100644 --- a/common/lset.cpp +++ b/common/lset.cpp @@ -905,6 +905,12 @@ LSET LSET::BackMask() return saved; } +LSET LSET::FrontBackMask() +{ + static const LSET saved = ( BackTechMask() | FrontTechMask() ).set( F_Cu ).set( B_Cu ); + return saved; +} + LSET LSET::ForbiddenFootprintLayers() { diff --git a/include/layer_ids.h b/include/layer_ids.h index 6d9080b8fd..26412ac945 100644 --- a/include/layer_ids.h +++ b/include/layer_ids.h @@ -689,6 +689,8 @@ public: */ static LSET BackMask(); + static LSET FrontBackMask(); + static LSET UserMask(); /** @@ -930,10 +932,8 @@ inline bool IsBackLayer( PCB_LAYER_ID aLayerId ) case B_Fab: return true; default: - ; + return false; } - - return false; } diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index 3c36c6af55..994564eb37 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -149,7 +149,10 @@ void FP_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) } SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); - SetMirrored( IsBackLayer( GetLayer() ) ); + + if( ( GetLayerSet() & LSET::FrontBackMask() ).any() ) + SetMirrored( !IsMirrored() ); + SetLocalCoord(); } diff --git a/pcbnew/fp_textbox.cpp b/pcbnew/fp_textbox.cpp index 3f140787d4..28c2fdd914 100644 --- a/pcbnew/fp_textbox.cpp +++ b/pcbnew/fp_textbox.cpp @@ -278,7 +278,10 @@ void FP_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) } SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); - SetMirrored( IsBackLayer( GetLayer() ) ); + + if( ( GetLayerSet() & LSET::FrontBackMask() ).any() ) + SetMirrored( !IsMirrored() ); + SetLocalCoord(); } diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index b6ffdd02df..70baf7f514 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -278,7 +278,8 @@ void PCB_DIMENSION_BASE::Mirror( const VECTOR2I& axis_pos, bool aMirrorLeftRight INVERT( m_end.y ); } - m_text.SetMirrored( !m_text.IsMirrored() ); + if( ( GetLayerSet() & LSET::FrontBackMask() ).any() ) + m_text.SetMirrored( !m_text.IsMirrored() ); Update(); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 2eb8a37ac4..4b819ecf9b 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -1904,7 +1904,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer ) else attrs.m_StrokeWidth = getLineThickness( aText->GetEffectiveTextPenWidth() ); - if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::PhysicalLayersMask() ).any() ) + if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::FrontBackMask() ).any() ) { attrs.m_Mirrored = !attrs.m_Mirrored; attrs.m_Halign = static_cast( -attrs.m_Halign ); @@ -1994,7 +1994,7 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer ) TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); attrs.m_StrokeWidth = getLineThickness( aTextBox->GetEffectiveTextPenWidth() ); - if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::PhysicalLayersMask() ).any() ) + if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::FrontBackMask() ).any() ) { attrs.m_Mirrored = !attrs.m_Mirrored; attrs.m_Halign = static_cast( -attrs.m_Halign ); @@ -2081,7 +2081,7 @@ void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer ) else attrs.m_StrokeWidth = getLineThickness( aText->GetEffectiveTextPenWidth() ); - if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::PhysicalLayersMask() ).any() ) + if( m_gal->IsFlippedX() && !( aText->GetLayerSet() & LSET::FrontBackMask() ).any() ) { attrs.m_Mirrored = !attrs.m_Mirrored; attrs.m_Halign = static_cast( -attrs.m_Halign ); @@ -2155,7 +2155,7 @@ void PCB_PAINTER::draw( const FP_TEXTBOX* aTextBox, int aLayer ) attrs.m_Angle = aTextBox->GetDrawRotation(); attrs.m_StrokeWidth = getLineThickness( aTextBox->GetEffectiveTextPenWidth() ); - if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::PhysicalLayersMask() ).any() ) + if( m_gal->IsFlippedX() && !( aTextBox->GetLayerSet() & LSET::FrontBackMask() ).any() ) { attrs.m_Mirrored = !attrs.m_Mirrored; attrs.m_Halign = static_cast( -attrs.m_Halign ); @@ -2446,7 +2446,7 @@ void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer ) wxString resolvedText = text.GetShownText(); TEXT_ATTRIBUTES attrs = text.GetAttributes(); - if( m_gal->IsFlippedX() && !( aDimension->GetLayerSet() & LSET::PhysicalLayersMask() ).any() ) + if( m_gal->IsFlippedX() && !( aDimension->GetLayerSet() & LSET::FrontBackMask() ).any() ) attrs.m_Mirrored = !attrs.m_Mirrored; if( outline_mode ) diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 91479ffd0b..c8029062c2 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -246,7 +246,9 @@ void PCB_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) } SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); - SetMirrored( !IsMirrored() ); + + if( ( GetLayerSet() & LSET::FrontBackMask() ).any() ) + SetMirrored( !IsMirrored() ); } diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index cb604c9948..d7d2aeb11d 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -383,7 +383,9 @@ void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) } SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); - SetMirrored( !IsMirrored() ); + + if( ( GetLayerSet() & LSET::FrontBackMask() ).any() ) + SetMirrored( !IsMirrored() ); }