PNS: preserve auto-detected track width when changing via sizes

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8046
This commit is contained in:
Jon Evans 2021-06-06 20:18:09 -04:00
parent 99710aba48
commit 3c6b98a0d5
4 changed files with 17 additions and 3 deletions

View File

@ -463,6 +463,7 @@ bool PNS_KICAD_IFACE_BASE::ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM*
}
aSizes.SetTrackWidth( trackWidth );
aSizes.SetTrackWidthIsExplicit( !found );
int viaDiameter = bds.m_ViasMinSize;
int viaDrill = bds.m_MinThroughDrill;

View File

@ -1543,8 +1543,16 @@ void LINE_PLACER::UpdateSizes( const SIZES_SETTINGS& aSizes )
if( !m_idle )
{
m_head.SetWidth( m_sizes.TrackWidth() );
m_tail.SetWidth( m_sizes.TrackWidth() );
// If the track width was originally determined from the rules resolver ("use netclass
// width") or continuing from an existing track, we don't want to change the width unless
// the user is moving to an explicitly-specified value.
// NOTE: This doesn't quite correctly handle the case of moving *from* an explicit value
// *to* the "use netclass width" value, but that is more complicated to handle.
if( m_sizes.TrackWidthIsExplicit() )
{
m_head.SetWidth( m_sizes.TrackWidth() );
m_tail.SetWidth( m_sizes.TrackWidth() );
}
if( m_head.EndsWithVia() )
{

View File

@ -40,6 +40,7 @@ public:
SIZES_SETTINGS() :
m_minClearance( 0 ),
m_trackWidth( 155000 ),
m_trackWidthIsExplicit( true ),
m_viaType( VIATYPE::THROUGH ),
m_viaDiameter( 600000 ),
m_viaDrill( 250000 ),
@ -61,6 +62,9 @@ public:
int TrackWidth() const { return m_trackWidth; }
void SetTrackWidth( int aWidth ) { m_trackWidth = aWidth; }
bool TrackWidthIsExplicit() const { return m_trackWidthIsExplicit; }
void SetTrackWidthIsExplicit( bool aIsExplicit ) { m_trackWidthIsExplicit = aIsExplicit; }
int DiffPairWidth() const { return m_diffPairWidth; }
int DiffPairGap() const { return m_diffPairGap; }
@ -102,6 +106,7 @@ public:
private:
int m_minClearance;
int m_trackWidth;
bool m_trackWidthIsExplicit;
VIATYPE m_viaType;
int m_viaDiameter;

View File

@ -1873,7 +1873,7 @@ int ROUTER_TOOL::onTrackViaSizeChanged( const TOOL_EVENT& aEvent )
PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
if( !m_router->GetCurrentNets().empty() )
m_iface->ImportSizes( sizes, nullptr, m_router->GetCurrentNets()[0] );
m_iface->ImportSizes( sizes, m_startItem, m_router->GetCurrentNets()[0] );
m_router->UpdateSizes( sizes );