Router: don't unnecessarily change track widths on layer change

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13546
This commit is contained in:
Mike Williams 2023-01-25 09:34:17 -05:00
parent bc65f3b515
commit a76a4f9788
1 changed files with 16 additions and 4 deletions

View File

@ -714,12 +714,24 @@ void ROUTER_TOOL::updateSizesAfterLayerSwitch( PCB_LAYER_ID targetLayer )
if( !constraint.IsNull() )
{
sizes.SetTrackWidth( std::max( bds.m_TrackMinWidth, constraint.m_Value.Opt() ) );
int width = sizes.TrackWidth();
if( sizes.TrackWidth() == constraint.m_Value.Opt() )
sizes.SetWidthSource( constraint.GetName() );
else
// Only change the size if we're explicitly using the net class, or we're out of range for our
// new constraints. Otherwise, just leave the track width alone so we don't change for no reason.
if( bds.UseNetClassTrack()
|| ( width < bds.m_TrackMinWidth )
|| ( width < constraint.m_Value.Min() )
|| ( width > constraint.m_Value.Max() ) )
{
sizes.SetTrackWidth( std::max( bds.m_TrackMinWidth, constraint.m_Value.Opt() ) );
}
if( sizes.TrackWidth() == width )
sizes.SetWidthSource( _( "existing track" ) );
else if( sizes.TrackWidth() == bds.m_TrackMinWidth )
sizes.SetWidthSource( _( "board minimum track width" ) );
else
sizes.SetWidthSource( constraint.GetName() );
}
}