Resolve trackwidth[0]/viasize[0] to be the netclass values.

If we don't have a netclass use the default netclass.

Fixes https://gitlab.com/kicad/code/kicad/issues/5957
This commit is contained in:
Jeff Young 2020-10-11 00:50:56 +01:00
parent f680ff17d6
commit 614d452f12
3 changed files with 30 additions and 15 deletions

View File

@ -485,10 +485,7 @@ public:
* ( using the default netclass value or a preset/custom value )
* the default netclass is always in m_TrackWidthList[0]
*/
inline int GetCurrentTrackWidth() const
{
return m_useCustomTrackVia ? m_customTrackWidth : m_TrackWidthList[m_trackWidthIndex];
}
int GetCurrentTrackWidth() const;
/**
* Function SetCustomTrackWidth
@ -534,13 +531,7 @@ public:
* ( using the default netclass value or a preset/custom value )
* the default netclass is always in m_TrackWidthList[0]
*/
inline int GetCurrentViaSize() const
{
if( m_useCustomTrackVia )
return m_customViaSize.m_Diameter;
else
return m_ViasDimensionsList[m_viaSizeIndex].m_Diameter;
}
int GetCurrentViaSize() const;
/**
* Function SetCustomViaSize

View File

@ -886,12 +886,25 @@ void BOARD_DESIGN_SETTINGS::SetViaSizeIndex( unsigned aIndex )
}
int BOARD_DESIGN_SETTINGS::GetCurrentViaSize() const
{
if( m_useCustomTrackVia )
return m_customViaSize.m_Diameter;
else if( m_viaSizeIndex == 0 )
return GetNetClasses().GetDefaultPtr()->GetViaDiameter();
else
return m_ViasDimensionsList[ m_viaSizeIndex ].m_Diameter;
}
int BOARD_DESIGN_SETTINGS::GetCurrentViaDrill() const
{
int drill;
if( m_useCustomTrackVia )
drill = m_customViaSize.m_Drill;
else if( m_viaSizeIndex == 0 )
drill = GetNetClasses().GetDefaultPtr()->GetViaDrill();
else
drill = m_ViasDimensionsList[ m_viaSizeIndex ].m_Drill;
@ -906,6 +919,17 @@ void BOARD_DESIGN_SETTINGS::SetTrackWidthIndex( unsigned aIndex )
}
int BOARD_DESIGN_SETTINGS::GetCurrentTrackWidth() const
{
if( m_useCustomTrackVia )
return m_customTrackWidth;
else if( m_trackWidthIndex == 0 )
return GetNetClasses().GetDefaultPtr()->GetTrackWidth();
else
return m_TrackWidthList[ m_trackWidthIndex ];
}
void BOARD_DESIGN_SETTINGS::SetDiffPairIndex( unsigned aIndex )
{
m_diffPairIndex = std::min( aIndex, (unsigned) 8 );

View File

@ -197,13 +197,13 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow()
sort( vias.begin(), vias.end() );
sort( diffPairs.begin(), diffPairs.end() );
trackWidths.insert( trackWidths.begin(), m_BrdSettings->m_TrackWidthList[ 0 ] );
trackWidths.insert( trackWidths.begin(), 0 ); // dummy value for "use netclass"
m_BrdSettings->m_TrackWidthList = trackWidths;
vias.insert( vias.begin(), m_BrdSettings->m_ViasDimensionsList[ 0 ] );
vias.insert( vias.begin(), { 0, 0 } ); // dummy value for "use netclass"
m_BrdSettings->m_ViasDimensionsList = vias;
diffPairs.insert( diffPairs.begin(), m_BrdSettings->m_DiffPairDimensionsList[ 0 ] );
diffPairs.insert( diffPairs.begin(), { 0, 0, 0 } ); // dummy value for "use netclass"
m_BrdSettings->m_DiffPairDimensionsList = diffPairs;
return true;