Flip anything on a side-specific layer, rather than physical layer.

Fixes https://gitlab.com/kicad/code/kicad/issues/12726
This commit is contained in:
Jeff Young 2022-10-24 16:22:27 +01:00
parent 0e758d6bc2
commit 4778122aa0
8 changed files with 30 additions and 13 deletions

View File

@ -905,6 +905,12 @@ LSET LSET::BackMask()
return saved; return saved;
} }
LSET LSET::FrontBackMask()
{
static const LSET saved = ( BackTechMask() | FrontTechMask() ).set( F_Cu ).set( B_Cu );
return saved;
}
LSET LSET::ForbiddenFootprintLayers() LSET LSET::ForbiddenFootprintLayers()
{ {

View File

@ -689,6 +689,8 @@ public:
*/ */
static LSET BackMask(); static LSET BackMask();
static LSET FrontBackMask();
static LSET UserMask(); static LSET UserMask();
/** /**
@ -930,10 +932,8 @@ inline bool IsBackLayer( PCB_LAYER_ID aLayerId )
case B_Fab: case B_Fab:
return true; return true;
default: default:
; return false;
} }
return false;
} }

View File

@ -149,7 +149,10 @@ void FP_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
} }
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
SetMirrored( IsBackLayer( GetLayer() ) );
if( ( GetLayerSet() & LSET::FrontBackMask() ).any() )
SetMirrored( !IsMirrored() );
SetLocalCoord(); SetLocalCoord();
} }

View File

@ -278,7 +278,10 @@ void FP_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
} }
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
SetMirrored( IsBackLayer( GetLayer() ) );
if( ( GetLayerSet() & LSET::FrontBackMask() ).any() )
SetMirrored( !IsMirrored() );
SetLocalCoord(); SetLocalCoord();
} }

View File

@ -278,7 +278,8 @@ void PCB_DIMENSION_BASE::Mirror( const VECTOR2I& axis_pos, bool aMirrorLeftRight
INVERT( m_end.y ); INVERT( m_end.y );
} }
m_text.SetMirrored( !m_text.IsMirrored() ); if( ( GetLayerSet() & LSET::FrontBackMask() ).any() )
m_text.SetMirrored( !m_text.IsMirrored() );
Update(); Update();
} }

View File

@ -1904,7 +1904,7 @@ void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
else else
attrs.m_StrokeWidth = getLineThickness( aText->GetEffectiveTextPenWidth() ); 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_Mirrored = !attrs.m_Mirrored;
attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign ); attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
@ -1994,7 +1994,7 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
attrs.m_StrokeWidth = getLineThickness( aTextBox->GetEffectiveTextPenWidth() ); 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_Mirrored = !attrs.m_Mirrored;
attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign ); attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
@ -2081,7 +2081,7 @@ void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer )
else else
attrs.m_StrokeWidth = getLineThickness( aText->GetEffectiveTextPenWidth() ); 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_Mirrored = !attrs.m_Mirrored;
attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign ); attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
@ -2155,7 +2155,7 @@ void PCB_PAINTER::draw( const FP_TEXTBOX* aTextBox, int aLayer )
attrs.m_Angle = aTextBox->GetDrawRotation(); attrs.m_Angle = aTextBox->GetDrawRotation();
attrs.m_StrokeWidth = getLineThickness( aTextBox->GetEffectiveTextPenWidth() ); 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_Mirrored = !attrs.m_Mirrored;
attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign ); attrs.m_Halign = static_cast<GR_TEXT_H_ALIGN_T>( -attrs.m_Halign );
@ -2446,7 +2446,7 @@ void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
wxString resolvedText = text.GetShownText(); wxString resolvedText = text.GetShownText();
TEXT_ATTRIBUTES attrs = text.GetAttributes(); 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; attrs.m_Mirrored = !attrs.m_Mirrored;
if( outline_mode ) if( outline_mode )

View File

@ -246,7 +246,9 @@ void PCB_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
} }
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
SetMirrored( !IsMirrored() );
if( ( GetLayerSet() & LSET::FrontBackMask() ).any() )
SetMirrored( !IsMirrored() );
} }

View File

@ -383,7 +383,9 @@ void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
} }
SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) ); SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
SetMirrored( !IsMirrored() );
if( ( GetLayerSet() & LSET::FrontBackMask() ).any() )
SetMirrored( !IsMirrored() );
} }